Search in sources :

Example 6 with RunnableCallback

use of com.alibaba.jstorm.callback.RunnableCallback 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)

Example 7 with RunnableCallback

use of com.alibaba.jstorm.callback.RunnableCallback in project jstorm by alibaba.

the class EventManagerImp method run.

@Override
public void run() {
    try {
        RunnableCallback r = queue.take();
        if (r == null) {
            return;
        }
        r.run();
        e = r.error();
        proccessinc();
    } catch (InterruptedException e) {
        LOG.info("InterruptedException when processing event ");
    }
}
Also used : RunnableCallback(com.alibaba.jstorm.callback.RunnableCallback)

Aggregations

RunnableCallback (com.alibaba.jstorm.callback.RunnableCallback)7 AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)3 IConnection (backtype.storm.messaging.IConnection)1 IContext (backtype.storm.messaging.IContext)1 DisruptorQueue (backtype.storm.utils.DisruptorQueue)1 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 QueueGauge (com.alibaba.jstorm.common.metric.QueueGauge)1 LocalAssignment (com.alibaba.jstorm.daemon.worker.LocalAssignment)1 WorkerHeartbeatRunable (com.alibaba.jstorm.daemon.worker.hearbeat.WorkerHeartbeatRunable)1 EventManagerZkPusher (com.alibaba.jstorm.event.EventManagerZkPusher)1 Assignment (com.alibaba.jstorm.schedule.Assignment)1 TaskShutdownDameon (com.alibaba.jstorm.task.TaskShutdownDameon)1 TimeoutBlockingWaitStrategy (com.lmax.disruptor.TimeoutBlockingWaitStrategy)1 WaitStrategy (com.lmax.disruptor.WaitStrategy)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 FileExistsException (org.apache.commons.io.FileExistsException)1 TException (org.apache.thrift.TException)1