Search in sources :

Example 1 with SimpleErrorEvent

use of org.gridkit.jvmtool.event.SimpleErrorEvent in project jvm-tools by aragozin.

the class EventDecoratorTest method verify_error_event.

@Test
public void verify_error_event() {
    SimpleErrorEvent ee = new SimpleErrorEvent(new Exception("Boom"));
    EventDecorator deco = new EventDecorator();
    ErrorEvent c = deco.wrap(ee);
    assertThat(c).is(eventEquals(ee));
}
Also used : SimpleErrorEvent(org.gridkit.jvmtool.event.SimpleErrorEvent) EventDecorator(org.gridkit.jvmtool.event.EventDecorator) SimpleErrorEvent(org.gridkit.jvmtool.event.SimpleErrorEvent) ErrorEvent(org.gridkit.jvmtool.event.ErrorEvent) Test(org.junit.Test)

Example 2 with SimpleErrorEvent

use of org.gridkit.jvmtool.event.SimpleErrorEvent in project jvm-tools by aragozin.

the class ThreadDumpSource method getUnclassifiedReader.

public EventReader<ThreadSnapshotEvent> getUnclassifiedReader() {
    if (files == null) {
        host.fail("No input files provided, used -f option");
    }
    final Iterator<String> it = files.iterator();
    ChainedEventReader<Event> reader = new ChainedEventReader<Event>() {

        @Override
        protected EventReader<Event> produceNext() {
            return it.hasNext() ? open(it.next()) : null;
        }

        private EventReader<Event> open(String next) {
            try {
                return ThreadEventCodec.createEventReader(new FileInputStream(next));
            } catch (IOException e) {
                return new SingleEventReader<Event>(new SimpleErrorEvent(e));
            }
        }
    };
    ShieldedEventReader<ThreadSnapshotEvent> shielderReader = new ShieldedEventReader<ThreadSnapshotEvent>(reader, ThreadSnapshotEvent.class, new ErrorHandler() {

        @Override
        public void onException(Exception e) {
            System.err.println("Stream reader error: " + e);
        }
    });
    return shielderReader;
}
Also used : ErrorHandler(org.gridkit.jvmtool.event.ErrorHandler) SimpleErrorEvent(org.gridkit.jvmtool.event.SimpleErrorEvent) IOException(java.io.IOException) ChainedEventReader(org.gridkit.jvmtool.event.ChainedEventReader) FileInputStream(java.io.FileInputStream) ParserException(org.gridkit.jvmtool.stacktrace.analytics.ParserException) IOException(java.io.IOException) ThreadSnapshotEvent(org.gridkit.jvmtool.codec.stacktrace.ThreadSnapshotEvent) ShieldedEventReader(org.gridkit.jvmtool.event.ShieldedEventReader) SimpleErrorEvent(org.gridkit.jvmtool.event.SimpleErrorEvent) ThreadSnapshotEvent(org.gridkit.jvmtool.codec.stacktrace.ThreadSnapshotEvent) Event(org.gridkit.jvmtool.event.Event)

Aggregations

SimpleErrorEvent (org.gridkit.jvmtool.event.SimpleErrorEvent)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ThreadSnapshotEvent (org.gridkit.jvmtool.codec.stacktrace.ThreadSnapshotEvent)1 ChainedEventReader (org.gridkit.jvmtool.event.ChainedEventReader)1 ErrorEvent (org.gridkit.jvmtool.event.ErrorEvent)1 ErrorHandler (org.gridkit.jvmtool.event.ErrorHandler)1 Event (org.gridkit.jvmtool.event.Event)1 EventDecorator (org.gridkit.jvmtool.event.EventDecorator)1 ShieldedEventReader (org.gridkit.jvmtool.event.ShieldedEventReader)1 ParserException (org.gridkit.jvmtool.stacktrace.analytics.ParserException)1 Test (org.junit.Test)1