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);
}
}
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));
}
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()));
}
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));
}
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));
}
Aggregations