• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GraphiteUDP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
@Override
public GraphiteSender get() {
    switch (configuration.getProtocol()) {
        case PICKLE:
            return new PickledGraphite(
                    configuration.getAddress(),
                    SocketFactory.getDefault(),
                    configuration.getCharset(),
                    configuration.getPickleBatchSize());
        case TCP:
            return new Graphite(configuration.getAddress(), SocketFactory.getDefault(), configuration.getCharset());
        case UDP:
            return new GraphiteUDP(configuration.getAddress());
        default:
            throw new IllegalArgumentException("Unknown Graphite protocol \"" + configuration.getProtocol() + "\"");
    }
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-metrics-reporter,代码行数:18,代码来源:GraphiteSenderProvider.java


示例2: initialiseMetrics

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
private void initialiseMetrics(AdminUsersConfig configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);

}
 
开发者ID:alphagov,项目名称:pay-adminusers,代码行数:9,代码来源:AdminUsersApp.java


示例3: initialiseMetrics

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
private void initialiseMetrics(CardConfiguration configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);

}
 
开发者ID:alphagov,项目名称:pay-cardid,代码行数:9,代码来源:CardApi.java


示例4: getReturnsGraphiteUDP

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
@Test
public void getReturnsGraphiteUDP() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration() {
        @Override
        public GraphiteProtocol getProtocol() {
            return GraphiteProtocol.UDP;
        }
    };
    final GraphiteSenderProvider provider = new GraphiteSenderProvider(configuration);

    final GraphiteSender graphiteSender = provider.get();
    assertTrue(graphiteSender instanceof GraphiteUDP);
    assertFalse(graphiteSender.isConnected());
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-metrics-reporter,代码行数:15,代码来源:GraphiteSenderProviderTest.java


示例5: get

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
@Test
public void get() throws Exception {
    final MetricsGraphiteReporterConfiguration configuration = new MetricsGraphiteReporterConfiguration();
    final GraphiteSender graphiteSender = new GraphiteUDP("127.0.0.1", 12345);
    final MetricRegistry metricRegistry = new MetricRegistry();
    final GraphiteReporterProvider provider = new GraphiteReporterProvider(configuration, graphiteSender, metricRegistry);

    final GraphiteReporter reporter = provider.get();
    assertNotNull(reporter);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-metrics-reporter,代码行数:11,代码来源:GraphiteReporterProviderTest.java


示例6: graphiteReporter

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
/**
 * Create reporter bean and tell Spring to call stop() when shutting down.
 * UPD must be enabled in carbon.conf
 * 
 * @return graphite reporter
 */
@Bean(destroyMethod = "stop")
public GraphiteReporter graphiteReporter() {
    final GraphiteSender graphite = new GraphiteUDP(new InetSocketAddress("localhost", 2003));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry).prefixedWith("camel-spring-boot").convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite);
    reporter.start(5, TimeUnit.SECONDS);
    return reporter;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:Application.java


示例7: initialiseMetrics

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
private void initialiseMetrics(PublicAuthConfiguration configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);

}
 
开发者ID:alphagov,项目名称:pay-publicauth,代码行数:9,代码来源:PublicAuthApp.java


示例8: initialiseMetrics

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
private void initialiseMetrics(PublicApiConfig configuration, Environment environment) {
    GraphiteSender graphiteUDP = new GraphiteUDP(configuration.getGraphiteHost(), Integer.valueOf(configuration.getGraphitePort()));
    GraphiteReporter.forRegistry(environment.metrics())
            .prefixedWith(SERVICE_METRICS_NODE)
            .build(graphiteUDP)
            .start(GRAPHITE_SENDING_PERIOD_SECONDS, TimeUnit.SECONDS);
}
 
开发者ID:alphagov,项目名称:pay-publicapi,代码行数:8,代码来源:PublicApi.java


