Beispiel #1
0
 private void populateTopicPartitionToOffsetToFiles() throws IOException {
   String prefix = getPrefix();
   String topicPrefix = getTopicPrefix();
   String[] paths = FileUtil.listRecursively(topicPrefix);
   for (String path : paths) {
     if (!path.endsWith("/_SUCCESS")) {
       LogFilePath logFilePath = new LogFilePath(prefix, path);
       TopicPartition topicPartition =
           new TopicPartition(logFilePath.getTopic(), logFilePath.getKafkaPartition());
       SortedMap<Long, HashSet<LogFilePath>> offsetToFiles =
           mTopicPartitionToOffsetToFiles.get(topicPartition);
       if (offsetToFiles == null) {
         offsetToFiles = new TreeMap<Long, HashSet<LogFilePath>>();
         mTopicPartitionToOffsetToFiles.put(topicPartition, offsetToFiles);
       }
       long offset = logFilePath.getOffset();
       HashSet<LogFilePath> logFilePaths = offsetToFiles.get(offset);
       if (logFilePaths == null) {
         logFilePaths = new HashSet<LogFilePath>();
         offsetToFiles.put(offset, logFilePaths);
       }
       logFilePaths.add(logFilePath);
     }
   }
 }