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

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

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

Logger.infoWithApp介绍

[英]Info with app.
[中]信息与应用程序。

代码示例

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

/**
 * 打印连接失败日志
 *
 * @param interfaceId  接口名称
 * @param providerInfo 服务端
 * @param transport    连接
 */
protected void printFailure(String interfaceId, ProviderInfo providerInfo, ClientTransport transport) {
  if (LOGGER.isInfoEnabled(consumerConfig.getAppName())) {
    LOGGER.infoWithApp(consumerConfig.getAppName(), "Connect to {} provider:{} failure !", interfaceId,
      providerInfo);
  }
}

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

/**
 * 打印连接失败日志
 *
 * @param interfaceId  接口名称
 * @param providerInfo 服务端
 * @param transport    连接
 */
protected void printFailure(String interfaceId, ProviderInfo providerInfo, ClientTransport transport) {
  if (LOGGER.isInfoEnabled(consumerConfig.getAppName())) {
    LOGGER.infoWithApp(consumerConfig.getAppName(), "Connect to {} provider:{} failure !", interfaceId,
      providerInfo);
  }
}

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

@Override
public void unSubscribe(ConsumerConfig config) {
  String appName = config.getAppName();
  if (!registryConfig.isSubscribe()) {
    // 注册中心不订阅
    if (LOGGER.isInfoEnabled(appName)) {
      LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE));
    }
  }
  // 注册Consumer节点
  if (config.isRegister()) {
    // 向服务器端发送取消订阅请求
    String url = ConsulRegistryHelper.convertConsumerToUrl(config);
    ConsulURL consulURL = ConsulURL.valueOf(url);
    consumerUrls.remove(config);
    notifyServiceListeners.remove(consulURL.getServiceKey());
  }
}

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

@Override
public void unSubscribe(ConsumerConfig config) {
  String appName = config.getAppName();
  if (!registryConfig.isSubscribe()) {
    // 注册中心不订阅
    if (LOGGER.isInfoEnabled(appName)) {
      LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE));
    }
  }
  // 注册Consumer节点
  if (config.isRegister()) {
    // 向服务器端发送取消订阅请求
    String url = ConsulRegistryHelper.convertConsumerToUrl(config);
    ConsulURL consulURL = ConsulURL.valueOf(url);
    consumerUrls.remove(config);
    notifyServiceListeners.remove(consulURL.getServiceKey());
  }
}

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

/**
 * 打印连接成功日志
 *
 * @param interfaceId  接口名称
 * @param providerInfo 服务端
 * @param transport    连接
 */
protected void printSuccess(String interfaceId, ProviderInfo providerInfo, ClientTransport transport) {
  if (LOGGER.isInfoEnabled(consumerConfig.getAppName())) {
    LOGGER.infoWithApp(consumerConfig.getAppName(), "Connect to {} provider:{} success ! The connection is "
      + NetUtils.connectToString(transport.remoteAddress(), transport.localAddress())
      , interfaceId, providerInfo);
  }
}

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

/**
 * 打印连接成功日志
 *
 * @param interfaceId  接口名称
 * @param providerInfo 服务端
 * @param transport    连接
 */
protected void printSuccess(String interfaceId, ProviderInfo providerInfo, ClientTransport transport) {
  if (LOGGER.isInfoEnabled(consumerConfig.getAppName())) {
    LOGGER.infoWithApp(consumerConfig.getAppName(), "Connect to {} provider:{} success ! The connection is "
      + NetUtils.connectToString(transport.remoteAddress(), transport.localAddress())
      , interfaceId, providerInfo);
  }
}

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

/**
 * 接口配置修改子节点Data
 *
 * @param config       接口配置
 * @param overridePath 覆盖Path
 * @param data         子节点Data
 * @throws Exception 转换配置异常
 */
public void updateConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
  if (data == null) {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive update data is null");
    }
  } else {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive update data: path=[" + data.getPath() + "]" +
        ", data=[" + StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
    }
    notifyListeners(config, overridePath, data, false, null);
  }
}

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

/**
 * 接口配置新增子节点Data
 *
 * @param config       接口配置
 * @param overridePath 覆盖Path
 * @param data         子节点Data
 * @throws Exception 转换配置异常
 */
