P
- Type of the protocol buffer implementationpublic abstract class YarnRpcAccessor<P>
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected P |
createProxy()
Creates the proxy.
|
void |
destroy() |
<T,S extends P> |
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. |
public YarnRpcAccessor(java.lang.Class<P> protocolClazz, org.apache.hadoop.conf.Configuration config)
protocolClazz
- the protocol clazzconfig
- the yarn configurationpublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean
public P getProxy()
public <T,S extends P> T execute(YarnRpcCallback<T,S> action) throws org.springframework.dao.DataAccessException
T
- the return typeS
- the proxy typeaction
- the actionorg.springframework.dao.DataAccessException
- the data access exceptionpublic org.apache.hadoop.conf.Configuration getConfiguration()
protected P createProxy() throws java.io.IOException
getUser()
returns
a non null user
, that
will be used to request the proxy with
a PrivilegedAction
.java.io.IOException
- if creation failsprotected org.apache.hadoop.security.UserGroupInformation getUser() throws java.io.IOException
user
used to
create the proxy. Default implementation delegates into
UserGroupInformation.getCurrentUser()
.java.io.IOException
- if login failscreateProxy()
protected abstract java.net.InetSocketAddress getRpcAddress(org.apache.hadoop.conf.Configuration configuration)
InetSocketAddress
where this accessor should connect.configuration
- the yarn configuration