|
@@ -197,13 +197,16 @@ public class RPC {
|
|
private static ClientCache CLIENTS=new ClientCache();
|
|
private static ClientCache CLIENTS=new ClientCache();
|
|
|
|
|
|
private static class Invoker implements InvocationHandler {
|
|
private static class Invoker implements InvocationHandler {
|
|
|
|
+ private Class<? extends VersionedProtocol> protocol;
|
|
private InetSocketAddress address;
|
|
private InetSocketAddress address;
|
|
private UserGroupInformation ticket;
|
|
private UserGroupInformation ticket;
|
|
private Client client;
|
|
private Client client;
|
|
private boolean isClosed = false;
|
|
private boolean isClosed = false;
|
|
|
|
|
|
- public Invoker(InetSocketAddress address, UserGroupInformation ticket,
|
|
|
|
- Configuration conf, SocketFactory factory) {
|
|
|
|
|
|
+ public Invoker(Class<? extends VersionedProtocol> protocol,
|
|
|
|
+ InetSocketAddress address, UserGroupInformation ticket,
|
|
|
|
+ Configuration conf, SocketFactory factory) {
|
|
|
|
+ this.protocol = protocol;
|
|
this.address = address;
|
|
this.address = address;
|
|
this.ticket = ticket;
|
|
this.ticket = ticket;
|
|
this.client = CLIENTS.getClient(conf, factory);
|
|
this.client = CLIENTS.getClient(conf, factory);
|
|
@@ -219,7 +222,7 @@ public class RPC {
|
|
|
|
|
|
ObjectWritable value = (ObjectWritable)
|
|
ObjectWritable value = (ObjectWritable)
|
|
client.call(new Invocation(method, args), address,
|
|
client.call(new Invocation(method, args), address,
|
|
- method.getDeclaringClass(), ticket);
|
|
|
|
|
|
+ protocol, ticket);
|
|
if (logDebug) {
|
|
if (logDebug) {
|
|
long callTime = System.currentTimeMillis() - startTime;
|
|
long callTime = System.currentTimeMillis() - startTime;
|
|
LOG.debug("Call: " + method.getName() + " " + callTime);
|
|
LOG.debug("Call: " + method.getName() + " " + callTime);
|
|
@@ -283,7 +286,8 @@ public class RPC {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public static VersionedProtocol waitForProxy(Class protocol,
|
|
|
|
|
|
+ public static VersionedProtocol waitForProxy(
|
|
|
|
+ Class<? extends VersionedProtocol> protocol,
|
|
long clientVersion,
|
|
long clientVersion,
|
|
InetSocketAddress addr,
|
|
InetSocketAddress addr,
|
|
Configuration conf
|
|
Configuration conf
|
|
@@ -301,7 +305,8 @@ public class RPC {
|
|
* @return the proxy
|
|
* @return the proxy
|
|
* @throws IOException if the far end through a RemoteException
|
|
* @throws IOException if the far end through a RemoteException
|
|
*/
|
|
*/
|
|
- static VersionedProtocol waitForProxy(Class protocol,
|
|
|
|
|
|
+ static VersionedProtocol waitForProxy(
|
|
|
|
+ Class<? extends VersionedProtocol> protocol,
|
|
long clientVersion,
|
|
long clientVersion,
|
|
InetSocketAddress addr,
|
|
InetSocketAddress addr,
|
|
Configuration conf,
|
|
Configuration conf,
|
|
@@ -334,7 +339,8 @@ public class RPC {
|
|
}
|
|
}
|
|
/** Construct a client-side proxy object that implements the named protocol,
|
|
/** Construct a client-side proxy object that implements the named protocol,
|
|
* talking to a server at the named address. */
|
|
* talking to a server at the named address. */
|
|
- public static VersionedProtocol getProxy(Class<?> protocol,
|
|
|
|
|
|
+ public static VersionedProtocol getProxy(
|
|
|
|
+ Class<? extends VersionedProtocol> protocol,
|
|
long clientVersion, InetSocketAddress addr, Configuration conf,
|
|
long clientVersion, InetSocketAddress addr, Configuration conf,
|
|
SocketFactory factory) throws IOException {
|
|
SocketFactory factory) throws IOException {
|
|
UserGroupInformation ugi = null;
|
|
UserGroupInformation ugi = null;
|
|
@@ -348,14 +354,15 @@ public class RPC {
|
|
|
|
|
|
/** Construct a client-side proxy object that implements the named protocol,
|
|
/** Construct a client-side proxy object that implements the named protocol,
|
|
* talking to a server at the named address. */
|
|
* talking to a server at the named address. */
|
|
- public static VersionedProtocol getProxy(Class<?> protocol,
|
|
|
|
|
|
+ public static VersionedProtocol getProxy(
|
|
|
|
+ Class<? extends VersionedProtocol> protocol,
|
|
long clientVersion, InetSocketAddress addr, UserGroupInformation ticket,
|
|
long clientVersion, InetSocketAddress addr, UserGroupInformation ticket,
|
|
Configuration conf, SocketFactory factory) throws IOException {
|
|
Configuration conf, SocketFactory factory) throws IOException {
|
|
|
|
|
|
VersionedProtocol proxy =
|
|
VersionedProtocol proxy =
|
|
(VersionedProtocol) Proxy.newProxyInstance(
|
|
(VersionedProtocol) Proxy.newProxyInstance(
|
|
protocol.getClassLoader(), new Class[] { protocol },
|
|
protocol.getClassLoader(), new Class[] { protocol },
|
|
- new Invoker(addr, ticket, conf, factory));
|
|
|
|
|
|
+ new Invoker(protocol, addr, ticket, conf, factory));
|
|
long serverVersion = proxy.getProtocolVersion(protocol.getName(),
|
|
long serverVersion = proxy.getProtocolVersion(protocol.getName(),
|
|
clientVersion);
|
|
clientVersion);
|
|
if (serverVersion == clientVersion) {
|
|
if (serverVersion == clientVersion) {
|
|
@@ -376,7 +383,8 @@ public class RPC {
|
|
* @return a proxy instance
|
|
* @return a proxy instance
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public static VersionedProtocol getProxy(Class<?> protocol,
|
|
|
|
|
|
+ public static VersionedProtocol getProxy(
|
|
|
|
+ Class<? extends VersionedProtocol> protocol,
|
|
long clientVersion, InetSocketAddress addr, Configuration conf)
|
|
long clientVersion, InetSocketAddress addr, Configuration conf)
|
|
throws IOException {
|
|
throws IOException {
|
|
|
|
|