Esempio n. 1
0
 public void operationComplete(ChannelFuture future) throws Exception {
   if (future.isSuccess()) {
     return;
   }
   if (request.getMessageType() != Constants.MESSAGE_TYPE_HEART) {
     connected = false;
   }
   InvocationResponse response = ProviderUtils.createFailResponse(request, future.getCause());
   processResponse(response);
 }
Esempio n. 2
0
 @Override
 public InvocationResponse doWrite(InvocationRequest request, Callback callback)
     throws NetworkException {
   Object[] msg = new Object[] {request, callback};
   ChannelFuture future = null;
   if (channel == null) {
     logger.error("channel is null ^^^^^^^^^^^^^^");
   } else {
     try {
       future = channel.write(msg);
     } catch (Exception e) {
       throw new NetworkException("remote call failed:" + request, e);
     }
     if (request.getMessageType() == Constants.MESSAGE_TYPE_SERVICE
         || request.getMessageType() == Constants.MESSAGE_TYPE_HEART) {
       future.addListener(new MsgWriteListener(request));
     }
   }
   return null;
 }
Esempio n. 3
0
 private void connectionException(Client client, Object attachment, Throwable e) {
   logger.info("exception while connecting to " + client, e);
   if (attachment == null) {
     return;
   }
   Object[] msg = (Object[]) attachment;
   if (msg[0] instanceof InvokerContext) {
     InvokerContext invokerContext = (InvokerContext) msg[0];
     InvocationRequest request = invokerContext.getRequest();
     if (request.getMessageType() == Constants.MESSAGE_TYPE_SERVICE && msg[1] != null) {
       try {
         Callback callback = (Callback) msg[1];
         if (client != null) {
           client.write(request, callback);
         } else {
           logger.error("no client found with service:" + request.getServiceName());
         }
       } catch (Throwable ex) {
         logger.error("", ex);
       }
       logger.error("", e);
     }
   }
 }
Esempio n. 4
0
 private String getRequestUrl(InvocationRequest request) {
   return request.getServiceName() + "#" + request.getMethodName();
 }