use of com.twitter.heron.common.utils.logging.ErrorReportLoggingHandler in project heron by twitter.
the class MetricsManager method main.
public static void main(String[] args) throws IOException {
if (args.length != 6) {
throw new RuntimeException("Invalid arguments; Usage: java com.twitter.heron.metricsmgr.MetricsManager " + "<id> <port> <topname> <topid> <heron_internals_config_filename> " + "<metrics_sinks_config_filename>");
}
String metricsmgrId = args[0];
int metricsPort = Integer.parseInt(args[1]);
String topologyName = args[2];
String topologyId = args[3];
String systemConfigFilename = args[4];
String metricsSinksConfigFilename = args[5];
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(systemConfigFilename, true).build();
// Add the SystemConfig into SingletonRegistry
SingletonRegistry.INSTANCE.registerSingleton(SystemConfig.HERON_SYSTEM_CONFIG, systemConfig);
// Init the logging setting and redirect the stdout and stderr to logging
// For now we just set the logging level as INFO; later we may accept an argument to set it.
Level loggingLevel = Level.INFO;
String loggingDir = systemConfig.getHeronLoggingDirectory();
// Log to file and TMaster
LoggingHelper.loggerInit(loggingLevel, true);
LoggingHelper.addLoggingHandler(LoggingHelper.getFileHandler(metricsmgrId, loggingDir, true, systemConfig.getHeronLoggingMaximumSizeMb() * Constants.MB_TO_BYTES, systemConfig.getHeronLoggingMaximumFiles()));
LoggingHelper.addLoggingHandler(new ErrorReportLoggingHandler());
LOG.info(String.format("Starting Metrics Manager for topology %s with topologyId %s with " + "Metrics Manager Id %s, Merics Manager Port: %d.", topologyName, topologyId, metricsmgrId, metricsPort));
LOG.info("System Config: " + systemConfig);
// Populate the config
MetricsSinksConfig sinksConfig = new MetricsSinksConfig(metricsSinksConfigFilename);
LOG.info("Sinks Config:" + sinksConfig.toString());
MetricsManager metricsManager = new MetricsManager(topologyName, METRICS_MANAGER_HOST, metricsPort, metricsmgrId, systemConfig, sinksConfig);
metricsManager.start();
LOG.info("Loops terminated. Metrics Manager exits.");
}
use of com.twitter.heron.common.utils.logging.ErrorReportLoggingHandler in project heron by twitter.
the class HeronInstance method main.
public static void main(String[] args) throws IOException {
if (args.length < 10) {
throw new RuntimeException("Invalid arguments; Usage is java com.twitter.heron.instance.HeronInstance " + "<topology_name> <topology_id> <instance_id> <component_name> <task_id> " + "<component_index> <stmgr_id> <stmgr_port> <metricsmgr_port> " + "<heron_internals_config_filename>");
}
String topologyName = args[0];
String topologyId = args[1];
String instanceId = args[2];
String componentName = args[3];
int taskId = Integer.parseInt(args[4]);
int componentIndex = Integer.parseInt(args[5]);
String streamId = args[6];
int streamPort = Integer.parseInt(args[7]);
int metricsPort = Integer.parseInt(args[8]);
SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(args[9], true).build();
// Add the SystemConfig into SingletonRegistry
SingletonRegistry.INSTANCE.registerSingleton(SystemConfig.HERON_SYSTEM_CONFIG, systemConfig);
// Create the protobuf Instance
PhysicalPlans.InstanceInfo instanceInfo = PhysicalPlans.InstanceInfo.newBuilder().setTaskId(taskId).setComponentIndex(componentIndex).setComponentName(componentName).build();
PhysicalPlans.Instance instance = PhysicalPlans.Instance.newBuilder().setInstanceId(instanceId).setStmgrId(streamId).setInfo(instanceInfo).build();
// Init the logging setting and redirect the stdout and stderr to logging
// For now we just set the logging level as INFO; later we may accept an argument to set it.
Level loggingLevel = Level.INFO;
String loggingDir = systemConfig.getHeronLoggingDirectory();
// Log to file and TMaster
LoggingHelper.loggerInit(loggingLevel, true);
LoggingHelper.addLoggingHandler(LoggingHelper.getFileHandler(instanceId, loggingDir, true, systemConfig.getHeronLoggingMaximumSizeMb() * Constants.MB_TO_BYTES, systemConfig.getHeronLoggingMaximumFiles()));
LoggingHelper.addLoggingHandler(new ErrorReportLoggingHandler());
LOG.info("\nStarting instance " + instanceId + " for topology " + topologyName + " and topologyId " + topologyId + " for component " + componentName + " with taskId " + taskId + " and componentIndex " + componentIndex + " and stmgrId " + streamId + " and stmgrPort " + streamPort + " and metricsManagerPort " + metricsPort);
LOG.info("System Config: " + systemConfig);
HeronInstance heronInstance = new HeronInstance(topologyName, topologyId, instance, streamPort, metricsPort);
heronInstance.start();
}
use of com.twitter.heron.common.utils.logging.ErrorReportLoggingHandler 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.");
}
Aggregations