本文整理汇总了Java中org.apache.kafka.common.utils.KafkaThread类的典型用法代码示例。如果您正苦于以下问题:Java KafkaThread类的具体用法?Java KafkaThread怎么用?Java KafkaThread使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KafkaThread类属于org.apache.kafka.common.utils包,在下文中一共展示了KafkaThread类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KafkaAdminClient
import org.apache.kafka.common.utils.KafkaThread; //导入依赖的package包/类
private KafkaAdminClient(AdminClientConfig config, String clientId, Time time, Metadata metadata,
Metrics metrics, KafkaClient client, TimeoutProcessorFactory timeoutProcessorFactory) {
this.defaultTimeoutMs = config.getInt(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG);
this.clientId = clientId;
this.time = time;
this.metadata = metadata;
List<InetSocketAddress> addresses = ClientUtils.parseAndValidateAddresses(
config.getList(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG));
this.metadata.update(Cluster.bootstrap(addresses), Collections.<String>emptySet(), time.milliseconds());
this.metrics = metrics;
this.client = client;
this.runnable = new AdminClientRunnable();
String threadName = "kafka-admin-client-thread" + (clientId.length() > 0 ? " | " + clientId : "");
this.thread = new KafkaThread(threadName, runnable, false);
this.timeoutProcessorFactory = (timeoutProcessorFactory == null) ?
new TimeoutProcessorFactory() : timeoutProcessorFactory;
this.maxRetries = config.getInt(AdminClientConfig.RETRIES_CONFIG);
config.logUnused();
log.debug("Created Kafka admin client {}", this.clientId);
thread.start();
}
示例2: init
import org.apache.kafka.common.utils.KafkaThread; //导入依赖的package包/类
@Override
public void init(List<KafkaMetric> metrics) {
for (KafkaMetric kafkaMetric : metrics) {
addMetricIfInterested(kafkaMetric);
}
LOG.info("Added {} Kafka metrics for Cruise Control metrics during initialization.", _interestedMetrics.size());
_metricsReporterRunner = new KafkaThread("CruiseControlMetricsReporterRunner", this, true);
_yammerMetricProcessor = new YammerMetricProcessor();
_metricsReporterRunner.start();
}