com.alipay.sofa.rpc.log.Logger.isWarnEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(226)

本文整理了Java中com.alipay.sofa.rpc.log.Logger.isWarnEnabled()方法的一些代码示例,展示了Logger.isWarnEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isWarnEnabled()方法的具体详情如下:
包路径:com.alipay.sofa.rpc.log.Logger
类名称:Logger
方法名:isWarnEnabled

Logger.isWarnEnabled介绍

[英]Is warn enabled boolean.
[中]已启用警告布尔值。

代码示例

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void run() {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn("SOFA RPC Framework catch JVM shutdown event, Run shutdown hook now.");
    }
    destroy(false);
  }
}, "SOFA-RPC-ShutdownHook"));

代码示例来源:origin: alipay/sofa-rpc

@Override
public boolean start() {
  if (namingService == null) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn("Nacos client should be initialized before starting.");
    }
    return false;
  }
  return true;
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void run() {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn("SOFA RPC Framework catch JVM shutdown event, Run shutdown hook now.");
    }
    destroy(false);
  }
}, "SOFA-RPC-ShutdownHook"));

代码示例来源:origin: alipay/sofa-rpc

@Override
public boolean start() {
  if (namingService == null) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn("Nacos client should be initialized before starting.");
    }
    return false;
  }
  return true;
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(),
        executor.getPoolSize(), executor.getLargestPoolSize(), executor
          .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue()
          .size(), executor.getQueue().remainingCapacity()));
    }
    throw new RejectedExecutionException();
  }
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(),
        executor.getPoolSize(), executor.getLargestPoolSize(), executor
          .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue()
          .size(), executor.getQueue().remainingCapacity()));
    }
    throw new RejectedExecutionException();
  }
}

代码示例来源:origin: alipay/sofa-rpc

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  super.exceptionCaught(ctx, cause);
  if (LOGGER.isWarnEnabled()) {
    LOGGER.warn("", cause);
  }
  ctx.close();
}

代码示例来源:origin: alipay/sofa-rpc

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  super.exceptionCaught(ctx, cause);
  if (LOGGER.isWarnEnabled()) {
    LOGGER.warn("", cause);
  }
  ctx.close();
}

代码示例来源:origin: alipay/sofa-rpc

private static void handleEvent(final Subscriber subscriber, final Event event) {
    try {
      subscriber.onEvent(event);
    } catch (Throwable e) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn("Handle " + event.getClass() + " error", e);
      }
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

private static void handleEvent(final Subscriber subscriber, final Event event) {
    try {
      subscriber.onEvent(event);
    } catch (Throwable e) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn("Handle " + event.getClass() + " error", e);
      }
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

/**
 * 4.3 客户端异步收到响应,做准备,例如设置到上下文
 */
public static void clientAsyncReceivedPrepare() {
  if (openTrace) {
    try {
      tracer.clientAsyncReceivedPrepare();
    } catch (Exception e) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn(e.getMessage(), e);
      }
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

/**
 * 4.3 客户端异步收到响应,做准备,例如设置到上下文
 */
public static void clientAsyncReceivedPrepare() {
  if (openTrace) {
    try {
      tracer.clientAsyncReceivedPrepare();
    } catch (Exception e) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn(e.getMessage(), e);
      }
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

/**
 * 检查状态,在结束调用的时候进行调用,防止资源泄露
 */
public static void checkState() {
  if (openTrace) {
    try {
      tracer.checkState();
    } catch (Exception e) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn(e.getMessage(), e);
      }
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

@Override
public void destroy() {
  // 销毁前备份一下
  // LocalRegistryHelper.backup(regFile, memoryCache);
  try {
    if (scheduledExecutorService != null) {
      scheduledExecutorService.shutdown();
      scheduledExecutorService = null;
    }
  } catch (Throwable t) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn(t.getMessage(), t);
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

/**
 * 检查状态,在结束调用的时候进行调用,防止资源泄露
 */
public static void checkState() {
  if (openTrace) {
    try {
      tracer.checkState();
    } catch (Exception e) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn(e.getMessage(), e);
      }
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void run() {
    try {
      ClientTransportFactory.releaseTransport(transport, 0);
    } catch (Exception e) {
      if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
        LOGGER.warnWithApp(consumerConfig.getAppName(),
          "catch exception but ignore it when close alive client : {}", providerInfo);
      }
    } finally {
      latch.countDown();
    }
  }
});

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void run() {
    try {
      ClientTransportFactory.releaseTransport(transport, 0);
    } catch (Exception e) {
      if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
        LOGGER.warnWithApp(consumerConfig.getAppName(),
          "catch exception but ignore it when close alive client : {}", providerInfo);
      }
    } finally {
      latch.countDown();
    }
  }
});

代码示例来源:origin: alipay/sofa-rpc

@Override
public SofaResponse invoke() {
  if (isCircuitBreakerOpen() && LOGGER.isWarnEnabled(invoker.getConfig().getAppName())) {
    LOGGER.warnWithApp(invoker.getConfig().getAppName(), "Circuit Breaker is opened, method: {}#{}",
      invoker.getConfig().getInterfaceId(), request.getMethodName());
  }
  return execute();
}

代码示例来源:origin: alipay/sofa-rpc

@Override
public SofaResponse invoke() {
  if (isCircuitBreakerOpen() && LOGGER.isWarnEnabled(invoker.getConfig().getAppName())) {
    LOGGER.warnWithApp(invoker.getConfig().getAppName(), "Circuit Breaker is opened, method: {}#{}",
      invoker.getConfig().getInterfaceId(), request.getMethodName());
  }
  return execute();
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  public SofaResponse invoke() {
    if (isCircuitBreakerOpen() && LOGGER.isWarnEnabled(invoker.getConfig().getAppName())) {
      LOGGER.warnWithApp(invoker.getConfig().getAppName(), "Circuit Breaker is opened, method: {}#{}",
        invoker.getConfig().getInterfaceId(), request.getMethodName());
    }
    Future delegate = this.toObservable().toBlocking().toFuture();
    RpcInternalContext.getContext().setFuture(new HystrixResponseFuture(delegate, this.responseFuture));
    if (this.sofaResponse == null && this.responseFuture == null) {
      // 没有执行 construct,熔断或是线程池拒绝
      return new SofaResponse();
    }
    return this.sofaResponse;
  }
}

相关文章