示例9: getReporter

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
@Override
public ScheduledReporter getReporter(MetricConfig config) {
	String host = config.getString(ARG_HOST, null);
	int port = config.getInteger(ARG_PORT, -1);

	if (host == null || host.length() == 0 || port < 1) {
		throw new IllegalArgumentException("Invalid host/port configuration. Host: " + host + " Port: " + port);
	}

	String prefix = config.getString(ARG_PREFIX, null);
	String conversionRate = config.getString(ARG_CONVERSION_RATE, null);
	String conversionDuration = config.getString(ARG_CONVERSION_DURATION, null);
	String protocol = config.getString(ARG_PROTOCOL, "TCP");

	com.codahale.metrics.graphite.GraphiteReporter.Builder builder =
		com.codahale.metrics.graphite.GraphiteReporter.forRegistry(registry);

	if (prefix != null) {
		builder.prefixedWith(prefix);
	}

	if (conversionRate != null) {
		builder.convertRatesTo(TimeUnit.valueOf(conversionRate));
	}

	if (conversionDuration != null) {
		builder.convertDurationsTo(TimeUnit.valueOf(conversionDuration));
	}

	Protocol prot;
	try {
		prot = Protocol.valueOf(protocol);
	} catch (IllegalArgumentException iae) {
		log.warn("Invalid protocol configuration: " + protocol + " Expected: TCP or UDP, defaulting to TCP.");
		prot = Protocol.TCP;
	}

	log.info("Configured GraphiteReporter with {host:{}, port:{}, protocol:{}}", host, port, prot);
	switch(prot) {
		case UDP:
			return builder.build(new GraphiteUDP(host, port));
		case TCP:
		default:
			return builder.build(new Graphite(host, port));
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:47,代码来源:GraphiteReporter.java


示例10: prepare

import com.codahale.metrics.graphite.GraphiteUDP; //导入依赖的package包/类
@Override public void prepare(Map<String, Object> conf) {
  if (conf.containsKey(GRAPHITE_HOST_OPTION)) {
    graphiteHost = (String) conf.get(GRAPHITE_HOST_OPTION);
  }
  else {
    throw new IllegalArgumentException("Field " + GRAPHITE_HOST_OPTION + " required.");
  }

  if (conf.containsKey(GRAPHITE_PORT_OPTION)) {
    graphitePort = Integer.parseInt((String) conf.get(GRAPHITE_PORT_OPTION));
  }
  else {
    throw new IllegalArgumentException("Field " + GRAPHITE_PORT_OPTION + " required.");
  }

  if (conf.containsKey(GRAPHITE_MIN_CONNECT_ATTEMPT_INTERVAL_SECS_OPTION)) {
    minConnectAttemptIntervalSecs = Integer
        .parseInt((String) conf.get(GRAPHITE_MIN_CONNECT_ATTEMPT_INTERVAL_SECS_OPTION));
  }
  else {
    minConnectAttemptIntervalSecs = DEFAULT_MIN_CONNECT_ATTEMPT_INTERVAL_SECS;
  }

  graphiteSocketAddr = new InetSocketAddress(graphiteHost, graphitePort);

  serverFingerprint = graphiteSocketAddr.getAddress() + ":" + graphiteSocketAddr.getPort();

  if (conf.containsKey(GRAPHITE_PROTOCOL_OPTION) && ((String)conf.get(GRAPHITE_PROTOCOL_OPTION)).equalsIgnoreCase("udp")) {
    // Use UDP client
    this.graphite = new GraphiteUDP(graphiteSocketAddr);
  } else {
    // Default TCP client
    int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
    if (conf.containsKey(GRAPHITE_CONNECT_TIMEOUT)) {
      connectTimeout = Integer.parseInt(conf.get(GRAPHITE_CONNECT_TIMEOUT).toString());
    }

    int readTimeout = DEFAULT_READ_TIMEOUT;
    if (conf.containsKey(GRAPHITE_READ_TIMEOUT)) {
      readTimeout = Integer.parseInt(conf.get(GRAPHITE_READ_TIMEOUT).toString());
    }

    ConfigurableSocketFactory socketFactory = new ConfigurableSocketFactory();
    socketFactory.setConnectTimeout(connectTimeout);
    socketFactory.setReadTimeout(readTimeout);

    this.graphite = new Graphite(graphiteSocketAddr, socketFactory);
  }
  lastConnectAttemptTimestampMs = 0;
  prefix = TagsHelper.getPrefix(conf);
}
 
开发者ID:verisign,项目名称:storm-graphite,代码行数:52,代码来源:GraphiteReporter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CloudletList类代码示例发布时间:2022-05-22
下一篇:
Java ContentVideoViewClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap