Search in sources :

Example 6 with SystemConfig

use of com.twitter.heron.common.config.SystemConfig in project heron by twitter.

the class HandleWriteTest method runStreamManagerClient.

void runStreamManagerClient() {
    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);
                HeronSocketOptions socketOptions = new HeronSocketOptions(systemConfig.getInstanceNetworkWriteBatchSizeBytes(), systemConfig.getInstanceNetworkWriteBatchTimeMs(), systemConfig.getInstanceNetworkReadBatchSizeBytes(), systemConfig.getInstanceNetworkReadBatchTimeMs(), systemConfig.getInstanceNetworkOptionsSocketSendBufferSizeBytes(), systemConfig.getInstanceNetworkOptionsSocketReceivedBufferSizeBytes());
                streamManagerClient = new StreamManagerClient(nioLooper, HOST, serverPort, "topology-name", "topologyId", UnitTestHelper.getInstance("bolt-id"), inStreamQueue, outStreamQueue, inControlQueue, socketOptions, gatewayMetrics);
                streamManagerClient.start();
                nioLooper.loop();
            } finally {
                streamManagerClient.stop();
                nioLooper.exitLoop();
            }
        }
    };
    threadsPool.execute(r);
}
Also used : SystemConfig(com.twitter.heron.common.config.SystemConfig) HeronSocketOptions(com.twitter.heron.common.network.HeronSocketOptions)

Example 7 with SystemConfig

use of com.twitter.heron.common.config.SystemConfig in project heron by twitter.

the class HandleReadTest method runStreamManagerClient.

void runStreamManagerClient() {
    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);
                HeronSocketOptions socketOptions = new HeronSocketOptions(systemConfig.getInstanceNetworkWriteBatchSizeBytes(), systemConfig.getInstanceNetworkWriteBatchTimeMs(), systemConfig.getInstanceNetworkReadBatchSizeBytes(), systemConfig.getInstanceNetworkReadBatchTimeMs(), systemConfig.getInstanceNetworkOptionsSocketSendBufferSizeBytes(), systemConfig.getInstanceNetworkOptionsSocketReceivedBufferSizeBytes());
                streamManagerClient = new StreamManagerClient(nioLooper, HOST, serverPort, "topology-name", "topologyId", UnitTestHelper.getInstance("bolt-id"), inStreamQueue, outStreamQueue, inControlQueue, socketOptions, gatewayMetrics);
                streamManagerClient.start();
                nioLooper.loop();
            } finally {
                streamManagerClient.stop();
                nioLooper.exitLoop();
            }
        }
    };
    threadsPool.execute(r);
}
Also used : SystemConfig(com.twitter.heron.common.config.SystemConfig) HeronSocketOptions(com.twitter.heron.common.network.HeronSocketOptions)

Example 8 with SystemConfig

use of com.twitter.heron.common.config.SystemConfig 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.");
}
Also used : MetricsSinksConfig(com.twitter.heron.metricsmgr.MetricsSinksConfig) Options(org.apache.commons.cli.Options) HeronSocketOptions(com.twitter.heron.common.network.HeronSocketOptions) SystemConfig(com.twitter.heron.common.config.SystemConfig) Config(com.twitter.heron.spi.common.Config) MetricsSinksConfig(com.twitter.heron.metricsmgr.MetricsSinksConfig) SystemConfig(com.twitter.heron.common.config.SystemConfig) TopologyMaster(com.twitter.heron.proto.tmaster.TopologyMaster) CommandLine(org.apache.commons.cli.CommandLine) Level(java.util.logging.Level) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) ErrorReportLoggingHandler(com.twitter.heron.common.utils.logging.ErrorReportLoggingHandler) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 9 with SystemConfig

use of com.twitter.heron.common.config.SystemConfig in project heron by twitter.

the class BoltMetrics method registerMetrics.

public void registerMetrics(TopologyContextImpl topologyContext) {
    SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);
    int interval = systemConfig.getHeronMetricsExportIntervalSec();
    topologyContext.registerMetric("__ack-count/default", ackCount, interval);
    topologyContext.registerMetric("__process-latency/default", processLatency, interval);
    topologyContext.registerMetric("__fail-latency/default", failLatency, interval);
    topologyContext.registerMetric("__fail-count/default", failCount, interval);
    topologyContext.registerMetric("__execute-count/default", executeCount, interval);
    topologyContext.registerMetric("__execute-latency/default", executeLatency, interval);
    topologyContext.registerMetric("__emit-count/default", emitCount, interval);
    topologyContext.registerMetric("__out-queue-full-count", outQueueFullCount, interval);
}
Also used : SystemConfig(com.twitter.heron.common.config.SystemConfig)

Example 10 with SystemConfig

use of com.twitter.heron.common.config.SystemConfig in project heron by twitter.

the class FullBoltMetrics method registerMetrics.

public void registerMetrics(TopologyContextImpl topologyContext) {
    SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);
    int interval = systemConfig.getHeronMetricsExportIntervalSec();
    topologyContext.registerMetric("__ack-count", ackCount, interval);
    topologyContext.registerMetric("__process-latency", processLatency, interval);
    topologyContext.registerMetric("__fail-latency", failLatency, interval);
    topologyContext.registerMetric("__fail-count", failCount, interval);
    topologyContext.registerMetric("__execute-count", executeCount, interval);
    topologyContext.registerMetric("__execute-latency", executeLatency, interval);
    topologyContext.registerMetric("__execute-time-ns", executeTimeNs, interval);
    topologyContext.registerMetric("__emit-count", emitCount, interval);
    topologyContext.registerMetric("__out-queue-full-count", outQueueFullCount, interval);
    topologyContext.registerMetric("__tuple-deserialization-time-ns", deserializationTimeNs, interval);
    topologyContext.registerMetric("__tuple-serialization-time-ns", serializationTimeNs, interval);
}
Also used : SystemConfig(com.twitter.heron.common.config.SystemConfig)

Aggregations

SystemConfig (com.twitter.heron.common.config.SystemConfig)14 HeronSocketOptions (com.twitter.heron.common.network.HeronSocketOptions)4 Level (java.util.logging.Level)4 ErrorReportLoggingHandler (com.twitter.heron.common.utils.logging.ErrorReportLoggingHandler)3 MetricsSinksConfig (com.twitter.heron.metricsmgr.MetricsSinksConfig)2 TopologyMaster (com.twitter.heron.proto.tmaster.TopologyMaster)2 NIOLooper (com.twitter.heron.common.basics.NIOLooper)1 PhysicalPlans (com.twitter.heron.proto.system.PhysicalPlans)1 Config (com.twitter.heron.spi.common.Config)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 Test (org.junit.Test)1