Beispiel #1
0
 private long getFinalizedTimestampMillis(String topic) throws Exception {
   final int numPartitions = mKafkaClient.getNumPartitions(topic);
   long minTimestamp = Long.MAX_VALUE;
   for (int partition = 0; partition < numPartitions; ++partition) {
     TopicPartition topicPartition = new TopicPartition(topic, partition);
     long timestamp = getFinalizedTimestampMillis(topicPartition);
     LOG.info(
         "finalized timestamp for topic "
             + topic
             + " partition "
             + partition
             + " is "
             + timestamp);
     if (timestamp == -1) {
       return -1;
     } else {
       if (timestamp < minTimestamp) {
         minTimestamp = timestamp;
       }
     }
   }
   if (minTimestamp == Long.MAX_VALUE) {
     return -1;
   }
   return minTimestamp;
 }
Beispiel #2
0
 private long getLastTimestampMillis(String topic) throws Exception {
   final int numPartitions = mKafkaClient.getNumPartitions(topic);
   long max_timestamp = Long.MIN_VALUE;
   for (int partition = 0; partition < numPartitions; ++partition) {
     TopicPartition topicPartition = new TopicPartition(topic, partition);
     long timestamp = getLastTimestampMillis(topicPartition);
     if (timestamp > max_timestamp) {
       max_timestamp = timestamp;
     }
   }
   if (max_timestamp == Long.MIN_VALUE) {
     return -1;
   }
   return max_timestamp;
 }