List of usage examples for org.apache.solr.client.solrj.response RequestStatusState COMPLETED
RequestStatusState COMPLETED
To view the source code for org.apache.solr.client.solrj.response RequestStatusState COMPLETED.
Click Source Link
From source file:org.codice.ddf.commands.solr.BackupCommandTest.java
License:Open Source License
@Test public void testPerformSolrCloudAsynchronousBackupStatus() throws Exception { // Set system properties setupSystemProperties(SolrCommands.CLOUD_SOLR_CLIENT_TYPE); // Setup BackupCommand for async backup BackupCommand backupCommand = getAsnychronousBackupCommand(getBackupLocation(), DEFAULT_CORE_NAME, miniSolrCloud.getSolrClient()); // Perform Test (backup) backupCommand.execute();/*from w w w. java 2s. co m*/ String requestId = getRequestId(consoleOutput.getOutput()); // Setup BackupCommand for status lookup BackupCommand statusBackupCommand = getStatusBackupCommand(requestId, miniSolrCloud.getSolrClient()); consoleOutput.reset(); // Perform status lookup statusBackupCommand.execute(); String status = waitForCompletedStatusOrFail(statusBackupCommand, consoleOutput); assertThat(status, is(RequestStatusState.COMPLETED.getKey())); }
From source file:org.codice.ddf.commands.solr.BackupCommandTest.java
License:Open Source License
private String waitForCompletedStatusOrFail(BackupCommand statusBackupCommand, ConsoleOutput consoleOutput) throws Exception { long startTime = System.currentTimeMillis(); long endTime = startTime + TimeUnit.MINUTES.toMillis(TIMEOUT_IN_MINUTES); String status = getRequestStatus(consoleOutput.getOutput()); while (!StringUtils.equals(status, RequestStatusState.COMPLETED.getKey())) { if (System.currentTimeMillis() >= endTime) { fail(String.format(//from w ww .ja va 2s . co m "The backup status command did not complete within %s minute(s). Current backup status: %s.", TimeUnit.MINUTES.toMillis(TIMEOUT_IN_MINUTES), status)); } TimeUnit.SECONDS.sleep(1); consoleOutput.reset(); statusBackupCommand.execute(); status = getRequestStatus(consoleOutput.getOutput()); } return status; }
From source file:org.codice.ddf.commands.solr.RestoreCommand.java
License:Open Source License
private boolean restore(SolrClient client, String collection, String backupLocation, String backupName) throws IOException, InterruptedException, SolrServerException { if (!canRestore(client, collection)) { LOGGER.warn("Unable to restore collection {}", collection); return false; }/*ww w. j av a2s .c om*/ CollectionAdminRequest.Restore restore = CollectionAdminRequest.AsyncCollectionAdminRequest .restoreCollection(collection, backupName).setLocation(backupLocation); String syncReqId = restore.processAsync(client); boolean restoreComplete = false; while (true) { CollectionAdminRequest.RequestStatusResponse requestStatusResponse = CollectionAdminRequest .requestStatus(syncReqId).process(client); RequestStatusState requestStatus = requestStatusResponse.getRequestStatus(); if (requestStatus == RequestStatusState.COMPLETED) { LOGGER.debug("Restore status: {}", requestStatus); restoreComplete = true; break; } else if (requestStatus == RequestStatusState.FAILED || requestStatus == RequestStatusState.NOT_FOUND) { LOGGER.debug("Restore status: {}", requestStatus); printErrorMessage("Restore failed. "); printResponseErrorMessages(requestStatusResponse); break; } TimeUnit.SECONDS.sleep(1); } return restoreComplete; }
From source file:org.codice.ddf.commands.solr.RestoreCommandTest.java
License:Open Source License
@Test public void testPerformSolrCloudAsynchronousRestoreStatus() throws Exception { setupSystemProperties(SolrCommands.CLOUD_SOLR_CLIENT_TYPE); RestoreCommand restoreCommand = getAsnychronousRestoreCommand(getBackupLocation(), DEFAULT_CORE_NAME, miniSolrCloud.getSolrClient()); restoreCommand.execute();/*from www .j a va 2s . c om*/ String requestId = getRequestId(consoleOutput.getOutput()); RestoreCommand statusRestoreCommand = getStatusRestoreCommand(requestId, miniSolrCloud.getSolrClient()); consoleOutput.reset(); statusRestoreCommand.execute(); String status = waitForCompletedStatusOrFail(statusRestoreCommand, consoleOutput); assertThat(status, is(RequestStatusState.COMPLETED.getKey())); }
From source file:org.codice.ddf.commands.solr.RestoreCommandTest.java
License:Open Source License
private String waitForCompletedStatusOrFail(RestoreCommand statusRestoreCommand, ConsoleOutput consoleOutput) throws Exception { long startTime = System.currentTimeMillis(); long endTime = startTime + TimeUnit.MINUTES.toMillis(TIMEOUT_IN_MINUTES); String status = getRequestStatus(consoleOutput.getOutput()); while (!StringUtils.equals(status, RequestStatusState.COMPLETED.getKey())) { if (System.currentTimeMillis() >= endTime) { fail(String.format(/* ww w.j a va 2 s. c o m*/ "The restore status command did not complete within %s minute(s). Current restore status: %s.", TIMEOUT_IN_MINUTES, status)); } TimeUnit.SECONDS.sleep(1); consoleOutput.reset(); statusRestoreCommand.execute(); status = getRequestStatus(consoleOutput.getOutput()); } return status; }