use of org.apache.cassandra.utils.concurrent.UncheckedInterruptedException in project cassandra by apache.
the class HintsDispatchExecutor method shutdownBlocking.
/*
* It's safe to terminate dispatch in process and to deschedule dispatch.
*/
void shutdownBlocking() {
scheduledDispatches.clear();
executor.shutdownNow();
try {
executor.awaitTermination(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
throw new UncheckedInterruptedException(e);
}
}
use of org.apache.cassandra.utils.concurrent.UncheckedInterruptedException in project cassandra by apache.
the class HintsService method transferHints.
/**
* Transfer all local hints to the hostId supplied by hostIdSupplier
*
* Flushes the buffer to make sure all hints are on disk and closes the hint writers
* so we don't leave any hint files around.
*
* After that, we serially dispatch all the hints in the HintsCatalog.
*
* If we fail delivering all hints, we will ask the hostIdSupplier for a new target host
* and retry delivering any remaining hints there, once, with a delay of 10 seconds before retrying.
*
* @param hostIdSupplier supplier of stream target host ids. This is generally
* the closest one according to the DynamicSnitch
* @return When this future is done, it either has streamed all hints to remote nodes or has failed with a proper
* log message
*/
public Future transferHints(Supplier<UUID> hostIdSupplier) {
Future flushFuture = writeExecutor.flushBufferPool(bufferPool);
Future closeFuture = writeExecutor.closeAllWriters();
try {
flushFuture.get();
closeFuture.get();
} catch (InterruptedException e) {
throw new UncheckedInterruptedException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
// unpause dispatch, or else transfer() will return immediately
resumeDispatch();
// wait for the current dispatch session to end
catalog.stores().forEach(dispatchExecutor::completeDispatchBlockingly);
return dispatchExecutor.transfer(catalog, hostIdSupplier);
}
use of org.apache.cassandra.utils.concurrent.UncheckedInterruptedException in project cassandra by apache.
the class SimpleClient method execute.
public Message.Response execute(Message.Request request, boolean throwOnErrorResponse) {
try {
request.attach(connection);
lastWriteFuture = channel.writeAndFlush(Collections.singletonList(request));
Message.Response msg = responseHandler.responses.poll(TIMEOUT_SECONDS, TimeUnit.SECONDS);
if (msg == null)
throw new RuntimeException("timeout");
if (throwOnErrorResponse && msg instanceof ErrorMessage)
throw new RuntimeException((Throwable) ((ErrorMessage) msg).error);
return msg;
} catch (InterruptedException e) {
throw new UncheckedInterruptedException(e);
}
}
Aggregations