TerrapinUtil { public static Integer extractPartitionName(String fileName, PartitionerType partitioner) { if (partitioner == PartitionerType.MODULUS || partitioner == PartitionerType.CASCADING) { if (!fileName.startsWith(Constants.FILE_PREFIX)) { return null; } try { return Integer.parseInt(fileName.substring(5, 10)); } catch (NumberFormatException e) { return null; } } return null; }  static String getHelixInstanceFromHDFSHost(String hdfsHostName); static PropertiesConfiguration readPropertiesExitOnFailure(String configFile); static Integer extractPartitionName(String fileName, PartitionerType partitioner); static String formatPartitionName(int partitionNumber); static String getPartitionName(ByteBuffer key,
                                        PartitionerType partitionerType,
                                        int numPartitions); static String hdfsDirToHelixResource(String hdfsDir); static String helixResourceToHdfsDir(String helixResource); static ZooKeeperClient getZooKeeperClient(String zkQuorum, int sessionTimeoutSeconds); static int getBucketSize(int numPartitions, boolean enableZkCompression); static String extractFileSetFromPath(String resource); static Pair<String, Integer> getBucketizedResourceAndPartitionNum(String helixPartition); static Pair<String, Integer> getNonBucketizedResourceAndPartitionNum(
      String helixPartition); static Pair<String, Integer> getResourceAndPartitionNum(String helixPartition); static String getViewPartitionName(String resource, int partition); static int getViewPartitionNumber(String viewPartitionName); static void compressIdealState(IdealState is); static String getZKQuorumFromConf(PropertiesConfiguration configuration); static List<HdfsFileStatus> getHdfsFileList(DFSClient hdfsClient,
                                                     String hdfsDir); static void loadFileSetData(ZooKeeperManager zkManager, FileSetInfo fsInfo, Options options); static List<Pair<Path, Long>> getS3FileList(AWSCredentials credentials,
      String s3Bucket, String s3KeyPrefix); static void setupConfiguration(Configuration conf,
                                        long dfsBlockSize,
                                        int dfsReplication);  }
@Test public void testExtractPartitionName() { assertEquals(new Integer(10), TerrapinUtil.extractPartitionName( Constants.FILE_PREFIX + "00010-ad2", PartitionerType.MODULUS)); assertEquals(new Integer(10), TerrapinUtil.extractPartitionName( Constants.FILE_PREFIX + "00010", PartitionerType.MODULUS)); Assert.assertNull(TerrapinUtil.extractPartitionName(Constants.FILE_PREFIX + "929-ad2", PartitionerType.MODULUS)); assertEquals(new Integer(10), TerrapinUtil.extractPartitionName( Constants.FILE_PREFIX + "00010-ad2", PartitionerType.CASCADING)); assertEquals(new Integer(10), TerrapinUtil.extractPartitionName( Constants.FILE_PREFIX + "00010", PartitionerType.CASCADING)); Assert.assertNull(TerrapinUtil.extractPartitionName(Constants.FILE_PREFIX + "929-ad2", PartitionerType.CASCADING)); }