public void addConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
  if (data == null) {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
    }
  } else {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive add data: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
    }
    notifyListeners(config, overridePath, data, false, null);
  }
}

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

/**
 * 接口配置修改子节点Data
 *
 * @param config     接口配置
 * @param configPath 配置Path
 * @param data       子节点Data
 */
public void updateConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
  if (data == null) {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive update data is null");
    }
  } else {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive update data: path=[" + data.getPath() + "]"
        + ", data=[" + StringSerializer.decode(data.getData()) + "]"
        + ", stat=[" + data.getStat() + "]");
    }
    notifyListeners(config, configPath, data, false);
  }
}

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

/**
 * 接口配置修改子节点Data
 *
 * @param config       接口配置
 * @param overridePath 覆盖Path
 * @param data         子节点Data
 * @throws Exception 转换配置异常
 */
public void updateConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
  if (data == null) {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive update data is null");
    }
  } else {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive update data: path=[" + data.getPath() + "]" +
        ", data=[" + StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
    }
    notifyListeners(config, overridePath, data, false, null);
  }
}

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

/**
 * 接口配置新增子节点Data
 *
 * @param config       接口配置
 * @param overridePath 覆盖Path
 * @param data         子节点Data
 * @throws Exception 转换配置异常
 */
public void addConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
  if (data == null) {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
    }
  } else {
    if (LOGGER.isInfoEnabled(config.getAppName())) {
      LOGGER.infoWithApp(config.getAppName(), "Receive add data: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
    }
    notifyListeners(config, overridePath, data, false, null);
  }
}

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

/**
 * Remove Provider
 *
 * @param config       ConsumerConfig
 * @param providerPath Provider path of zookeeper
 * @param data         Event data
 * @param currentData  provider data list
 * @throws UnsupportedEncodingException decode error
 */
public void removeProvider(ConsumerConfig config, String providerPath, ChildData data, List<ChildData> currentData)
  throws UnsupportedEncodingException {
  if (LOGGER.isInfoEnabled(config.getAppName())) {
    LOGGER.infoWithApp(config.getAppName(),
      "Receive remove provider: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]" + ", list=[" +
        currentData.size() + "]");
  }
  notifyListeners(config, providerPath, currentData, false);
}

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

/**
 * Update Provider
 *
 * @param config       ConsumerConfig
 * @param providerPath Provider path of zookeeper
 * @param data         Event data
 * @param currentData  provider data list
 * @throws UnsupportedEncodingException decode error
 */
public void updateProvider(ConsumerConfig config, String providerPath, ChildData data, List<ChildData> currentData)
  throws UnsupportedEncodingException {
  if (LOGGER.isInfoEnabled(config.getAppName())) {
    LOGGER.infoWithApp(config.getAppName(),
      "Receive update provider: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]" + ", list=[" +
        currentData.size() + "]");
  }
  notifyListeners(config, providerPath, currentData, false);
}

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

/**
 * Add provider
 *
 * @param config       ConsumerConfig
 * @param providerPath Provider path of zookeeper
 * @param data         Event data
 * @param currentData  provider data list
 * @throws UnsupportedEncodingException decode error
 */
public void addProvider(ConsumerConfig config, String providerPath, ChildData data, List<ChildData> currentData)
  throws UnsupportedEncodingException {
  if (LOGGER.isInfoEnabled(config.getAppName())) {
    LOGGER.infoWithApp(config.getAppName(),
      "Receive add provider: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]" + ", list=[" +
        currentData.size() + "]");
  }
  notifyListeners(config, providerPath, currentData, true);
}

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

/**
 * Update Provider
 *
 * @param config       ConsumerConfig
 * @param providerPath Provider path of zookeeper
 * @param data         Event data
 * @param currentData  provider data list
 * @throws UnsupportedEncodingException decode error
 */
public void updateProvider(ConsumerConfig config, String providerPath, ChildData data, List<ChildData> currentData)
  throws UnsupportedEncodingException {
  if (LOGGER.isInfoEnabled(config.getAppName())) {
    LOGGER.infoWithApp(config.getAppName(),
      "Receive update provider: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]" + ", list=[" +
        currentData.size() + "]");
  }
  notifyListeners(config, providerPath, currentData, false);
}

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

