Search in sources :

Example 1 with QueueGauge

use of com.alibaba.jstorm.common.metric.QueueGauge in project jstorm by alibaba.

the class Worker method startDispatchThread.

private AsyncLoopThread startDispatchThread() {
    // send tuple directly from netty server
    // send control tuple to dispatch thread
    // startDispatchDisruptor();
    IContext context = workerData.getContext();
    String topologyId = workerData.getTopologyId();
    // create recv connection
    Map stormConf = workerData.getStormConf();
    long timeout = JStormUtils.parseLong(stormConf.get(Config.TOPOLOGY_DISRUPTOR_WAIT_TIMEOUT), 10);
    WaitStrategy waitStrategy = new TimeoutBlockingWaitStrategy(timeout, TimeUnit.MILLISECONDS);
    int queueSize = JStormUtils.parseInt(stormConf.get(Config.TOPOLOGY_CTRL_BUFFER_SIZE), 256);
    DisruptorQueue recvControlQueue = DisruptorQueue.mkInstance("Dispatch-control", ProducerType.MULTI, queueSize, waitStrategy, false, 0, 0);
    // metric for recvControlQueue
    QueueGauge revCtrlGauge = new QueueGauge(recvControlQueue, MetricDef.RECV_CTRL_QUEUE);
    JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.RECV_CTRL_QUEUE, MetricType.GAUGE), new AsmGauge(revCtrlGauge));
    IConnection recvConnection = context.bind(topologyId, workerData.getPort(), workerData.getDeserializeQueues(), recvControlQueue, false, workerData.getTaskIds());
    workerData.setRecvConnection(recvConnection);
    // create recvice control messages's thread
    RunnableCallback recvControlDispather = new VirtualPortCtrlDispatch(workerData, recvConnection, recvControlQueue, MetricDef.RECV_THREAD);
    return new AsyncLoopThread(recvControlDispather, false, Thread.MAX_PRIORITY, true);
}
Also used : IContext(backtype.storm.messaging.IContext) DisruptorQueue(backtype.storm.utils.DisruptorQueue) IConnection(backtype.storm.messaging.IConnection) RunnableCallback(com.alibaba.jstorm.callback.RunnableCallback) QueueGauge(com.alibaba.jstorm.common.metric.QueueGauge) TimeoutBlockingWaitStrategy(com.lmax.disruptor.TimeoutBlockingWaitStrategy) AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread) AsmGauge(com.alibaba.jstorm.common.metric.AsmGauge) TimeoutBlockingWaitStrategy(com.lmax.disruptor.TimeoutBlockingWaitStrategy) WaitStrategy(com.lmax.disruptor.WaitStrategy)

Aggregations

IConnection (backtype.storm.messaging.IConnection)1 IContext (backtype.storm.messaging.IContext)1 DisruptorQueue (backtype.storm.utils.DisruptorQueue)1 AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)1 RunnableCallback (com.alibaba.jstorm.callback.RunnableCallback)1 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 QueueGauge (com.alibaba.jstorm.common.metric.QueueGauge)1 TimeoutBlockingWaitStrategy (com.lmax.disruptor.TimeoutBlockingWaitStrategy)1 WaitStrategy (com.lmax.disruptor.WaitStrategy)1