use of org.gridkit.jvmtool.event.CommonEvent in project jvm-tools by aragozin.
the class EventDecoratorTest method verify_generic_event.
@Test
public void verify_generic_event() {
GenericEvent a = new GenericEvent();
a.timestamp(10000);
a.tags().put("A", "1");
a.tags().put("B", "2");
a.tags().put("B", "3");
a.tags().put("C", "4");
a.counters().set("X", 10);
a.counters().set("zzz", Long.MAX_VALUE);
GenericEvent b = new GenericEvent(a);
assertThat(b).is(eventEquals(a));
EventDecorator deco = new EventDecorator();
CommonEvent c = deco.wrap(b);
assertThat(c).is(eventEquals(a));
deco.timestamp(77777);
deco.tags().put("F", "10");
deco.counters().set("__", 25);
assertThat(c.timestamp()).isEqualTo(77777);
assertThat(c.tags()).containsOnly("A", "B", "C", "F");
assertThat(c.counters()).containsOnly("X", "zzz", "__");
}
use of org.gridkit.jvmtool.event.CommonEvent in project jvm-tools by aragozin.
the class ThreadSnapshotEventPojo method loadFromRawEvent.
public void loadFromRawEvent(ThreadTraceEvent event) {
threadId(-1);
threadName(null);
threadState(null);
CommonEvent cevent = (CommonEvent) event;
copyCommonEventFrom(cevent);
if (cevent.counters().getValue(JvmEvents.THREAD_ID) >= 0) {
threadId(cevent.counters().getValue(JvmEvents.THREAD_ID));
}
threadName(cevent.tags().firstTagFor(JvmEvents.THREAD_NAME));
threadState(state(cevent.tags().firstTagFor(JvmEvents.THREAD_STATE)));
stackTrace(event.stackTrace());
}
use of org.gridkit.jvmtool.event.CommonEvent in project jvm-tools by aragozin.
the class EventReadWriteTest method verify_simple_event.
@Test
public void verify_simple_event() throws Exception {
TestDataEvent a = new TestDataEvent();
a.timestamp(1000);
a.tag("A", "1");
a.tag("B", "1");
a.tag("B", "2");
a.tag("C", "0");
a.set("qwerty", 10);
a.set("QWERTY", Long.MAX_VALUE - Integer.MAX_VALUE);
CommonEvent b = (CommonEvent) safeWriteReadEvents(a).iterator().next();
assertThat(b).isNotInstanceOf(ThreadSnapshotEvent.class);
assertThat(b.timestamp()).isEqualTo(1000);
assertThat(b.counters().getValue("qwerty")).isEqualTo(10);
assertThat(b.counters().getValue("QWERTY")).isEqualTo(Long.MAX_VALUE - Integer.MAX_VALUE);
assertThat(b.tags()).containsOnly("A", "B", "C");
assertThat(b.tags().tagsFor("A")).containsOnly("1");
assertThat(b.tags().tagsFor("B")).containsOnly("1", "2");
assertThat(b.tags().tagsFor("C")).containsOnly("0");
assertThat(b).is(eventEquals(a));
}
Aggregations