Example usage for org.apache.hadoop.ipc RPC getProtocolVersion

List of usage examples for org.apache.hadoop.ipc RPC getProtocolVersion

Introduction

In this page you can find the example usage for org.apache.hadoop.ipc RPC getProtocolVersion.

Prototype

static public long getProtocolVersion(Class<?> protocol) 

Source Link

Document

Get the protocol version from protocol class.

Usage

From source file:backup.datanode.ipc.DataNodeBackupRPC.java

License:Apache License

public static DataNodeBackupRPC getDataNodeBackupRPC(InetSocketAddress dataNodeIPCAddress, Configuration conf,
        UserGroupInformation ugi) throws IOException, InterruptedException {
    int port = conf.getInt(DFS_BACKUP_DATANODE_RPC_PORT_KEY, DFS_BACKUP_DATANODE_RPC_PORT_DEFAULT);
    if (port == 0) {
        port = dataNodeIPCAddress.getPort() + 1;
    }/*from  w  ww  . j  a va 2s  . c  o  m*/
    InetSocketAddress dataNodeAddress = new InetSocketAddress(dataNodeIPCAddress.getAddress(), port);
    return RPC.getProtocolProxy(DataNodeBackupRPC.class, RPC.getProtocolVersion(DataNodeBackupRPC.class),
            dataNodeAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf)).getProxy();
}

From source file:backup.namenode.ipc.NameNodeBackupRPC.java

License:Apache License

public static NameNodeBackupRPC getDataNodeBackupRPC(InetSocketAddress nameNodeIPCAddres, Configuration conf,
        UserGroupInformation ugi) throws IOException, InterruptedException {
    int port = conf.getInt(DFS_BACKUP_NAMENODE_RPC_PORT_KEY, DFS_BACKUP_NAMENODE_RPC_PORT_DEFAULT);
    if (port == 0) {
        port = nameNodeIPCAddres.getPort() + 1;
    }//from www  . j  a va 2 s  .  c  o m
    InetSocketAddress nameNodeAddress = new InetSocketAddress(nameNodeIPCAddres.getAddress(), port);
    return RPC.getProtocolProxy(NameNodeBackupRPC.class, RPC.getProtocolVersion(NameNodeBackupRPC.class),
            nameNodeAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf)).getProxy();
}

From source file:com.intel.hadoopRPCBenchmark.protocol.BenchmarkEngineProtocolClientSideTranslatorPB.java

License:Apache License

public BenchmarkEngineProtocolClientSideTranslatorPB(InetSocketAddress nameNodeAddr, Configuration conf)
        throws IOException {
    RPC.setProtocolEngine(conf, BenchmarkEngineProtocolPB.class, ProtobufRpcEngine.class);
    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    rpcProxy = RPC.getProxy(BenchmarkEngineProtocolPB.class,
            RPC.getProtocolVersion(BenchmarkEngineProtocolPB.class), nameNodeAddr, ugi, conf,
            NetUtils.getSocketFactory(conf, BenchmarkEngineProtocolPB.class));
}

From source file:org.apache.hoya.yarn.appmaster.rpc.HoyaClusterProtocolProxy.java

License:Apache License

@Override
public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash)
        throws IOException {
    if (!protocol.equals(RPC.getProtocolName(HoyaClusterProtocolPB.class))) {
        throw new IOException("Serverside implements " + RPC.getProtocolName(HoyaClusterProtocolPB.class)
                + ". The following requested protocol is unknown: " + protocol);
    }// www .j  a v a  2s  .  c  o m

    return ProtocolSignature.getProtocolSignature(clientMethodsHash,
            RPC.getProtocolVersion(HoyaClusterProtocol.class), HoyaClusterProtocol.class);
}

From source file:org.apache.ratis.hadooprpc.Proxy.java

License:Apache License

public static <PROTOCOL> PROTOCOL getProxy(Class<PROTOCOL> clazz, String addressStr, Configuration conf)
        throws IOException {
    RPC.setProtocolEngine(conf, clazz, ProtobufRpcEngineShaded.class);
    return RPC.getProxy(clazz, RPC.getProtocolVersion(clazz),
            org.apache.ratis.util.NetUtils.createSocketAddr(addressStr), UserGroupInformation.getCurrentUser(),
            conf, NetUtils.getSocketFactory(conf, clazz));
}

From source file:org.apache.slider.server.appmaster.rpc.SliderClusterProtocolProxy.java

License:Apache License

@Override
public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash)
        throws IOException {
    if (!protocol.equals(RPC.getProtocolName(SliderClusterProtocolPB.class))) {
        throw new IOException("Serverside implements " + RPC.getProtocolName(SliderClusterProtocolPB.class)
                + ". The following requested protocol is unknown: " + protocol);
    }// w  w w  . j ava  2  s .co  m

    return ProtocolSignature.getProtocolSignature(clientMethodsHash,
            RPC.getProtocolVersion(SliderClusterProtocol.class), SliderClusterProtocol.class);
}

From source file:uk.ac.gla.terrier.probos.job.ProbosJobService.java

License:Open Source License

