Search in sources :

Example 1 with SlaveLooper

use of com.twitter.heron.common.basics.SlaveLooper 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.");
    }
    SlaveLooper sinkExecutorLoop = new SlaveLooper();
    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, heronMetricsExportIntervalSec);
    // Set up the SinkContext
    SinkContext sinkContext = new SinkContextImpl(topologyName, metricsmgrId, sinkId, internalCounters);
    SinkExecutor sinkExecutor = new SinkExecutor(sinkId, sink, sinkExecutorLoop, executorInMetricsQueue, sinkContext);
    sinkExecutor.setPropertyMap(config.getConfigForSink(sinkId));
    return sinkExecutor;
}
Also used : IMetricsSink(com.twitter.heron.spi.metricsmgr.sink.IMetricsSink) MetricsCollector(com.twitter.heron.common.utils.metrics.MetricsCollector) Communicator(com.twitter.heron.common.basics.Communicator) MetricsRecord(com.twitter.heron.spi.metricsmgr.metrics.MetricsRecord) SinkContext(com.twitter.heron.spi.metricsmgr.sink.SinkContext) SinkExecutor(com.twitter.heron.metricsmgr.executor.SinkExecutor) MultiCountMetric(com.twitter.heron.api.metric.MultiCountMetric) SinkContextImpl(com.twitter.heron.metricsmgr.sink.SinkContextImpl) SlaveLooper(com.twitter.heron.common.basics.SlaveLooper)

Example 2 with SlaveLooper

use of com.twitter.heron.common.basics.SlaveLooper in project heron by twitter.

the class ActivateDeactivateTest method before.

@Before
public void before() throws Exception {
    UnitTestHelper.addSystemConfigToSingleton();
    slaveLooper = new SlaveLooper();
    outStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(slaveLooper, null);
    outStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    inStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(null, slaveLooper);
    inStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    slaveMetricsOut = new Communicator<Metrics.MetricPublisherPublishMessage>(slaveLooper, null);
    slaveMetricsOut.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    inControlQueue = new Communicator<InstanceControlMsg>(null, slaveLooper);
    slave = new Slave(slaveLooper, inStreamQueue, outStreamQueue, inControlQueue, slaveMetricsOut);
    threadsPool = Executors.newSingleThreadExecutor();
    threadsPool.execute(slave);
}
Also used : Slave(com.twitter.heron.instance.Slave) InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) SlaveLooper(com.twitter.heron.common.basics.SlaveLooper) Before(org.junit.Before)

Example 3 with SlaveLooper

use of com.twitter.heron.common.basics.SlaveLooper in project heron by twitter.

the class SpoutInstanceTest method before.

@Before
public void before() throws Exception {
    UnitTestHelper.addSystemConfigToSingleton();
    tupleReceived = 0;
    heronDataTupleList = new ArrayList<HeronTuples.HeronDataTuple>();
    ackCount = new AtomicInteger(0);
    failCount = new AtomicInteger(0);
    testLooper = new SlaveLooper();
    slaveLooper = new SlaveLooper();
    outStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(slaveLooper, testLooper);
    outStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    inStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(testLooper, slaveLooper);
    inStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    slaveMetricsOut = new Communicator<Metrics.MetricPublisherPublishMessage>(slaveLooper, testLooper);
    slaveMetricsOut.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    inControlQueue = new Communicator<InstanceControlMsg>(testLooper, slaveLooper);
    slave = new Slave(slaveLooper, inStreamQueue, outStreamQueue, inControlQueue, slaveMetricsOut);
    threadsPool = Executors.newSingleThreadExecutor();
    threadsPool.execute(slave);
}
Also used : Slave(com.twitter.heron.instance.Slave) InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SlaveLooper(com.twitter.heron.common.basics.SlaveLooper) Before(org.junit.Before)

Example 4 with SlaveLooper

use of com.twitter.heron.common.basics.SlaveLooper in project heron by twitter.

the class ConnectTest method before.

@Before
public void before() throws Exception {
    UnitTestHelper.addSystemConfigToSingleton();
    nioLooper = new NIOLooper();
    slaveLooper = new SlaveLooper();
    inStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(nioLooper, slaveLooper);
    inStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    outStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(slaveLooper, nioLooper);
    outStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    inControlQueue = new Communicator<InstanceControlMsg>(nioLooper, slaveLooper);
    gatewayMetrics = new GatewayMetrics();
    threadsPool = Executors.newSingleThreadExecutor();
    // Get an available port
    serverPort = SysUtils.getFreePort();
}
Also used : InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) SlaveLooper(com.twitter.heron.common.basics.SlaveLooper) NIOLooper(com.twitter.heron.common.basics.NIOLooper) GatewayMetrics(com.twitter.heron.metrics.GatewayMetrics) Before(org.junit.Before)

Example 5 with SlaveLooper

use of com.twitter.heron.common.basics.SlaveLooper in project heron by twitter.

the class HandleReadTest method before.

@Before
public void before() throws Exception {
    UnitTestHelper.addSystemConfigToSingleton();
    nioLooper = new NIOLooper();
    slaveLooper = new SlaveLooper();
    inStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(nioLooper, slaveLooper);
    inStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    outStreamQueue = new Communicator<HeronTuples.HeronTupleSet>(slaveLooper, nioLooper);
    outStreamQueue.init(Constants.QUEUE_BUFFER_SIZE, Constants.QUEUE_BUFFER_SIZE, 0.5);
    inControlQueue = new Communicator<InstanceControlMsg>(nioLooper, slaveLooper);
    gatewayMetrics = new GatewayMetrics();
    threadsPool = Executors.newSingleThreadExecutor();
    // Get an available port
    serverPort = SysUtils.getFreePort();
}
Also used : InstanceControlMsg(com.twitter.heron.instance.InstanceControlMsg) SlaveLooper(com.twitter.heron.common.basics.SlaveLooper) NIOLooper(com.twitter.heron.common.basics.NIOLooper) GatewayMetrics(com.twitter.heron.metrics.GatewayMetrics) Before(org.junit.Before)

Aggregations

SlaveLooper (com.twitter.heron.common.basics.SlaveLooper)9 Before (org.junit.Before)8 InstanceControlMsg (com.twitter.heron.instance.InstanceControlMsg)7 Slave (com.twitter.heron.instance.Slave)4 NIOLooper (com.twitter.heron.common.basics.NIOLooper)3 GatewayMetrics (com.twitter.heron.metrics.GatewayMetrics)3 MultiCountMetric (com.twitter.heron.api.metric.MultiCountMetric)2 SinkContextImpl (com.twitter.heron.metricsmgr.sink.SinkContextImpl)2 SinkContext (com.twitter.heron.spi.metricsmgr.sink.SinkContext)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Communicator (com.twitter.heron.common.basics.Communicator)1 MetricsCollector (com.twitter.heron.common.utils.metrics.MetricsCollector)1 SinkExecutor (com.twitter.heron.metricsmgr.executor.SinkExecutor)1 MetricsRecord (com.twitter.heron.spi.metricsmgr.metrics.MetricsRecord)1 IMetricsSink (com.twitter.heron.spi.metricsmgr.sink.IMetricsSink)1