shunping commented on code in PR #36242:
URL: https://github.com/apache/beam/pull/36242#discussion_r2373056923
##########
sdks/go/pkg/beam/runners/prism/internal/engine/elementmanager.go:
##########
@@ -504,6 +504,40 @@ func (em *ElementManager) Bundles(ctx context.Context,
upstreamCancelFn context.
return runStageCh
}
+// DumpStages puts all the stage information into a string and returns it.
+func (em *ElementManager) DumpStages() string {
+ var stageState []string
+ ids := maps.Keys(em.stages)
+ if em.testStreamHandler != nil {
+ stageState = append(stageState, fmt.Sprintf("TestStreamHandler:
completed %v, curIndex %v of %v events: %+v, processingTime %v, %v, ptEvents %v
\n",
+ em.testStreamHandler.completed,
em.testStreamHandler.nextEventIndex, len(em.testStreamHandler.events),
em.testStreamHandler.events, em.testStreamHandler.processingTime,
mtime.FromTime(em.testStreamHandler.processingTime), em.processTimeEvents))
+ } else {
+ stageState = append(stageState, fmt.Sprintf("ElementManager
Now: %v processingTimeEvents: %v injectedBundles: %v\n",
em.ProcessingTimeNow(), em.processTimeEvents.events, em.injectedBundles))
+ }
+ sort.Strings(ids)
+ for _, id := range ids {
+ ss := em.stages[id]
+ inW := ss.InputWatermark()
+ outW := ss.OutputWatermark()
+ upPCol, upW := ss.UpstreamWatermark()
+ upS := em.pcolParents[upPCol]
+ if upS == "" {
+ upS = "IMPULSE " // (extra spaces to allow print to
align better.)
+ }
+ stageState = append(stageState, fmt.Sprintln(id, "watermark
in", inW, "out", outW, "upstream", upW, "from", upS, "pending", ss.pending,
"byKey", ss.pendingByKeys, "inprogressKeys", ss.inprogressKeys, "byBundle",
ss.inprogressKeysByBundle, "holds", ss.watermarkHolds.heap, "holdCounts",
ss.watermarkHolds.counts, "holdsInBundle", ss.inprogressHoldsByBundle,
"pttEvents", ss.processingTimeTimers.toFire, "bundlesToInject",
ss.bundlesToInject))
+
+ var outputConsumers, sideConsumers []string
+ for _, col := range ss.outputIDs {
+ outputConsumers = append(outputConsumers,
em.consumers[col]...)
+ for _, l := range em.sideConsumers[col] {
+ sideConsumers = append(sideConsumers, l.Global)
+ }
+ }
+ stageState = append(stageState, fmt.Sprintf("\tsideInputs: %v
outputCols: %v outputConsumers: %v sideConsumers: %v\n", ss.sides,
ss.outputIDs, outputConsumers, sideConsumers))
+ }
+ return strings.Join(stageState, "")
+}
Review Comment:
Ack. This function is only called once at the end of a pipeline (successful
or failed) and the number of stages will not be too many to cause an efficiency
difference with `strings.Builder`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]