new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary); collectionName = collectionName.split(",")[0]; if (!collectionNames.contains(collectionName)) { new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary); new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary); collectionName = collectionName.split(",")[0]; if (!collectionNames.contains(collectionName)) { new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary);
private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection) throws IOException, SolrServerException, KeeperException, InterruptedException { if (!checkIfCollectionExists(client, collection)) { Integer numShards = config.get(NUM_SHARDS); Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE); Integer replicationFactor = config.get(REPLICATION_FACTOR); // Ideally this property used so a new configset is not uploaded for every single // index (collection) created in solr. // if a generic configSet is not set, make the configset name the same as the collection. // This was the default behavior before a default configSet could be specified String genericConfigSet = config.has(SOLR_DEFAULT_CONFIG) ? config.get(SOLR_DEFAULT_CONFIG):collection; CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setConfigName(genericConfigSet); createRequest.setCollectionName(collection); createRequest.setNumShards(numShards); createRequest.setMaxShardsPerNode(maxShardsPerNode); createRequest.setReplicationFactor(replicationFactor); CollectionAdminResponse createResponse = createRequest.process(client); if (createResponse.isSuccess()) { logger.trace("Collection {} successfully created.", collection); } else { throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages())); } } waitForRecoveriesToFinish(client, collection); }
protected void createCollectionIfNotExist(CloudSolrClient client, String collectionName) { Set<String> collectionNames = client.getZkStateReader().getClusterState().getCollections(); if (!collectionNames.contains(collectionName)) { try { new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(getSolrCloudNumShards()) .setMaxShardsPerNode(getSolrCloudNumShards()).setConfigName(getSolrCloudConfigName()).process(client); } catch (SolrServerException e) { throw ExceptionHelper.refineException(e); } catch (IOException e) { throw ExceptionHelper.refineException(e); } } }
CollectionAdminRequest.Create req = new CollectionAdminRequest.Create(); CollectionAdminResponse response = req.setCollectionName(solrCollection) .setReplicationFactor(remoteSolrServerConfiguration.getSolrReplicationFactor())
CollectionAdminRequest.Create req = new CollectionAdminRequest.Create(); CollectionAdminResponse response = req.setCollectionName(solrCollection) .setReplicationFactor(remoteSolrServerConfiguration.getSolrReplicationFactor())
private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection) throws IOException, SolrServerException, KeeperException, InterruptedException { if (!checkIfCollectionExists(client, collection)) { Integer numShards = config.get(NUM_SHARDS); Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE); Integer replicationFactor = config.get(REPLICATION_FACTOR); CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setConfigName(collection); createRequest.setCollectionName(collection); createRequest.setNumShards(numShards); createRequest.setMaxShardsPerNode(maxShardsPerNode); createRequest.setReplicationFactor(replicationFactor); CollectionAdminResponse createResponse = createRequest.process(client); if (createResponse.isSuccess()) { logger.trace("Collection {} successfully created.", collection); } else { throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages())); } } waitForRecoveriesToFinish(client, collection); }
private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection) throws IOException, SolrServerException, KeeperException, InterruptedException { if (!checkIfCollectionExists(client, collection)) { Integer numShards = config.get(NUM_SHARDS); Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE); Integer replicationFactor = config.get(REPLICATION_FACTOR); CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setConfigName(collection); createRequest.setCollectionName(collection); createRequest.setNumShards(numShards); createRequest.setMaxShardsPerNode(maxShardsPerNode); createRequest.setReplicationFactor(replicationFactor); CollectionAdminResponse createResponse = createRequest.process(client); if (createResponse.isSuccess()) { logger.trace("Collection {} successfully created.", collection); } else { throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages())); } } waitForRecoveriesToFinish(client, collection); }
/** * Returns a SolrRequest for creating a collection using a default configSet * * This requires that there is either a single configset configured in the cluster, or * that there is a configset with the same name as the collection * * @param collection the collection name * @param numShards the number of shards in the collection * @param numReplicas the replication factor of the collection */ public static Create createCollection(String collection, int numShards, int numReplicas) { return new Create(collection, null, numShards, numReplicas, 0, 0); }
static void createCollection( String collection, int numShards, int replicationFactor, AuthorizedSolrClient client) throws Exception { CollectionAdminRequest.Create create = new CollectionAdminRequest.Create() .setCollectionName(collection) .setNumShards(numShards) .setReplicationFactor(replicationFactor) .setMaxShardsPerNode(2); client.process(create); }
/** * Returns a SolrRequest for creating a collection with the implicit router and specific types of replicas * @param collection the collection name * @param config the collection config * @param shards a shard definition string * @param numNrtReplicas the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#NRT} * @param numTlogReplicas the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#TLOG} * @param numPullReplicas the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#PULL} */ public static Create createCollectionWithImplicitRouter(String collection, String config, String shards, int numNrtReplicas, int numTlogReplicas, int numPullReplicas) { return new Create(collection, config, ImplicitDocRouter.NAME, null, checkNotNull("shards",shards), numNrtReplicas, numTlogReplicas, numPullReplicas); }
/** * Returns a SolrRequest for creating a collection * @param collection the collection name * @param config the collection config * @param numShards the number of shards in the collection * @param numNrtReplicas the number of {@link org.apache.solr.common.cloud.Replica.Type#NRT} replicas * @param numTlogReplicas the number of {@link org.apache.solr.common.cloud.Replica.Type#TLOG} replicas * @param numPullReplicas the number of {@link org.apache.solr.common.cloud.Replica.Type#PULL} replicas */ public static Create createCollection(String collection, String config, Integer numShards, Integer numNrtReplicas, Integer numTlogReplicas, Integer numPullReplicas) { return new Create(collection, config, numShards, numNrtReplicas, numTlogReplicas, numPullReplicas); }
protected void createCloudCollection(String name, int numShards) throws IOException, SolrServerException { CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setCollectionName(name); createRequest.setNumShards(numShards); createRequest.process(getClient()); }
/** * Returns a SolrRequest for creating a collection * @param collection the collection name * @param config the collection config * @param numShards the number of shards in the collection * @param numReplicas the replication factor of the collection (same as numNrtReplicas) */ public static Create createCollection(String collection, String config, int numShards, int numReplicas) { return new Create(collection, config, numShards, numReplicas, null, null); }
/** * Returns a SolrRequest for creating a collection with the implicit router * @param collection the collection name * @param config the collection config * @param shards a shard definition string * @param numReplicas the replication factor of the collection */ public static Create createCollectionWithImplicitRouter(String collection, String config, String shards, int numReplicas) { return new Create(collection, config, shards, numReplicas); }