@Test public void testUpdateHiveEnvContent() throws Exception { setupIoCContext(); final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); } }); String testContent = " if [ \"$SERVICE\" = \"cli\" ]; then\n" + " if [ -z \"$DEBUG\" ]; then\n" + " export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit\"\n" + " else\n" + " export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit\"\n" + " fi\n" + " fi\n" + "\n" + "export HADOOP_HEAPSIZE=\"{{hive_heapsize}}\"\n" + "export HADOOP_CLIENT_OPTS=\"-Xmx${HADOOP_HEAPSIZE}m $HADOOP_CLIENT_OPTS\"\n" + "\n" + "# Set HADOOP_HOME to point to a specific hadoop install directory\n" + "HADOOP_HOME=${HADOOP_HOME:-{{hadoop_home}}}\n"; String expectedResult = " if [ \"$SERVICE\" = \"cli\" ]; then\n" + " if [ -z \"$DEBUG\" ]; then\n" + " export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit\"\n" + " else\n" + " export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit\"\n" + " fi\n" + " fi\n" + "\n" + "\n" + "\n" + "# Set HADOOP_HOME to point to a specific hadoop install directory\n" + "HADOOP_HOME=${HADOOP_HOME:-{{hadoop_home}}}\n"; assertEquals(expectedResult, mockInjector.getInstance(UpgradeCatalog212.class).updateHiveEnvContent(testContent)); }
protected String updateHiveEnvContent(String hiveEnvContent) { if(hiveEnvContent == null) { return null; } String oldHeapSizeRegex = "export HADOOP_HEAPSIZE=\"\\{\\{hive_heapsize\\}\\}\"\\s*\\n" + "export HADOOP_CLIENT_OPTS=\"-Xmx\\$\\{HADOOP_HEAPSIZE\\}m \\$HADOOP_CLIENT_OPTS\""; String newAuxJarPath = ""; return hiveEnvContent.replaceAll(oldHeapSizeRegex, Matcher.quoteReplacement(newAuxJarPath)); }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected String updateHiveEnvContent(String hiveEnvContent) { if(hiveEnvContent == null) { return null; } String oldHeapSizeRegex = "export HADOOP_HEAPSIZE=\"\\{\\{hive_heapsize\\}\\}\"\\s*\\n" + "export HADOOP_CLIENT_OPTS=\"-Xmx\\$\\{HADOOP_HEAPSIZE\\}m \\$HADOOP_CLIENT_OPTS\""; String newAuxJarPath = ""; return hiveEnvContent.replaceAll(oldHeapSizeRegex, Matcher.quoteReplacement(newAuxJarPath)); } }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected String updateHiveEnvContent(String hiveEnvContent) { if(hiveEnvContent == null) { return null; } String oldHeapSizeRegex = "export HADOOP_HEAPSIZE=\"\\{\\{hive_heapsize\\}\\}\"\\s*\\n" + "export HADOOP_CLIENT_OPTS=\"-Xmx\\$\\{HADOOP_HEAPSIZE\\}m \\$HADOOP_CLIENT_OPTS\""; String newAuxJarPath = ""; return hiveEnvContent.replaceAll(oldHeapSizeRegex, Matcher.quoteReplacement(newAuxJarPath)); } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected String updateHiveEnvContent(String hiveEnvContent) { if(hiveEnvContent == null) { return null; } String oldHeapSizeRegex = "export HADOOP_HEAPSIZE=\"\\{\\{hive_heapsize\\}\\}\"\\s*\\n" + "export HADOOP_CLIENT_OPTS=\"-Xmx\\$\\{HADOOP_HEAPSIZE\\}m \\$HADOOP_CLIENT_OPTS\""; String newAuxJarPath = ""; return hiveEnvContent.replaceAll(oldHeapSizeRegex, Matcher.quoteReplacement(newAuxJarPath)); } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected String updateHiveEnvContent(String hiveEnvContent) { if(hiveEnvContent == null) { return null; } String oldHeapSizeRegex = "export HADOOP_HEAPSIZE=\"\\{\\{hive_heapsize\\}\\}\"\\s*\\n" + "export HADOOP_CLIENT_OPTS=\"-Xmx\\$\\{HADOOP_HEAPSIZE\\}m \\$HADOOP_CLIENT_OPTS\""; String newAuxJarPath = ""; return hiveEnvContent.replaceAll(oldHeapSizeRegex, Matcher.quoteReplacement(newAuxJarPath)); } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); @Override String getTargetVersion(); @Override String getSourceVersion();  }