Search in sources :

Example 1 with HazelcastClientNotActiveException

use of com.hazelcast.client.HazelcastClientNotActiveException in project hazelcast by hazelcast.

the class ClientInvocation method notifyException.

public void notifyException(Throwable exception) {
    if (!lifecycleService.isRunning()) {
        clientInvocationFuture.complete(new HazelcastClientNotActiveException(exception.getMessage(), exception));
        return;
    }
    if ((isBindToSingleConnection() && exception instanceof IOException) || System.currentTimeMillis() > retryTimeoutPointInMillis) {
        clientInvocationFuture.complete(exception);
        return;
    }
    if (isRetrySafeException(exception) || invocationService.isRedoOperation() || (exception instanceof TargetDisconnectedException && clientMessage.isRetryable())) {
        try {
            ClientExecutionServiceImpl executionServiceImpl = (ClientExecutionServiceImpl) this.executionService;
            executionServiceImpl.schedule(this, RETRY_WAIT_TIME_IN_SECONDS, TimeUnit.SECONDS);
        } catch (RejectedExecutionException e) {
            if (logger.isFinestEnabled()) {
                logger.finest("Retry could not be scheduled ", e);
            }
            clientInvocationFuture.complete(exception);
        }
        return;
    }
    clientInvocationFuture.complete(exception);
}
Also used : HazelcastClientNotActiveException(com.hazelcast.client.HazelcastClientNotActiveException) TargetDisconnectedException(com.hazelcast.spi.exception.TargetDisconnectedException) IOException(java.io.IOException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with HazelcastClientNotActiveException

use of com.hazelcast.client.HazelcastClientNotActiveException in project hazelcast by hazelcast.

the class ClientInvocationServiceSupport method shutdown.

@Override
public void shutdown() {
    isShutdown = true;
    responseThread.interrupt();
    Iterator<ClientInvocation> iterator = callIdMap.values().iterator();
    while (iterator.hasNext()) {
        ClientInvocation invocation = iterator.next();
        iterator.remove();
        invocation.notifyException(new HazelcastClientNotActiveException("Client is shutting down"));
    }
    assert callIdMap.isEmpty();
}
Also used : HazelcastClientNotActiveException(com.hazelcast.client.HazelcastClientNotActiveException)

Example 3 with HazelcastClientNotActiveException

use of com.hazelcast.client.HazelcastClientNotActiveException in project hazelcast by hazelcast.

the class ClientInvocationServiceSupport method send.

protected void send(ClientInvocation invocation, ClientConnection connection) throws IOException {
    if (isShutdown) {
        throw new HazelcastClientNotActiveException("Client is shut down");
    }
    registerInvocation(invocation);
    ClientMessage clientMessage = invocation.getClientMessage();
    if (!isAllowedToSendRequest(connection, invocation) || !writeToConnection(connection, clientMessage)) {
        final long callId = clientMessage.getCorrelationId();
        ClientInvocation clientInvocation = deRegisterCallId(callId);
        if (clientInvocation != null) {
            throw new IOException("Packet not send to " + connection.getEndPoint());
        } else {
            if (invocationLogger.isFinestEnabled()) {
                invocationLogger.finest("Invocation not found to deregister for call id " + callId);
            }
            return;
        }
    }
    invocation.setSendConnection(connection);
}
Also used : HazelcastClientNotActiveException(com.hazelcast.client.HazelcastClientNotActiveException) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) IOException(java.io.IOException)

Aggregations

HazelcastClientNotActiveException (com.hazelcast.client.HazelcastClientNotActiveException)3 IOException (java.io.IOException)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 TargetDisconnectedException (com.hazelcast.spi.exception.TargetDisconnectedException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1