Example usage for org.apache.solr.common.cloud Slice getRange

List of usage examples for org.apache.solr.common.cloud Slice getRange

Introduction

In this page you can find the example usage for org.apache.solr.common.cloud Slice getRange.

Prototype

public DocRouter.Range getRange() 

Source Link

Usage

From source file:org.apache.sentry.tests.e2e.solr.TestUpdateOperations.java

License:Apache License

private void checkUpdateDistribPhase(CloudSolrServer server, String collectionName, String userName,
        DistribPhase distribPhase) throws Exception {
    String path = "/" + collectionName + "/update?commit=true";
    String updateDistribParam = "";
    if (distribPhase != null) {
        updateDistribParam = distribPhase.toString();
        path += "&update.distrib=" + updateDistribParam;
    }/* ww  w. j  ava 2s  . com*/
    String docId = "testUpdateDistribDoc" + updateDistribParam;
    String body = "<add><doc><field name=\"id\">" + docId + "</field></doc></add>";

    String node = null;
    ClusterState clusterState = server.getZkStateReader().getClusterState();
    for (Slice slice : clusterState.getActiveSlices(collectionName)) {
        if (slice.getRange().includes(docId.hashCode())) {
            node = slice.getLeader().getNodeName().replace("_solr", "/solr");
        }
    }
    assertNotNull("Expected to find leader node for document", node);

    String ret = makeHttpRequest(server, node, "POST", path, body.getBytes("UTF-8"), "text/xml");
    assertTrue("Expected sentry exception", ret.contains("SentrySolrAuthorizationException: " + "User "
            + userName + " does not have privileges for " + collectionName));
}