Class MigrationOpTracker


  • public class MigrationOpTracker
    extends java.lang.Object
    Used to track information related to a migration operation.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  MigrationOpTracker.Checker
      Interface for specifying the callback function for the consistency check.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void consistency​(MigrationOpTracker.Checker checker)
      Check the consistency of a read result.
      void error​(MigrationOrigin origin)
      Report that an error has occurred for the specified origin.
      void invoked​(MigrationOrigin origin)
      Call this to report that an origin was invoked (executed).
      void latency​(MigrationOrigin origin, java.time.Duration duration)
      Report the latency of an operation.
      void op​(MigrationOp op)
      Sets the migration related operation associated with these tracking measurements.
      • Methods inherited from class java.lang.Object

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

      • op

        public void op​(@NotNull
                       MigrationOp op)
        Sets the migration related operation associated with these tracking measurements.
        Parameters:
        op - the operation being tracked
      • error

        public void error​(@NotNull
                          MigrationOrigin origin)
        Report that an error has occurred for the specified origin.
        Parameters:
        origin - the origin of the error
      • consistency

        public void consistency​(@NotNull
                                MigrationOpTracker.Checker checker)
        Check the consistency of a read result. This method should be invoked if the `check` function is defined for the migration and both reads ("new"/"old") were done.

        The function will use the checkRatio to determine if the check should be executed, and it will record the result.

        If the consistency check function throws an exception, then no measurement for consistency will be included in the generated migration op event.

        Example calling the check function from the migration config.

         if (checker != null &&
           oldResult.success &&
           newResult.success
         ) {
           // Temporary variables for the lambda invocation.
           MigrationResult@lt;TReadResult@gt; finalNewResult = newResult;
           MigrationResult@lt;TReadResult@gt; finalOldResult = oldResult;
        
           tracker.consistency(() -> checker.check(finalOldResult.result,
           finalNewResult.result));
         }
         
        Parameters:
        checker - The function which executes the check. This is not the `check` function from the migration options, but instead should be a parameter-less function that calls that function.
      • latency

        public void latency​(@NotNull
                            MigrationOrigin origin,
                            @NotNull
                            java.time.Duration duration)
        Report the latency of an operation.
        Parameters:
        origin - the origin the latency is being reported for
        duration - the latency of the operation
      • invoked

        public void invoked​(@NotNull
                            MigrationOrigin origin)
        Call this to report that an origin was invoked (executed). There are some situations where the expectation is that both the old and new implementation will be used, but with writes it is possible that the non-authoritative will not execute. Reporting the execution allows for more accurate analytics.
        Parameters:
        origin - the origin that was invoked