[ 
https://issues.apache.org/jira/browse/HIVE-17751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16321809#comment-16321809
 ] 

Alexander Kolbasov edited comment on HIVE-17751 at 1/11/18 7:23 AM:
--------------------------------------------------------------------

Looks like we can use reflection to deal with embedded metastore. Something 
along these lines:

{code:java}
      //
      // instantiate the metastore server handler directly instead of connecting
      // through the network
      //
      // The code below simulates the following code
      //
      // client = HiveMetaStore.newRetryingHMSHandler("hive client", this.conf, 
true);
      //
      // using reflection API. This is done to avoid dependency of 
MetastoreClient on Hive Metastore.
      // Note that newRetryingHMSHandler is static method, so we pass null as 
the object reference.
      //
      try {
        Class<?> clazz = Class.forName(HIVE_METASTORE_CLASS);
        //noinspection JavaReflectionMemberAccess
        Method method = clazz.getMethod(HIVE_METASTORE_CREATE_HANDLER_METHOD,
            String.class, Configuration.class, Boolean.TYPE);
        client =
            (ThriftHiveMetastore.Iface)method.invoke(null, "hive client", 
this.conf, true);

      } catch (ClassNotFoundException
          | NoSuchMethodException
          | InvocationTargetException
          | IllegalAccessException e) {
        throw new MetaException(e.getMessage());
      }
{code}


was (Author: akolb):
Looks like we can use reflection to deal with embedded metastore. Something 
along these lines:

{code}
      //
      // instantiate the metastore server handler directly instead of connecting
      // through the network
      //
      // The code below simulates the following code
      //
      // client = HiveMetaStore.newRetryingHMSHandler("hive client", this.conf, 
true);
      //
      // using reflection API. This is done to avoid dependency of 
MetastoreClient on Hive Metastore.
      // Note that newRetryingHMSHandler is static method, so we pass null as 
the object reference.
      //
      try {
        Class<?> clazz = Class.forName(HIVE_METASTORE_CLASS);
        //noinspection JavaReflectionMemberAccess
        Method method = clazz.getMethod(HIVE_METASTORE_CREATE_HANDLER_METHOD,
            String.class, Configuration.class, Boolean.TYPE);
        client =
            (ThriftHiveMetastore.Iface)method.invoke(null, "hive client", 
this.conf, true);

      } catch (ClassNotFoundException
          | NoSuchMethodException
          | InvocationTargetException
          | IllegalAccessException e) {
        throw new MetaException(e.getMessage());
      }
{code}

> Separate HMS Client and HMS server into separate sub-modules
> ------------------------------------------------------------
>
>                 Key: HIVE-17751
>                 URL: https://issues.apache.org/jira/browse/HIVE-17751
>             Project: Hive
>          Issue Type: Sub-task
>          Components: Standalone Metastore
>            Reporter: Vihang Karajgaonkar
>            Assignee: Vihang Karajgaonkar
>
> external applications which are interfacing with HMS should ideally only 
> include HMSClient library instead of one big library containing server as 
> well. We should ideally have a thin client library so that cross version 
> support for external applications is easier. We should sub-divide the 
> standalone module into possibly 3 modules (one for common classes, one for 
> client classes and one for server) or 2 sub-modules (one for client and one 
> for server) so that we can generate separate jars for HMS client and server.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to