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