Class PTransformFunctionRegistry


  • public class PTransformFunctionRegistry
    extends java.lang.Object
    A class to register and retrieve functions for bundle processing (i.e. the start, or finish function). The purpose of this class is to wrap these functions with instrumentation for metrics and other telemetry collection.

    Usage:

     // Instantiate and use the registry for each class of functions. i.e. start. finish.
     PTransformFunctionRegistry startFunctionRegistry;
     PTransformFunctionRegistry finishFunctionRegistry;
     startFunctionRegistry.register(myStartThrowingRunnable);
     finishFunctionRegistry.register(myFinishThrowingRunnable);
    
     // Then invoke the functions by iterating over them, in your desired order: i.e.
     for (ThrowingRunnable startFunction : startFunctionRegistry.getFunctions()) {
       startFunction.run();
     }
    
     for (ThrowingRunnable finishFunction : Lists.reverse(finishFunctionRegistry.getFunctions())) {
       finishFunction.run();
     }
     // Note: this is used in ProcessBundleHandler.
     
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<org.apache.beam.sdk.function.ThrowingRunnable> getFunctions()  
      void register​(java.lang.String pTransformId, java.lang.String pTransformUniqueName, org.apache.beam.sdk.function.ThrowingRunnable runnable)
      Register the runnable to process the specific pTransformId and track its execution time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PTransformFunctionRegistry

        public PTransformFunctionRegistry​(org.apache.beam.runners.core.metrics.ShortIdMap shortIds,
                                          ExecutionStateSampler.ExecutionStateTracker stateTracker,
                                          java.lang.String executionStateUrn)
        Construct the registry to run for either start or finish bundle functions.
        Parameters:
        shortIds - - Provides short ids for MetricsApi.MonitoringInfo.
        stateTracker - - The tracker to enter states in order to calculate execution time metrics.
        executionStateUrn - - The URN for the execution state .
    • Method Detail

      • register

        public void register​(java.lang.String pTransformId,
                             java.lang.String pTransformUniqueName,
                             org.apache.beam.sdk.function.ThrowingRunnable runnable)
        Register the runnable to process the specific pTransformId and track its execution time.
        Parameters:
        pTransformId -
        pTransformUniqueName -
        runnable -
      • getFunctions

        public java.util.List<org.apache.beam.sdk.function.ThrowingRunnable> getFunctions()
        Returns:
        A list of wrapper functions which will invoke the registered functions indirectly. The order of registry is maintained.