コード例 #1
0
 static {
   boolean disabled;
   if (SystemPropertyUtil.get("io.netty.noResourceLeakDetection") != null) {
     boolean disabled = SystemPropertyUtil.getBoolean("io.netty.noResourceLeakDetection", false);
     logger.debug("-Dio.netty.noResourceLeakDetection: {}", Boolean.valueOf(disabled));
     logger.warn(
         "-Dio.netty.noResourceLeakDetection is deprecated. Use '-D{}={}' instead.",
         "io.netty.leakDetectionLevel",
         DEFAULT_LEVEL.name().toLowerCase());
   } else {
     disabled = false;
   }
   Level defaultLevel = disabled ? Level.DISABLED : DEFAULT_LEVEL;
   String levelStr =
       SystemPropertyUtil.get("io.netty.leakDetectionLevel", defaultLevel.name())
           .trim()
           .toUpperCase();
   Level level = DEFAULT_LEVEL;
   for (Level l : EnumSet.allOf(Level.class)) {
     if ((levelStr.equals(l.name())) || (levelStr.equals(String.valueOf(l.ordinal())))) {
       level = l;
     }
   }
   level = level;
   if (logger.isDebugEnabled()) {
     logger.debug("-D{}: {}", "io.netty.leakDetectionLevel", level.name().toLowerCase());
   }
 }
コード例 #2
0
 @Override
 protected void encode(ChannelHandlerContext ctx, SingleResponse response, List<Object> out)
     throws WeixinException {
   String content = response.toContent();
   ctx.writeAndFlush(HttpUtil.createHttpResponse(content, ServerToolkits.CONTENTTYPE$TEXT_PLAIN));
   logger.debug("encode single response:{}", content);
 }
コード例 #3
0
 private static void processGoAwayWriteResult(
     final ChannelHandlerContext ctx,
     final int lastStreamId,
     final long errorCode,
     final ByteBuf debugData,
     ChannelFuture future) {
   try {
     if (future.isSuccess()) {
       if (errorCode != NO_ERROR.code()) {
         if (logger.isDebugEnabled()) {
           logger.debug(
               format(
                   "Sent GOAWAY: lastStreamId '%d', errorCode '%d', "
                       + "debugData '%s'. Forcing shutdown of the connection.",
                   lastStreamId, errorCode, debugData.toString(UTF_8)),
               future.cause());
         }
         ctx.close();
       }
     } else {
       if (logger.isErrorEnabled()) {
         logger.error(
             format(
                 "Sending GOAWAY failed: lastStreamId '%d', errorCode '%d', "
                     + "debugData '%s'. Forcing shutdown of the connection.",
                 lastStreamId, errorCode, debugData.toString(UTF_8)),
             future.cause());
       }
       ctx.close();
     }
   } finally {
     // We're done with the debug data now.
     debugData.release();
   }
 }
コード例 #4
0
ファイル: SslHandler.java プロジェクト: hsoumare/netty
  /** Notify all the handshake futures about the failure during the handshake. */
  private void setHandshakeFailure(Throwable cause) {
    // Release all resources such as internal buffers that SSLEngine
    // is managing.
    engine.closeOutbound();

    try {
      engine.closeInbound();
    } catch (SSLException e) {
      // only log in debug mode as it most likely harmless and latest chrome still trigger
      // this all the time.
      //
      // See https://github.com/netty/netty/issues/1340
      String msg = e.getMessage();
      if (msg == null || !msg.contains("possible truncation attack")) {
        logger.debug("SSLEngine.closeInbound() raised an exception.", e);
      }
    }
    notifyHandshakeFailure(cause);
    for (; ; ) {
      PendingWrite write = pendingUnencryptedWrites.poll();
      if (write == null) {
        break;
      }
      write.failAndRecycle(cause);
    }
  }
コード例 #5
0
  static {
    DEFAULT_EVENT_LOOP_THREADS =
        Math.max(
            1,
            SystemPropertyUtil.getInt(
                "io.netty.eventLoopThreads", Runtime.getRuntime().availableProcessors() * 2));

    if (logger.isDebugEnabled()) {
      logger.debug("-Dio.netty.eventLoopThreads: {}", DEFAULT_EVENT_LOOP_THREADS);
    }
  }
