Home > HBase > HBase RPC

HBase RPC

HBaseRPC is the class that facilitates the RPC communication between client proxy and remote server.
Based on java dynamic proxy pattern, HBaseRPC uses an Invoker class which implements the InvocationHandler to
intercept client side method call and then marshall the method name and arguments through HBaseClient.

If you look at the proxy client creation method, Proxy.newProxyInstance in HBaseRPC, you will see
the following code where new Invoker instance is passed into method

 VersionedProtocol proxy =
        (VersionedProtocol) Proxy.newProxyInstance(
            protocol.getClassLoader(), new Class[] { protocol },
            new Invoker(addr, ticket, conf, factory, rpcTimeout));

Basically, the Invoker implements the InvocationHandler to intercept proxy side method call as follows

private static class Invoker implements InvocationHandler {

  public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
      final boolean logDebug = LOG.isDebugEnabled();
      long startTime = 0;
      if (logDebug) {
        startTime = System.currentTimeMillis();
      }
      HbaseObjectWritable value = (HbaseObjectWritable)
        client.call(new Invocation(method, args), address, ticket, rpcTimeout);
      if (logDebug) {
        long callTime = System.currentTimeMillis() - startTime;
        LOG.debug("Call: " + method.getName() + " " + callTime);
      }
      return value.get();
    }

From the above, you will notice the use of client.call method. Here, the client is of class HBaseClient that handles the network layer marshalling of method name and parameter arguments to the
remote listening server. See below.

HbaseObjectWritable value = (HbaseObjectWritable)
        client.call(new Invocation(method, args), address, ticket, rpcTimeout);

We will take a look at HBaseClient in the next post.

Advertisements
Categories: HBase
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: