Example usage for org.apache.solr.client.solrj.request CollectionAdminRequest addReplicaToShard

List of usage examples for org.apache.solr.client.solrj.request CollectionAdminRequest addReplicaToShard

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.request CollectionAdminRequest addReplicaToShard.

Prototype

public static AddReplica addReplicaToShard(String collection, String shard) 

Source Link

Document

Returns a SolrRequest to add a replica of type org.apache.solr.common.cloud.Replica.Type#NRT to a shard in a collection

Usage

From source file:com.shaie.solr.solrj.CollectionAdminHelper.java

License:Apache License

/** Adds a replica to the given collection and shard. */
public AddReplicaResponse addReplica(String collectionName, String shardName, String nodeName) {
    if (!collectionExists(collectionName)) {
        throw new IllegalArgumentException("collection [" + collectionName + "] does not exist");
    }/*  w w w  .  j a  v a 2 s  . co m*/

    try {
        final CollectionAdminRequest.AddReplica addReplicaRequest = CollectionAdminRequest
                .addReplicaToShard(collectionName, shardName).setNode(nodeName);
        final CollectionAdminResponse response = addReplicaRequest.process(solrClient);
        return new AddReplicaResponse(response);
    } catch (IOException | SolrServerException e) {
        throw new RuntimeException(e);
    }
}