Search in sources :

Example 6 with CycleResult

use of io.engineblock.activityapi.cyclelog.buffers.results.CycleResult in project engineblock by engineblock.

the class CycleLogDumperUtility method dumpData.

private void dumpData(String filename, DisplayType displayType) {
    File filepath = new File(filename);
    MappedByteBuffer mbb = null;
    if (!filepath.exists()) {
        if (!filepath.getPath().endsWith(".cyclelog")) {
            filepath = new File(filename + ".cyclelog");
            if (!filepath.exists()) {
                throw new RuntimeException("neither '" + filename + "' nor  '" + filename + ".cyclelog' exists!");
            }
        }
    }
    try {
        RandomAccessFile raf = new RandomAccessFile(filepath, "rw");
        mbb = raf.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, raf.length());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    int readsize = 100;
    if (mbb.remaining() > 0) {
        CycleResultsRLEBufferReadable readable = null;
        while (mbb.remaining() > 0) {
            readable = new CycleResultsRLEBufferReadable(readsize, mbb);
            for (CycleResultsSegment segment : readable) {
                switch(displayType) {
                    case cycles:
                        for (CycleResult cycleResult : segment) {
                            System.out.println(cycleResult);
                        }
                        break;
                    case spans:
                        System.out.println(segment.toString());
                        break;
                }
            }
        }
    }
}
Also used : CycleResultsRLEBufferReadable(io.engineblock.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferReadable) MappedByteBuffer(java.nio.MappedByteBuffer) RandomAccessFile(java.io.RandomAccessFile) CycleResultsSegment(io.engineblock.activityapi.cyclelog.buffers.results.CycleResultsSegment) CycleResult(io.engineblock.activityapi.cyclelog.buffers.results.CycleResult) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 7 with CycleResult

use of io.engineblock.activityapi.cyclelog.buffers.results.CycleResult in project engineblock by engineblock.

the class CycleLogOutput method onCycleResultSegment.

@Override
public void onCycleResultSegment(CycleResultsSegment segment) {
    for (CycleResult cycleResult : segment) {
        if (filter == null || filter.test(cycleResult)) {
            boolean buffered = targetBuffer.onCycleResult(cycleResult);
            if (!buffered) {
                flush();
                targetBuffer = new CycleResultsRLEBufferTarget(extentSizeInSpans);
                boolean bufferedAfterFlush = targetBuffer.onCycleResult(cycleResult);
                if (!bufferedAfterFlush) {
                    throw new RuntimeException("Failed to record result in new target buffer");
                }
            }
        }
    }
}
Also used : CycleResultsRLEBufferTarget(io.engineblock.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferTarget) CycleResult(io.engineblock.activityapi.cyclelog.buffers.results.CycleResult)

Aggregations

CycleResult (io.engineblock.activityapi.cyclelog.buffers.results.CycleResult)7 ArrayList (java.util.ArrayList)5 CycleResultsRLEBufferReadable (io.engineblock.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferReadable)4 CycleResultsRLEBufferTarget (io.engineblock.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferTarget)3 Test (org.testng.annotations.Test)3 CycleResultsSegment (io.engineblock.activityapi.cyclelog.buffers.results.CycleResultsSegment)2 ResultReadable (io.engineblock.activityapi.cyclelog.buffers.results.ResultReadable)1 SimpleCycleResult (io.engineblock.activityapi.cyclelog.outputs.SimpleCycleResult)1 File (java.io.File)1 RandomAccessFile (java.io.RandomAccessFile)1 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1