use of org.apache.cassandra.utils.progress.ProgressEvent in project cassandra by apache.
the class TracingTest method test_progress_listener.
@Test
public void test_progress_listener() {
List<String> traces = new ArrayList<>();
Tracing tracing = new TracingImpl(traces);
tracing.newSession(Tracing.TraceType.REPAIR);
tracing.begin("test-request", Collections.<String, String>emptyMap());
tracing.get().enableActivityNotification("test-tag");
tracing.get().addProgressListener(new ProgressListener() {
public void progress(String tag, ProgressEvent pe) {
assert "test-tag".equals(tag);
assert "test-trace".equals(pe.getMessage());
}
});
tracing.get().trace("test-trace");
tracing.stopSession();
assert null == tracing.get();
}
use of org.apache.cassandra.utils.progress.ProgressEvent in project cassandra by apache.
the class LegacyJMXProgressSupportTest method testSessionFailed.
@Test
public void testSessionFailed() {
int cmd = 321;
String message = String.format("Repair session %s for range %s failed with error %s", UUID.randomUUID(), new Range<Token>(new Murmur3Partitioner.LongToken(3), new Murmur3Partitioner.LongToken(4)).toString(), new RuntimeException("error"));
Optional<int[]> result = LegacyJMXProgressSupport.getLegacyUserdata(String.format("repair:%d", cmd), new ProgressEvent(ProgressEventType.PROGRESS, 2, 10, message));
assertTrue(result.isPresent());
assertArrayEquals(new int[] { cmd, ActiveRepairService.Status.SESSION_FAILED.ordinal() }, result.get());
}
use of org.apache.cassandra.utils.progress.ProgressEvent in project cassandra by apache.
the class LegacyJMXProgressSupportTest method testFinished.
@Test
public void testFinished() {
int cmd = 321;
Optional<int[]> result = LegacyJMXProgressSupport.getLegacyUserdata(String.format("repair:%d", cmd), new ProgressEvent(ProgressEventType.COMPLETE, 2, 10, "bla"));
assertTrue(result.isPresent());
assertArrayEquals(new int[] { cmd, ActiveRepairService.Status.FINISHED.ordinal() }, result.get());
}
use of org.apache.cassandra.utils.progress.ProgressEvent in project cassandra by apache.
the class LegacyJMXProgressSupportTest method testStarted.
@Test
public void testStarted() {
int cmd = 321;
Optional<int[]> result = LegacyJMXProgressSupport.getLegacyUserdata(String.format("repair:%d", cmd), new ProgressEvent(ProgressEventType.START, 0, 100, "bla"));
assertTrue(result.isPresent());
assertArrayEquals(new int[] { cmd, ActiveRepairService.Status.STARTED.ordinal() }, result.get());
}
use of org.apache.cassandra.utils.progress.ProgressEvent in project cassandra by apache.
the class JMXNotificationProgressListener method handleNotification.
@SuppressWarnings("unchecked")
@Override
public void handleNotification(Notification notification, Object handback) {
switch(notification.getType()) {
case "progress":
String tag = (String) notification.getSource();
if (this.isInterestedIn(tag)) {
Map<String, Integer> progress = (Map<String, Integer>) notification.getUserData();
String message = notification.getMessage();
ProgressEvent event = new ProgressEvent(ProgressEventType.values()[progress.get("type")], progress.get("progressCount"), progress.get("total"), message);
this.progress(tag, event);
}
break;
case JMXConnectionNotification.NOTIFS_LOST:
handleNotificationLost(notification.getTimeStamp(), notification.getMessage());
break;
case JMXConnectionNotification.FAILED:
handleConnectionFailed(notification.getTimeStamp(), notification.getMessage());
break;
case JMXConnectionNotification.CLOSED:
handleConnectionClosed(notification.getTimeStamp(), notification.getMessage());
break;
}
}
Aggregations