当前位置: 首页>>代码示例>>Java>>正文


Java Collector类代码示例

本文整理汇总了Java中io.confluent.support.metrics.common.Collector的典型用法代码示例。如果您正苦于以下问题:Java Collector类的具体用法?Java Collector怎么用?Java Collector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Collector类属于io.confluent.support.metrics.common包,在下文中一共展示了Collector类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCollectMetrics

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
@Test
public void testCollectMetrics() {
  // Given
  TimeUtils time = new TimeUtils();
  Uuid uuid = new Uuid();
  long unixTimeAtTestStart = time.nowInUnixTime();
  Collector metricsCollector = new BasicCollector(mockServer, time, uuid);

  // When
  GenericContainer metricsRecord = metricsCollector.collectMetrics();

  // Then
  assertThat(metricsRecord).isInstanceOf(SupportKafkaMetricsBasic.class);
  assertThat(metricsRecord.getSchema()).isEqualTo(SupportKafkaMetricsBasic.getClassSchema());
  SupportKafkaMetricsBasic basicRecord = (SupportKafkaMetricsBasic) metricsRecord;
  assertThat(basicRecord.getTimestamp()).isBetween(unixTimeAtTestStart, time.nowInUnixTime());
  assertThat(basicRecord.getKafkaVersion()).isEqualTo(AppInfoParser.getVersion());
  assertThat(basicRecord.getConfluentPlatformVersion()).isEqualTo(Version.getVersion());
  assertThat(basicRecord.getCollectorState()).isEqualTo(metricsCollector.getRuntimeState().stateId());
  assertThat(basicRecord.getBrokerProcessUUID()).isEqualTo(uuid.toString());
}
 
开发者ID:confluentinc,项目名称:support-metrics-client,代码行数:22,代码来源:BasicCollectorTest.java

示例2: init

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
public void init() {
  customerId = supportConfig.getCustomerId();
  metricsCollector = metricsCollector();
  metricsCollector.setRuntimeState(Collector.RuntimeState.Running);

  reportIntervalMs = supportConfig.getReportIntervalMs();
  supportTopic = supportConfig.getKafkaTopic();

  if (!supportTopic.isEmpty()) {
    kafkaSubmitter = new KafkaSubmitter(zkClientProvider(), supportTopic);
  } else {
    kafkaSubmitter = null;
  }

  String endpointHTTP = supportConfig.getEndpointHTTP();
  String endpointHTTPS = supportConfig.getEndpointHTTPS();
  String proxyURI = supportConfig.getProxy();

  if (!endpointHTTP.isEmpty() || !endpointHTTPS.isEmpty()) {
    confluentSubmitter = new ConfluentSubmitter(customerId, endpointHTTP, endpointHTTPS,
        proxyURI, responseHandler
    );
  } else {
    confluentSubmitter = null;
  }

  if (!reportingEnabled()) {
    log.info("Metrics collection disabled by component configuration");
  }
}
 
开发者ID:confluentinc,项目名称:support-metrics-common,代码行数:31,代码来源:BaseMetricsReporter.java

示例3: run

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
@Override
public void run() {
  try {
    if (reportingEnabled()) {
      boolean terminateEarly = waitForServer();
      if (terminateEarly) {
        log.info("Metrics collection stopped before it even started");
      } else {
        log.info("Starting metrics collection from monitored component...");
        while (!Thread.currentThread().isInterrupted()) {
          submitMetrics();
          Thread.sleep(Jitter.addOnePercentJitter(reportIntervalMs));

        }
      }
    }
  } catch (InterruptedException i) {
    metricsCollector.setRuntimeState(Collector.RuntimeState.ShuttingDown);
    submitMetrics();
    log.info("Graceful terminating metrics collection because the monitored component is "
             + "shutting down...");
    Thread.currentThread().interrupt();
  } catch (Exception e) {
    log.error("Terminating metrics collection from monitored component because: {}",
        e.getMessage());
  } finally {
    log.info("Metrics collection stopped");
  }
}
 
开发者ID:confluentinc,项目名称:support-metrics-common,代码行数:30,代码来源:BaseMetricsReporter.java

示例4: waitForServer

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
/**
 * Waits for the monitored service to fully start up.
 *
 * <p>This is a blocking call.  This method will return if and only if:
 *
 * <ul> <li>The service has successfully started.  The return value will be false.</li> <li>The
 * server is shutting down.  The return value will be true.</li> <li>The current thread was
 * interrupted.  The return value will be true.</li> </ul>
 */
private boolean waitForServer() {
  boolean terminateEarly = false;
  try {
    boolean keepWaitingForServerToStartup = true;
    while (keepWaitingForServerToStartup && !Thread.currentThread().isInterrupted()) {

      if (enableSettlingTime) {
        long waitTimeMs = Jitter.addOnePercentJitter(SETTLING_TIME_MS);
        log.info("Waiting {} ms for the monitored service to finish starting up...", waitTimeMs);
        Thread.sleep(waitTimeMs);
      }

      if (isShuttingDown()) {
        keepWaitingForServerToStartup = false;
        terminateEarly = true;
        metricsCollector.setRuntimeState(Collector.RuntimeState.ShuttingDown);
        log.info("Stopping metrics collection prematurely because service is shutting down");
      } else {
        if (isReadyForMetricsCollection()) {
          log.info("Monitored service is now ready");
          keepWaitingForServerToStartup = false;
        }
      }
    }
  } catch (InterruptedException i) {
    terminateEarly = true;
    metricsCollector.setRuntimeState(Collector.RuntimeState.ShuttingDown);
    Thread.currentThread().interrupt();
  }
  return terminateEarly;
}
 
开发者ID:confluentinc,项目名称:support-metrics-common,代码行数:41,代码来源:BaseMetricsReporter.java

示例5: metricsCollector

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
@Override
protected Collector metricsCollector() {
  return metricsCollector;
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:5,代码来源:KsqlVersionChecker.java

示例6: getCollector

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
public Collector getCollector() {
  return collector;
}
 
开发者ID:confluentinc,项目名称:support-metrics-client,代码行数:4,代码来源:CollectorFactory.java

示例7: metricsCollector

import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
protected abstract Collector metricsCollector(); 
开发者ID:confluentinc,项目名称:support-metrics-common,代码行数:2,代码来源:BaseMetricsReporter.java


注:本文中的io.confluent.support.metrics.common.Collector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。