Example usage for org.apache.hadoop.hdfs.protocol ClientProtocol versionID

List of usage examples for org.apache.hadoop.hdfs.protocol ClientProtocol versionID

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol ClientProtocol versionID.

Prototype

long versionID

To view the source code for org.apache.hadoop.hdfs.protocol ClientProtocol versionID.

Click Source Link

Document

Until version 69, this class ClientProtocol served as both the client interface to the NN AND the RPC protocol used to communicate with the NN.

Usage

From source file:common.NameNode.java

License:Apache License

public long getProtocolVersion(String protocol, long clientVersion) throws IOException {
    if (protocol.equals(ClientProtocol.class.getName())) {
        return ClientProtocol.versionID;
    } else if (protocol.equals(DatanodeProtocol.class.getName())) {
        return DatanodeProtocol.versionID;
    } else if (protocol.equals(NamenodeProtocol.class.getName())) {
        return NamenodeProtocol.versionID;
    } else if (protocol.equals(RefreshAuthorizationPolicyProtocol.class.getName())) {
        return RefreshAuthorizationPolicyProtocol.versionID;
    } else if (protocol.equals(RefreshUserToGroupMappingsProtocol.class.getName())) {
        return RefreshUserToGroupMappingsProtocol.versionID;
    } else {/*from w w  w.  j  a  v a 2  s. c om*/
        throw new IOException("Unknown protocol to name node: " + protocol);
    }
}

From source file:edu.uci.ics.hyracks.hadoop.compat.util.HadoopAdapter.java

License:Apache License

public static VersionedProtocol getProtocol(Class<? extends VersionedProtocol> protocolClass,
        InetSocketAddress inetAddress, JobConf jobConf) throws IOException {
    VersionedProtocol versionedProtocol = RPC.getProxy(protocolClass, ClientProtocol.versionID, inetAddress,
            jobConf);/*from w ww . j a  va 2 s . com*/
    return versionedProtocol;
}

From source file:org.cstor.cproc.cloudComputingFramework.CProcFramework.java

License:Apache License

public static void main(String argv[]) throws Exception {

    LOG.info("CProcFramework  version for hadoop-0.20.2-patch : 32");

    //GCThreadGC/*from   w w  w.ja  v a  2  s  .co  m*/
    Thread th = new Thread(new GCThread());
    th.start();

    //LOG.info("CProcFramework [NameNode IP:Port]");
    StringUtils.startupShutdownMessage(CProcFramework.class, argv, LOG);
    //hdfs-site.xml,core-site.xml
    CProcConfiguration cprocConf = CProcConfiguration.getCProcConfiguration();
    RpcConfiguration rpcConf = RpcConfiguration.getRpcConfiguration();
    setParamToRpcConf(cprocConf, rpcConf);

    CProcFramework cpf = null;
    ClientProtocol nameNode = null;
    ClientDatanodeProtocol dataNode = null;
    InetSocketAddress dataNodeAddr = null;
    InetSocketAddress nameNodeAddr = null;
    try {

        boolean isNN = true;

        //LOG.info("conf.get(\"fs.default.name\") == " + conf.get("cProc.name.") );
        //wzt ??? ?? net0 192.168.139.21 9000
        if (argv.length >= 3) {
            network = argv[0];
            namenodeAddress = argv[1];
            port = argv[2];
        } else {

            LOG.info("CProcFramework [network adapter] [namenode Address]");
            System.exit(0);

        }
        LOG.info("network = " + network);

        try {
            nameNodeAddr = NetUtils.createSocketAddr(namenodeAddress);
        } catch (IllegalArgumentException e) {
            //nameNodeAddr = NetUtils.createSocketAddr(argv[0]);
        }

        LOG.info("NameNodeAddr = " + nameNodeAddr);

        //-----------------------get all DN and get conf of NN----------------------------------

        ArrayList<String> DNIP = new ArrayList<String>();

        // Configuration confInFunc = new Configuration();

        nameNode = (ClientProtocol) RPC.getProxy(ClientProtocol.class, ClientProtocol.versionID, nameNodeAddr,
                rpcConf, NetUtils.getSocketFactory(rpcConf, ClientProtocol.class));

        DatanodeDescriptor[] dds = nameNode.getAllDatanode();

        // LOG.info("==========");
        for (DatanodeDescriptor dd : dds) {
            LOG.info(dd.getHost());
            //LOG.info(dd.getHostName());
            //LOG.info(dd.getDatanodeReport());
            DNIP.add(dd.getHost());
        }
        //LOG.info("==========");
        //conf = nameNode.getConfiguration();
        setParamToCprocConf(nameNode.getConfiguration(), rpcConf);

        LOG.info("getHostIP.getLocalIP() = " + getHostIPcProc.getLocalIP(network));

        //-----------------------if this node is a DN get conf----------------------------------

        if (DNIP.contains(getHostIPcProc.getLocalIP(network))) {
            dataNodeAddr = NetUtils
                    .createSocketAddr("127.0.0.1:" + rpcConf.get("dfs.datanode.ipc.address").split(":")[1]);

            dataNode = (ClientDatanodeProtocol) RPC.getProxy(ClientDatanodeProtocol.class,
                    ClientDatanodeProtocol.versionID, dataNodeAddr, rpcConf,
                    NetUtils.getSocketFactory(rpcConf, ClientDatanodeProtocol.class));

            //conf = dataNode.getConfiguration();
            LOG.info("This is DataNode!!");
            isNN = false;
        } else {
            LOG.info("This is NameNode!!");
            isNN = true;
        }

        cpf = createCProcFramework(nameNode, dataNode, cprocConf, rpcConf, isNN, nameNodeAddr);

        cpf.waitForStop();

    } catch (Throwable e) {
        LOG.error(StringUtils.stringifyException(e));
        System.exit(-1);
    } finally {
        //20131210RPC
        //          if(nameNode != null){
        //             RPC.stopProxy(nameNode);
        //          }
        //          if(dataNode != null){
        //             RPC.stopProxy(dataNode);
        //          }
    }
}