コード例 #1
0
 @Override
 public void removeOffset(
     TopicName topicName, String subscriptionName, KafkaTopicName topic, int partition)
     throws Exception {
   String offsetPath =
       KafkaZookeeperPaths.partitionOffsetPath(
           kafkaNamesMapper.toConsumerGroupId(Subscription.getId(topicName, subscriptionName)),
           topic,
           partition);
   curatorFramework.delete().forPath(offsetPath);
 }
コード例 #2
0
 @Override
 public void commitOffset(Subscription subscription, PartitionOffset partitionOffset)
     throws Exception {
   long firstToRead = partitionOffset.getOffset() + 1;
   byte[] data = String.valueOf(firstToRead).getBytes(Charset.forName("UTF-8"));
   String offsetPath =
       KafkaZookeeperPaths.partitionOffsetPath(
           kafkaNamesMapper.toConsumerGroupId(subscription),
           partitionOffset.getTopic(),
           partitionOffset.getPartition());
   try {
     curatorFramework.setData().forPath(offsetPath, data);
   } catch (KeeperException.NoNodeException ex) {
     curatorFramework.create().creatingParentsIfNeeded().forPath(offsetPath, data);
   }
 }