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;
}
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();
}
};
}
Aggregations