@Test public void do_not_log_errors_when_hazelcast_is_not_active() { logging.setLevel(DEBUG); doThrow(new HazelcastInstanceNotActiveException()).when(sharedHealthState).writeMine(any()); ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class); underTest.start(); verify(executorService).scheduleWithFixedDelay(runnableCaptor.capture(), eq(1L), eq(10L), eq(TimeUnit.SECONDS)); Runnable runnable = runnableCaptor.getValue(); runnable.run(); assertThat(logging.getLogs(ERROR)).isEmpty(); assertThat(logging.hasLog(DEBUG, "Hazelcast is no more active")).isTrue(); } }
@Override public RuntimeException get() { return new HazelcastInstanceNotActiveException(); } })
@Override public boolean removeLifecycleListener(String registrationId) { throw new HazelcastInstanceNotActiveException(); } }
public HazelcastInstanceImpl getOriginal() { final HazelcastInstanceImpl hazelcastInstance = original; if (hazelcastInstance == null) { throw new HazelcastInstanceNotActiveException(); } return hazelcastInstance; }
@Override public Throwable createException(String message, Throwable cause) { return new HazelcastInstanceNotActiveException(message); } });
@Override public RuntimeException get() { return new HazelcastInstanceNotActiveException(); } })
@Override public Throwable createException(String message, Throwable cause) { return new HazelcastInstanceNotActiveException(message); } });
public HazelcastInstanceImpl getOriginal() { final HazelcastInstanceImpl hazelcastInstance = original; if (hazelcastInstance == null) { throw new HazelcastInstanceNotActiveException(); } return hazelcastInstance; }
@Override public String addLifecycleListener(LifecycleListener lifecycleListener) { throw new HazelcastInstanceNotActiveException(); }
private void failIfNotRunning() { if (!nodeEngine.isRunning()) { throw new HazelcastInstanceNotActiveException(); } }
private boolean engineActive() { NodeState state = context.node.getState(); if (state == NodeState.ACTIVE) { return true; } boolean allowed = state == NodeState.PASSIVE && (op instanceof AllowedDuringPassiveState); if (!allowed) { notifyError(new HazelcastInstanceNotActiveException("State: " + state + " Operation: " + op.getClass())); remote = false; } return allowed; }
public void shutdown() { alive = false; for (Invocation invocation : this) { try { invocation.notifyError(new HazelcastInstanceNotActiveException()); } catch (Throwable e) { logger.warning(invocation + " could not be notified with shutdown message -> " + e.getMessage(), e); } } } }
private boolean engineActive() { NodeState state = context.node.getState(); if (state == NodeState.ACTIVE) { return true; } boolean allowed = state == NodeState.PASSIVE && (op instanceof AllowedDuringPassiveState); if (!allowed) { notifyError(new HazelcastInstanceNotActiveException("State: " + state + " Operation: " + op.getClass())); remote = false; } return allowed; }
private void completeWhenRetryRejected(RejectedExecutionException e) { if (context.logger.isFinestEnabled()) { context.logger.finest(e); } complete(new HazelcastInstanceNotActiveException(e.getMessage())); }
private void completeWhenRetryRejected(RejectedExecutionException e) { if (context.logger.isFinestEnabled()) { context.logger.finest(e); } complete(new HazelcastInstanceNotActiveException(e.getMessage())); }
private void sendResponseAfterOperationError(Operation operation, Throwable e) { try { if (node.getState() != NodeState.SHUT_DOWN) { operation.sendResponse(e); } else if (operation.executedLocally()) { operation.sendResponse(new HazelcastInstanceNotActiveException()); } } catch (Throwable t) { logger.warning("While sending op error... op: " + operation + ", error: " + e, t); } }
private void sendResponseAfterOperationError(Operation operation, Throwable e) { try { if (node.getState() != NodeState.SHUT_DOWN) { operation.sendResponse(e); } else if (operation.executedLocally()) { operation.sendResponse(new HazelcastInstanceNotActiveException()); } } catch (Throwable t) { logger.warning("While sending op error... op: " + operation + ", error: " + e, t); } }
private void handleAuthenticationFailure() { Exception exception; if (nodeEngine.isRunning()) { String message = "Client " + endpoint + " must authenticate before any operation."; logger.severe(message); exception = new RetryableHazelcastException(new StubAuthenticationException(message)); } else { exception = new HazelcastInstanceNotActiveException(); } sendClientMessage(exception); connection.close("Authentication failed. " + exception.getMessage(), null); }
private void handleAuthenticationFailure() { Exception exception; if (nodeEngine.isRunning()) { String message = "Client " + endpoint + " must authenticate before any operation."; logger.severe(message); exception = new RetryableHazelcastException(new StubAuthenticationException(message)); } else { exception = new HazelcastInstanceNotActiveException(); } sendClientMessage(exception); connection.close("Authentication failed. " + exception.getMessage(), null); }
void initializeAndProcessMessage() throws Throwable { if (!node.getNodeExtension().isStartCompleted()) { throw new HazelcastInstanceNotActiveException("Hazelcast instance is not ready yet!"); } parameters = decodeClientMessage(clientMessage); Credentials credentials = endpoint.getCredentials(); interceptBefore(credentials); checkPermissions(endpoint); processMessage(); interceptAfter(credentials); }