Esempio n. 1
0
 private void receive(SendPacket sendPacket, PinpointSocket pinpointSocket) {
   try {
     worker.execute(new Dispatch(sendPacket.getPayload(), pinpointSocket.getRemoteAddress()));
   } catch (RejectedExecutionException e) {
     // cause is clear - full stack trace not necessary
     logger.warn("RejectedExecutionException Caused:{}", e.getMessage());
   }
 }
Esempio 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));
        }
      }
    }