org.opennms.core.logging.Logging.withPrefixCloseable()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(152)

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

Logging.withPrefixCloseable介绍

暂无

代码示例

代码示例来源:origin: OpenNMS/opennms

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try(Logging.MDCCloseable closeable = Logging.withPrefixCloseable("web")) {
      super.handle(target,baseRequest,request,response);
    }
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  protected void doInTransactionWithoutResult(final TransactionStatus status) {
    try (MDCCloseable mdc = Logging.withPrefixCloseable(LOG_PREFIX)) {
      runnable.run();
      m_minionDao.flush();
    }
  }
});

代码示例来源:origin: OpenNMS/opennms

@Override
public void handleMessage(Log eventLog) {
  try (Logging.MDCCloseable mdc = Logging.withPrefixCloseable(Eventd.LOG4J_CATEGORY)) {
    eventForwarder.sendNowSync(eventLog);
  }
}

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

@Override
public void handleMessage(Log eventLog) {
  try (Logging.MDCCloseable mdc = Logging.withPrefixCloseable(Eventd.LOG4J_CATEGORY)) {
    eventForwarder.sendNowSync(eventLog);
  }
}

代码示例来源:origin: org.opennms/opennms-jetty

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try(Logging.MDCCloseable closeable = Logging.withPrefixCloseable("web")) {
      super.handle(target,baseRequest,request,response);
    }
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = CAMEL.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Camel Sink Client: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = SQS.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable AWS SQS Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Kafka Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = CAMEL.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Camel Sink Server: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: org.opennms.core.ipc.sink.kafka/org.opennms.core.ipc.sink.kafka.server

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Kafka Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

public void init() throws IOException {
  try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
    // Defaults
    kafkaConfig.clear();
    kafkaConfig.put("key.serializer", StringSerializer.class.getCanonicalName());
    kafkaConfig.put("value.serializer", ByteArraySerializer.class.getCanonicalName());
    // Retrieve all of the properties from org.opennms.core.ipc.sink.kafka.cfg
    KafkaConfigProvider configProvider = new OsgiKafkaConfigProvider(KafkaSinkConstants.KAFKA_CONFIG_PID, configAdmin);
    kafkaConfig.putAll(configProvider.getProperties());
    LOG.info("KafkaRemoteMessageDispatcherFactory: initializing the Kafka producer with: {}", kafkaConfig);
    producer = Utils.runWithGivenClassLoader(() -> new KafkaProducer<>(kafkaConfig), KafkaProducer.class.getClassLoader());
    onInit();
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(RpcStrategy.getRpcStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(RpcClientFactory.LOG_PREFIX)) {
      LOG.debug("Enable Kafka RPC: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Kafka Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: org.opennms.core.ipc.sink.kafka/org.opennms.core.ipc.sink.kafka.client

public void init() throws IOException {
  try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
    // Defaults
    kafkaConfig.clear();
    kafkaConfig.put("key.serializer", StringSerializer.class.getCanonicalName());
    kafkaConfig.put("value.serializer", ByteArraySerializer.class.getCanonicalName());
    // Retrieve all of the properties from org.opennms.core.ipc.sink.kafka.cfg
    KafkaConfigProvider configProvider = new OsgiKafkaConfigProvider(KafkaSinkConstants.KAFKA_CONFIG_PID, configAdmin);
    kafkaConfig.putAll(configProvider.getProperties());
    LOG.info("KafkaRemoteMessageDispatcherFactory: initializing the Kafka producer with: {}", kafkaConfig);
    producer = Utils.runWithGivenClassLoader(() -> new KafkaProducer<>(kafkaConfig), KafkaProducer.class.getClassLoader());
    onInit();
  }
}

代码示例来源:origin: org.opennms.core.ipc.rpc/org.opennms.core.ipc.rpc.kafka

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(RpcStrategy.getRpcStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(RpcClientFactory.LOG_PREFIX)) {
      LOG.debug("Enable Kafka RPC: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = SQS.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable AWS SQS Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: org.opennms.core.ipc.sink.kafka/org.opennms.core.ipc.sink.kafka.client

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Kafka Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: org.opennms.core.ipc.sink/org.opennms.core.ipc.sink.kafka-impl

@Override
  public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
    final boolean enabled = KAFKA.equals(SinkStrategy.getSinkStrategy());
    try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
      LOG.debug("Enable Kafka Sink: {}", enabled);
    }
    return enabled;
  }
}

代码示例来源:origin: OpenNMS/opennms

/**
 * Initializes the producers.
 *
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void init() throws IOException {
  try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
    try {
      sqs = awsSqsManager.getSQSClient();
    } catch (AmazonSQSException e) {
      LOG.error("Can't create an AmazonSQS Object", e);
    }
    onInit();
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
public <S extends Message, T extends Message> void dispatch(SinkModule<S, T> module, String topic, T message) {
  try (MDCCloseable mdc = Logging.withPrefixCloseable(MessageConsumerManager.LOG_PREFIX)) {
    LOG.trace("dispatch({}): sending message {}", topic, message);
    try {
      final String queueUrl = awsSqsManager.getSinkQueueUrlAndCreateIfNecessary(module.getId());
      final String messageId = awsSqsManager.sendMessage(queueUrl, new String(module.marshal((T)message), StandardCharsets.UTF_8));
      LOG.debug("SQS Message with ID {} has been successfully sent to {}", messageId, queueUrl);
    } catch (InterruptedException ex) {
      LOG.warn("Interrupted while trying to send message. Aborting.", ex);
    } catch (RuntimeException ex) {
      LOG.error("Unexpected AWS SDK exception while sending a message. Aborting.", ex);
    }
  }
}

相关文章