コード例 #6
0
 /**
  * Implementation of a an observer which checks for RedisURI beans and stores them in {@link
  * #redisUris} for later association with corresponding repository beans.
  *
  * @param <T> The type.
  * @param processBean The annotated type as defined by CDI.
  */
 @SuppressWarnings("unchecked")
 <T> void processBean(@Observes ProcessBean<T> processBean) {
   Bean<T> bean = processBean.getBean();
   for (Type type : bean.getTypes()) {
     // Check if the bean is an RedisURI.
     if (type instanceof Class<?> && RedisURI.class.isAssignableFrom((Class<?>) type)) {
       Set<Annotation> qualifiers = new HashSet<Annotation>(bean.getQualifiers());
       if (bean.isAlternative() || !redisUris.containsKey(qualifiers)) {
         LOGGER.debug(
             String.format(
                 "Discovered '%s' with qualifiers %s.", RedisURI.class.getName(), qualifiers));
         redisUris.put(qualifiers, (Bean<RedisURI>) bean);
       }
     }
   }
 }
コード例 #7
0
ファイル: SslHandler.java プロジェクト: njutony1991/netty
  /** Notify all the handshake futures about the successfully handshake */
  private void setHandshakeSuccess() {
    // Work around the JVM crash which occurs when a cipher suite with GCM enabled.
    final String cipherSuite = String.valueOf(engine.getSession().getCipherSuite());
    if (!wantsDirectBuffer && (cipherSuite.contains("_GCM_") || cipherSuite.contains("-GCM-"))) {
      wantsInboundHeapBuffer = true;
    }

    handshakePromise.trySuccess(ctx.channel());

    if (logger.isDebugEnabled()) {
      logger.debug("{} HANDSHAKEN: {}", ctx.channel(), engine.getSession().getCipherSuite());
    }
    ctx.fireUserEventTriggered(SslHandshakeCompletionEvent.SUCCESS);

    if (readDuringHandshake && !ctx.channel().config().isAutoRead()) {
      readDuringHandshake = false;
      ctx.read();
    }
  }
コード例 #8
0
ファイル: SslHandler.java プロジェクト: njutony1991/netty
  /** Notify all the handshake futures about the failure during the handshake. */
  private void setHandshakeFailure(ChannelHandlerContext ctx, Throwable cause) {
    // Release all resources such as internal buffers that SSLEngine
    // is managing.
    engine.closeOutbound();

    try {
      engine.closeInbound();
    } catch (SSLException e) {
      // only log in debug mode as it most likely harmless and latest chrome still trigger
      // this all the time.
      //
      // See https://github.com/netty/netty/issues/1340
      String msg = e.getMessage();
      if (msg == null || !msg.contains("possible truncation attack")) {
        logger.debug("{} SSLEngine.closeInbound() raised an exception.", ctx.channel(), e);
      }
    }
    notifyHandshakeFailure(cause);
    pendingUnencryptedWrites.removeAndFailAll(cause);
  }
コード例 #9
0
ファイル: SslHandler.java プロジェクト: hsoumare/netty
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    if (ignoreException(cause)) {
      // It is safe to ignore the 'connection reset by peer' or
      // 'broken pipe' error after sending close_notify.
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Swallowing a harmless 'connection reset by peer / broken pipe' error that occurred "
                + "while writing close_notify in response to the peer's close_notify",
            cause);
      }

      // Close the connection explicitly just in case the transport
      // did not close the connection automatically.
      if (ctx.channel().isActive()) {
        ctx.close();
      }
    } else {
      ctx.fireExceptionCaught(cause);
    }
  }
コード例 #10
0
ファイル: PublishProcesser.java プロジェクト: ifa6/mqtt.io
  public Message proc(Message msg, ChannelHandlerContext ctx) {
    String clientId = MemPool.getClientId(ctx.channel());
    if (clientId == null) {
      return DISCONNECT;
    }

    PublishMessage pm = (PublishMessage) msg;
    Set<ChannelEntity> channelEntitys = MemPool.getChannelByTopics(pm.getTopic());
    if (channelEntitys == null) {
      return null;
    }

    for (ChannelEntity channelEntity : channelEntitys) {
      logger.debug(
          "PUBLISH to ChannelEntity topic = "
              + pm.getTopic()
              + " payload = "
              + pm.getDataAsString());
      channelEntity.write(pm);
    }

    return null;
  }
コード例 #11
0
 static {
   InternalLogger logger = InternalLoggerFactory.getInstance(SocketConnectionAttemptTest.class);
   logger.debug("-Dio.netty.testsuite.badHost: {}", BAD_HOST);
   logger.debug("-Dio.netty.testsuite.badPort: {}", BAD_PORT);
 }
コード例 #12
0
 public void debug(Object arg0, Throwable arg1) {
   if (arg1 == null) return;
   if (arg0 != null) _log.debug(arg0.toString(), arg1);
   else _log.debug("null", arg1);
 }
コード例 #13
0
 public void debug(Object arg0) {
   if (arg0 != null) _log.debug(arg0.toString());
   else _log.debug("null");
 }