use of org.platformlayer.jobs.model.JobLog in project platformlayer by platformlayer.
the class JobLogStoreBase method deserialize.
protected JobLog deserialize(InputSupplier<? extends InputStream> iss, int logSkip) throws IOException {
ArrayList<JobLogLine> lines = Lists.newArrayList();
InputStream is = null;
CodedInputStream in = null;
try {
is = iss.getInput();
is = new GZIPInputStream(is);
in = CodedInputStream.newInstance(is);
int i = 0;
JobDataProtobuf.JobLogLine.Builder protobuf = JobDataProtobuf.JobLogLine.newBuilder();
while (!in.isAtEnd()) {
int length = in.readRawVarint32();
if (i < logSkip) {
in.skipRawBytes(length);
} else {
int oldLimit = in.pushLimit(length);
protobuf.clear();
protobuf.mergeFrom(in);
JobLogLine line = new JobLogLine();
line.level = protobuf.getLevel();
line.timestamp = protobuf.getTimestamp();
line.message = protobuf.getMessage();
line.type = protobuf.getType();
if (protobuf.hasException()) {
line.exception = mapFromProtobuf(protobuf.getExceptionBuilder());
}
lines.add(line);
in.popLimit(oldLimit);
}
i++;
}
} finally {
// Closeables.closeQuietly(in);
Closeables.closeQuietly(is);
}
JobLog jobLog = new JobLog();
jobLog.lines = lines;
return jobLog;
}
Aggregations