/** * Checks if the string is all digits or one of the SentinelCheckpoint values. * * @param string * @return true if and only if the string is all digits or one of the SentinelCheckpoint values */ private static boolean isDigitsOrSentinelValue(String string) { return SequenceNumberValidator.isDigits(string) || isSentinelValue(string); }
/** * Sequence numbers are converted, sentinels are given a value of -1. Note this method is only used after special * logic associated with SHARD_END and the case of comparing two sentinel values has already passed, so we map * sentinel values LATEST and TRIM_HORIZON to negative numbers so that they are considered less than sequence * numbers. * * @param checkpointValue string to convert to big integer value * @return a BigInteger value representation of the checkpointValue */ private static BigInteger bigIntegerValue(String checkpointValue) { if (SequenceNumberValidator.isDigits(checkpointValue)) { return new BigInteger(checkpointValue); } else if (SentinelCheckpoint.LATEST.toString().equals(checkpointValue)) { return LATEST_BIG_INTEGER_VALUE; } else if (SentinelCheckpoint.TRIM_HORIZON.toString().equals(checkpointValue)) { return TRIM_HORIZON_BIG_INTEGER_VALUE; } else { throw new IllegalArgumentException("Expected a string of digits, TRIM_HORIZON, or LATEST but received " + checkpointValue); } }
boolean atShardEnd = ExtendedSequenceNumber.SHARD_END.getSequenceNumber().equals(sequenceNumber); if (!atShardEnd && !isDigits(sequenceNumber)) { LOG.info("Sequence number must be numeric, but was " + sequenceNumber); throw new IllegalArgumentException("Sequence number must be numeric, but was " + sequenceNumber);