Search in sources :

Example 1 with BackPressureStatus

use of org.apache.storm.messaging.netty.BackPressureStatus in project storm by apache.

the class WorkerState method refreshBackPressureStatus.

// checks if the tasks which had back pressure are now free again. if so, sends an update to other workers
public void refreshBackPressureStatus() {
    LOG.debug("Checking for change in Backpressure status on worker's tasks");
    boolean bpSituationChanged = bpTracker.refreshBpTaskList();
    if (bpSituationChanged) {
        BackPressureStatus bpStatus = bpTracker.getCurrStatus();
        receiver.sendBackPressureStatus(bpStatus);
    }
}
Also used : BackPressureStatus(org.apache.storm.messaging.netty.BackPressureStatus)

Example 2 with BackPressureStatus

use of org.apache.storm.messaging.netty.BackPressureStatus 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 3 with BackPressureStatus

use of org.apache.storm.messaging.netty.BackPressureStatus in project storm by apache.

the class BackPressureTrackerTest method testGetBackpressure.

@Test
public void testGetBackpressure() {
    int taskIdNoBackPressure = 1;
    JCQueue noBackPressureQueue = mock(JCQueue.class);
    BackPressureTracker tracker = new BackPressureTracker(WORKER_ID, Collections.singletonMap(taskIdNoBackPressure, noBackPressureQueue), new StormMetricRegistry(), Collections.singletonMap(taskIdNoBackPressure, "testComponent"));
    BackPressureStatus status = tracker.getCurrStatus();
    assertThat(status.workerId, is(WORKER_ID));
    assertThat(status.nonBpTasks, contains(taskIdNoBackPressure));
    assertThat(status.bpTasks, is(empty()));
}
Also used : JCQueue(org.apache.storm.utils.JCQueue) BackPressureStatus(org.apache.storm.messaging.netty.BackPressureStatus) StormMetricRegistry(org.apache.storm.metrics2.StormMetricRegistry) Test(org.junit.Test)

Example 4 with BackPressureStatus

use of org.apache.storm.messaging.netty.BackPressureStatus 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 5 with BackPressureStatus

use of org.apache.storm.messaging.netty.BackPressureStatus 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)

Aggregations

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