public static String getUniqueName ( JobConf conf , String name ) { int partition = conf . getInt ( "mapred.task.partition" , - 1 ) ; if ( partition == - 1 ) { throw new IllegalArgumentException ( "This method can only be called from within a Job" ) ; } String taskType = ( conf . getBoolean ( "mapred.task.is.map" , true ) ) ? "m" : "r" ; NumberFormat numberFormat = NumberFormat . getInstance ( ) ; numberFormat . setMinimumIntegerDigits ( 5 ) ; numberFormat . setGroupingUsed ( false ) ; return name + "-" + taskType + "-" + numberFormat . format ( partition ) ; }
Helper function to generate a name that is unique for the task .