Search in sources :

Example 6 with ProgressEvent

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();
}
Also used : ProgressListener(org.apache.cassandra.utils.progress.ProgressListener) ArrayList(java.util.ArrayList) ProgressEvent(org.apache.cassandra.utils.progress.ProgressEvent) Test(org.junit.Test)

Example 7 with ProgressEvent

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());
}
Also used : Range(org.apache.cassandra.dht.Range) Murmur3Partitioner(org.apache.cassandra.dht.Murmur3Partitioner) ProgressEvent(org.apache.cassandra.utils.progress.ProgressEvent) Test(org.junit.Test)

Example 8 with ProgressEvent

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());
}
Also used : ProgressEvent(org.apache.cassandra.utils.progress.ProgressEvent) Test(org.junit.Test)

Example 9 with ProgressEvent

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());
}
Also used : ProgressEvent(org.apache.cassandra.utils.progress.ProgressEvent) Test(org.junit.Test)

Example 10 with ProgressEvent

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;
    }
}
Also used : ProgressEvent(org.apache.cassandra.utils.progress.ProgressEvent) Map(java.util.Map)

Aggregations

ProgressEvent (org.apache.cassandra.utils.progress.ProgressEvent)10 Test (org.junit.Test)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Range (org.apache.cassandra.dht.Range)2 Token (org.apache.cassandra.dht.Token)2 ProgressListener (org.apache.cassandra.utils.progress.ProgressListener)2 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 Murmur3Partitioner (org.apache.cassandra.dht.Murmur3Partitioner)1 AbstractReplicationStrategy (org.apache.cassandra.locator.AbstractReplicationStrategy)1 TraceState (org.apache.cassandra.tracing.TraceState)1 Pair (org.apache.cassandra.utils.Pair)1 ProgressEventType (org.apache.cassandra.utils.progress.ProgressEventType)1