Ejemplo n.º 1
0
 @Override
 public void run() {
   try {
     TBase<?, ?> tBase = SerializationUtils.deserialize(bytes, deserializerFactory);
     dispatchHandler.dispatchSendMessage(tBase);
   } catch (TException e) {
     if (logger.isWarnEnabled()) {
       logger.warn(
           "packet serialize error. SendSocketAddress:{} Cause:{}",
           remoteAddress,
           e.getMessage(),
           e);
     }
     if (logger.isDebugEnabled()) {
       logger.debug("packet dump hex:{}", PacketUtils.dumpByteArray(bytes));
     }
   } catch (Exception e) {
     // there are cases where invalid headers are received
     if (logger.isWarnEnabled()) {
       logger.warn(
           "Unexpected error. SendSocketAddress:{} Cause:{}", remoteAddress, e.getMessage(), e);
     }
     if (logger.isDebugEnabled()) {
       logger.debug("packet dump hex:{}", PacketUtils.dumpByteArray(bytes));
     }
   }
 }
Ejemplo n.º 2
0
    @Override
    public void run() {

      byte[] bytes = requestPacket.getPayload();
      SocketAddress remoteAddress = pinpointSocket.getRemoteAddress();
      try {
        TBase<?, ?> tBase = SerializationUtils.deserialize(bytes, deserializerFactory);
        if (tBase instanceof L4Packet) {
          if (logger.isDebugEnabled()) {
            L4Packet packet = (L4Packet) tBase;
            logger.debug("tcp l4 packet {}", packet.getHeader());
          }
          return;
        }
        TBase result = dispatchHandler.dispatchRequestMessage(tBase);
        if (result != null) {
          byte[] resultBytes = SerializationUtils.serialize(result, serializerFactory);
          pinpointSocket.response(requestPacket, resultBytes);
        }
      } catch (TException e) {
        if (logger.isWarnEnabled()) {
          logger.warn(
              "packet serialize error. SendSocketAddress:{} Cause:{}",
              remoteAddress,
              e.getMessage(),
              e);
        }
        if (logger.isDebugEnabled()) {
          logger.debug("packet dump hex:{}", PacketUtils.dumpByteArray(bytes));
        }
      } catch (Exception e) {
        // there are cases where invalid headers are received
        if (logger.isWarnEnabled()) {
          logger.warn(
              "Unexpected error. SendSocketAddress:{} Cause:{}", remoteAddress, e.getMessage(), e);
        }
        if (logger.isDebugEnabled()) {
          logger.debug("packet dump hex:{}", PacketUtils.dumpByteArray(bytes));
        }
      }
    }