Class OffsetConsolidationShardedIT

All Implemented Interfaces:
Testing

public class OffsetConsolidationShardedIT extends AbstractShardedMongoConnectorIT
  • Field Details

    • TOPIC_PREFIX

      public static final String TOPIC_PREFIX
      See Also:
    • EVENT_COMPARATOR

      private static final Comparator<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> EVENT_COMPARATOR
      Compares change event by cluster time
    • config

      public Configuration config
    • connectorConfig

      private io.debezium.connector.mongodb.MongoDbConnectorConfig connectorConfig
    • allRouterEvents

      private final SortedSet<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> allRouterEvents
      Contains all events consumed from router (always at least 4)
    • shardEvents0

      private final List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> shardEvents0
      Guaranteed to contain all consumed from shard0 (always at least 2)
    • shardEvents1

      private final List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> shardEvents1
      Guaranteed to contain all consumed from shard1 (always at least 2)
  • Constructor Details

    • OffsetConsolidationShardedIT

      public OffsetConsolidationShardedIT()
  • Method Details

    • setupDatabase

      public void setupDatabase()
    • insertInitialDocuments

      public void insertInitialDocuments(io.debezium.connector.mongodb.ChangeStreamPipeline pipeline)
    • storeReplicaSetModeOffsets

      private void storeReplicaSetModeOffsets(List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> shard0, List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> shard1) throws InterruptedException
      Throws:
      InterruptedException
    • storeShardedModeOffsets

      private void storeShardedModeOffsets(List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> events) throws InterruptedException
      Throws:
      InterruptedException
    • prepareReplicaSetOffset

      private Map<Map<String,?>,Map<String,?>> prepareReplicaSetOffset(String rsName, List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> events)
    • nextToLastElement

      public static <T> T nextToLastElement(List<T> collection)
    • getOffsetEvent

      public com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument> getOffsetEvent(List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> shard0, List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> shard1)
      Gets the older out of the two next-to-last events consumed by shard specific change streams.
      Returns:
      offset event
    • getOffsetEvent

      public com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument> getOffsetEvent(List<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> events)
      Gets next-to-last event consumed by router change streams.
      Returns:
      offset event
    • getExpectedIds

      public Set<String> getExpectedIds(com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument> offsetEvent)
    • getExpectedIds

      public Set<String> getExpectedIds(Collection<com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.BsonDocument>> events)
    • shouldConsolidateOffsetsFromRsMode

      public void shouldConsolidateOffsetsFromRsMode() throws InterruptedException
      Throws:
      InterruptedException
    • shouldUseOffsetsFromShardedMode

      public void shouldUseOffsetsFromShardedMode() throws InterruptedException
      Throws:
      InterruptedException
    • shouldFailToConsolidateOffsetsFromRsModeWhenInvalidationIsNotAllowed

      public void shouldFailToConsolidateOffsetsFromRsModeWhenInvalidationIsNotAllowed() throws InterruptedException
      Throws:
      InterruptedException
    • shouldFailToConsolidateOffsetsFromRsModeWhenOneShardOffsetIsMissing

      public void shouldFailToConsolidateOffsetsFromRsModeWhenOneShardOffsetIsMissing() throws InterruptedException
      Throws:
      InterruptedException