Example usage for org.springframework.remoting RemoteConnectFailureException RemoteConnectFailureException

List of usage examples for org.springframework.remoting RemoteConnectFailureException RemoteConnectFailureException

Introduction

In this page you can find the example usage for org.springframework.remoting RemoteConnectFailureException RemoteConnectFailureException.

Prototype

public RemoteConnectFailureException(String msg, Throwable cause) 

Source Link

Document

Constructor for RemoteConnectFailureException.

Usage

From source file:org.apache.mina.springrpc.MinaClientInterceptor.java

protected RemoteAccessException convertMinaAccessException(Throwable ex) {
    if (ex instanceof SocketException) {
        throw new RemoteConnectFailureException(
                "Could not connect to Mina remote service at [" + getServiceUrl() + "]", ex);
    } else if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError
            || ex instanceof InvalidClassException) {
        throw new RemoteAccessException(
                "Could not deserialize result from Mina remote service [" + getServiceUrl() + "]", ex);
    } else {/*ww  w.j  a  v  a 2s  . c  om*/
        throw new RemoteAccessException("Could not access Mina remote service at [" + getServiceUrl() + "]",
                ex);
    }
}

From source file:com.turbospaces.network.NetworkCommunicationDispatcher.java

/**
 * send message(in form of {@link MethodCall}) to the remote destination with assigned correlation id.
 * //from   w  ww .ja  v a2s .c o m
 * @param destinations
 *            the target server nodes
 * @param methodCall
 *            remote method call
 * @param objectBuffer
 *            kryo's object buffer for entity serialization
 * @return original methodCall (pre-populated with correlation id)
 */
public MethodCall[] sendAndReceive(final MethodCall methodCall, final ObjectBuffer objectBuffer,
        final Address... destinations) {
    int size = destinations.length;
    MethodCall[] result = new MethodCall[size];
    Long[] ids = new Long[size];
    Object[] monitors = new Object[size];
    Message[] messages = new Message[size];

    for (int i = 0; i < size; i++) {
        Long correlationId = correlationIds.incrementAndGet();
        methodCall.setCorrelationId(correlationId.longValue());

        Message message = new Message();
        message.setSrc(configuration.getJChannel().getAddress());
        message.setDest(destinations[i]);
        message.setBuffer(objectBuffer.writeClassAndObject(methodCall));

        try {
            monitors[i] = requestResponseCorrelator.put(correlationId, null);
            ids[i] = correlationId;
            messages[i] = message;
            configuration.getJChannel().send(message);
            LOGGER.debug("sent jgroups message with correlation_id={} and destinations={}, methodCall={}",
                    new Object[] { correlationId, destinations, methodCall });
        } catch (Exception t) {
            requestResponseCorrelator.clear(correlationId);
            throw new RemoteConnectFailureException("unable to send message to " + destinations[i], t);
        }
    }

    // now collect all results in synchronous manner
    for (int i = 0; i < size; i++) {
        Long id = ids[i];
        Object monitor = monitors[i];
        result[i] = requestResponseCorrelator.responseFor(id, monitor,
                configuration.getCommunicationTimeoutInMillis());
    }

    return verifyNoExceptions(result, messages, methodCall);
}

From source file:org.xins.common.spring.XinsClientInterceptor.java

/**
 * Convert the given XINS exception to an appropriate Spring RemoteAccessException.
 *
 * @param ex//from  w  w  w. ja  v a 2  s .c  o m
 *    the exception to convert.
 *
 * @return
 *    the RemoteAccessException to throw.
 */
protected RemoteAccessException convertXinsAccessException(Throwable ex) {
    if (ex instanceof GenericCallException) {
        throw new RemoteConnectFailureException(
                "Cannot connect to Burlap remote service at [" + getServiceUrl() + "]", ex);
    } else {
        throw new RemoteAccessException("Cannot access Burlap remote service at [" + getServiceUrl() + "]", ex);
    }
}

From source file:com.turbospaces.spaces.SpaceReceiveAdapter.java

private void sendResponseBackAfterExecution(final MethodCall methodCall, final Runnable task,
        final Address address, final ObjectBuffer objectBuffer) throws RemoteConnectFailureException {
    try {//  w  ww  . ja  v a  2 s  . com
        task.run();
    } catch (RuntimeException ex) {
        methodCall.setException(ex);
        logger.error(ex.getMessage(), ex);
        Throwables.propagate(ex);
    } finally {
        JChannel jChannel = jSpace.getSpaceConfiguration().getJChannel();
        Message messageBack = new Message();
        messageBack.setBuffer(objectBuffer.writeClassAndObject(methodCall));
        messageBack.setDest(address);
        messageBack.setSrc(jChannel.getAddress());

        try {
            jChannel.send(messageBack);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new RemoteConnectFailureException("unable to send response back to " + address, e);
        }
    }
}

From source file:org.springframework.remoting.rmi.RmiClientInterceptorUtils.java

/**
 * Convert the given RemoteException that happened during remote access
 * to Spring's RemoteAccessException if the method signature does not
 * support RemoteException. Else, return the original RemoteException.
 * @param method the invoked method/*  w ww.j  av  a2 s . c  o  m*/
 * @param ex the RemoteException that happened
 * @param isConnectFailure whether the given exception should be considered
 * a connect failure
 * @param serviceName the name of the service (for debugging purposes)
 * @return the exception to be thrown to the caller
 */
public static Exception convertRmiAccessException(Method method, RemoteException ex, boolean isConnectFailure,
        String serviceName) {

    if (logger.isDebugEnabled()) {
        logger.debug("Remote service [" + serviceName + "] threw exception", ex);
    }
    if (ReflectionUtils.declaresException(method, ex.getClass())) {
        return ex;
    } else {
        if (isConnectFailure) {
            return new RemoteConnectFailureException(
                    "Could not connect to remote service [" + serviceName + "]", ex);
        } else {
            return new RemoteAccessException("Could not access remote service [" + serviceName + "]", ex);
        }
    }
}