class HiveEndpoint {

  public Optional<Table> getTable(CloseableMetaStoreClient client, String database, String table) {
    Table oldReplicaTable = null;
    try {
      log.debug("Checking for existing table {}.{}", database, table);
      oldReplicaTable = client.getTable(database, table);
      log.debug("Existing table found.");
    } catch (NoSuchObjectException e) {
      log.debug("Table '{}.{}' not found.", database, table);
    } catch (TException e) {
      String message = String.format("Cannot fetch table metadata for '%s.%s'", database, table);
      log.error(message, e);
      throw new MetaStoreClientException(message, e);
    }
    return Optional.fromNullable(oldReplicaTable);
  }

  @Autowired public  HiveEndpoint(String name, HiveConf hiveConf, Supplier<CloseableMetaStoreClient> metaStoreClientSupplier);

}