Search in sources :

Example 1 with Communicator

use of org.apache.heron.common.basics.Communicator in project heron by twitter.

the class MetricsManager method initSinkExecutor.

private SinkExecutor initSinkExecutor(String sinkId) {
    IMetricsSink sink;
    String classname = (String) config.getConfigForSink(sinkId).get(MetricsSinksConfig.CONFIG_KEY_CLASSNAME);
    try {
        sink = (IMetricsSink) Class.forName(classname).newInstance();
    } catch (InstantiationException e) {
        throw new RuntimeException(e + " IMetricsSink class must have a no-arg constructor.");
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e + " IMetricsSink class must be concrete.");
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e + " IMetricsSink class must be a class path.");
    }
    ExecutorLooper sinkExecutorLoop = new ExecutorLooper();
    Communicator<MetricsRecord> executorInMetricsQueue = new Communicator<MetricsRecord>(null, sinkExecutorLoop);
    // Since MetricsCollector is not thread-safe,
    // we need to specify individual MetricsCollector and MultiCountMetric
    // for different SinkExecutor
    MetricsCollector sinkMetricsCollector = new MetricsCollector(sinkExecutorLoop, metricsQueue);
    MultiCountMetric internalCounters = new MultiCountMetric();
    sinkMetricsCollector.registerMetric(sinkId, internalCounters, (int) heronMetricsExportInterval.getSeconds());
    // Set up the SinkContext
    SinkContext sinkContext = new SinkContextImpl(topologyName, cluster, role, environment, metricsmgrId, sinkId, internalCounters);
    SinkExecutor sinkExecutor = new SinkExecutor(sinkId, sink, sinkExecutorLoop, executorInMetricsQueue, sinkContext);
    sinkExecutor.setPropertyMap(config.getConfigForSink(sinkId));
    return sinkExecutor;
}
Also used : IMetricsSink(org.apache.heron.spi.metricsmgr.sink.IMetricsSink) MetricsCollector(org.apache.heron.common.utils.metrics.MetricsCollector) Communicator(org.apache.heron.common.basics.Communicator) MetricsRecord(org.apache.heron.spi.metricsmgr.metrics.MetricsRecord) SinkContext(org.apache.heron.spi.metricsmgr.sink.SinkContext) SinkExecutor(org.apache.heron.metricsmgr.executor.SinkExecutor) MultiCountMetric(org.apache.heron.api.metric.MultiCountMetric) ExecutorLooper(org.apache.heron.common.basics.ExecutorLooper) SinkContextImpl(org.apache.heron.metricsmgr.sink.SinkContextImpl)

Aggregations

MultiCountMetric (org.apache.heron.api.metric.MultiCountMetric)1 Communicator (org.apache.heron.common.basics.Communicator)1 ExecutorLooper (org.apache.heron.common.basics.ExecutorLooper)1 MetricsCollector (org.apache.heron.common.utils.metrics.MetricsCollector)1 SinkExecutor (org.apache.heron.metricsmgr.executor.SinkExecutor)1 SinkContextImpl (org.apache.heron.metricsmgr.sink.SinkContextImpl)1 MetricsRecord (org.apache.heron.spi.metricsmgr.metrics.MetricsRecord)1 IMetricsSink (org.apache.heron.spi.metricsmgr.sink.IMetricsSink)1 SinkContext (org.apache.heron.spi.metricsmgr.sink.SinkContext)1