samza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] cameronlee314 commented on a change in pull request #918: SAMZA-2094: Implement the StartpointVisitor for the KafkaSystemConsumer.
Date Wed, 20 Feb 2019 01:03:47 GMT
cameronlee314 commented on a change in pull request #918: SAMZA-2094: Implement the StartpointVisitor
for the KafkaSystemConsumer.
URL: https://github.com/apache/samza/pull/918#discussion_r258286825
 
 

 ##########
 File path: samza-kafka/src/main/java/org/apache/samza/system/kafka/KafkaSystemConsumer.java
 ##########
 @@ -285,6 +321,27 @@ public void register(SystemStreamPartition systemStreamPartition, String
offset)
     metrics.registerTopicAndPartition(toTopicAndPartition(tp));
   }
 
+  @Override
+  public void register(SystemStreamPartition systemStreamPartition, Startpoint startpoint)
{
+    if (started.get()) {
+      String exceptionMessage = String.format("KafkaSystemConsumer: %s had started. Registration
of ssp: %s, startpoint: %s failed.", this, systemStreamPartition, startpoint);
+      throw new SamzaException(exceptionMessage);
+    }
+
+    if (!Objects.equals(systemStreamPartition.getSystem(), systemName)) {
+      LOG.warn("{}: ignoring SSP {}, because this consumer's system doesn't match.", this,
systemStreamPartition);
+      return;
+    }
+
+    LOG.debug("Registering the ssp: {}, startpoint: {} with the consumer.", systemStreamPartition,
startpoint);
+
+    super.register(systemStreamPartition, startpoint);
+
+    TopicPartition topicPartition = toTopicPartition(systemStreamPartition);
+    topicPartitionToStartpointMap.put(topicPartition, startpoint);
 
 Review comment:
   I was thinking of the case where `existingOffset` corresponds to the current checkpoint,
and someone tries to set the offset to something after the current checkpoint. It looks like
this code prevents someone from explicitly setting an offset to something after the `existingOffset`.
   Now that you added the offset check to `SystemConsumers`, it looks like this removed functionality
is now handled there.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message