@Test public void testLoadHDFSConfigFromEnv() throws IOException { final String k1 = "what is connector?"; final String v1 = "Hive"; final String catalogName = "HiveCatalog"; final File hadoopConfDir = tempFolder.newFolder(); final File hdfsSiteFile = new File(hadoopConfDir, "hdfs-site.xml"); writeProperty(hdfsSiteFile, k1, v1); final Map<String, String> originalEnv = System.getenv(); final Map<String, String> newEnv = new HashMap<>(originalEnv); newEnv.put("HADOOP_CONF_DIR", hadoopConfDir.getAbsolutePath()); CommonTestUtils.setEnv(newEnv); final CatalogDescriptor catalogDescriptor = new HiveCatalogDescriptor(); final Map<String, String> properties = catalogDescriptor.toProperties(); final HiveConf hiveConf; try { final HiveCatalog hiveCatalog = (HiveCatalog) TableFactoryService.find(CatalogFactory.class, properties) .createCatalog(catalogName, properties); hiveConf = hiveCatalog.getHiveConf(); } finally { CommonTestUtils.setEnv(originalEnv); } assertEquals(v1, hiveConf.get(k1, null)); }
@Override public Catalog createCatalog(String name, Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final String defaultDatabase = descriptorProperties.getOptionalString(CATALOG_DEFAULT_DATABASE) .orElse(HiveCatalog.DEFAULT_DB); final Optional<String> hiveConfDir = descriptorProperties.getOptionalString(CATALOG_HIVE_CONF_DIR); final String version = descriptorProperties.getOptionalString(CATALOG_HIVE_VERSION).orElse(HiveShimLoader.getHiveVersion()); return new HiveCatalog(name, defaultDatabase, hiveConfDir.orElse(null), version); }
HiveCatalogFactory implements CatalogFactory { @Override public Catalog createCatalog(String name, Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final String defaultDatabase = descriptorProperties.getOptionalString(CATALOG_DEFAULT_DATABASE) .orElse(HiveCatalog.DEFAULT_DB); final Optional<String> hiveConfDir = descriptorProperties.getOptionalString(CATALOG_HIVE_CONF_DIR); final String version = descriptorProperties.getOptionalString(CATALOG_HIVE_VERSION).orElse(HiveShimLoader.getHiveVersion()); return new HiveCatalog(name, defaultDatabase, hiveConfDir.orElse(null), version); } }
HiveCatalogFactory implements CatalogFactory { @Override public Catalog createCatalog(String name, Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final String defaultDatabase = descriptorProperties.getOptionalString(CATALOG_DEFAULT_DATABASE) .orElse(HiveCatalog.DEFAULT_DB); final Optional<String> hiveConfDir = descriptorProperties.getOptionalString(CATALOG_HIVE_CONF_DIR); final String version = descriptorProperties.getOptionalString(CATALOG_HIVE_VERSION).orElse(HiveShimLoader.getHiveVersion()); return new HiveCatalog(name, defaultDatabase, hiveConfDir.orElse(null), version); }  }
HiveCatalogFactory implements CatalogFactory { @Override public Catalog createCatalog(String name, Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final String defaultDatabase = descriptorProperties.getOptionalString(CATALOG_DEFAULT_DATABASE) .orElse(HiveCatalog.DEFAULT_DB); final Optional<String> hiveConfDir = descriptorProperties.getOptionalString(CATALOG_HIVE_CONF_DIR); final String version = descriptorProperties.getOptionalString(CATALOG_HIVE_VERSION).orElse(HiveShimLoader.getHiveVersion()); return new HiveCatalog(name, defaultDatabase, hiveConfDir.orElse(null), version); }  @Override Map<String, String> requiredContext(); @Override List<String> supportedProperties(); @Override Catalog createCatalog(String name, Map<String, String> properties); }
HiveCatalogFactory implements CatalogFactory { @Override public Catalog createCatalog(String name, Map<String, String> properties) { final DescriptorProperties descriptorProperties = getValidatedProperties(properties); final String defaultDatabase = descriptorProperties.getOptionalString(CATALOG_DEFAULT_DATABASE) .orElse(HiveCatalog.DEFAULT_DB); final Optional<String> hiveConfDir = descriptorProperties.getOptionalString(CATALOG_HIVE_CONF_DIR); final String version = descriptorProperties.getOptionalString(CATALOG_HIVE_VERSION).orElse(HiveShimLoader.getHiveVersion()); return new HiveCatalog(name, defaultDatabase, hiveConfDir.orElse(null), version); }  @Override Map<String, String> requiredContext(); @Override List<String> supportedProperties(); @Override Catalog createCatalog(String name, Map<String, String> properties);  }