UpgradeCatalog220 extends AbstractUpgradeCatalog { protected String updateHiveEnvContentHDP23(String hiveEnvContent) { if(hiveEnvContent == null) { return null; } String oldHeapSizeRegex = "# The heap size of the jvm stared by hive shell script can be controlled via:\\s*\\n"; String newHeapSizeRegex = "# The heap size of the jvm stared by hive shell script can be controlled via:\n" + "\n" + "if [ \"$SERVICE\" = \"metastore\" ]; then\n" + " export HADOOP_HEAPSIZE={{hive_metastore_heapsize}} # Setting for HiveMetastore\n" + "else\n" + " export HADOOP_HEAPSIZE={{hive_heapsize}} # Setting for HiveServer2 and Client\n" + "fi\n" + "\n" + "export HADOOP_CLIENT_OPTS=\"$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE}m\"\n" + "\n"; return hiveEnvContent.replaceFirst(oldHeapSizeRegex, Matcher.quoteReplacement(newHeapSizeRegex)); } @Inject  UpgradeCatalog220(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); @Transactional void bootstrapRepoVersionForHDP21(); static final String UPGRADE_PACKAGE_COL; static final String UPGRADE_TYPE_COL; static final String REPO_VERSION_TABLE; }
@Test public void testUpdateHiveEnvContentHDP23() throws Exception { UpgradeCatalog220 upgradeCatalog220 = new UpgradeCatalog220(injector); String testContent = "# The heap size of the jvm stared by hive shell script can be controlled via:\n" + "\n" + "# Larger heap size may be required when running queries over large number of files or partitions.\n"; String expectedResult = "# The heap size of the jvm stared by hive shell script can be controlled via:\n" + "\n" + "if [ \"$SERVICE\" = \"metastore\" ]; then\n" + " export HADOOP_HEAPSIZE={{hive_metastore_heapsize}} # Setting for HiveMetastore\n" + "else\n" + " export HADOOP_HEAPSIZE={{hive_heapsize}} # Setting for HiveServer2 and Client\n" + "fi\n" + "\n" + "export HADOOP_CLIENT_OPTS=\"$HADOOP_CLIENT_OPTS -Xmx${HADOOP_HEAPSIZE}m\"\n" + "\n" + "# Larger heap size may be required when running queries over large number of files or partitions.\n"; Assert.assertEquals(expectedResult, upgradeCatalog220.updateHiveEnvContentHDP23(testContent)); }