use of org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting in project beam by apache.
the class SimpleExecutionState method getLullMessage.
@VisibleForTesting
public String getLullMessage(Thread trackedThread, Duration millis) {
// TODO(ajamato): Share getLullMessage code with DataflowExecutionState.
String userStepName = this.labelsMetadata.getOrDefault(MonitoringInfoConstants.Labels.PTRANSFORM, null);
StringBuilder message = new StringBuilder();
message.append("Operation ongoing");
if (userStepName != null) {
message.append(" in step ").append(userStepName);
}
message.append(" for at least ").append(formatDuration(millis)).append(" without outputting or completing in state ").append(getStateName());
message.append("\n");
StackTraceElement[] fullTrace = trackedThread.getStackTrace();
for (StackTraceElement e : fullTrace) {
message.append(" at ").append(e).append("\n");
}
return message.toString();
}
use of org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting in project beam by apache.
the class MemoryMonitor method tryUploadHeapDumpIfItExists.
@VisibleForTesting
boolean tryUploadHeapDumpIfItExists() {
if (uploadToGCSPath == null) {
return false;
}
boolean uploadedHeapDump = false;
File localSource = getDefaultHeapDumpPath();
LOG.info("Looking for heap dump at {}", localSource);
if (localSource.exists()) {
LOG.warn("Heap dump {} detected, attempting to upload to GCS", localSource);
String remoteDest = String.format("%s/heap_dump%s.hprof", uploadToGCSPath, UUID.randomUUID().toString());
ResourceId resource = FileSystems.matchNewResource(remoteDest, false);
try {
uploadFileToGCS(localSource, resource);
uploadedHeapDump = true;
LOG.warn("Heap dump {} uploaded to {}", localSource, remoteDest);
} catch (IOException e) {
LOG.error("Error uploading heap dump to {}", remoteDest, e);
}
try {
Files.delete(localSource.toPath());
LOG.info("Deleted local heap dump {}", localSource);
} catch (IOException e) {
LOG.warn("Unable to delete local heap dump {}", localSource, e);
}
}
return uploadedHeapDump;
}
use of org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting in project beam by apache.
the class LengthPrefixUnknownCoders method forInstructionOutput.
/**
* Wrap unknown coders with a {@link LengthPrefixCoder} for the given {@link InstructionOutput}.
*/
@VisibleForTesting
static InstructionOutput forInstructionOutput(InstructionOutput input, boolean replaceWithByteArrayCoder) throws Exception {
InstructionOutput cloudOutput = clone(input, InstructionOutput.class);
cloudOutput.setCodec(forCodec(cloudOutput.getCodec(), replaceWithByteArrayCoder));
return cloudOutput;
}
use of org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting in project beam by apache.
the class BeamIOPushDownRule method findUtilizedInputRefs.
/**
* Given a {@code RexNode}, find all {@code RexInputRef}s a node or it's children nodes use.
*
* @param inputRowType {@code RelDataType} used for looking up names of {@code RexInputRef}.
* @param startNode A node to start at.
* @param usedFields Names of {@code RexInputRef}s are added to this list.
*/
@VisibleForTesting
void findUtilizedInputRefs(RelDataType inputRowType, RexNode startNode, Set<String> usedFields) {
Queue<RexNode> prerequisites = new ArrayDeque<>();
prerequisites.add(startNode);
// Assuming there are no cyclic nodes, traverse dependency tree until all RexInputRefs are found
while (!prerequisites.isEmpty()) {
RexNode node = prerequisites.poll();
if (node instanceof RexCall) {
// Composite expression, example: "=($t11, $t12)"
RexCall compositeNode = (RexCall) node;
// Expression from example above contains 2 operands: $t11, $t12
prerequisites.addAll(compositeNode.getOperands());
} else if (node instanceof RexInputRef) {
// Input reference
// Find a field in an inputRowType for the input reference
int inputFieldIndex = ((RexInputRef) node).getIndex();
RelDataTypeField field = inputRowType.getFieldList().get(inputFieldIndex);
// If we have not seen it before - add it to the list (hash set)
usedFields.add(field.getName());
} else if (node instanceof RexLiteral) {
// Does not contain information about columns utilized by a Calc
} else {
throw new UnsupportedOperationException("Unexpected RexNode encountered: " + node.getClass().getSimpleName());
}
}
}
use of org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting in project beam by apache.
the class BeamFnStatusClient method getActiveProcessBundleState.
@VisibleForTesting
String getActiveProcessBundleState() {
StringJoiner activeBundlesState = new StringJoiner("\n");
activeBundlesState.add("========== ACTIVE PROCESSING BUNDLES ==========");
if (processBundleCache.getActiveBundleProcessors().isEmpty()) {
activeBundlesState.add("No active processing bundles.");
} else {
List<BundleState> bundleStates = new ArrayList<>();
processBundleCache.getActiveBundleProcessors().keySet().stream().forEach(instruction -> {
BundleProcessor bundleProcessor = processBundleCache.find(instruction);
if (bundleProcessor != null) {
ExecutionStateTracker executionStateTracker = bundleProcessor.getStateTracker();
Thread trackedTread = executionStateTracker.getTrackedThread();
if (trackedTread != null) {
bundleStates.add(new BundleState(instruction, trackedTread.getName(), executionStateTracker.getMillisSinceLastTransition()));
}
}
});
bundleStates.stream().sorted(Comparator.comparing(BundleState::getTimeSinceTransition).reversed()).limit(// only keep top 10
10).forEachOrdered(bundleState -> {
activeBundlesState.add(String.format("---- Instruction %s ----", bundleState.getInstruction()));
activeBundlesState.add(String.format("Tracked thread: %s", bundleState.getTrackedThreadName()));
activeBundlesState.add(String.format("Time since transition: %.2f seconds%n", bundleState.getTimeSinceTransition() / 1000.0));
});
}
return activeBundlesState.toString();
}
Aggregations