Esempio n. 1
0
 private NavigableSet<Calendar> getPartitions(String topic) throws IOException, ParseException {
   final String s3Prefix = "s3n://" + mConfig.getS3Bucket() + "/" + mConfig.getS3Path();
   String[] partitions = {"dt="};
   LogFilePath logFilePath =
       new LogFilePath(s3Prefix, topic, partitions, mConfig.getGeneration(), 0, 0, mFileExtension);
   String parentDir = logFilePath.getLogFileParentDir();
   String[] partitionDirs = FileUtil.list(parentDir);
   Pattern pattern = Pattern.compile(".*/dt=(\\d\\d\\d\\d-\\d\\d-\\d\\d)$");
   TreeSet<Calendar> result = new TreeSet<Calendar>();
   for (String partitionDir : partitionDirs) {
     Matcher matcher = pattern.matcher(partitionDir);
     if (matcher.find()) {
       String date = matcher.group(1);
       SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
       format.setTimeZone(TimeZone.getTimeZone("UTC"));
       Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
       calendar.setTime(format.parse(date));
       result.add(calendar);
     }
   }
   return result;
 }