Package com.mongodb.kafka.connect.util
Class ResumeTokenUtils
java.lang.Object
com.mongodb.kafka.connect.util.ResumeTokenUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic OptionalLong
getResponseOffsetSecs
(org.bson.BsonDocument response) static org.bson.BsonTimestamp
getTimestampFromResumeToken
(org.bson.BsonDocument resumeToken) The resume token has the following structure: It is a document with a single field named "_data" with a string value The string is hex-encoded The first byte is the "canonical type" for a BSON timestamp, encoded as an unsigned byte.static byte[]
-
Method Details
-
getTimestampFromResumeToken
public static org.bson.BsonTimestamp getTimestampFromResumeToken(org.bson.BsonDocument resumeToken) The resume token has the following structure:- It is a document with a single field named "_data" with a string value
- The string is hex-encoded
- The first byte is the "canonical type" for a BSON timestamp, encoded as an unsigned byte. It should always equal 130.
- The next 8 bytes are the BSON timestamp representing the operation time, encoded as an
unsigned long value with big endian byte order (unlike BSON itself, which is little
endian). The
BsonTimestamp
class contains the logic for pulling out the seconds since the epoch from that value. See http://bsonspec.org for details. - There are more fields encoded in the resume token, but we don't need to decode them as operation time is always first
- Parameters:
resumeToken
- a BSonDocument containing the resume token- Returns:
- the operation time contained within the resume token
-
parseHex
-
getResponseOffsetSecs
- Parameters:
response
- The response from theCommandListener
.- Returns:
- The offset in seconds. The response operationTime, minus the postBatchResumeToken.
-