List of usage examples for org.apache.solr.common.cloud Slice getRange
public DocRouter.Range getRange()
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)); }