List of usage examples for org.springframework.remoting RemoteAccessException RemoteAccessException
public RemoteAccessException(String msg)
From source file:com.zz.cluster4spring.support.invocation.DefaultEndpointSelectionPolicy.java
/** * Selects endpoint for invocation from the given list of endpoints. Simply * selects the first element from the list. * * @param aEndpoints// w w w. j a v a2s .co m * list of endpoints available for invocation of remote service * @return selected endpoints * @throws org.springframework.remoting.RemoteAccessException * throw if some error occured during seleting endpoint for * invocation */ public E selectServiceEndpoint(List<E> aEndpoints) throws RemoteAccessException { if (aEndpoints == null) { String message = "Unable to obtain service endpoint - list of endpoints is null"; if (fLog.isErrorEnabled()) { fLog.error(message); } throw new RemoteAccessException(message); } E result = null; try { // we simply always return first item from the list result = aEndpoints.iterator().next(); if (fLog.isTraceEnabled()) { SI serviceInfo = result.getServiceInfo(); String message = format("EndPoint selected. Service URL: [{0}]", serviceInfo); fLog.trace(message); } } catch (Exception e) { throw new RemoteLookupFailureException("Unable to obtain service endpoint", e); } return result; }
From source file:com.zz.cluster4spring.support.invocation.ShuffleEndpointSelectionPolicy.java
/** * Selects endpoint for invocation from the given list of endpoints. This * implementation creates copy of given list, shuffle it and selects * firstendpoint from resulting list./*ww w .jav a 2 s . c o m*/ * * @param aEndpoints * list of endpoints available for invocation of remote service * @return selected endpoints * @throws org.springframework.remoting.RemoteAccessException * throw if some error occured during seleting endpoint for * invocation * @see Collections#shuffle(java.util.List) */ public E selectServiceEndpoint(List<E> aEndpoints) throws RemoteAccessException { if (aEndpoints == null) { String message = "Unable to obtain service endpoint - list of endpoints is null"; if (fLog.isErrorEnabled()) { fLog.error(message); } throw new RemoteAccessException(message); } // we create copy of originated list, shuffle it and select first item // from that list List<E> copy = new ArrayList<E>(aEndpoints); Collections.shuffle(copy); E result = copy.get(0); if (fLog.isTraceEnabled()) { SI serviceInfo = result.getServiceInfo(); String message = format("EndPoint selected. Service URL: [{0}]", serviceInfo); fLog.trace(message); } return result; }
From source file:com.turbospaces.network.NetworkCommunicationDispatcher.java
/** * check each particular response and verify that there are no remote exceptions, otherwise thrown proper combined * exception./* w w w .j a v a 2 s . c om*/ * * @param result * remote execution result * @param messages * remote messages that have been sent to server node * @param methodCall * original method call * * @return result itself */ @VisibleForTesting static MethodCall[] verifyNoExceptions(final MethodCall[] result, final Message[] messages, final MethodCall methodCall) { int size = result.length; List<String> remoteExceptions = null; for (int i = 0; i < size; i++) { Message message = messages[i]; Address destination = message.getDest(); if (result[i] != null) { String exceptionAsString = result[i].getExceptionAsString(); if (exceptionAsString != null) { if (remoteExceptions == null) remoteExceptions = Lists.newArrayList(); remoteExceptions.add(String.format("failed to execute %s on %s due to: \n %s", methodCall, destination, exceptionAsString)); } } } if (remoteExceptions != null) { StringBuilder builder = new StringBuilder(); builder.append("unable to call remote method(s) due to single(multiple) failures: ").append("\n"); for (String e : remoteExceptions) { builder.append("\t"); builder.append(e); builder.append("\n"); } String failure = builder.toString(); LOGGER.error(failure); throw new RemoteAccessException(failure); } return result; }