org.apache.hadoop.ipc.VersionedProtocol Java Examples

The following examples show how to use org.apache.hadoop.ipc.VersionedProtocol. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WritableRpcEngine.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #2
Source File: WritableRpcEngine.java    From big-c with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #3
Source File: TestDFSClientUpdateNameNodeSignature.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * 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);    
}
 
Example #4
Source File: ConnectionPermission.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #5
Source File: ConnectionPermission.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: WritableRpcEngine.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** 
 * 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);
    }
  }

}
 
Example #7
Source File: WritableRpcEngine.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** 
 * 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);
    }
  }

}
 
Example #8
Source File: DirectTaskUmbilical.java    From RDFS with Apache License 2.0 4 votes vote down vote up
public List<VersionedProtocol> getCreatedProxies() {
  return Collections.singletonList((VersionedProtocol)jobTracker);
}