Search in sources :

Example 6 with JobLog

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;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) JobLogLine(org.platformlayer.jobs.model.JobLogLine) GZIPInputStream(java.util.zip.GZIPInputStream) CodedInputStream(com.google.protobuf.CodedInputStream) InputStream(java.io.InputStream) CodedInputStream(com.google.protobuf.CodedInputStream) JobLog(org.platformlayer.jobs.model.JobLog)

Aggregations

JobLog (org.platformlayer.jobs.model.JobLog)6 JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)3 PlatformLayerClient (org.platformlayer.PlatformLayerClient)2 JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)2 JobLogLine (org.platformlayer.jobs.model.JobLogLine)2 CodedInputStream (com.google.protobuf.CodedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 PlatformLayerClientNotFoundException (org.platformlayer.PlatformLayerClientNotFoundException)1 OpsException (org.platformlayer.ops.OpsException)1 ActiveJobExecution (org.platformlayer.ops.tasks.ActiveJobExecution)1