Java Code Examples for org.apache.solr.client.solrj.response.CollectionAdminResponse#getResponse()
The following examples show how to use
org.apache.solr.client.solrj.response.CollectionAdminResponse#getResponse() .
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: AsyncCallRequestStatusResponseTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @Test public void testAsyncCallStatusResponse() throws Exception { int numShards = 4; int numReplicas = 1; Create createCollection = CollectionAdminRequest.createCollection("asynccall", "conf", numShards, numReplicas); createCollection.setMaxShardsPerNode(100); String asyncId = createCollection.processAsync(cluster.getSolrClient()); waitForState("Expected collection 'asynccall' to have "+numShards+" shards and "+ numShards*numReplicas+" replica", "asynccall", clusterShape(numShards, numShards*numReplicas)); RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId, 30, cluster.getSolrClient()); assertEquals("Unexpected request status: " + state, "completed", state.getKey()); CollectionAdminRequest.RequestStatus requestStatus = CollectionAdminRequest.requestStatus(asyncId); CollectionAdminResponse rsp = requestStatus.process(cluster.getSolrClient()); NamedList<?> r = rsp.getResponse(); if (OverseerCollectionMessageHandler.INCLUDE_TOP_LEVEL_RESPONSE) { final int actualNumOfElems = 3+(numShards*numReplicas); // responseHeader, success, status, + old responses per every replica assertEquals("Expected "+actualNumOfElems+" elements in the response" + r.jsonStr(), actualNumOfElems, r.size()); } else { // responseHeader, success, status assertEquals("Expected 3 elements in the response" + r.jsonStr(), 3, r.size()); } assertNotNull("Expected 'responseHeader' response" + r, r.get("responseHeader")); assertNotNull("Expected 'status' response" + r, r.get("status")); { final NamedList<?> success = (NamedList<?>)r.get("success"); assertNotNull("Expected 'success' response" + r, success); final int actualSuccessElems = 2*(numShards*numReplicas); // every replica responds once on submit and once on complete assertEquals("Expected "+actualSuccessElems+ " elements in the success element" + success.jsonStr(), actualSuccessElems, success.size()); } }
Example 2
Source File: SystemCollectionCompatTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testBackCompat() throws Exception { CollectionAdminRequest.OverseerStatus status = new CollectionAdminRequest.OverseerStatus(); CloudSolrClient solrClient = cluster.getSolrClient(); CollectionAdminResponse adminResponse = status.process(solrClient); NamedList<Object> response = adminResponse.getResponse(); String leader = (String) response.get("leader"); log.info("Overseer Status indicates that the overseer is: {}", leader); JettySolrRunner overseerNode = null; List<JettySolrRunner> jettySolrRunners = cluster.getJettySolrRunners(); for (int i = 0; i < jettySolrRunners.size(); i++) { JettySolrRunner runner = jettySolrRunners.get(i); if (runner.getNodeName().equals(leader)) { overseerNode = runner; break; } } assertNotNull(overseerNode); LogWatcherConfig watcherCfg = new LogWatcherConfig(true, null, "WARN", 100); @SuppressWarnings({"rawtypes"}) LogWatcher watcher = LogWatcher.newRegisteredLogWatcher(watcherCfg, null); watcher.reset(); // restart Overseer to trigger the back-compat check if (log.isInfoEnabled()) { log.info("Stopping Overseer Node: {} ({})", overseerNode.getNodeName(), overseerNode.getLocalPort()); } cluster.stopJettySolrRunner(overseerNode); log.info("Waiting for new overseer election..."); TimeOut timeOut = new TimeOut(30, TimeUnit.SECONDS, cloudManager.getTimeSource()); while (!timeOut.hasTimedOut()) { adminResponse = status.process(solrClient); response = adminResponse.getResponse(); String newLeader = (String) response.get("leader"); if (newLeader != null && !leader.equals(newLeader)) { log.info("...new overseer is: {}", newLeader); break; } timeOut.sleep(200); } if (timeOut.hasTimedOut()) { fail("time out waiting for new Overseer leader"); } TimeOut timeOut1 = new TimeOut(60, TimeUnit.SECONDS, cloudManager.getTimeSource()); boolean foundWarning = false; boolean foundSchemaWarning = false; // TODO: replace this polling logic with a LogWatcher that uses a queue we can await() on... log.info("Polling for log watcher to detect expected log messages..."); while (!timeOut1.hasTimedOut()) { timeOut1.sleep(1000); SolrDocumentList history = watcher.getHistory(-1, null); for (SolrDocument doc : history) { if (!Overseer.class.getName().equals(doc.getFieldValue("logger"))) { continue; } if (doc.getFieldValue("message").toString().contains("re-indexing")) { if (log.isInfoEnabled()) { log.info("Found re-indexing message: {}", doc.getFieldValue("message")); } foundWarning = true; } if (doc.getFieldValue("message").toString().contains("timestamp")) { if (log.isInfoEnabled()) { log.info("Found timestamp message: {}", doc.getFieldValue("message")); } foundSchemaWarning = true; } } if (foundWarning && foundSchemaWarning) { break; } } log.info("Done polling log watcher: foundWarning={} foundSchemaWarning={}", foundWarning, foundSchemaWarning); assertTrue("re-indexing warning not found", foundWarning); assertTrue("timestamp field incompatibility warning not found", foundSchemaWarning); }
Example 3
Source File: TriggerIntegrationTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testContinueTriggersOnOverseerRestart() throws Exception { CollectionAdminRequest.OverseerStatus status = new CollectionAdminRequest.OverseerStatus(); CloudSolrClient solrClient = cluster.getSolrClient(); CollectionAdminResponse adminResponse = status.process(solrClient); NamedList<Object> response = adminResponse.getResponse(); String leader = (String) response.get("leader"); JettySolrRunner overseerNode = null; int index = -1; List<JettySolrRunner> jettySolrRunners = cluster.getJettySolrRunners(); for (int i = 0; i < jettySolrRunners.size(); i++) { JettySolrRunner runner = jettySolrRunners.get(i); if (runner.getNodeName().equals(leader)) { overseerNode = runner; index = i; break; } } assertNotNull(overseerNode); String setTriggerCommand = "{" + "'set-trigger' : {" + "'name' : 'node_added_triggerCTOOR'," + "'event' : 'nodeAdded'," + "'waitFor' : '" + waitForSeconds + "s'," + "'enabled' : true," + "'actions' : [{'name':'test','class':'" + TestTriggerAction.class.getName() + "'}]" + "}}"; @SuppressWarnings({"rawtypes"}) SolrRequest req = AutoScalingRequest.create(SolrRequest.METHOD.POST, setTriggerCommand); response = solrClient.request(req); assertEquals(response.get("result").toString(), "success"); assertTrue("Trigger was not init()ed even after await()ing an excessive amount of time", actionInitCalled.await(60, TimeUnit.SECONDS)); // stop the overseer, somebody else will take over as the overseer JettySolrRunner j = cluster.stopJettySolrRunner(index); cluster.waitForJettyToStop(j); Thread.sleep(10000); JettySolrRunner newNode = cluster.startJettySolrRunner(); cluster.waitForAllNodes(30); assertTrue("trigger did not fire even after await()ing an excessive amount of time", triggerFiredLatch.await(60, TimeUnit.SECONDS)); assertTrue(triggerFired.get()); NodeAddedTrigger.NodeAddedEvent nodeAddedEvent = (NodeAddedTrigger.NodeAddedEvent) events.iterator().next(); assertNotNull(nodeAddedEvent); @SuppressWarnings({"unchecked"}) List<String> nodeNames = (List<String>)nodeAddedEvent.getProperty(TriggerEvent.NODE_NAMES); assertTrue(nodeNames.contains(newNode.getNodeName())); }