use of com.yahoo.log.InvalidLogFormatException 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();
}
}
}
use of com.yahoo.log.InvalidLogFormatException in project vespa by vespa-engine.
the class ArchiverHandlerTestCase method testFilenameCreation.
/**
* Test that the ArchiverHandler creates correct filenames.
*/
@Test
public void testFilenameCreation() throws IOException {
File tmpDir = temporaryFolder.newFolder();
try {
ArchiverHandler a = new ArchiverHandler(tmpDir.getAbsolutePath(), 1024);
LogMessage msg1 = LogMessage.parseNativeFormat("1139322725\thost\tthread\tservice\tcomponent\tinfo\tpayload");
LogMessage msg2 = LogMessage.parseNativeFormat("1161172200\thost\tthread\tservice\tcomponent\tinfo\tpayload");
assertEquals(tmpDir.getAbsolutePath() + "/2006/02/07/14", a.getPrefix(msg1));
assertEquals(tmpDir.getAbsolutePath() + "/2006/10/18/11", a.getPrefix(msg2));
assertEquals(a.getPrefix(msg1).length(), a.getPrefix(msg2).length());
a.close();
} catch (InvalidLogFormatException e) {
fail(e.toString());
} finally {
IOUtils.recursiveDeleteDir(tmpDir);
}
}
use of com.yahoo.log.InvalidLogFormatException in project vespa by vespa-engine.
the class RankSetupValidator method validateFail.
private void validateFail(String output, SearchCluster sc, String sdName, DeployLogger deployLogger) {
String errMsg = "For search cluster '" + sc.getClusterName() + "', search definition '" + sdName + "': error in rank setup. Details:\n";
for (String line : output.split("\n")) {
// Remove debug lines from start script
if (line.startsWith("debug\t"))
continue;
try {
LogMessage logmsg = LogMessage.parseNativeFormat(line);
errMsg = errMsg + logmsg.getLevel() + ": " + logmsg.getPayload() + "\n";
} catch (InvalidLogFormatException e) {
errMsg = errMsg + line + "\n";
}
}
if (force) {
deployLogger.log(LogLevel.WARNING, errMsg + "(Continuing because of force.)");
} else {
throw new IllegalArgumentException(errMsg);
}
}
use of com.yahoo.log.InvalidLogFormatException in project vespa by vespa-engine.
the class LogConnection method read.
public void read() throws IOException {
if (!readBuffer.hasRemaining()) {
try {
readBuffer.putChar(readBuffer.capacity() - 2, '\n');
readBuffer.flip();
String s = ReadLine.readLine(readBuffer);
if (s == null) {
return;
}
log.log(LogLevel.DEBUG, "Log message too long. Message from " + socket.socket().getInetAddress() + " exceeds " + readBuffer.capacity() + ". The message was: " + s);
LogMessage msg = LogMessage.parseNativeFormat(s);
dispatcher.handle(msg);
} catch (InvalidLogFormatException e) {
log.log(LogLevel.DEBUG, "Invalid log message", e);
} finally {
readBuffer.clear();
}
return;
}
int ret = socket.read(readBuffer);
if (ret == -1) {
close();
return;
}
if (ret == 0) {
if (log.isLoggable(Level.FINE)) {
log.log(LogLevel.DEBUG, "zero byte read occurred");
}
}
// update global counter
totalBytesRead += ret;
readBuffer.flip();
String s;
while ((s = ReadLine.readLine(readBuffer)) != null) {
try {
LogMessage msg = LogMessage.parseNativeFormat(s);
dispatcher.handle(msg);
} catch (InvalidLogFormatException e) {
log.log(LogLevel.DEBUG, "Invalid log message", e);
}
}
}
use of com.yahoo.log.InvalidLogFormatException 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);
}
Aggregations