use of com.twitter.heron.metricsmgr.MetricsSinksConfig in project incubator-heron by apache.
the class MetricsCacheManager method main.
public static void main(String[] args) throws Exception {
Options options = constructOptions();
Options helpOptions = constructHelpOptions();
CommandLineParser parser = new DefaultParser();
// parse the help options first.
CommandLine cmd = parser.parse(helpOptions, args, true);
if (cmd.hasOption("h")) {
usage(options);
return;
}
try {
// Now parse the required options
cmd = parser.parse(options, args);
} catch (ParseException e) {
usage(options);
throw new RuntimeException("Error parsing command line options: ", e);
}
Level logLevel = Level.INFO;
if (cmd.hasOption("v")) {
logLevel = Level.ALL;
}
String cluster = cmd.getOptionValue("cluster");
String role = cmd.getOptionValue("role");
String environ = cmd.getOptionValue("environment");
int masterPort = Integer.valueOf(cmd.getOptionValue("master_port"));
int statsPort = Integer.valueOf(cmd.getOptionValue("stats_port"));
String systemConfigFilename = cmd.getOptionValue("system_config_file");
String overrideConfigFilename = cmd.getOptionValue("override_config_file");
String metricsSinksConfigFilename = cmd.getOptionValue("sink_config_file");
String topologyName = cmd.getOptionValue("topology_name");
String topologyId = cmd.getOptionValue("topology_id");
String metricsCacheMgrId = cmd.getOptionValue("metricscache_id");
// read heron internal config file
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(systemConfigFilename, true).putAll(overrideConfigFilename, true).build();
// Log to file and sink(exception)
LoggingHelper.loggerInit(logLevel, true);
LoggingHelper.addLoggingHandler(LoggingHelper.getFileHandler(metricsCacheMgrId, systemConfig.getHeronLoggingDirectory(), true, systemConfig.getHeronLoggingMaximumSize(), systemConfig.getHeronLoggingMaximumFiles()));
LoggingHelper.addLoggingHandler(new ErrorReportLoggingHandler());
LOG.info(String.format("Starting MetricsCache for topology %s with topologyId %s with " + "MetricsCache Id %s, master port: %d.", topologyName, topologyId, metricsCacheMgrId, masterPort));
LOG.info("System Config: " + systemConfig);
// read sink config file
MetricsSinksConfig sinksConfig = new MetricsSinksConfig(metricsSinksConfigFilename);
LOG.info("Sinks Config: " + sinksConfig.toString());
// build config from cli
Config config = Config.toClusterMode(Config.newBuilder().putAll(ConfigLoader.loadClusterConfig()).putAll(Config.newBuilder().put(Key.CLUSTER, cluster).put(Key.ROLE, role).put(Key.ENVIRON, environ).build()).putAll(Config.newBuilder().put(Key.TOPOLOGY_NAME, topologyName).put(Key.TOPOLOGY_ID, topologyId).build()).build());
LOG.info("Cli Config: " + config.toString());
// build metricsCache location
TopologyMaster.MetricsCacheLocation metricsCacheLocation = TopologyMaster.MetricsCacheLocation.newBuilder().setTopologyName(topologyName).setTopologyId(topologyId).setHost(InetAddress.getLocalHost().getHostName()).setControllerPort(// not used for metricscache
-1).setMasterPort(masterPort).setStatsPort(statsPort).build();
MetricsCacheManager metricsCacheManager = new MetricsCacheManager(topologyName, METRICS_CACHE_HOST, masterPort, statsPort, systemConfig, sinksConfig, config, metricsCacheLocation);
metricsCacheManager.start();
LOG.info("Loops terminated. MetricsCache Manager exits.");
}
use of com.twitter.heron.metricsmgr.MetricsSinksConfig in project heron by twitter.
the class MetricsCacheManager method main.
public static void main(String[] args) throws Exception {
Options options = constructOptions();
Options helpOptions = constructHelpOptions();
CommandLineParser parser = new DefaultParser();
// parse the help options first.
CommandLine cmd = parser.parse(helpOptions, args, true);
if (cmd.hasOption("h")) {
usage(options);
return;
}
try {
// Now parse the required options
cmd = parser.parse(options, args);
} catch (ParseException e) {
usage(options);
throw new RuntimeException("Error parsing command line options: ", e);
}
Level logLevel = Level.INFO;
if (cmd.hasOption("v")) {
logLevel = Level.ALL;
}
String cluster = cmd.getOptionValue("cluster");
String role = cmd.getOptionValue("role");
String environ = cmd.getOptionValue("environment");
int masterPort = Integer.valueOf(cmd.getOptionValue("master_port"));
int statsPort = Integer.valueOf(cmd.getOptionValue("stats_port"));
String systemConfigFilename = cmd.getOptionValue("system_config_file");
String metricsSinksConfigFilename = cmd.getOptionValue("sink_config_file");
String topologyName = cmd.getOptionValue("topology_name");
String topologyId = cmd.getOptionValue("topology_id");
String metricsCacheMgrId = cmd.getOptionValue("metricscache_id");
// read heron internal config file
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(systemConfigFilename, true).build();
// Log to file and sink(exception)
LoggingHelper.loggerInit(logLevel, true);
LoggingHelper.addLoggingHandler(LoggingHelper.getFileHandler(metricsCacheMgrId, systemConfig.getHeronLoggingDirectory(), true, systemConfig.getHeronLoggingMaximumSizeMb() * Constants.MB_TO_BYTES, systemConfig.getHeronLoggingMaximumFiles()));
LoggingHelper.addLoggingHandler(new ErrorReportLoggingHandler());
LOG.info(String.format("Starting MetricsCache for topology %s with topologyId %s with " + "MetricsCache Id %s, master port: %d.", topologyName, topologyId, metricsCacheMgrId, masterPort));
LOG.info("System Config: " + systemConfig);
// read sink config file
MetricsSinksConfig sinksConfig = new MetricsSinksConfig(metricsSinksConfigFilename);
LOG.info("Sinks Config: " + sinksConfig.toString());
// build config from cli
Config config = Config.toClusterMode(Config.newBuilder().putAll(ConfigLoader.loadClusterConfig()).putAll(Config.newBuilder().put(Key.CLUSTER, cluster).put(Key.ROLE, role).put(Key.ENVIRON, environ).build()).putAll(Config.newBuilder().put(Key.TOPOLOGY_NAME, topologyName).put(Key.TOPOLOGY_ID, topologyId).build()).build());
LOG.info("Cli Config: " + config.toString());
// build metricsCache location
TopologyMaster.MetricsCacheLocation metricsCacheLocation = TopologyMaster.MetricsCacheLocation.newBuilder().setTopologyName(topologyName).setTopologyId(topologyId).setHost(InetAddress.getLocalHost().getHostName()).setControllerPort(// not used for metricscache
-1).setMasterPort(masterPort).setStatsPort(statsPort).build();
MetricsCacheManager metricsCacheManager = new MetricsCacheManager(topologyName, METRICS_CACHE_HOST, masterPort, statsPort, systemConfig, sinksConfig, config, metricsCacheLocation);
metricsCacheManager.start();
LOG.info("Loops terminated. MetricsCache Manager exits.");
}
use of com.twitter.heron.metricsmgr.MetricsSinksConfig in project heron by twitter.
the class MetricsCacheTest method testMetricCache.
@Test
public void testMetricCache() throws IOException {
// prepare config files
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(CONFIG_SYSTEM_PATH, true).build();
MetricsSinksConfig sinksConfig = new MetricsSinksConfig(CONFIG_SINK_PATH);
// initialize metric cache, except looper
MetricsCache mc = new MetricsCache(systemConfig, sinksConfig, new NIOLooper());
mc.addMetrics(TopologyMaster.PublishMetrics.newBuilder().addMetrics(TopologyMaster.MetricDatum.newBuilder().setComponentName("c1").setInstanceId("i1").setName("__jvm-uptime-secs").setTimestamp(System.currentTimeMillis()).setValue("0.1")).addExceptions(TopologyMaster.TmasterExceptionLog.newBuilder().setComponentName("c1").setHostname("h1").setInstanceId("i1").setStacktrace("s1").setLogging("l1").setCount(1).setFirsttime(String.valueOf(System.currentTimeMillis())).setLasttime(String.valueOf(System.currentTimeMillis()))).build());
// query last 10 seconds
TopologyMaster.MetricResponse response = mc.getMetrics(TopologyMaster.MetricRequest.newBuilder().setComponentName("c1").addInstanceId("i1").setInterval(10).addMetric("__jvm-uptime-secs").build());
assertEquals(response.getMetricCount(), 1);
assertEquals(response.getMetric(0).getInstanceId(), "i1");
assertEquals(response.getMetric(0).getMetricCount(), 1);
assertEquals(response.getMetric(0).getMetric(0).getName(), "__jvm-uptime-secs");
assertEquals(response.getMetric(0).getMetric(0).getValue(), "0.1");
}
use of com.twitter.heron.metricsmgr.MetricsSinksConfig in project incubator-heron by apache.
the class MetricsCacheTest method testMetricCache.
@Test
public void testMetricCache() throws IOException {
// prepare config files
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(CONFIG_SYSTEM_PATH, true).build();
MetricsSinksConfig sinksConfig = new MetricsSinksConfig(CONFIG_SINK_PATH);
// initialize metric cache, except looper
MetricsCache mc = new MetricsCache(systemConfig, sinksConfig, new NIOLooper());
mc.addMetrics(TopologyMaster.PublishMetrics.newBuilder().addMetrics(TopologyMaster.MetricDatum.newBuilder().setComponentName("c1").setInstanceId("i1").setName("__jvm-uptime-secs").setTimestamp(System.currentTimeMillis()).setValue("0.1")).addExceptions(TopologyMaster.TmasterExceptionLog.newBuilder().setComponentName("c1").setHostname("h1").setInstanceId("i1").setStacktrace("s1").setLogging("l1").setCount(1).setFirsttime(String.valueOf(System.currentTimeMillis())).setLasttime(String.valueOf(System.currentTimeMillis()))).build());
// query last 10 seconds
TopologyMaster.MetricResponse response = mc.getMetrics(TopologyMaster.MetricRequest.newBuilder().setComponentName("c1").addInstanceId("i1").setInterval(10).addMetric("__jvm-uptime-secs").build());
assertEquals(response.getMetricCount(), 1);
assertEquals(response.getMetric(0).getInstanceId(), "i1");
assertEquals(response.getMetric(0).getMetricCount(), 1);
assertEquals(response.getMetric(0).getMetric(0).getName(), "__jvm-uptime-secs");
assertEquals(response.getMetric(0).getMetric(0).getValue(), "0.1");
}
Aggregations