for (final MinorFragmentProfile minor : minors) { final List<OperatorProfile> ops = new ArrayList<>(minor.getOperatorProfileList()); Collections.sort(ops, Comparators.operatorId); for (final OperatorProfile op : ops) { opmap.put(ip, l); opmap.get(ip).add(new ImmutablePair<>(op, minor.getMinorFragmentId()));
private void fragmentDone(final FragmentStatus status) { final boolean stateChanged = updateFragmentStatus(status); if (stateChanged) { // since we're in the fragment done clause and this was a change from previous final NodeTracker node = nodeMap.get(status.getProfile().getEndpoint()); node.fragmentComplete(); finishedFragments.incrementAndGet(); } }
tb.appendMillis(firstStart.getStartTime() - start); // First Start tb.appendMillis(lastStart.getStartTime() - start); // Last Start tb.appendMillis(firstEnd.getEndTime() - start); // First End tb.appendMillis(lastEnd.getEndTime() - start); // Last End tb.appendTime(lastUpdate.getLastUpdate(), null); // Last Update tb.appendTime(lastProgress.getLastProgress(), null); // Last Progress tb.appendBytes(maxMem.getMaxMemoryUsed(), null); // Max Peak Memory
if (minorFragmentProfile.getOperatorProfileList() == null) { continue; for (OperatorProfile operatorProfile : minorFragmentProfile.getOperatorProfileList()) { totalTimeInMillis += toMillis(operatorProfile.getProcessNanos() + operatorProfile.getWaitNanos() + operatorProfile.getSetupNanos()); final CoreOperatorType operatorType = CoreOperatorType.valueOf(operatorProfile.getOperatorType());
public Builder mergeFrom(com.dremio.exec.proto.UserBitShared.MinorFragmentProfile other) { if (other == com.dremio.exec.proto.UserBitShared.MinorFragmentProfile.getDefaultInstance()) return this; if (other.hasState()) { setState(other.getState()); if (other.hasError()) { mergeError(other.getError()); if (other.hasMinorFragmentId()) { setMinorFragmentId(other.getMinorFragmentId()); if (other.hasStartTime()) { setStartTime(other.getStartTime()); if (other.hasEndTime()) { setEndTime(other.getEndTime()); if (other.hasMemoryUsed()) { setMemoryUsed(other.getMemoryUsed()); if (other.hasMaxMemoryUsed()) { setMaxMemoryUsed(other.getMaxMemoryUsed()); if (other.hasEndpoint()) { mergeEndpoint(other.getEndpoint()); if (other.hasLastUpdate()) { setLastUpdate(other.getLastUpdate()); if (other.hasLastProgress()) {
withBlockedSplits = complete.get(0).getPerResourceBlockedDurationCount() > 0; final ArrayList<OperatorProfile> ops = new ArrayList<>(minor.getOperatorProfileList()); final long wallClockTime = minor.getEndTime() - minor.getStartTime(); final long waitDuration = minor.getSleepingDuration(); final long blockedDuration = minor.getBlockedDuration(); builder.appendCell(new OperatorPathBuilder().setMajor(major).setMinor(minor).build(), null); // Thread ID builder.appendCell(minor.getEndpoint().getAddress(), null); // Host name builder.appendMillis(minor.getStartTime() - start); // Start builder.appendMillis(minor.getEndTime() - start); // End final long runtime = minor.hasRunDuration() ? minor.getRunDuration() : wallClockTime - waitDuration - blockedDuration; if (minor.hasFirstRun()) { builder.appendMillis(minor.getFirstRun() - minor.getStartTime()); // First-run builder.appendMillis(minor.getSetupDuration()); // Setup builder.appendMillis(minor.getRunDuration()); // Runtime builder.appendMillis(minor.getFinishDuration()); // Finish } else { builder.appendMillis(0); // First-run long blockedOnDownstreamDuration = minor.getBlockedOnDownstreamDuration(); long blockedOnUpstreamDuration = minor.getBlockedOnUpstreamDuration(); long blockedOnOtherDuration = 0; for (BlockedResourceDuration resourceDuration : minor.getPerResourceBlockedDurationList()) { switch (resourceDuration.getCategory()) { case UPSTREAM: List<OperatorProfile> operators = minor.getOperatorProfileList();
if(message.hasState()) output.writeEnum(1, message.getState().getNumber(), false); if(message.hasError()) output.writeObject(2, message.getError(), com.dremio.exec.proto.SchemaUserBitShared.DremioPBError.WRITE, false); if(message.hasMinorFragmentId()) output.writeInt32(3, message.getMinorFragmentId(), false); for(com.dremio.exec.proto.UserBitShared.OperatorProfile operatorProfile : message.getOperatorProfileList()) output.writeObject(4, operatorProfile, com.dremio.exec.proto.SchemaUserBitShared.OperatorProfile.WRITE, true); if(message.hasStartTime()) output.writeInt64(5, message.getStartTime(), false); if(message.hasEndTime()) output.writeInt64(6, message.getEndTime(), false); if(message.hasMemoryUsed()) output.writeInt64(7, message.getMemoryUsed(), false); if(message.hasMaxMemoryUsed()) output.writeInt64(8, message.getMaxMemoryUsed(), false); if(message.hasEndpoint()) output.writeObject(9, message.getEndpoint(), com.dremio.exec.proto.SchemaCoordinationProtos.NodeEndpoint.WRITE, false); if(message.hasLastUpdate()) output.writeInt64(10, message.getLastUpdate(), false); if(message.hasLastProgress()) output.writeInt64(11, message.getLastProgress(), false); if(message.hasSleepingDuration()) output.writeInt64(1001, message.getSleepingDuration(), false); if(message.hasBlockedDuration()) output.writeInt64(1002, message.getBlockedDuration(), false);
QueryProfile profile = grabber.getProfile(); Optional<OperatorProfile> scanProfile = FluentIterable.from(profile.getFragmentProfile(0).getMinorFragmentProfile(0).getOperatorProfileList()) .firstMatch(new Predicate<OperatorProfile>() { @Override
@Override public void statusUpdate(final FragmentStatus status) { logger.debug("New fragment status was provided to QueryManager of {}", status); switch(status.getProfile().getState()) { case AWAITING_ALLOCATION: case RUNNING: case CANCELLATION_REQUESTED: updateFragmentStatus(status); break; case FAILED: logger.info("Fragment {} failed, cancelling remaining fragments.", QueryIdHelper.getQueryIdentifier(status.getHandle())); completionListener.failed(UserRemoteException.create(status.getProfile().getError())); fragmentDone(status); break; case FINISHED: FragmentHandle fragmentHandle = status.getHandle(); if (fragmentHandle.getMajorFragmentId() == 0) { cancelExecutingFragments(); } fragmentDone(status); break; case CANCELLED: fragmentDone(status); break; default: throw new UnsupportedOperationException(String.format("Received status of %s", status)); } } };
@Override public FragmentInfo apply(final FragmentExecutor fragmentExecutor) { final FragmentStatus status = fragmentExecutor.getStatus(); final ExecProtos.FragmentHandle handle = fragmentExecutor.getHandle(); final MinorFragmentProfile profile = status == null ? null : status.getProfile(); Long memoryUsed = profile == null ? 0 : profile.getMemoryUsed(); Long rowsProcessed = profile == null ? 0 : getRowsProcessed(profile); Timestamp startTime = profile == null ? new Timestamp(0) : new Timestamp(profile.getStartTime()); return new FragmentInfo(dbContext.get().getEndpoint().getAddress(), QueryIdHelper.getQueryId(handle.getQueryId()), handle.getMajorFragmentId(), handle.getMinorFragmentId(), memoryUsed, rowsProcessed, startTime, fragmentExecutor.getBlockingStatus(), fragmentExecutor.getTaskDescriptor()); }
private boolean updateFragmentStatus(final FragmentStatus fragmentStatus) { final FragmentHandle fragmentHandle = fragmentStatus.getHandle(); final FragmentData data = fragmentDataMap.get(fragmentHandle); final FragmentState oldState = data.getState(); final boolean inTerminalState = isTerminal(oldState); final FragmentState currentState = fragmentStatus.getProfile().getState(); if (inTerminalState || (oldState == FragmentState.CANCELLATION_REQUESTED && !isTerminal(currentState))) { // Already in a terminal state, or invalid state transition from CANCELLATION_REQUESTED. This shouldn't happen. logger.warn(String.format("Received status message for fragment %s after fragment was in state %s. New state was %s", QueryIdHelper.getQueryIdentifier(fragmentHandle), oldState, currentState)); return false; } data.setStatus(fragmentStatus); return oldState != currentState; }
private boolean madeProgress(final FragmentStatus prev, final FragmentStatus cur) { final MinorFragmentProfile previous = prev.getProfile(); final MinorFragmentProfile current = cur.getProfile(); if (previous.getState() != current.getState()) { return true; } if (previous.getOperatorProfileCount() != current.getOperatorProfileCount()) { return true; } for(int i =0; i < current.getOperatorProfileCount(); i++){ if (madeProgress(previous.getOperatorProfile(i), current.getOperatorProfile(i))) { return true; } } return false; }
public FragmentState getState() { return status.getProfile().getState(); }
public int compare(final MinorFragmentProfile o1, final MinorFragmentProfile o2) { return Long.compare(o1.getEndTime(), o2.getEndTime()); } };
public int compare(final MinorFragmentProfile o1, final MinorFragmentProfile o2) { return Long.compare(o1.getStartTime(), o2.getStartTime()); } };
private long getRowsProcessed(MinorFragmentProfile profile) { long maxRecords = 0; for (OperatorProfile operatorProfile : profile.getOperatorProfileList()) { long records = 0; for (StreamProfile inputProfile :operatorProfile.getInputProfileList()) { if (inputProfile.hasRecords()) { records += inputProfile.getRecords(); } } maxRecords = Math.max(maxRecords, records); } return maxRecords; }
public int compare(final MinorFragmentProfile o1, final MinorFragmentProfile o2) { return Long.compare(o1.getEndTime() - o1.getStartTime(), o2.getEndTime() - o2.getStartTime()); } };
@Override public void fragmentStatusUpdate(FragmentStatus status) throws RpcException { ExternalId id = ExternalIdHelper.toExternal(status.getHandle().getQueryId()); ManagedForeman managed = externalIdToForeman.get(id); if (managed == null) { // TODO(DX-7242): this is a little chatty since a failed query will often log a bunch of fragments // We need a better mechanism to debug this. logger.info("A fragment status message arrived post query termination, dropping. Fragment [{}] reported a state of {}.", QueryIdHelper.getFragmentId(status.getHandle()), status.getProfile().getState()); } else { managed.foreman.updateStatus(status); } }
@Override public long getValue(MinorFragmentProfile p) { return p.getBlockedDuration(); } };
@Override public long getValue(MinorFragmentProfile p) { return p.hasFirstRun() ? (p.getFirstRun() - p.getStartTime()) : 0; } };