public static Map<Long, InProgressTx> txnBackwardsCompatCheck(int defaultLongTimeout, long longTimeoutTolerance,
                                                                Map<Long, InProgressTx> inProgress) {
    for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) {
      long writePointer = entry.getKey();
      long expiration = entry.getValue().getExpiration();
      // LONG transactions will either have a negative expiration or expiration set to the long timeout
      // use a fudge factor on the expiration check, since expiraton is set based on system time, not the write pointer
      if (entry.getValue().getType() == null &&
          (expiration < 0 ||
              (getTxExpirationFromWritePointer(writePointer, defaultLongTimeout) - expiration
                  < longTimeoutTolerance))) {
        // handle null expiration
        long newExpiration = getTxExpirationFromWritePointer(writePointer, defaultLongTimeout);
        InProgressTx compatTx =
          new InProgressTx(entry.getValue().getVisibilityUpperBound(), newExpiration, TransactionType.LONG,
              entry.getValue().getCheckpointWritePointers());
        entry.setValue(compatTx);
      } else if (entry.getValue().getType() == null) {
        InProgressTx compatTx =
          new InProgressTx(entry.getValue().getVisibilityUpperBound(), entry.getValue().getExpiration(),
                           TransactionType.SHORT, entry.getValue().getCheckpointWritePointers());
        entry.setValue(compatTx);
      }
    }
    return inProgress;
  }
public static Map < Long , InProgressTx > txnBackwardsCompatCheck ( int defaultLongTimeout , long longTimeoutTolerance , Map < Long , InProgressTx > inProgress ) { for ( Map . Entry < Long , InProgressTx > entry : inProgress . entrySet ( ) ) { long writePointer = entry . getKey ( ) ; long expiration = entry . getValue ( ) . getExpiration ( ) ; if ( entry . getValue ( ) . getType ( ) == null && ( expiration < 0 || ( getTxExpirationFromWritePointer ( writePointer , defaultLongTimeout ) - expiration < longTimeoutTolerance ) ) ) { long newExpiration = getTxExpirationFromWritePointer ( writePointer , defaultLongTimeout ) ; InProgressTx compatTx = new InProgressTx ( entry . getValue ( ) . getVisibilityUpperBound ( ) , newExpiration , TransactionType . LONG , entry . getValue ( ) . getCheckpointWritePointers ( ) ) ; entry . setValue ( compatTx ) ; } else if ( entry . getValue ( ) . getType ( ) == null ) { InProgressTx compatTx = new InProgressTx ( entry . getValue ( ) . getVisibilityUpperBound ( ) , entry . getValue ( ) . getExpiration ( ) , TransactionType . SHORT , entry . getValue ( ) . getCheckpointWritePointers ( ) ) ; entry . setValue ( compatTx ) ; } } return inProgress ; }
Check if in-progress transactions need to be migrated to have expiration time and type, if so do the migration.
This is required for backwards compatibility, when long running transactions were represented
with expiration time -1. This can be removed when we stop supporting SnapshotCodec version 1.