private static HiveConf getHiveConf(Optional<String> hcatURI) { try { return HiveConfFactory.get(hcatURI, SharedResourcesBrokerFactory.getImplicitBroker()); } catch (IOException nce) { throw new RuntimeException("Implicit broker is not correctly configured, failed to fetch a HiveConf object", nce); } }
/** * * @param hcatURI User specified hcatURI. * @param broker A shared resource broker * @return a {@link HiveConf} with specified hcatURI if any. * @throws IOException */ public static <S extends ScopeType<S>> HiveConf get(Optional<String> hcatURI, SharedResourcesBroker<S> broker) throws IOException { try { SharedHiveConfKey confKey = hcatURI.isPresent() && StringUtils.isNotBlank(hcatURI.get()) ? new SharedHiveConfKey(hcatURI.get()) : SharedHiveConfKey.INSTANCE; return broker.getSharedResource(new HiveConfFactory<>(), confKey); } catch (NotConfiguredException nce) { throw new IOException(nce); } }
@Test public void testHiveConfFactory() throws Exception { HiveConf hiveConf = HiveConfFactory.get(Optional.absent(), SharedResourcesBrokerFactory.getImplicitBroker()); HiveConf hiveConf1 = HiveConfFactory.get(Optional.absent(), SharedResourcesBrokerFactory.getImplicitBroker()); Assert.assertEquals(hiveConf, hiveConf1); // When there's no hcatURI specified, the default hive-site should be loaded. Assert.assertTrue(hiveConf.getVar(METASTOREURIS).equals("file:///test")); Assert.assertTrue(hiveConf.get(HIVE_METASTORE_TOKEN_SIGNATURE).equals("file:///test")); HiveConf hiveConf2 = HiveConfFactory.get(Optional.of("hcat1"), SharedResourcesBrokerFactory.getImplicitBroker()); HiveConf hiveConf3 = HiveConfFactory.get(Optional.of("hcat1"), SharedResourcesBrokerFactory.getImplicitBroker()); Assert.assertEquals(hiveConf2, hiveConf3); HiveConf hiveConf4 = HiveConfFactory.get(Optional.of("hcat11"), SharedResourcesBrokerFactory.getImplicitBroker()); Assert.assertNotEquals(hiveConf3, hiveConf4); Assert.assertNotEquals(hiveConf4, hiveConf); // THe uri should be correctly set. Assert.assertEquals(hiveConf3.getVar(METASTOREURIS), "hcat1"); Assert.assertEquals(hiveConf3.get(HIVE_METASTORE_TOKEN_SIGNATURE), "hcat1"); Assert.assertEquals(hiveConf4.getVar(METASTOREURIS), "hcat11"); Assert.assertEquals(hiveConf4.get(HIVE_METASTORE_TOKEN_SIGNATURE), "hcat11"); } }
try { hiveConf = SharedResourcesBrokerFactory .getImplicitBroker().getSharedResource(new HiveConfFactory<>(), SharedHiveConfKey.INSTANCE); deserializer = ReflectionUtils.newInstance(hiveConf.getClassByName(serde).asSubclass(Deserializer.class), hiveConf);
private static HiveConf getHiveConf(Optional<String> hcatURI) { try { return HiveConfFactory.get(hcatURI, SharedResourcesBrokerFactory.getImplicitBroker()); } catch (IOException nce) { throw new RuntimeException("Implicit broker is not correctly configured, failed to fetch a HiveConf object", nce); } }
/** * * @param hcatURI User specified hcatURI. * @param broker A shared resource broker * @return a {@link HiveConf} with specified hcatURI if any. * @throws IOException */ public static <S extends ScopeType<S>> HiveConf get(Optional<String> hcatURI, SharedResourcesBroker<S> broker) throws IOException { try { SharedHiveConfKey confKey = hcatURI.isPresent() && StringUtils.isNotBlank(hcatURI.get()) ? new SharedHiveConfKey(hcatURI.get()) : SharedHiveConfKey.INSTANCE; return broker.getSharedResource(new HiveConfFactory<>(), confKey); } catch (NotConfiguredException nce) { throw new IOException(nce); } }
try { hiveConf = SharedResourcesBrokerFactory .getImplicitBroker().getSharedResource(new HiveConfFactory<>(), SharedHiveConfKey.INSTANCE); deserializer = ReflectionUtils.newInstance(hiveConf.getClassByName(serde).asSubclass(Deserializer.class), hiveConf);