/**
 * Add provider
 *
 * @param config       ConsumerConfig
 * @param providerPath Provider path of zookeeper
 * @param data         Event data
 * @param currentData  provider data list
 * @throws UnsupportedEncodingException decode error
 */
public void addProvider(ConsumerConfig config, String providerPath, ChildData data, List<ChildData> currentData)
  throws UnsupportedEncodingException {
  if (LOGGER.isInfoEnabled(config.getAppName())) {
    LOGGER.infoWithApp(config.getAppName(),
      "Receive add provider: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]" + ", list=[" +
        currentData.size() + "]");
  }
  notifyListeners(config, providerPath, currentData, true);
}

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

/**
 * Remove Provider
 *
 * @param config       ConsumerConfig
 * @param providerPath Provider path of zookeeper
 * @param data         Event data
 * @param currentData  provider data list
 * @throws UnsupportedEncodingException decode error
 */
public void removeProvider(ConsumerConfig config, String providerPath, ChildData data, List<ChildData> currentData)
  throws UnsupportedEncodingException {
  if (LOGGER.isInfoEnabled(config.getAppName())) {
    LOGGER.infoWithApp(config.getAppName(),
      "Receive remove provider: path=[" + data.getPath() + "]" + ", data=[" +
        StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]" + ", list=[" +
        currentData.size() + "]");
  }
  notifyListeners(config, providerPath, currentData, false);
}

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

@Override
  public void degrade(MeasureResultDetail measureResultDetail) {
    InvocationStatDimension statDimension = measureResultDetail.getInvocationStatDimension();
    String appName = statDimension.getAppName();
    if (LOGGER.isInfoEnabled(appName)) {
      String service = statDimension.getService();
      long timeWindow = measureResultDetail.getTimeWindow();
      long windowCount = measureResultDetail.getWindowCount();
      double abnormalRate = measureResultDetail.getAbnormalRate();
      double averageAbnormalRate = measureResultDetail.getAverageAbnormalRate();
      String ip = statDimension.getIp();

      LOGGER.infoWithApp(appName,
        LogCodes.getLog(LogCodes.INFO_REGULATION_ABNORMAL, timeWindow, service, appName,
          windowCount, abnormalRate, averageAbnormalRate, ip));
    }
  }
}

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

@Override
  public void degrade(MeasureResultDetail measureResultDetail) {
    InvocationStatDimension statDimension = measureResultDetail.getInvocationStatDimension();
    String appName = statDimension.getAppName();
    if (LOGGER.isInfoEnabled(appName)) {
      String service = statDimension.getService();
      long timeWindow = measureResultDetail.getTimeWindow();
      long windowCount = measureResultDetail.getWindowCount();
      double abnormalRate = measureResultDetail.getAbnormalRate();
      double averageAbnormalRate = measureResultDetail.getAverageAbnormalRate();
      String ip = statDimension.getIp();

      LOGGER.infoWithApp(appName,
        LogCodes.getLog(LogCodes.INFO_REGULATION_ABNORMAL, timeWindow, service, appName,
          windowCount, abnormalRate, averageAbnormalRate, ip));
    }
  }
}

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

/**
 * 注册单条服务信息
 *
 * @param appName      应用名
 * @param serviceName  服务关键字
 * @param providerInfo 服务提供者数据
 */
protected void doRegister(String appName, String serviceName, ProviderInfo providerInfo) {
  registerAppInfoOnce(appName);
  if (LOGGER.isInfoEnabled(appName)) {
    LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB, serviceName));
  }
  PublishServiceRequest publishServiceRequest = new PublishServiceRequest();
  publishServiceRequest.setServiceName(serviceName);
  ProviderMetaInfo providerMetaInfo = new ProviderMetaInfo();
  providerMetaInfo.setProtocol(providerInfo.getProtocolType());
  providerMetaInfo.setSerializeType(providerInfo.getSerializationType());
  providerMetaInfo.setAppName(appName);
  providerMetaInfo.setVersion(VERSION);
  publishServiceRequest.setProviderMetaInfo(providerMetaInfo);
  client.publishService(publishServiceRequest);
}

相关文章