Search in sources :

Example 1 with ServiceConnectFailedException

use of com.sleepycat.je.rep.utilint.ServiceDispatcher.ServiceConnectFailedException in project qpid-broker-j by apache.

the class ReplicatedEnvironmentFacade method getPermittedHostsFromHelper.

private static Collection<String> getPermittedHostsFromHelper(final String nodeName, final String groupName, final String helperNodeName, final String helperHostPort, final int dbPingSocketTimeout) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(String.format("Requesting state of the node '%s' at '%s'", helperNodeName, helperHostPort));
    }
    if (helperNodeName == null || "".equals(helperNodeName)) {
        throw new IllegalConfigurationException(String.format("A helper node is not specified for node '%s'" + " joining the group '%s'", nodeName, groupName));
    }
    Collection<String> permittedNodes = null;
    try {
        ReplicationNodeImpl node = new ReplicationNodeImpl(helperNodeName, helperHostPort);
        NodeState state = getRemoteNodeState(groupName, node, dbPingSocketTimeout);
        byte[] applicationState = state.getAppState();
        return convertApplicationStateBytesToPermittedNodeList(applicationState);
    } catch (SocketTimeoutException ste) {
        throw new ExternalServiceTimeoutException(String.format("Timed out trying to connect to existing node '%s' at '%s'", helperNodeName, helperHostPort), ste);
    } catch (IOException | ServiceConnectFailedException e) {
        throw new ExternalServiceException(String.format("Cannot connect to existing node '%s' at '%s'", helperNodeName, helperHostPort), e);
    } catch (BinaryProtocol.ProtocolException e) {
        String message = String.format("Unexpected protocol exception '%s' encountered while retrieving state for node '%s' (%s) from group '%s'", e.getUnexpectedMessage(), helperNodeName, helperHostPort, groupName);
        LOGGER.warn(message, e);
        throw new ExternalServiceException(message, e);
    } catch (RuntimeException e) {
        throw new ExternalServiceException(String.format("Cannot retrieve state for node '%s' (%s) from group '%s'", helperNodeName, helperHostPort, groupName), e);
    }
}
Also used : ExternalServiceTimeoutException(org.apache.qpid.server.util.ExternalServiceTimeoutException) BinaryProtocol(com.sleepycat.je.rep.utilint.BinaryProtocol) ExternalServiceException(org.apache.qpid.server.util.ExternalServiceException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException) SocketTimeoutException(java.net.SocketTimeoutException) ServiceConnectFailedException(com.sleepycat.je.rep.utilint.ServiceDispatcher.ServiceConnectFailedException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException)

Aggregations

BinaryProtocol (com.sleepycat.je.rep.utilint.BinaryProtocol)1 ServiceConnectFailedException (com.sleepycat.je.rep.utilint.ServiceDispatcher.ServiceConnectFailedException)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1 ExternalServiceException (org.apache.qpid.server.util.ExternalServiceException)1 ExternalServiceTimeoutException (org.apache.qpid.server.util.ExternalServiceTimeoutException)1 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)1