Spring for Apache Hadoop

org.springframework.yarn.rpc
Class YarnRpcAccessor<P>

java.lang.Object
  extended by org.springframework.yarn.rpc.YarnRpcAccessor<P>
Type Parameters:
P - Type of the protocol buffer implementation
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
AppmasterCmTemplate, AppmasterRmTemplate, ClientRmTemplate

public abstract class YarnRpcAccessor<P>
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Base implementation for accessing yarn components over protocol buffer rpc system.

Author:
Janne Valkealahti

Constructor Summary
YarnRpcAccessor(java.lang.Class<P> protocolClazz, org.apache.hadoop.conf.Configuration config)
          Instantiates a new yarn rpc accessor with a protocol class and Yarn configuration.
 
Method Summary
 void afterPropertiesSet()
           
protected  P createProxy()
          Creates the proxy.
 void destroy()
           
<T,S extends P>
T
execute(YarnRpcCallback<T,S> action)
          Execute given action callback on the rpc proxy.
 org.apache.hadoop.conf.Configuration getConfiguration()
          Gets the Yarn configuration.
 P getProxy()
          Gets the proxy handled by this accessor.
protected abstract  java.net.InetSocketAddress getRpcAddress(org.apache.hadoop.conf.Configuration configuration)
          Gets the InetSocketAddress where this accessor should connect.
protected  org.apache.hadoop.security.UserGroupInformation getUser()
          Gets the user used to create the proxy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YarnRpcAccessor

public YarnRpcAccessor(java.lang.Class<P> protocolClazz,
                       org.apache.hadoop.conf.Configuration config)
Instantiates a new yarn rpc accessor with a protocol class and Yarn configuration.

Parameters:
protocolClazz - the protocol clazz
config - the yarn configuration
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

destroy

public void destroy()
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean

getProxy

public P getProxy()
Gets the proxy handled by this accessor.

Returns:
the proxy

execute

public <T,S extends P> T execute(YarnRpcCallback<T,S> action)
          throws org.springframework.dao.DataAccessException
Execute given action callback on the rpc proxy.

Type Parameters:
T - the return type
S - the proxy type
Parameters:
action - the action
Returns:
the result from a callback execution
Throws:
org.springframework.dao.DataAccessException - the data access exception

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Gets the Yarn configuration.

Returns:
the Yarn configuration

createProxy

protected P createProxy()
                 throws java.io.IOException
Creates the proxy. If getUser() returns a non null user, that will be used to request the proxy with a PrivilegedAction.

Returns:
the proxy
Throws:
java.io.IOException

getUser

protected org.apache.hadoop.security.UserGroupInformation getUser()
                                                           throws java.io.IOException
Gets the user used to create the proxy. Default implementation delegates into UserGroupInformation.getCurrentUser().

Returns:
the user
Throws:
java.io.IOException - if login fails
See Also:
createProxy()

getRpcAddress

protected abstract java.net.InetSocketAddress getRpcAddress(org.apache.hadoop.conf.Configuration configuration)
Gets the InetSocketAddress where this accessor should connect.

Parameters:
configuration - the yarn configuration
Returns:
address of rpc endpoint

Spring for Apache Hadoop