本文整理了Java中com.alipay.sofa.rpc.log.Logger.warnWithApp()
方法的一些代码示例,展示了Logger.warnWithApp()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warnWithApp()
方法的具体详情如下:
包路径:com.alipay.sofa.rpc.log.Logger
类名称:Logger
方法名:warnWithApp
[英]Warn with app.
[中]使用应用程序发出警告。
代码示例来源:origin: alipay/sofa-rpc
/**
* 打印连不上日志
*
* @param interfaceId 接口名称
* @param providerInfo 服务端
* @param transport 连接
* @param e 错误
*/
protected void printDead(String interfaceId, ProviderInfo providerInfo, ClientTransport transport, Exception e) {
Throwable cause = e.getCause();
if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
LOGGER.warnWithApp(consumerConfig.getAppName(),
"Connect to {} provider:{} failure !! The exception is " + ExceptionUtils.toShortString(e, 1)
+ (cause != null ? ", cause by " + cause.getMessage() + "." : "."),
interfaceId, providerInfo);
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 打印连不上日志
*
* @param interfaceId 接口名称
* @param providerInfo 服务端
* @param transport 连接
* @param e 错误
*/
protected void printDead(String interfaceId, ProviderInfo providerInfo, ClientTransport transport, Exception e) {
Throwable cause = e.getCause();
if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
LOGGER.warnWithApp(consumerConfig.getAppName(),
"Connect to {} provider:{} failure !! The exception is " + ExceptionUtils.toShortString(e, 1)
+ (cause != null ? ", cause by " + cause.getMessage() + "." : "."),
interfaceId, providerInfo);
}
}
代码示例来源: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
/**
* 检查方法,例如方法名、多态(重载)方法
*
* @param itfClass 接口类
*/
protected void checkMethods(Class<?> itfClass) {
ConcurrentHashMap<String, Boolean> methodsLimit = new ConcurrentHashMap<String, Boolean>();
for (Method method : itfClass.getMethods()) {
String methodName = method.getName();
if (methodsLimit.containsKey(methodName)) {
// 重名的方法
if (LOGGER.isWarnEnabled(providerConfig.getAppName())) {
LOGGER.warnWithApp(providerConfig.getAppName(), "Method with same name \"" + itfClass.getName()
+ "." + methodName + "\" exists ! The usage of overloading method in rpc is deprecated.");
}
}
// 判断服务下方法的黑白名单
Boolean include = methodsLimit.get(methodName);
if (include == null) {
include = inList(providerConfig.getInclude(), providerConfig.getExclude(), methodName); // 检查是否在黑白名单中
methodsLimit.putIfAbsent(methodName, include);
}
providerConfig.setMethodsLimit(methodsLimit);
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 客户端已经超时了(例如在队列里等待太久了),丢弃这个请求
*
* @param appName 应用
* @param serviceName 服务
* @param remoteAddress 远程地址
* @return 丢弃的异常
*/
private SofaRpcException clientTimeoutWhenReceiveRequest(String appName, String serviceName, String remoteAddress) {
String errorMsg = LogCodes.getLog(
LogCodes.ERROR_DISCARD_TIMEOUT_REQUEST, serviceName, remoteAddress);
if (LOGGER.isWarnEnabled(appName)) {
LOGGER.warnWithApp(appName, errorMsg);
}
return new SofaRpcException(RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg);
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 客户端已经超时了(例如在队列里等待太久了),丢弃这个请求
*
* @param appName 应用
* @param serviceName 服务
* @param remoteAddress 远程地址
* @return 丢弃的异常
*/
private SofaRpcException clientTimeoutWhenReceiveRequest(String appName, String serviceName, String remoteAddress) {
String errorMsg = LogCodes.getLog(
LogCodes.ERROR_DISCARD_TIMEOUT_REQUEST, serviceName, remoteAddress);
if (LOGGER.isWarnEnabled(appName)) {
LOGGER.warnWithApp(appName, errorMsg);
}
return new SofaRpcException(RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg);
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 客户端已经超时了(例如在业务执行时间太长),丢弃这个返回值
*
* @param appName 应用
* @param serviceName 服务
* @param remoteAddress 远程地址
* @return 丢弃的异常
*/
private SofaRpcException clientTimeoutWhenSendResponse(String appName, String serviceName, String remoteAddress) {
String errorMsg = LogCodes.getLog(
LogCodes.ERROR_DISCARD_TIMEOUT_RESPONSE, serviceName, remoteAddress);
if (LOGGER.isWarnEnabled(appName)) {
LOGGER.warnWithApp(appName, errorMsg);
}
return new SofaRpcException(RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg);
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 客户端已经超时了(例如在业务执行时间太长),丢弃这个返回值
*
* @param appName 应用
* @param serviceName 服务
* @param remoteAddress 远程地址
* @return 丢弃的异常
*/
private SofaRpcException clientTimeoutWhenSendResponse(String appName, String serviceName, String remoteAddress) {
String errorMsg = LogCodes.getLog(
LogCodes.ERROR_DISCARD_TIMEOUT_RESPONSE, serviceName, remoteAddress);
if (LOGGER.isWarnEnabled(appName)) {
LOGGER.warnWithApp(appName, errorMsg);
}
return new SofaRpcException(RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg);
}
代码示例来源:origin: alipay/sofa-rpc
@Override
public void run() {
// 状态变化通知监听器
for (ConsumerStateListener listener : onAvailable) {
try {
listener.onAvailable(consumerConfig.getConsumerBootstrap().getProxyIns());
} catch (Exception e) {
LOGGER.warnWithApp(consumerConfig.getAppName(),
"Failed to notify consumer state listener when state change to available");
}
}
}
});
代码示例来源:origin: alipay/sofa-rpc
@Override
public void run() {
// 状态变化通知监听器
for (ConsumerStateListener listener : onAvailable) {
try {
listener.onAvailable(consumerConfig.getConsumerBootstrap().getProxyIns());
} catch (Exception e) {
LOGGER.warnWithApp(consumerConfig.getAppName(),
"Failed to notify consumer state listener when state change to available");
}
}
}
});
代码示例来源:origin: alipay/sofa-rpc
/**
* 检测服务节点的一些信息
*
* @param providerGroup 服务列表分组
*/
protected void checkProviderInfo(ProviderGroup providerGroup) {
List<ProviderInfo> providerInfos = providerGroup == null ? null : providerGroup.getProviderInfos();
if (CommonUtils.isEmpty(providerInfos)) {
return;
}
Iterator<ProviderInfo> iterator = providerInfos.iterator();
while (iterator.hasNext()) {
ProviderInfo providerInfo = iterator.next();
if (!StringUtils.equals(providerInfo.getProtocolType(), consumerConfig.getProtocol())) {
if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
LOGGER.warnWithApp(consumerConfig.getAppName(),
"Unmatched protocol between consumer [{}] and provider [{}].",
consumerConfig.getProtocol(), providerInfo.getProtocolType());
}
}
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 检测服务节点的一些信息
*
* @param providerGroup 服务列表分组
*/
protected void checkProviderInfo(ProviderGroup providerGroup) {
List<ProviderInfo> providerInfos = providerGroup == null ? null : providerGroup.getProviderInfos();
if (CommonUtils.isEmpty(providerInfos)) {
return;
}
Iterator<ProviderInfo> iterator = providerInfos.iterator();
while (iterator.hasNext()) {
ProviderInfo providerInfo = iterator.next();
if (!StringUtils.equals(providerInfo.getProtocolType(), consumerConfig.getProtocol())) {
if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
LOGGER.warnWithApp(consumerConfig.getAppName(),
"Unmatched protocol between consumer [{}] and provider [{}].",
consumerConfig.getProtocol(), providerInfo.getProtocolType());
}
}
}
}
代码示例来源: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;
}
}
代码示例来源: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;
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 取消订阅服务列表
*/
public void unSubscribe() {
if (StringUtils.isEmpty(consumerConfig.getDirectUrl()) && consumerConfig.isSubscribe()) {
List<RegistryConfig> registryConfigs = consumerConfig.getRegistry();
if (registryConfigs != null) {
for (RegistryConfig registryConfig : registryConfigs) {
Registry registry = RegistryFactory.getRegistry(registryConfig);
try {
registry.unSubscribe(consumerConfig);
} catch (Exception e) {
String appName = consumerConfig.getAppName();
if (LOGGER.isWarnEnabled(appName)) {
LOGGER.warnWithApp(appName,
"Catch exception when unSubscribe from registry: " + registryConfig.getId()
+ ", but you can ignore if it's called by JVM shutdown hook", e);
}
}
}
}
}
}
代码示例来源:origin: alipay/sofa-rpc
@Override
public void updateProviders(ProviderGroup providerGroup) {
checkProviderInfo(providerGroup);
ProviderGroup oldProviderGroup = addressHolder.getProviderGroup(providerGroup.getName());
if (ProviderHelper.isEmpty(providerGroup)) {
addressHolder.updateProviders(providerGroup);
if (!ProviderHelper.isEmpty(oldProviderGroup)) {
if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
LOGGER.warnWithApp(consumerConfig.getAppName(), "Provider list is emptied, may be all " +
"providers has been closed, or this consumer has been add to blacklist");
closeTransports();
}
}
} else {
addressHolder.updateProviders(providerGroup);
connectionHolder.updateProviders(providerGroup);
}
if (EventBus.isEnable(ProviderInfoUpdateEvent.class)) {
ProviderInfoUpdateEvent event = new ProviderInfoUpdateEvent(consumerConfig, oldProviderGroup, providerGroup);
EventBus.post(event);
}
}
代码示例来源:origin: alipay/sofa-rpc
@Override
public void updateProviders(ProviderGroup providerGroup) {
checkProviderInfo(providerGroup);
ProviderGroup oldProviderGroup = addressHolder.getProviderGroup(providerGroup.getName());
if (ProviderHelper.isEmpty(providerGroup)) {
addressHolder.updateProviders(providerGroup);
if (!ProviderHelper.isEmpty(oldProviderGroup)) {
if (LOGGER.isWarnEnabled(consumerConfig.getAppName())) {
LOGGER.warnWithApp(consumerConfig.getAppName(), "Provider list is emptied, may be all " +
"providers has been closed, or this consumer has been add to blacklist");
closeTransports();
}
}
} else {
addressHolder.updateProviders(providerGroup);
connectionHolder.updateProviders(providerGroup);
}
if (EventBus.isEnable(ProviderInfoUpdateEvent.class)) {
ProviderInfoUpdateEvent event = new ProviderInfoUpdateEvent(consumerConfig, oldProviderGroup, providerGroup);
EventBus.post(event);
}
}
内容来源于网络,如有侵权,请联系作者删除!