Search in sources :

Example 1 with MalformedEventException

use of com.yahoo.log.event.MalformedEventException in project vespa by vespa-engine.

the class LogMessageTestCase method testEvents.

/**
 * Read in some events and make sure we are able to identify
 * them as such.
 */
@Test
public void testEvents() throws IOException {
    String eventfile = "src/test/files/event.txt.gz";
    BufferedReader br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(eventfile))));
    for (String line = br.readLine(); line != null; line = br.readLine()) {
        try {
            LogMessage m = LogMessage.parseNativeFormat(line);
            try {
                Event event = m.getEvent();
                assertNotNull(event);
            } catch (MalformedEventException evx) {
                fail();
            }
        } catch (InvalidLogFormatException e) {
            fail();
        }
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) InputStreamReader(java.io.InputStreamReader) LogMessage(com.yahoo.log.LogMessage) InvalidLogFormatException(com.yahoo.log.InvalidLogFormatException) MalformedEventException(com.yahoo.log.event.MalformedEventException) BufferedReader(java.io.BufferedReader) Event(com.yahoo.log.event.Event) FileInputStream(java.io.FileInputStream)

Example 2 with MalformedEventException

use of com.yahoo.log.event.MalformedEventException in project vespa by vespa-engine.

the class MetricsFilterTestCase method testValueEvents.

@Test
public void testValueEvents() throws InvalidLogFormatException, IOException {
    MetricsFilter filter = new MetricsFilter();
    String filename = "src/test/files/value-events.txt";
    BufferedReader br = new BufferedReader(new FileReader(filename));
    for (String line = br.readLine(); line != null; line = br.readLine()) {
        LogMessage m = LogMessage.parseNativeFormat(line);
        assertNotNull(m);
        try {
            Event event = m.getEvent();
            assertNotNull(event);
        } catch (MalformedEventException e) {
            fail();
        }
        if (filter.isLoggable(m)) {
            assertTrue(true);
        } else {
            fail();
        }
    }
}
Also used : LogMessage(com.yahoo.log.LogMessage) MalformedEventException(com.yahoo.log.event.MalformedEventException) BufferedReader(java.io.BufferedReader) Event(com.yahoo.log.event.Event) FileReader(java.io.FileReader) MetricsFilter(com.yahoo.logserver.filter.MetricsFilter)

Example 3 with MalformedEventException

use of com.yahoo.log.event.MalformedEventException in project vespa by vespa-engine.

the class EventTestCase method testFullParse.

public void testFullParse() {
    try {
        Event event = Event.parse("count/1 name=\"data_searched_mb\" value=15115168.3940149993");
        assertTrue(event instanceof Count);
        assertEquals("data_searched_mb", event.getValue("name"));
        assertEquals("15115168", event.getValue("value"));
    } catch (MalformedEventException e) {
        fail("Malformed Event Exception on parsing");
    }
}
Also used : MalformedEventException(com.yahoo.log.event.MalformedEventException) Event(com.yahoo.log.event.Event) Count(com.yahoo.log.event.Count)

Example 4 with MalformedEventException

use of com.yahoo.log.event.MalformedEventException in project vespa by vespa-engine.

the class VerifyLogfile method main.

public static void main(String[] args) throws IOException {
    int messages = 0;
    int events = 0;
    int invalidLogMessages = 0;
    int invalidEvents = 0;
    int numFiles = 0;
    if (args.length < 1) {
        System.err.println("\nPlease provide name of log file(s)\n");
    }
    for (int i = 0; i < args.length; i++) {
        BufferedReader br = new BufferedReader(new FileReader(args[i]));
        numFiles++;
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            messages++;
            LogMessage m;
            try {
                m = LogMessage.parseNativeFormat(line);
                if (m.getLevel() == LogLevel.EVENT) {
                    events++;
                    m.getEvent();
                }
            } catch (MalformedEventException e) {
                System.out.println("EVENT\t" + line);
                invalidEvents++;
            } catch (InvalidLogFormatException e) {
                System.out.println("MESSAGE\t" + line);
                invalidLogMessages++;
            }
        }
        br.close();
    }
    System.err.println("numFiles: " + numFiles);
    System.err.println("messages: " + messages);
    System.err.println("events: " + events);
    System.err.println("invalidLogMessages: " + invalidLogMessages);
    System.err.println("invalidEvents: " + invalidEvents);
}
Also used : LogMessage(com.yahoo.log.LogMessage) InvalidLogFormatException(com.yahoo.log.InvalidLogFormatException) MalformedEventException(com.yahoo.log.event.MalformedEventException) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader)

Example 5 with MalformedEventException

use of com.yahoo.log.event.MalformedEventException in project vespa by vespa-engine.

the class NoMetricsFilterTestCase method testValueEvents.

@Test
public void testValueEvents() throws InvalidLogFormatException, IOException {
    NoMetricsFilter filter = new NoMetricsFilter();
    MetricsFilter metricsFilter = new MetricsFilter();
    String filename = "src/test/files/value-events.txt";
    BufferedReader br = new BufferedReader(new FileReader(filename));
    for (String line = br.readLine(); line != null; line = br.readLine()) {
        LogMessage m = LogMessage.parseNativeFormat(line);
        assertNotNull(m);
        try {
            Event event = m.getEvent();
            assertNotNull(event);
        } catch (MalformedEventException e) {
            fail();
        }
        if (filter.isLoggable(m)) {
            fail();
        } else {
            assertTrue(true);
        }
        if (metricsFilter.isLoggable(m)) {
            assertTrue(true);
        } else {
            fail();
        }
    }
}
Also used : NoMetricsFilter(com.yahoo.logserver.filter.NoMetricsFilter) LogMessage(com.yahoo.log.LogMessage) MalformedEventException(com.yahoo.log.event.MalformedEventException) BufferedReader(java.io.BufferedReader) Event(com.yahoo.log.event.Event) FileReader(java.io.FileReader) MetricsFilter(com.yahoo.logserver.filter.MetricsFilter) NoMetricsFilter(com.yahoo.logserver.filter.NoMetricsFilter)

Aggregations

MalformedEventException (com.yahoo.log.event.MalformedEventException)5 LogMessage (com.yahoo.log.LogMessage)4 Event (com.yahoo.log.event.Event)4 BufferedReader (java.io.BufferedReader)4 FileReader (java.io.FileReader)3 InvalidLogFormatException (com.yahoo.log.InvalidLogFormatException)2 MetricsFilter (com.yahoo.logserver.filter.MetricsFilter)2 Count (com.yahoo.log.event.Count)1 NoMetricsFilter (com.yahoo.logserver.filter.NoMetricsFilter)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 GZIPInputStream (java.util.zip.GZIPInputStream)1