private static IHMSHandler newRetryingHMSHandler(IHMSHandler baseHandler, Configuration conf, boolean local) throws MetaException { return RetryingHMSHandler.getProxy(conf, baseHandler, local); }
public static IHMSHandler getProxy(Configuration conf, IHMSHandler baseHandler, boolean local) throws MetaException { RetryingHMSHandler handler = new RetryingHMSHandler(conf, baseHandler, local); return (IHMSHandler) Proxy.newProxyInstance( RetryingHMSHandler.class.getClassLoader(), new Class[] { IHMSHandler.class }, handler); }
MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), null, metaStoreInitData); try { if (reloadConf || gotNewConnectUrl) { baseHandler.setConf(getActiveConf()); String lastUrl = MetaStoreInit.getConnectionURL(getActiveConf()); gotNewConnectUrl = MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), lastUrl, metaStoreInitData);
private RetryingHMSHandler(Configuration origConf, IHMSHandler baseHandler, boolean local) throws MetaException { this.origConf = origConf; this.baseHandler = baseHandler; if (local) { baseHandler.setConf(origConf); // tests expect configuration changes applied directly to metastore } activeConf = baseHandler.getConf(); // This has to be called before initializing the instance of HMSHandler // Using the hook on startup ensures that the hook always has priority // over settings in *.xml. The thread local conf needs to be used because at this point // it has already been initialized using hiveConf. MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), null, metaStoreInitData); try { //invoking init method of baseHandler this way since it adds the retry logic //in case of transient failures in init method invoke(baseHandler, baseHandler.getClass().getDeclaredMethod("init", (Class<?>[]) null), null); } catch (Throwable e) { LOG.error("HMSHandler Fatal error: " + ExceptionUtils.getStackTrace(e)); MetaException me = new MetaException(e.getMessage()); me.initCause(e); throw me; } }
private void init() throws MetaException { // Using the hook on startup ensures that the hook always has priority // over settings in *.xml. The thread local conf needs to be used because at this point // it has already been initialized using hiveConf. MetaStoreInit.updateConnectionURL(hiveConf, getConf(), null, metaStoreInitData); }
protected RetryingHMSHandler(HiveConf hiveConf, String name) throws MetaException { this.hiveConf = hiveConf; // This has to be called before initializing the instance of HMSHandler init(); this.base = (IHMSHandler) new HiveMetaStore.HMSHandler(name, hiveConf); }
private void initMS() { base.setConf(getConf()); }
/** * Create retrying HMS handler for embedded metastore. * * <h1>IMPORTANT</h1> * * This method is called indirectly by HiveMetastoreClient and HiveMetaStoreClientPreCatalog * using reflection. It can not be removed and its arguments can't be changed without matching * change in HiveMetastoreClient and HiveMetaStoreClientPreCatalog. * * @param conf configuration to use * @throws MetaException */ static Iface newRetryingHMSHandler(Configuration conf) throws MetaException { HMSHandler baseHandler = new HiveMetaStore.HMSHandler("hive client", conf, false); return RetryingHMSHandler.getProxy(conf, baseHandler, true); }
public static IHMSHandler getProxy(HiveConf hiveConf, IHMSHandler baseHandler, boolean local) throws MetaException { RetryingHMSHandler handler = new RetryingHMSHandler(hiveConf, baseHandler, local); return (IHMSHandler) Proxy.newProxyInstance( RetryingHMSHandler.class.getClassLoader(), new Class[] { IHMSHandler.class }, handler); }
private RetryingHMSHandler(HiveConf hiveConf, IHMSHandler baseHandler, boolean local) throws MetaException { this.origConf = hiveConf; this.baseHandler = baseHandler; if (local) { baseHandler.setConf(hiveConf); // tests expect configuration changes applied directly to metastore } activeConf = baseHandler.getConf(); // This has to be called before initializing the instance of HMSHandler // Using the hook on startup ensures that the hook always has priority // over settings in *.xml. The thread local conf needs to be used because at this point // it has already been initialized using hiveConf. MetaStoreInit.updateConnectionURL(hiveConf, getActiveConf(), null, metaStoreInitData); baseHandler.init(); }
@Test(expected = MetaException.class) public void testRetriesLimit() throws MetaException { IHMSHandler mockBaseHandler = Mockito.mock(IHMSHandler.class); Mockito.when(mockBaseHandler.getConf()).thenReturn(conf); Mockito.doThrow(JDOException.class).when(mockBaseHandler).init(); RetryingHMSHandler.getProxy(conf, mockBaseHandler, false); Mockito.verify(mockBaseHandler, Mockito.times(RETRY_ATTEMPTS)).init(); }
public static IHMSHandler getProxy(HiveConf hiveConf, String name) throws MetaException { RetryingHMSHandler handler = new RetryingHMSHandler(hiveConf, name); return (IHMSHandler) Proxy.newProxyInstance( RetryingHMSHandler.class.getClassLoader(), new Class[] { IHMSHandler.class }, handler); }
private RetryingHMSHandler(HiveConf hiveConf, IHMSHandler baseHandler, boolean local) throws MetaException { this.origConf = hiveConf; this.baseHandler = baseHandler; if (local) { baseHandler.setConf(hiveConf); // tests expect configuration changes applied directly to metastore } activeConf = baseHandler.getConf(); // This has to be called before initializing the instance of HMSHandler // Using the hook on startup ensures that the hook always has priority // over settings in *.xml. The thread local conf needs to be used because at this point // it has already been initialized using hiveConf. MetaStoreInit.updateConnectionURL(hiveConf, getActiveConf(), null, metaStoreInitData); baseHandler.init(); }
@Test public void testNoRetryInit() throws MetaException { IHMSHandler mockBaseHandler = Mockito.mock(IHMSHandler.class); Mockito.when(mockBaseHandler.getConf()).thenReturn(conf); Mockito.doNothing().when(mockBaseHandler).init(); RetryingHMSHandler.getProxy(conf, mockBaseHandler, false); Mockito.verify(mockBaseHandler, Mockito.times(1)).init(); }
public static IHMSHandler getProxy(HiveConf hiveConf, IHMSHandler baseHandler, boolean local) throws MetaException { RetryingHMSHandler handler = new RetryingHMSHandler(hiveConf, baseHandler, local); return (IHMSHandler) Proxy.newProxyInstance( RetryingHMSHandler.class.getClassLoader(), new Class[] { IHMSHandler.class }, handler); }
MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), null, metaStoreInitData); try { if (reloadConf || gotNewConnectUrl) { baseHandler.setConf(getActiveConf()); String lastUrl = MetaStoreInit.getConnectionURL(getActiveConf()); gotNewConnectUrl = MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), lastUrl, metaStoreInitData);
@Test public void testRetryInit() throws MetaException { IHMSHandler mockBaseHandler = Mockito.mock(IHMSHandler.class); Mockito.when(mockBaseHandler.getConf()).thenReturn(conf); Mockito .doThrow(JDOException.class) .doNothing() .when(mockBaseHandler).init(); RetryingHMSHandler.getProxy(conf, mockBaseHandler, false); Mockito.verify(mockBaseHandler, Mockito.times(2)).init(); }
MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), null, metaStoreInitData); try { if (reloadConf || gotNewConnectUrl) { baseHandler.setConf(getActiveConf()); String lastUrl = MetaStoreInit.getConnectionURL(getActiveConf()); gotNewConnectUrl = MetaStoreInit.updateConnectionURL(origConf, getActiveConf(), lastUrl, metaStoreInitData);
@Test public void testWrappedMetaExceptionRetry() throws MetaException { IHMSHandler mockBaseHandler = Mockito.mock(IHMSHandler.class); Mockito.when(mockBaseHandler.getConf()).thenReturn(conf); //JDOException wrapped in MetaException wrapped in InvocationException MetaException me = new MetaException("Dummy exception"); me.initCause(new JDOException()); InvocationTargetException ex = new InvocationTargetException(me); Mockito .doThrow(me) .doNothing() .when(mockBaseHandler).init(); RetryingHMSHandler.getProxy(conf, mockBaseHandler, false); Mockito.verify(mockBaseHandler, Mockito.times(2)).init(); } }