Search in sources :

Example 6 with WaitStrategyPark

use of org.apache.storm.policy.WaitStrategyPark in project storm by apache.

the class BoltExecutor method makeSystemBoltWaitStrategy.

private static IWaitStrategy makeSystemBoltWaitStrategy() {
    WaitStrategyPark ws = new WaitStrategyPark();
    Map<String, Object> conf = new HashMap<>();
    conf.put(Config.TOPOLOGY_BOLT_WAIT_PARK_MICROSEC, 5000);
    ws.prepare(conf, WaitSituation.BOLT_WAIT);
    return ws;
}
Also used : HashMap(java.util.HashMap) WaitStrategyPark(org.apache.storm.policy.WaitStrategyPark)

Example 7 with WaitStrategyPark

use of org.apache.storm.policy.WaitStrategyPark in project storm by apache.

the class ExecutorTransferMultiThreadingTest method setup.

@Before
public void setup() throws NoSuchFieldException {
    topoConf = Utils.readStormConfig();
    String topologyId = "multi-threaded-topo-test";
    StormTopology stormTopology = createStormTopology();
    WorkerTopologyContext workerTopologyContext = mock(WorkerTopologyContext.class);
    when(workerTopologyContext.getRawTopology()).thenReturn(stormTopology);
    when(workerTopologyContext.getComponentId(selfTaskId)).thenReturn(sourceComp);
    when(workerTopologyContext.getComponentId(remoteTaskId)).thenReturn(destComp);
    workerState = mock(WorkerState.class);
    when(workerState.getWorkerTopologyContext()).thenReturn(workerTopologyContext);
    Map<Integer, JCQueue> receiveQMap = new HashMap<>();
    // local recvQ is not important in this test; simple mock it
    receiveQMap.put(selfTaskId, mock(JCQueue.class));
    when(workerState.getLocalReceiveQueues()).thenReturn(receiveQMap);
    when(workerState.getTopologyId()).thenReturn(topologyId);
    when(workerState.getPort()).thenReturn(6701);
    when(workerState.getMetricRegistry()).thenReturn(new StormMetricRegistry());
    when(workerState.tryTransferRemote(any(), any(), any())).thenCallRealMethod();
    // the actual worker transfer queue to be used in this test
    // taskId for worker transfer queue should be -1.
    // But there is already one worker transfer queue initialized by WorkerTransfer class (taskId=-1).
    // However the taskId is only used for metrics and it is not important here. Making it -100 to avoid collision.
    transferQueue = new JCQueue("worker-transfer-queue", "worker-transfer-queue", 1024, 0, 1, new WaitStrategyPark(100), workerState.getTopologyId(), Constants.SYSTEM_COMPONENT_ID, Collections.singletonList(-100), workerState.getPort(), workerState.getMetricRegistry());
    // Replace the transferQueue inside WorkerTransfer (inside WorkerState) with the customized transferQueue to be used in this test
    WorkerTransfer workerTransfer = new WorkerTransfer(workerState, topoConf, 2);
    FieldSetter.setField(workerTransfer, workerTransfer.getClass().getDeclaredField("transferQueue"), transferQueue);
    FieldSetter.setField(workerState, workerState.getClass().getDeclaredField("workerTransfer"), workerTransfer);
    generalTopologyContext = mock(GeneralTopologyContext.class);
}
Also used : WorkerTopologyContext(org.apache.storm.task.WorkerTopologyContext) GeneralTopologyContext(org.apache.storm.task.GeneralTopologyContext) JCQueue(org.apache.storm.utils.JCQueue) HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) WaitStrategyPark(org.apache.storm.policy.WaitStrategyPark) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) WorkerState(org.apache.storm.daemon.worker.WorkerState) WorkerTransfer(org.apache.storm.daemon.worker.WorkerTransfer) Before(org.junit.Before)

Example 8 with WaitStrategyPark

use of org.apache.storm.policy.WaitStrategyPark in project storm by apache.

the class JCQueuePerfTest method oneProducer2Consumers.

private static void oneProducer2Consumers(int prodBatchSz) {
    WaitStrategyPark ws = new WaitStrategyPark(100);
    StormMetricRegistry registry = new StormMetricRegistry();
    JCQueue q1 = new JCQueue("q1", "q1", 1024, 0, prodBatchSz, ws, "test", "test", Collections.singletonList(1000), 1000, registry);
    JCQueue q2 = new JCQueue("q2", "q2", 1024, 0, prodBatchSz, ws, "test", "test", Collections.singletonList(1000), 1000, registry);
    final Producer2 prod1 = new Producer2(q1, q2);
    final Consumer cons1 = new Consumer(q1);
    final Consumer cons2 = new Consumer(q2);
    runAllThds(prod1, cons1, cons2);
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) WaitStrategyPark(org.apache.storm.policy.WaitStrategyPark) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry)

Aggregations

WaitStrategyPark (org.apache.storm.policy.WaitStrategyPark)8 StormMetricRegistry (org.apache.storm.metrics2.StormMetricRegistry)7 JCQueue (org.apache.storm.utils.JCQueue)7 HashMap (java.util.HashMap)2 WorkerState (org.apache.storm.daemon.worker.WorkerState)1 WorkerTransfer (org.apache.storm.daemon.worker.WorkerTransfer)1 StormTopology (org.apache.storm.generated.StormTopology)1 GeneralTopologyContext (org.apache.storm.task.GeneralTopologyContext)1 WorkerTopologyContext (org.apache.storm.task.WorkerTopologyContext)1 Before (org.junit.Before)1