Search in sources :

Example 1 with BackpressureState

use of org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState in project storm by apache.

the class BackPressureTrackerTest method testSetBackpressureWithExistingBackpressure.

@Test
public void testSetBackpressureWithExistingBackpressure() {
    int taskId = 1;
    JCQueue queue = mock(JCQueue.class);
    BackPressureTracker tracker = new BackPressureTracker(WORKER_ID, ImmutableMap.of(taskId, queue), new StormMetricRegistry(), ImmutableMap.of(taskId, "component-1"));
    BackpressureState state = tracker.getBackpressureState(taskId);
    tracker.recordBackPressure(state);
    boolean backpressureChanged = tracker.recordBackPressure(state);
    BackPressureStatus status = tracker.getCurrStatus();
    assertThat(backpressureChanged, is(false));
    assertThat(status.workerId, is(WORKER_ID));
    assertThat(status.bpTasks, contains(taskId));
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) BackpressureState(org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState) BackPressureStatus(org.apache.storm.messaging.netty.BackPressureStatus) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) Test(org.junit.Test)

Example 2 with BackpressureState

use of org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState in project storm by apache.

the class BackPressureTrackerTest method testSetLastOverflowCount.

@Test
public void testSetLastOverflowCount() {
    int taskId = 1;
    int overflow = 5;
    JCQueue queue = mock(JCQueue.class);
    BackPressureTracker tracker = new BackPressureTracker(WORKER_ID, ImmutableMap.of(taskId, queue), new StormMetricRegistry(), ImmutableMap.of(taskId, "component-1"));
    BackpressureState state = tracker.getBackpressureState(taskId);
    tracker.recordBackPressure(state);
    tracker.setLastOverflowCount(state, overflow);
    BackpressureState retrievedState = tracker.getBackpressureState(taskId);
    int lastOverflowCount = tracker.getLastOverflowCount(retrievedState);
    assertThat(lastOverflowCount, is(overflow));
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) BackpressureState(org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) Test(org.junit.Test)

Example 3 with BackpressureState

use of org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState in project storm by apache.

the class BackPressureTrackerTest method testRefreshBackpressureWithEmptyOverflow.

@Test
public void testRefreshBackpressureWithEmptyOverflow() {
    int taskId = 1;
    JCQueue queue = mock(JCQueue.class);
    when(queue.isEmptyOverflow()).thenReturn(true);
    BackPressureTracker tracker = new BackPressureTracker(WORKER_ID, ImmutableMap.of(taskId, queue), new StormMetricRegistry(), ImmutableMap.of(taskId, "component-1"));
    BackpressureState state = tracker.getBackpressureState(taskId);
    tracker.recordBackPressure(state);
    boolean backpressureChanged = tracker.refreshBpTaskList();
    BackPressureStatus status = tracker.getCurrStatus();
    assertThat(backpressureChanged, is(true));
    assertThat(status.workerId, is(WORKER_ID));
    assertThat(status.nonBpTasks, contains(taskId));
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) BackpressureState(org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState) BackPressureStatus(org.apache.storm.messaging.netty.BackPressureStatus) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) Test(org.junit.Test)

Example 4 with BackpressureState

use of org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState in project storm by apache.

the class BackPressureTrackerTest method testRefreshBackPressureWithNonEmptyOverflow.

@Test
public void testRefreshBackPressureWithNonEmptyOverflow() {
    int taskId = 1;
    JCQueue queue = mock(JCQueue.class);
    when(queue.isEmptyOverflow()).thenReturn(false);
    BackPressureTracker tracker = new BackPressureTracker(WORKER_ID, ImmutableMap.of(taskId, queue), new StormMetricRegistry(), ImmutableMap.of(taskId, "component-1"));
    BackpressureState state = tracker.getBackpressureState(taskId);
    tracker.recordBackPressure(state);
    boolean backpressureChanged = tracker.refreshBpTaskList();
    BackPressureStatus status = tracker.getCurrStatus();
    assertThat(backpressureChanged, is(false));
    assertThat(status.workerId, is(WORKER_ID));
    assertThat(status.bpTasks, contains(taskId));
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) BackpressureState(org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState) BackPressureStatus(org.apache.storm.messaging.netty.BackPressureStatus) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) Test(org.junit.Test)

Example 5 with BackpressureState

use of org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState in project storm by apache.

the class BackPressureTrackerTest method testSetBackpressure.

@Test
public void testSetBackpressure() {
    int taskIdNoBackPressure = 1;
    JCQueue noBackPressureQueue = mock(JCQueue.class);
    int taskIdBackPressure = 2;
    JCQueue backPressureQueue = mock(JCQueue.class);
    BackPressureTracker tracker = new BackPressureTracker(WORKER_ID, ImmutableMap.of(taskIdNoBackPressure, noBackPressureQueue, taskIdBackPressure, backPressureQueue), new StormMetricRegistry(), ImmutableMap.of(taskIdNoBackPressure, "NoBackPressureComponent", taskIdBackPressure, "BackPressureComponent"));
    BackpressureState state = tracker.getBackpressureState(taskIdBackPressure);
    boolean backpressureChanged = tracker.recordBackPressure(state);
    BackPressureStatus status = tracker.getCurrStatus();
    assertThat(backpressureChanged, is(true));
    assertThat(status.workerId, is(WORKER_ID));
    assertThat(status.nonBpTasks, contains(taskIdNoBackPressure));
    assertThat(status.bpTasks, contains(taskIdBackPressure));
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) BackpressureState(org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState) BackPressureStatus(org.apache.storm.messaging.netty.BackPressureStatus) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) Test(org.junit.Test)

Aggregations

BackpressureState (org.apache.storm.daemon.worker.BackPressureTracker.BackpressureState)6 JCQueue (org.apache.storm.utils.JCQueue)6 BackPressureStatus (org.apache.storm.messaging.netty.BackPressureStatus)5 StormMetricRegistry (org.apache.storm.metrics2.StormMetricRegistry)5 Test (org.junit.Test)5 AddressedTuple (org.apache.storm.tuple.AddressedTuple)1