use of io.crate.action.sql.BaseResultReceiver in project crate by crate.
the class RetryOnFailureResultReceiverTest method testRetryIsInvokedOnIndexNotFoundException.
@Test
public void testRetryIsInvokedOnIndexNotFoundException() throws Exception {
AtomicInteger numRetries = new AtomicInteger(0);
BaseResultReceiver resultReceiver = new BaseResultReceiver();
ClusterState initialState = clusterService.state();
RetryOnFailureResultReceiver retryOnFailureResultReceiver = new RetryOnFailureResultReceiver(clusterService, initialState, indexName -> true, resultReceiver, UUID.randomUUID(), (newJobId, receiver) -> numRetries.incrementAndGet());
// Must have a different cluster state then the initial state to trigger a retry
clusterService.submitStateUpdateTask("dummy", new DummyUpdate());
assertBusy(() -> assertThat(initialState, Matchers.not(sameInstance(clusterService.state()))));
retryOnFailureResultReceiver.fail(new IndexNotFoundException("t1"));
assertThat(numRetries.get(), is(1));
}
use of io.crate.action.sql.BaseResultReceiver in project crate by crate.
the class TableStatsService method updateStats.
public void updateStats() {
if (clusterService.localNode() == null) {
/*
During a long startup (e.g. during an upgrade process) the localNode() may be null
and this would lead to NullPointerException in the TransportExecutor.
*/
LOGGER.debug("Could not retrieve table stats. localNode is not fully available yet.");
return;
}
if (!clusterService.state().nodes().isLocalNodeElectedMaster()) {
// `ANALYZE` will publish the new stats to all nodes, so we need only a single node running it.
return;
}
try {
BaseResultReceiver resultReceiver = new BaseResultReceiver();
resultReceiver.completionFuture().whenComplete((res, err) -> {
scheduledRefresh = scheduleNextRefresh(refreshInterval);
if (err != null) {
LOGGER.error("Error running periodic " + STMT + "", err);
}
});
session.quickExec(STMT, stmt -> PARSED_STMT, resultReceiver, Row.EMPTY);
} catch (Throwable t) {
LOGGER.error("error retrieving table stats", t);
}
}
Aggregations