@Override
public int run(String[] args) throws Exception {
    final String secret = System.getenv("PBS_SECRET");

    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    Iterator<Token<?>> iter = credentials.getAllTokens().iterator();
    LOG.info("Executing with tokens:");
    while (iter.hasNext()) {
        Token<?> token = iter.next();
        LOG.info(token.toString());/*ww w .  j  av a 2s.c o m*/
        if (token.getKind().equals(AMRMTokenIdentifier.KIND_NAME)) {
            iter.remove();
        }
    }

    SshServer sshd = getSSHServer(secret);

    sshd.start();
    running.set(true);

    int jobId = Integer.parseInt(System.getenv("PBS_JOBID"));
    String hostPort = System.getenv("PBS_CONTROLLER");
    String[] hostPortSplit = hostPort.split(":");
    final String serverHostname = hostPortSplit[0];
    final int serverPort = Integer.parseInt(hostPortSplit[1]);
    final InetSocketAddress server = new InetSocketAddress(serverHostname, serverPort);

    Configuration conf = this.getConf();
    PBSInteractiveClient client = RPC.getProxy(PBSInteractiveClient.class,
            RPC.getProtocolVersion(PBSInteractiveClient.class), server, UserGroupInformation.getCurrentUser(),
            conf, NetUtils.getDefaultSocketFactory(conf));

    LOG.info("Sister for " + jobId + " started on " + sshd.getPort() + " with secret " + secret);
    informController(secret, sshd.getPort(), jobId, client);
    while (running.get()) {
        Thread.sleep(1000);
    }
    LOG.info("Ssh terminated by running variable");
    sshd.stop(true);
    RPC.stopProxy(client);
    return 0;
}

From source file:uk.ac.gla.terrier.probos.master.ProbosApplicationMasterServiceImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
public ProbosApplicationMasterServiceImpl(ApplicationMasterParameters parameters, Configuration _conf)
        throws Exception {
    super(parameters, _conf);
    LOG.info("Starting " + this.getClass().getSimpleName() + " on " + Utils.getHostname());

    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    probosTokens = new ArrayList<Token<ProbosDelegationTokenIdentifier>>();
    Iterator<Token<?>> iter = credentials.getAllTokens().iterator();
    LOG.info("Executing on " + Utils.getHostname() + " with tokens:");
    while (iter.hasNext()) {
        Token<?> token = iter.next();
        LOG.info(token.toString());//w  w  w.  ja  va2s .c o  m
        if (token.getKind().equals(ProbosDelegationTokenIdentifier.KIND_NAME)) {
            probosTokens.add((Token<ProbosDelegationTokenIdentifier>) token);
        }
    }
    renewer = new ProbosTokenRenewer();

    this.conf = _conf;
    StringWriter sw = new StringWriter();
    Configuration.dumpConfiguration(conf, sw);
    //LOG.info("Master conf is " + sw.toString());

    for (String k : REQUIRED_ENV) {
        if (System.getenv(k) == null)
            throw new IllegalArgumentException("Env " + k + " must be set");
    }

    String hostPort = System.getenv("PBS_CONTROLLER");
    String[] hostPortSplit = hostPort.split(":");
    final String serverHostname = hostPortSplit[0];
    final int port = Integer.parseInt(hostPortSplit[1]);

    final InetSocketAddress server = new InetSocketAddress(serverHostname, port);
    masterClient = RPC.getProxy(PBSMasterClient.class, RPC.getProtocolVersion(PBSMasterClient.class), server,
            UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf));
    controllerClient = PBSClientFactory.getPBSClient();
    LOG.info("Connected to controller " + hostPort);

    jobId = Integer.parseInt(System.getenv("PBS_JOBID"));
    container = System.getenv("CONTAINER_ID");
    masterClient.jobEvent(jobId, EventType.MASTER_START, container, null);

    final List<Entry<String, HttpServlet>> masterServlets = new ArrayList<>();
    masterServlets.add(new MapEntry<String, HttpServlet>("/",
            new JobProgressServlet("./", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/qstatjob",
            new QstatJobServlet("./qstatjob", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/conf",
            new ConfServlet("./conf", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/kittenconf",
            new KittenConfServlet("./kittenconf", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/logs",
            new LogsServlet("./logs", masterServlets, controllerClient, this)));

    //0 means any random free port
    webServer = new WebServer("ProbosControllerHttp", masterServlets, 0);
    webServer.init(_conf);
}

From source file:uk.ac.gla.terrier.probos.PBSClientFactory.java

License:Open Source License

public static PBSClient getPBSClient() throws IOException {
    if (forcedClient != null)
        return forcedClient;

    final Configuration c = new Configuration();
    final PConfiguration pConf = new PConfiguration(c);
    String _serverHostname = pConf.get(PConfiguration.KEY_CONTROLLER_HOSTNAME);
    if (System.getenv("PBS_DEFAULT") != null) {
        _serverHostname = System.getenv("PBS_DEFAULT");
    }//from w w w . j av  a 2 s  .  c o m
    final String serverHostname = _serverHostname;
    LOG.debug("Connecting to server " + serverHostname);

    InetSocketAddress server = new InetSocketAddress(serverHostname,
            pConf.getInt(PConfiguration.KEY_CONTROLLER_PORT, 8027));
    LOG.debug("Connecting to server at address " + server.toString());
    PBSClient rtr = RPC.getProxy(PBSClient.class, RPC.getProtocolVersion(PBSClient.class), server,
            UserGroupInformation.getCurrentUser(), pConf, NetUtils.getDefaultSocketFactory(c));
    LOG.debug("Got RPC connection!");
    return rtr;
}