private static Set<String> getChildItems(String parent, final Set<String> fields) { Set<String> children = Sets.newHashSet(); for (String field : fields) { if (field.startsWith(parent + ".")) { children.add(field.substring((parent + ".").length())); } else if (field.startsWith(parent)) { children.add(field); } } return children; }
public void setTriggerFunctions(Collection<String> triggerFunctions) { this.triggerFunctions = (triggerFunctions instanceof Set) ? (Set)triggerFunctions : Sets.newHashSet(triggerFunctions); }
@Override public Set<String> findUserIdsConnectedTo(String providerId, Set<String> providerUserIds) { log.info("Called findUserIdsConnectedTo with parameters ", providerId, providerUserIds); return Sets.newHashSet(); }
public void convertTextAnnotationsToNamedEntities(String[] tokens, List<TextAnnotation> TextAnnotations, Map<String, Set<String>> namedEntities) { for (TextAnnotation TextAnnotation : TextAnnotations) { int start = TextAnnotation.getSpan().getStart(); int end = TextAnnotation.getSpan().getEnd(); String[] TextAnnotationData = Arrays.copyOfRange(tokens, start, end); String content = Joiner.on(" ").join(TextAnnotationData); String type = TextAnnotation.getType(); if (!namedEntities.containsKey(type)) { Set<String> typeList = Sets.newHashSet(); namedEntities.put(type, typeList); } namedEntities.get(type).add(content); } }
@ApiOperation(value = "Add dependency to the csar with given id.") @RequestMapping(value = "/{csarId:.+?}/dependencies", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("isAuthenticated()") @Audit @Deprecated public RestResponse<Boolean> addDependency(@PathVariable String csarId, @Valid @RequestBody CSARDependency dependency) { Csar csar = csarService.getOrFail(csarId); csarAuthorizationFilter.checkWriteAccess(csar); Set<CSARDependency> existingDependencies = csar.getDependencies(); if (existingDependencies == null) { existingDependencies = Sets.newHashSet(); csar.setDependencies(existingDependencies); } boolean couldBeSaved = existingDependencies.add(dependency); csarDAO.save(csar); return RestResponseBuilder.<Boolean> builder().data(couldBeSaved).build(); }
@And("^The application's deployment should succeed after (\\d+) minutes$") public void The_application_s_deployment_should_succeed_after_minutes(long numberOfMinutes) throws Throwable { // null value for environmentName => use default environment assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.DEPLOYED, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), numberOfMinutes * 60L * 1000L, null, true); }
private Set<String> getUndeployedApplicationNames(List<DeploymentDTO> list) { Set<String> names = Sets.newHashSet(); for (DeploymentDTO dto : list) { if (dto.getDeployment().getEndDate() != null) { names.add(dto.getSource().getName()); } } return names; }
@When("^I have the environment \"([^\"]*)\" with status \"([^\"]*)\" for the application \"([^\"]*)\"$") public void I_have_the_environment_with_status_for_the_application(String envName, String expectedStatus, String appName) throws Throwable { assertStatus(appName, DeploymentStatus.valueOf(expectedStatus), Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), 10000L, envName); }
@And("^The application's deployment must succeed after (\\d+) minutes$") public void The_application_s_deployment_must_succeed_after_minutes(long numberOfMinutes) throws Throwable { // null value for environmentName => use default environment assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.DEPLOYED, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), numberOfMinutes * 60L * 1000L, null, false); }
@Then("^The application's deployment must succeed$") public void The_application_s_deployment_must_succeed() throws Throwable { // null value for environmentName => use default environment assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.DEPLOYED, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), 15000L, null); }
@Then("^The application's deployment must finish with warning$") public void The_application_s_deployment_must_finish_with_warning() throws Throwable { assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.WARNING, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), 10000L, null); }
@Then("^The application's deployment must fail$") public void The_application_s_deployment_must_fail() throws Throwable { assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.FAILURE, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), 10000L, null); }
@And("^The deployment update should succeed after (\\d+) minutes$") public void The_deployment_update_should_succeed_after_minutes(long numberOfMinutes) throws Throwable { // null value for environmentName => use default environment assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.UPDATED, Sets.newHashSet(DeploymentStatus.UPDATE_IN_PROGRESS), numberOfMinutes * 60L * 1000L, null, true); }
@And("^The deployment update should fail$") public void The_deployment_update_should_fail() throws Throwable { // null value for environmentName => use default environment // FIXME: for the moment when the update fails, the status of the deployment is DEPLOYED !! assertStatus(ApplicationStepDefinitions.CURRENT_APPLICATION.getName(), DeploymentStatus.DEPLOYED, Sets.newHashSet(DeploymentStatus.UPDATE_IN_PROGRESS, DeploymentStatus.UPDATE_FAILURE), 1 * 60L * 1000L, null, true); }
@Given("^I undeploy all environments for applications$") public void I_undeploy_all_applications() throws Throwable { assertNotNull(ApplicationStepDefinitions.CURRENT_APPLICATIONS); for (String applicationName : ApplicationStepDefinitions.CURRENT_APPLICATIONS.keySet()) { Application application = ApplicationStepDefinitions.CURRENT_APPLICATIONS.get(applicationName); log.info("APPLICATION : {} - {}", application.getName(), application.getId()); // for each application undeploy all environment Map<String, String> environments = Context.getInstance().getAllEnvironmentForApplication(applicationName); for (Map.Entry<String, String> env : environments.entrySet()) { log.info(env.getKey() + "/" + env.getValue()); log.info("ENVIRONMENT to undeploy : {} - {}", env.getKey(), env.getValue()); Context.getRestClientInstance().delete("/rest/v1/applications/" + application.getId() + "/environments/" + env.getValue() + "/deployment"); assertStatus(application.getName(), DeploymentStatus.UNDEPLOYED, Sets.newHashSet(DeploymentStatus.UNDEPLOYMENT_IN_PROGRESS), 10 * 60L * 1000L, null); } } }
@Then("^The deployment must succeed$") public void The_deployment_must_succeed() throws Throwable { String deploymentId = Context.getInstance().getTopologyDeploymentId(); assertDeploymentStatus(deploymentId, DeploymentStatus.DEPLOYED, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), 10000L); }
@Then("^The deployment must fail$") public void The_deployment_must_fail() throws Throwable { String deploymentId = Context.getInstance().getTopologyDeploymentId(); assertDeploymentStatus(deploymentId, DeploymentStatus.FAILURE, Sets.newHashSet(DeploymentStatus.INIT_DEPLOYMENT, DeploymentStatus.DEPLOYMENT_IN_PROGRESS), 10000L); }
@Inject public AwsEc2UnicastHostsProvider(Settings settings, TransportService transportService, AmazonEC2 client, Version version) { super(settings); this.transportService = transportService; this.client = client; this.version = version; this.hostType = HostType.valueOf(componentSettings.get("host_type", "private_ip").toUpperCase()); this.bindAnyGroup = componentSettings.getAsBoolean("any_group", true); this.groups = ImmutableSet.copyOf(componentSettings.getAsArray("groups")); this.tags = componentSettings.getByPrefix("tag.").getAsMap(); Set<String> availabilityZones = Sets.newHashSet(componentSettings.getAsArray("availability_zones")); if (componentSettings.get("availability_zones") != null) { availabilityZones.addAll(Strings.commaDelimitedListToSet(componentSettings.get("availability_zones"))); } this.availabilityZones = ImmutableSet.copyOf(availabilityZones); if (logger.isDebugEnabled()) { logger.debug("using host_type [{}], tags [{}], groups [{}] with any_group [{}], availability_zones [{}]", hostType, tags, groups, bindAnyGroup, availabilityZones); } }
@Then("^the response should contains (\\d+) deployments DTO and applications with an end date set$") public void the_response_should_contains_deployments_DTO_and_applications_with_an_en_date_set(int deploymentsCount, List<String> applicationNames) throws Throwable { RestResponse<?> response = JsonUtil.read(Context.getInstance().getRestResponse()); assertNotNull(response.getData()); List<DeploymentDTO> dtoList = JsonUtil.toList(JsonUtil.toString(response.getData()), DeploymentDTO.class, Application.class); assertNotNull(dtoList); assertEquals(deploymentsCount, dtoList.size()); Set<String> expectedNames = Sets.newHashSet(applicationNames); Set<String> actualNames = getUndeployedApplicationNames(dtoList); assertEquals(expectedNames, actualNames); }
private void doUndeployApplication(String applicationName, String environmentName, boolean failsafe) throws Throwable { String applicationId = Context.getInstance().getApplicationId(applicationName); String envId = environmentName == null ? Context.getInstance().getDefaultApplicationEnvironmentId(applicationName) : Context.getInstance().getApplicationEnvironmentId(applicationName, environmentName); String statusRequest = "/rest/v1/applications/" + applicationId + "/environments/" + envId + "/status"; RestResponse<String> statusResponse = JsonUtil.read(Context.getRestClientInstance().get(statusRequest), String.class); if (failsafe) { if (statusResponse.getError() != null) { log.warn("Error was supposed to be null but was : ", statusResponse.getError()); } } else { assertNull(statusResponse.getError()); } DeploymentStatus deploymentStatus = DeploymentStatus.valueOf(statusResponse.getData()); if (!DeploymentStatus.UNDEPLOYED.equals(deploymentStatus) || !DeploymentStatus.UNDEPLOYMENT_IN_PROGRESS.equals(deploymentStatus)) { Context.getInstance().registerRestResponse( Context.getRestClientInstance().delete("/rest/v1/applications/" + applicationId + "/environments/" + envId + "/deployment")); } assertStatus(applicationName, DeploymentStatus.UNDEPLOYED, Sets.newHashSet(DeploymentStatus.UNDEPLOYMENT_IN_PROGRESS), 10 * 60L * 1000L, null, failsafe); }