private void dispose(IOException error) { ArrayList<FutureResponse> requests=null; synchronized(requestMap) { if( this.error==null) { this.error = error; requests = new ArrayList<FutureResponse>(requestMap.values()); requestMap.clear(); } } if( requests!=null ) { for (Iterator<FutureResponse> iter = requests.iterator(); iter.hasNext();) { FutureResponse fr = iter.next(); fr.set(new ExceptionResponse(error)); } } }
public void onCommand(Object o) { Command command = null; if (o instanceof Command) { command = (Command)o; } else { throw new ClassCastException("Object cannot be converted to a Command, Object: " + o); } if (command.isResponse()) { Response response = (Response)command; FutureResponse future = null; synchronized (requestMap) { future = requestMap.remove(Integer.valueOf(response.getCorrelationId())); } if (future != null) { future.set(response); } else { if (debug) { LOG.debug("Received unexpected response: {" + command + "}for command id: " + response.getCorrelationId()); } } } else { getTransportListener().onCommand(command); } }
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback, this); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }
private void dispose(IOException error) { ArrayList<FutureResponse> requests=null; synchronized(requestMap) { if( this.error==null) { this.error = error; requests = new ArrayList<FutureResponse>(requestMap.values()); requestMap.clear(); } } if( requests!=null ) { for (Iterator<FutureResponse> iter = requests.iterator(); iter.hasNext();) { FutureResponse fr = iter.next(); fr.set(new ExceptionResponse(error)); } } }
private void dispose(IOException error) { ArrayList<FutureResponse> requests=null; synchronized(requestMap) { if( this.error==null) { this.error = error; requests = new ArrayList<FutureResponse>(requestMap.values()); requestMap.clear(); } } if( requests!=null ) { for (Iterator<FutureResponse> iter = requests.iterator(); iter.hasNext();) { FutureResponse fr = iter.next(); fr.set(new ExceptionResponse(error)); } } }
private void dispose(IOException error) { ArrayList<FutureResponse> requests=null; synchronized(requestMap) { if( this.error==null) { this.error = error; requests = new ArrayList<FutureResponse>(requestMap.values()); requestMap.clear(); } } if( requests!=null ) { for (Iterator<FutureResponse> iter = requests.iterator(); iter.hasNext();) { FutureResponse fr = iter.next(); fr.set(new ExceptionResponse(error)); } } }
private void dispose(IOException error) { ArrayList<FutureResponse> requests=null; synchronized(requestMap) { if( this.error==null) { this.error = error; requests = new ArrayList<FutureResponse>(requestMap.values()); requestMap.clear(); } } if( requests!=null ) { for (Iterator<FutureResponse> iter = requests.iterator(); iter.hasNext();) { FutureResponse fr = iter.next(); fr.set(new ExceptionResponse(error)); } } }
protected void doStop(ServiceStopper serviceStopper) throws IOException { brokerControl.removeBrokerModelChangedListener(this); brokerControl.removeMessageDistribution(this); IOException stopped = new IOException("stopped"); ArrayList<MultiCallback> requests; synchronized (requestMap) { requests = new ArrayList<>(requestMap.keySet()); requestMap.clear(); } for (MultiCallback multiCallback : requests) { FutureResponse futureResponse = new FutureResponse(multiCallback.getCallback()); futureResponse.set(new ExceptionResponse(stopped)); multiCallback.onCompletion(futureResponse); } }
protected void doStop(ServiceStopper serviceStopper) throws IOException { brokerControl.removeBrokerModelChangedListener(this); brokerControl.removeMessageDistribution(this); IOException stopped = new IOException("stopped"); ArrayList<MultiCallback> requests; synchronized (requestMap) { requests = new ArrayList<>(requestMap.keySet()); requestMap.clear(); } for (MultiCallback multiCallback : requests) { FutureResponse futureResponse = new FutureResponse(multiCallback.getCallback()); futureResponse.set(new ExceptionResponse(stopped)); multiCallback.onCompletion(futureResponse); } }
public void onCommand(Object o) { Command command = null; if (o instanceof Command) { command = (Command)o; } else { throw new ClassCastException("Object cannot be converted to a Command, Object: " + o); } if (command.isResponse()) { Response response = (Response)command; FutureResponse future = null; synchronized (requestMap) { future = requestMap.remove(Integer.valueOf(response.getCorrelationId())); } if (future != null) { future.set(response); } else { if (debug) { LOG.debug("Received unexpected response: {" + command + "}for command id: " + response.getCorrelationId()); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(Object o) { Command command = null; if (o instanceof Command) { command = (Command)o; } else { throw new ClassCastException("Object cannot be converted to a Command, Object: " + o); } if (command.isResponse()) { Response response = (Response)command; FutureResponse future = null; synchronized (requestMap) { future = requestMap.remove(Integer.valueOf(response.getCorrelationId())); } if (future != null) { future.set(response); } else { if (debug) { LOG.debug("Received unexpected response: {" + command + "}for command id: " + response.getCorrelationId()); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(Object o) { Command command = null; if (o instanceof Command) { command = (Command)o; } else { throw new ClassCastException("Object cannot be converted to a Command, Object: " + o); } if (command.isResponse()) { Response response = (Response)command; FutureResponse future = null; synchronized (requestMap) { future = requestMap.remove(Integer.valueOf(response.getCorrelationId())); } if (future != null) { future.set(response); } else { if (debug) { LOG.debug("Received unexpected response: {" + command + "}for command id: " + response.getCorrelationId()); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(Object o) { Command command = null; if (o instanceof Command) { command = (Command)o; } else { throw new ClassCastException("Object cannot be converted to a Command, Object: " + o); } if (command.isResponse()) { Response response = (Response)command; FutureResponse future = null; synchronized (requestMap) { future = requestMap.remove(Integer.valueOf(response.getCorrelationId())); } if (future != null) { future.set(response); } else { if (debug) { LOG.debug("Received unexpected response: {" + command + "}for command id: " + response.getCorrelationId()); } } } else { getTransportListener().onCommand(command); } }
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback, this); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback, this); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback, this); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }