Java Code Examples for org.apache.solr.common.util.StrUtils#join()
The following examples show how to use
org.apache.solr.common.util.StrUtils#join() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateAliasCmd.java From lucene-solr with Apache License 2.0 | 6 votes |
private void validateAllCollectionsExistAndNoDuplicates(List<String> collectionList, ZkStateReader zkStateReader) { final String collectionStr = StrUtils.join(collectionList, ','); if (new HashSet<>(collectionList).size() != collectionList.size()) { throw new SolrException(BAD_REQUEST, String.format(Locale.ROOT, "Can't create collection alias for collections='%s', since it contains duplicates", collectionStr)); } ClusterState clusterState = zkStateReader.getClusterState(); Set<String> aliasNames = zkStateReader.getAliases().getCollectionAliasListMap().keySet(); for (String collection : collectionList) { if (clusterState.getCollectionOrNull(collection) == null && !aliasNames.contains(collection)) { throw new SolrException(BAD_REQUEST, String.format(Locale.ROOT, "Can't create collection alias for collections='%s', '%s' is not an existing collection or alias", collectionStr, collection)); } } }
Example 2
Source File: CreateAliasCmd.java From lucene-solr with Apache License 2.0 | 5 votes |
private void callCreatePlainAlias(ZkNodeProps message, String aliasName, ZkStateReader zkStateReader) { final List<String> canonicalCollectionList = parseCollectionsParameter(message.get("collections")); if (canonicalCollectionList.isEmpty()) { throw new SolrException(BAD_REQUEST, "'collections' parameter doesn't contain any collection names."); } final String canonicalCollectionsString = StrUtils.join(canonicalCollectionList, ','); validateAllCollectionsExistAndNoDuplicates(canonicalCollectionList, zkStateReader); zkStateReader.aliasesManager .applyModificationAndExportToZk(aliases -> aliases.cloneWithCollectionAlias(aliasName, canonicalCollectionsString)); }
Example 3
Source File: CreateAliasCmd.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void callCreateRoutedAlias(ZkNodeProps message, String aliasName, ZkStateReader zkStateReader, ClusterState state) throws Exception { // Validate we got a basic minimum if (!message.getProperties().keySet().containsAll(RoutedAlias.MINIMAL_REQUIRED_PARAMS)) { throw new SolrException(BAD_REQUEST, "A routed alias requires these params: " + RoutedAlias.MINIMAL_REQUIRED_PARAMS + " plus some create-collection prefixed ones."); } // convert values to strings Map<String, String> props = new LinkedHashMap<>(); message.getProperties().forEach((key, value) -> props.put(key, String.valueOf(value))); // Further validation happens here RoutedAlias routedAlias = RoutedAlias.fromProps(aliasName, props); if (routedAlias == null) { // should never happen here, but keep static analysis in IDE's happy... throw new SolrException(SERVER_ERROR,"Tried to create a routed alias with no type!"); } if (!props.keySet().containsAll(routedAlias.getRequiredParams())) { throw new SolrException(BAD_REQUEST, "Not all required params were supplied. Missing params: " + StrUtils.join(Sets.difference(routedAlias.getRequiredParams(), props.keySet()), ',')); } // Create the first collection. String initialColl = routedAlias.computeInitialCollectionName(); ensureAliasCollection(aliasName, zkStateReader, state, routedAlias.getAliasMetadata(), initialColl); // Create/update the alias zkStateReader.aliasesManager.applyModificationAndExportToZk(aliases -> aliases .cloneWithCollectionAlias(aliasName, initialColl) .cloneWithCollectionAliasProperties(aliasName, routedAlias.getAliasMetadata())); }
Example 4
Source File: OverseerCollectionMessageHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
void checkRequired(ZkNodeProps message, String... props) { for (String prop : props) { if(message.get(prop) == null){ throw new SolrException(ErrorCode.BAD_REQUEST, StrUtils.join(Arrays.asList(props),',') +" are required params" ); } } }
Example 5
Source File: OverseerTaskProcessor.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public String toString() { return StrUtils.join(ImmutableSet.of(runningTasks, blockedTasks.keySet()), ','); }
Example 6
Source File: LockTree.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public String toString() { return StrUtils.join(node.constructPath(new LinkedList<>()), '/'); }