Search in sources :

Example 1 with PartitionProfile

use of org.apache.hyracks.control.common.job.profiling.om.PartitionProfile in project asterixdb by apache.

the class ProfilingPartitionWriterFactory method createFrameWriter.

@Override
public IFrameWriter createFrameWriter(final int receiverIndex) throws HyracksDataException {
    final IFrameWriter writer = new ConnectorSenderProfilingFrameWriter(ctx, delegate.createFrameWriter(receiverIndex), cd.getConnectorId(), senderIndex, receiverIndex);
    return new IFrameWriter() {

        private long openTime;

        private long closeTime;

        MultiResolutionEventProfiler mrep = new MultiResolutionEventProfiler(N_SAMPLES);

        @Override
        public void open() throws HyracksDataException {
            openTime = System.currentTimeMillis();
            writer.open();
        }

        @Override
        public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
            mrep.reportEvent();
            writer.nextFrame(buffer);
        }

        @Override
        public void fail() throws HyracksDataException {
            writer.fail();
        }

        @Override
        public void close() throws HyracksDataException {
            closeTime = System.currentTimeMillis();
            try {
                ((Task) ctx).setPartitionSendProfile(new PartitionProfile(new PartitionId(ctx.getJobletContext().getJobId(), cd.getConnectorId(), senderIndex, receiverIndex), openTime, closeTime, mrep));
            } finally {
                writer.close();
            }
        }

        @Override
        public void flush() throws HyracksDataException {
            writer.flush();
        }
    };
}
Also used : MultiResolutionEventProfiler(org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler) IFrameWriter(org.apache.hyracks.api.comm.IFrameWriter) Task(org.apache.hyracks.control.nc.Task) PartitionProfile(org.apache.hyracks.control.common.job.profiling.om.PartitionProfile) PartitionId(org.apache.hyracks.api.partitions.PartitionId) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)1 PartitionId (org.apache.hyracks.api.partitions.PartitionId)1 MultiResolutionEventProfiler (org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler)1 PartitionProfile (org.apache.hyracks.control.common.job.profiling.om.PartitionProfile)1 Task (org.apache.hyracks.control.nc.Task)1