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; }
@Override protected Collection<T> getCollectionInstance() { return Sets.newLinkedHashSet(); } }
SortedSet<WeightedDiscoveryNode> set = newTreeSet(); for (DiscoveryNode node : nodes) { String s = node.attributes().get(GathererConstants.GATHERER_LOAD); } else if (request.getMinimumLength()) { SortedSet<WeightedDiscoveryNode> set = newTreeSet(); for (DiscoveryNode node : nodes) { String s = node.attributes().get(GathererConstants.GATHERER_LENGTH);
/** * Retrieves the current indexes and types from elasticsearch * @return a set containing the indexes available in the elasticsearch cluster and their types */ protected Set<Index> getIndexes() { ClusterStateResponse response = unwrapShellNativeClient().client().admin().cluster().prepareState().setFilterBlocks(true) .setFilterRoutingTable(true).setFilterNodes(true).execute().actionGet(); Set<Index> newIndexes = new HashSet<Index>(); for (IndexMetaData indexMetaData : response.getState().metaData().indices().values()) { logger.trace("Processing index {}", indexMetaData.index()); Set<String> typeNames = Sets.filter(indexMetaData.mappings().keySet(), new Predicate<String>() { @Override public boolean apply(String s) { return !MapperService.DEFAULT_MAPPING.equals(s); } }); String[] types = typeNames.toArray(new String[typeNames.size()]); newIndexes.add(new Index(indexMetaData.index(), false, types)); for (String alias : indexMetaData.aliases().keySet()) { newIndexes.add(new Index(alias, true, types)); } } return newIndexes; }
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(); }
private boolean topLevelDirInExcess(ZipFile zipFile) { //We don't rely on ZipEntry#isDirectory because it might be that there is no explicit dir //but the files path do contain dirs, thus they are going to be extracted on sub-folders anyway Enumeration<? extends ZipArchiveEntry> zipEntries = zipFile.getEntries(); Set<String> topLevelDirNames = newHashSet(); while (zipEntries.hasMoreElements()) { ZipArchiveEntry zipEntry = zipEntries.nextElement(); String zipEntryName = zipEntry.getName().replace('\\', '/'); int slash = zipEntryName.indexOf('/'); //if there isn't a slash in the entry name it means that we have a file in the top-level if (slash == -1) { return false; } topLevelDirNames.add(zipEntryName.substring(0, slash)); //if we have more than one top-level folder if (topLevelDirNames.size() > 1) { return false; } } return topLevelDirNames.size() == 1; }
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(); }
Set<RelationshipType> indexedRelationshipTypes = Sets.newHashSet(); for (RelationshipTemplate relTemplate : template.getValue().getRelationships().values()) { RelationshipType indexedRelationshipType = toscaTypeSearchService.getElementInDependencies(RelationshipType.class, relTemplate.getType(),
@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); } } }