public RetryingHMSHandler(Configuration conf, IHMSHandler baseHandler, boolean local)
      throws MetaException {
    super(conf, baseHandler, local);
    retryInterval = MetastoreConf.getTimeVar(origConf,
        ConfVars.HMS_HANDLER_INTERVAL, TimeUnit.MILLISECONDS);
    retryLimit = MetastoreConf.getIntVar(origConf, ConfVars.HMS_HANDLER_ATTEMPTS);

    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;
    }
  }
@Test
  public void testRetryingHMSHandler() throws Exception {
    String dbName = "hive4159";
    String tblName = "tmptbl";

    new DatabaseBuilder()
        .setName(dbName)
        .create(msc, conf);

    Assert.assertEquals(2, AlternateFailurePreListener.getCallCount());

    new TableBuilder()
        .setDbName(dbName)
        .setTableName(tblName)
        .addCol("c1", ColumnType.STRING_TYPE_NAME)
        .create(msc, conf);

    Assert.assertEquals(4, AlternateFailurePreListener.getCallCount());
  }