本文整理汇总了Java中org.apache.hadoop.ipc.VersionedProtocol类的典型用法代码示例。如果您正苦于以下问题:Java VersionedProtocol类的具体用法?Java VersionedProtocol怎么用?Java VersionedProtocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VersionedProtocol类属于org.apache.hadoop.ipc包,在下文中一共展示了VersionedProtocol类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Invocation
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
public Invocation(Method method, Object[] parameters) {
this.methodName = method.getName();
this.parameterClasses = method.getParameterTypes();
this.parameters = parameters;
rpcVersion = writableRpcVersion;
if (method.getDeclaringClass().equals(VersionedProtocol.class)) {
//VersionedProtocol is exempted from version check.
clientVersion = 0;
clientMethodsHash = 0;
} else {
this.clientVersion = RPC.getProtocolVersion(method.getDeclaringClass());
this.clientMethodsHash = ProtocolSignature.getFingerprint(method
.getDeclaringClass().getMethods());
}
this.declaringClassProtocolName =
RPC.getProtocolName(method.getDeclaringClass());
}
示例2: testNameNodeFingerprintSent
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
/**
* This function tests the method signature fingerprint passed back from
* name-node with MetaInfo is correct.
*/
@SuppressWarnings("unchecked")
public void testNameNodeFingerprintSent() throws IOException {
InetSocketAddress addr = cluster.getNameNode().getNameNodeDNAddress();
DFSClient client = new DFSClient(addr, cluster.getNameNode().getConf());
client.namenode.create("/testNameNodeFingerprintSent.txt", FsPermission
.getDefault(), client.getClientName(), true, (short)1, 65535L);
Class<? extends VersionedProtocol> inter;
try {
inter = (Class<? extends VersionedProtocol>)Class.forName(ClientProtocol.class.getName());
} catch (Exception e) {
throw new IOException(e);
}
long serverVersion = ClientProtocol.versionID;
int serverFpFromNn = ProtocolSignature.getFingerprint(ProtocolSignature.getProtocolSignature(
0, serverVersion, inter).getMethods());
LocatedBlockWithMetaInfo loc = client.namenode.addBlockAndFetchMetaInfo("/testNameNodeFingerprintSent.txt",
client.getClientName(), null, 0L);
int serverFp = loc.getMethodFingerPrint();
TestCase.assertEquals(serverFpFromNn, serverFp);
FileSystem fs = cluster.getFileSystem();
Path f = new Path("/testNameNodeFingerprintSent1.txt");
DataOutputStream a_out = fs.create(f);
a_out.writeBytes("something");
a_out.close();
LocatedBlocksWithMetaInfo locs = client.namenode.openAndFetchMetaInfo("/testNameNodeFingerprintSent.txt",
0L, 0L);
TestCase.assertEquals(locs.getMethodFingerPrint(), serverFp);
}
示例3: implies
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
@Override
public boolean implies(Permission permission) {
if (permission instanceof ConnectionPermission) {
ConnectionPermission that = (ConnectionPermission)permission;
if (that.protocol.equals(VersionedProtocol.class)) {
return true;
}
return this.protocol.equals(that.protocol);
}
return false;
}
示例4: Server
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
/**
* Construct an RPC server.
* @param protocolClass - the protocol being registered
* can be null for compatibility with old usage (see below for details)
* @param protocolImpl the protocol impl that will be called
* @param conf the configuration to use
* @param bindAddress the address to bind on to listen for connection
* @param port the port to listen for connections on
* @param numHandlers the number of method handler threads to run
* @param verbose whether each call should be logged
*/
public Server(Class<?> protocolClass, Object protocolImpl,
Configuration conf, String bindAddress, int port,
int numHandlers, int numReaders, int queueSizePerHandler,
boolean verbose, SecretManager<? extends TokenIdentifier> secretManager,
String portRangeConfig)
throws IOException {
super(bindAddress, port, null, numHandlers, numReaders,
queueSizePerHandler, conf,
classNameBase(protocolImpl.getClass().getName()), secretManager,
portRangeConfig);
this.verbose = verbose;
Class<?>[] protocols;
if (protocolClass == null) { // derive protocol from impl
/*
* In order to remain compatible with the old usage where a single
* target protocolImpl is suppled for all protocol interfaces, and
* the protocolImpl is derived from the protocolClass(es)
* we register all interfaces extended by the protocolImpl
*/
protocols = RPC.getProtocolInterfaces(protocolImpl.getClass());
} else {
if (!protocolClass.isAssignableFrom(protocolImpl.getClass())) {
throw new IOException("protocolClass "+ protocolClass +
" is not implemented by protocolImpl which is of class " +
protocolImpl.getClass());
}
// register protocol class and its super interfaces
registerProtocolAndImpl(RPC.RpcKind.RPC_WRITABLE, protocolClass, protocolImpl);
protocols = RPC.getProtocolInterfaces(protocolClass);
}
for (Class<?> p : protocols) {
if (!p.equals(VersionedProtocol.class)) {
registerProtocolAndImpl(RPC.RpcKind.RPC_WRITABLE, p, protocolImpl);
}
}
}
示例5: getCreatedProxies
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
public List<VersionedProtocol> getCreatedProxies() {
return Collections.singletonList((VersionedProtocol)jobTracker);
}
示例6: VersionedProtocolPointer
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
/**
* Init c'tor
*/
public VersionedProtocolPointer(VersionedProtocol client) {
this.client = client;
}
示例7: getClient
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
public VersionedProtocol getClient() {
return client;
}
示例8: setClient
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
public void setClient(VersionedProtocol client) {
this.client = client;
}
示例9: newNamenode
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
@Override
public void newNamenode(VersionedProtocol namenode) {
this.namenodeRPC = (ClientProxyProtocol) namenode;
}
示例10: newNamenode
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
@Override
public void newNamenode(VersionedProtocol namenode) {
failoverNamenode.setNameNode((NamenodeProtocol) namenode);
}
示例11: newNamenode
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
@Override
public void newNamenode(VersionedProtocol namenode) {
failoverClient.setNameNode((ClientProtocol) namenode);
}
示例12: stop
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
public static void stop(VersionedProtocol v) {
RPC.stopProxy(v);
}
示例13: newNamenode
import org.apache.hadoop.ipc.VersionedProtocol; //导入依赖的package包/类
/**
* Once we know about a new namenode, instruct the client that it should
* failover to this new namenode
*/
public void newNamenode(VersionedProtocol namenode);