Search in sources :

Example 1 with MultiResolutionEventProfiler

use of org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler in project asterixdb by apache.

the class TaskProfile method toJSON.

@Override
public ObjectNode toJSON() {
    ObjectMapper om = new ObjectMapper();
    ObjectNode json = om.createObjectNode();
    json.put("activity-id", taskAttemptId.getTaskId().getActivityId().toString());
    json.put("partition", taskAttemptId.getTaskId().getPartition());
    json.put("attempt", taskAttemptId.getAttempt());
    if (partitionSendProfile != null) {
        ArrayNode pspArray = om.createArrayNode();
        for (PartitionProfile pp : partitionSendProfile.values()) {
            ObjectNode ppObj = om.createObjectNode();
            PartitionId pid = pp.getPartitionId();
            ObjectNode pidObj = om.createObjectNode();
            pidObj.put("job-id", pid.getJobId().toString());
            pidObj.put("connector-id", pid.getConnectorDescriptorId().toString());
            pidObj.put("sender-index", pid.getSenderIndex());
            pidObj.put("receiver-index", pid.getReceiverIndex());
            ppObj.set("partition-id", pidObj);
            ppObj.put("open-time", pp.getOpenTime());
            ppObj.put("close-time", pp.getCloseTime());
            MultiResolutionEventProfiler samples = pp.getSamples();
            ppObj.put("offset", samples.getOffset());
            int resolution = samples.getResolution();
            int sampleCount = samples.getCount();
            ArrayNode ftA = om.createArrayNode();
            int[] ft = samples.getSamples();
            for (int i = 0; i < sampleCount; ++i) {
                ftA.add(ft[i]);
            }
            ppObj.set("frame-times", ftA);
            ppObj.put("resolution", resolution);
            pspArray.add(ppObj);
        }
        json.set("partition-send-profile", pspArray);
    }
    populateCounters(json);
    return json;
}
Also used : MultiResolutionEventProfiler(org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) PartitionId(org.apache.hyracks.api.partitions.PartitionId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with MultiResolutionEventProfiler

use of org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler 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

PartitionId (org.apache.hyracks.api.partitions.PartitionId)2 MultiResolutionEventProfiler (org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ByteBuffer (java.nio.ByteBuffer)1 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)1 PartitionProfile (org.apache.hyracks.control.common.job.profiling.om.PartitionProfile)1 Task (org.apache.hyracks.control.nc.Task)1