本文整理汇总了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());
}
示例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");
}
}
示例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");
}
}
示例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;
}
示例5: metricsCollector
import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
@Override
protected Collector metricsCollector() {
return metricsCollector;
}
示例6: getCollector
import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
public Collector getCollector() {
return collector;
}
示例7: metricsCollector
import io.confluent.support.metrics.common.Collector; //导入依赖的package包/类
protected abstract Collector metricsCollector();