FixLzoCodecPath extends AbstractServerAction { public static String fixLzoJarPath(String oldPropertyValue) { return oldPropertyValue.replaceAll( "(/usr/hdp/)[^\\\\:]+(/hadoop/lib/hadoop-lzo-(\\d\\.)+)(\\$\\{hdp.version\\}|(\\d\\.){3}\\d-\\d+)(\\.jar)", "$1\\$\\{hdp.version\\}$2\\$\\{hdp.version\\}$6"); }  @Override CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext); static String fixLzoJarPath(String oldPropertyValue);  }
@Test public void testFixLzoJarPath() throws Exception { String oldContent = "$PWD/mr-framework/hadoop/share/hadoop/mapreduce/*:" + "$PWD/mr-framework/hadoop/share/hadoop/mapreduce/lib/*:" + "$PWD/mr-framework/hadoop/share/hadoop/common/*:" + "$PWD/mr-framework/hadoop/share/hadoop/common/lib/*:" + "$PWD/mr-framework/hadoop/share/hadoop/yarn/*:/usr/hdp/2.3.4.0-3485/hadoop/lib/hadoop-lzo-0.6.0.2.3.4.0-3485.jar:" + "$PWD/mr-framework/hadoop/share/hadoop/yarn/lib/*:$PWD/mr-framework/hadoop/share/hadoop/hdfs/*:" + "$PWD/mr-framework/hadoop/share/hadoop/hdfs/lib/*:$PWD/mr-framework/hadoop/share/hadoop/tools/lib/*:" + "/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure"; String newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("$PWD/mr-framework/hadoop/share/hadoop/mapreduce/*:" + "$PWD/mr-framework/hadoop/share/hadoop/mapreduce/lib/*:" + "$PWD/mr-framework/hadoop/share/hadoop/common/*:$PWD/mr-framework/hadoop/share/hadoop/common/lib/*:" + "$PWD/mr-framework/hadoop/share/hadoop/yarn/*:/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:" + "$PWD/mr-framework/hadoop/share/hadoop/yarn/lib/*:$PWD/mr-framework/hadoop/share/hadoop/hdfs/*:" + "$PWD/mr-framework/hadoop/share/hadoop/hdfs/lib/*:$PWD/mr-framework/hadoop/share/hadoop/tools/lib/*:" + "/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure", newContent); oldContent = "/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure"; newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure", newContent); oldContent = "/usr/hdp/2.3.4.0-3485/hadoop/lib/hadoop-lzo-0.6.0.2.3.4.0-345.jar:/etc/hadoop/conf/secure"; newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure", newContent); oldContent = "/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.2.3.4.0-345.jar:/etc/hadoop/conf/secure"; newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure", newContent); oldContent = "/usr/hdp/2.3.4.0-3485/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure"; newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar:/etc/hadoop/conf/secure", newContent); oldContent = "/usr/hdp/2.3.4.0-3485/hadoop/lib/hadoop-lzo-0.6.0.2.3.4.0-1.jar"; newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("/usr/hdp/${hdp.version}/hadoop/lib/hadoop-lzo-0.6.0.${hdp.version}.jar", newContent); oldContent = "/etc/hadoop/conf/secure"; newContent = FixLzoCodecPath.fixLzoJarPath(oldContent); assertEquals("/etc/hadoop/conf/secure", newContent); }