本文整理汇总了Java中com.timgroup.statsd.NonBlockingStatsDClient类的典型用法代码示例。如果您正苦于以下问题:Java NonBlockingStatsDClient类的具体用法?Java NonBlockingStatsDClient怎么用?Java NonBlockingStatsDClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NonBlockingStatsDClient类属于com.timgroup.statsd包,在下文中一共展示了NonBlockingStatsDClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
/**
* @see org.apache.flink.api.common.functions.AbstractRichFunction#open(org.apache.flink.configuration.Configuration)
*/
public void open(Configuration parameters) throws Exception {
////////////////////////////////////////////////////////////////////////////////////////////////
// prepare settings and initialize client
final Settings settings = Settings.builder().put(ES_SETTING_CLUSTER_NAME, clusterName).build();
this.client = TransportClient.builder().settings(settings).build();
for(final ElasticsearchNodeAddress ta : transportAddresses) {
this.client.addTransportAddress(
new InetSocketTransportAddress(
new InetSocketAddress(ta.getHost(), ta.getPort())));
LOG.info("elasticsearch connection [host="+ta.getHost()+", port="+ta.getPort()+"]");
}
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
// if provided initialize the statsd client
if(StringUtils.isNotBlank(this.statsdHost) || this.statsdPort > 0)
this.statsdClient = new NonBlockingStatsDClient(this.statsdPrefix, this.statsdHost, this.statsdPort);
////////////////////////////////////////////////////////////////////////////////////////////////
}
示例2: prepare
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
/**
* This method makes it easy to pass statsd instance during the tests
*/
public void prepare(Map<String, Object> conf, StatsDClient statsd){
topologyName = (String) Optional.fromNullable(conf.get(TOPOLOGYNAME)).or(getRequiredValue(conf, "topology.name"));
if (statsd == null) {
String statsdHost = (String) Optional.fromNullable(conf.get(HOST)).or("localhost");
Integer port = (Integer) Optional.fromNullable(conf.get(PORT)).or(8125);
String[] globalTags = (String[]) Optional.fromNullable(conf.get(TAGS)).or(new String[0]);
logger.info("Initializing the datadog statsd client for {} with value {}:{} {}", topologyName, statsdHost, port, globalTags);
this.statsd = new NonBlockingStatsDClient(
TagsHelper.getPrefix(conf),
statsdHost,
port,
globalTags
);
}
else {
this.statsd = statsd;
}
}
示例3: ProgressMonitor
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
public ProgressMonitor(SecorConfig config)
throws Exception
{
mConfig = config;
mZookeeperConnector = new ZookeeperConnector(mConfig);
mKafkaClient = new KafkaClient(mConfig);
mMessageParser = (MessageParser) ReflectionUtil.createMessageParser(
mConfig.getMessageParserClass(), mConfig);
mPrefix = mConfig.getMonitoringPrefix();
if (Strings.isNullOrEmpty(mPrefix)) {
mPrefix = "secor";
}
if (mConfig.getStatsDHostPort() != null && !mConfig.getStatsDHostPort().isEmpty()) {
HostAndPort hostPort = HostAndPort.fromString(mConfig.getStatsDHostPort());
mStatsDClient = new NonBlockingStatsDClient(null, hostPort.getHostText(), hostPort.getPort());
}
}
示例4: StatsdMetricsReporterService
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
public StatsdMetricsReporterService(Map<String, Object> props, String name) {
StatsdMetricsReporterServiceConfig config = new StatsdMetricsReporterServiceConfig(props);
_name = name;
_metricNames = config.getList(StatsdMetricsReporterServiceConfig.REPORT_METRICS_CONFIG);
_reportIntervalSec = config.getInt(StatsdMetricsReporterServiceConfig.REPORT_INTERVAL_SEC_CONFIG);
_executor = Executors.newSingleThreadScheduledExecutor();
_metricNamePrefix = config.getString(StatsdMetricsReporterServiceConfig.REPORT_STATSD_PREFIX);
_statsdClient = new NonBlockingStatsDClient(_metricNamePrefix,
config.getString(StatsdMetricsReporterServiceConfig.REPORT_STATSD_HOST),
config.getInt(StatsdMetricsReporterServiceConfig.REPORT_STATSD_PORT));
}
示例5: StatsdMetricWriter
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
/**
* Create a new writer with the given parameters.
* @param prefix the prefix to apply to all metric names (can be null)
* @param host the hostname for the statsd server
* @param port the port for the statsd server
*/
public StatsdMetricWriter(String prefix, String host, int port) {
prefix = StringUtils.hasText(prefix) ? prefix : null;
while (prefix != null && prefix.endsWith(".")) {
prefix = prefix.substring(0, prefix.length() - 1);
}
this.client = new NonBlockingStatsDClient(prefix, host, port,
new LoggingStatsdErrorHandler());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:StatsdMetricWriter.java
示例6: createClient
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
private StatsDClient createClient(String address, int port, StatsDClientErrorHandler errorHandler) {
try {
return new NonBlockingStatsDClient("rapture", address, port, errorHandler);
} catch (StatsDClientException e1) {
log.error(String.format("Error initializing statsd client with host %s - %s", address, ExceptionToString.format(e1)));
return new NoOpStatsDClient();
}
}
示例7: createStatsDClient
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
/**
* Returns an initialized instance of the StatsDClient If StatsD is enabled
* this is a NonBlockingStatsDClient which guarantees not to block the thread or
* throw exceptions. If StatsD is not enabled it creates a NoOpStatsDClient which
* contains all empty methods
*
* @return initialized StatsDClient
*/
protected StatsDClient createStatsDClient() {
if (kafkaProducerConfiguration.getStatsDConfiguration() != null) {
final String prefix = kafkaProducerConfiguration.getStatsDConfiguration().getPrefix();
final String host = kafkaProducerConfiguration.getStatsDConfiguration().getHost();
final int port = kafkaProducerConfiguration.getStatsDConfiguration().getPort();
return new NonBlockingStatsDClient(prefix, host, port);
} else {
return new NoOpStatsDClient();
}
}
示例8: GoNotificationPlugin
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
public GoNotificationPlugin() {
Config defaultConfig = null;
Config config = null;
defaultConfig = ConfigFactory.load(getClass().getClassLoader());
String userHome = System.getProperty("user.home");
File configFile = new File(userHome + File.separator + CONF_FILENAME);
if (!configFile.exists()) {
LOGGER.warn(String.format("The configuration file %s was not found, using defaults. The configuration file should be set up.", configFile));
config = defaultConfig;
} else {
config = ConfigFactory.parseFile(configFile).withFallback(defaultConfig);
}
statesForHistograms = config.getStringList("datadog.create_histograms_for_states");
histogramMetric = config.getString("datadog.histogram_metric");
statesForEvents = config.getStringList("datadog.create_events_for_states");
String prefix = config.getString("datadog.prefix");
List<String> tagList = config.getStringList("datadog.tags");
String[] tags = tagList.toArray(new String[tagList.size()]);
String statsdHost = config.getString("statsd.host");
int statsdPort = config.getInt("statsd.port");
statsd = new NonBlockingStatsDClient(
prefix,
statsdHost,
statsdPort,
tags
);
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
hostname = "";
}
}
示例9: build
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
/**
* @return A new LivenessReporter (just a thread, really) that has not yet been started
*/
public LivenessReporter build() {
if (statsdHost == null || statsdPort == null) {
logger.info("StatsHost or StatsdPort is null, skipping construction of the LivenessReporter");
return null;
}
logger.info("Constructing StatsDClient for '{}' on port '{}'", statsdHost, statsdPort);
StatsDClient statsdClient = new NonBlockingStatsDClient(statsdPrefix, statsdHost, statsdPort, 10000, tags);
return build(statsdClient, this.livenessMetric, this.livenessFrequencySec);
}
示例10: prepare
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map stormConf, Object registrationArgument,
TopologyContext context, IErrorReporter errorReporter) {
parseConfig(stormConf);
if (registrationArgument instanceof Map) {
parseConfig((Map) registrationArgument);
}
statsd = new NonBlockingStatsDClient(statsdPrefix + clean(topologyName), statsdHost, statsdPort);
}
示例11: createStatsd
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
private StatsDClient createStatsd() {
try {
return new NonBlockingStatsDClient(prefix, host, port);
} catch (StatsDClientException ex) {
log.error("KafkaStatsDReporter cannot be started");
throw ex;
}
}
示例12: createStatsd
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
private StatsDClient createStatsd() {
try {
return new NonBlockingStatsDClient(
prefix, /* prefix to any stats; may be null or empty string */
host, /* common case: localhost */
port /* port */
);
} catch (StatsDClientException ex) {
log.error("Reporter cannot be started");
throw ex;
}
}
示例13: StatsdService
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
@Inject
public StatsdService(Settings settings, ClusterService clusterService, IndicesService indicesService,
NodeService nodeService)
{
super(settings);
this.clusterService = clusterService;
this.indicesService = indicesService;
this.nodeService = nodeService;
this.statsdRefreshInternal = settings.getAsTime("metrics.statsd.every", TimeValue.timeValueMinutes(1));
this.statsdHost = settings.get("metrics.statsd.host");
this.statsdPort = settings.getAsInt("metrics.statsd.port", 8125);
this.statsdPrefix = settings.get("metrics.statsd.prefix", "elasticsearch" + "." + settings.get("cluster.name"));
this.statsdClient = new NonBlockingStatsDClient(statsdPrefix, statsdHost, statsdPort);
}
示例14: StatsdReporter
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
public StatsdReporter(String host, int port, String prefix) throws IOException {
super(Metrics.defaultRegistry(), "statsd");
statsd = new NonBlockingStatsDClient(prefix, host, port);
vm = VirtualMachineMetrics.getInstance();
clock = Clock.defaultClock();
previous_run_times = new HashMap<String, Integer>();
previous_run_counts = new HashMap<String, Integer>();
}
示例15: createStatsDClient
import com.timgroup.statsd.NonBlockingStatsDClient; //导入依赖的package包/类
/**
* Returns an initialized instance of the StatsDClient If StatsD is enabled
* this is a NonBlockingStatsDClient which guarantees not to block the thread or
* throw exceptions. If StatsD is not enabled it creates a NoOpStatsDClient which
* contains all empty methods
*
* @return initialized StatsDClient
*/
protected StatsDClient createStatsDClient() {
final boolean enabled = getOptionalBooleanConfig(STATSD_ENABLED, DEFAULT_STATSD_ENABLED);
if (enabled) {
final String prefix = getOptionalStringConfig(STATSD_PREFIX, DEFAULT_STATSD_PREFIX);
final String host = getOptionalStringConfig(STATSD_HOST, DEFAULT_STATSD_HOST);
final int port = getOptionalIntConfig(STATSD_PORT, DEFAULT_STATSD_PORT);
return new NonBlockingStatsDClient(prefix, host, port);
}
else {
return new NoOpStatsDClient();
}
}