List of usage examples for org.apache.hadoop.ipc RPC getProxy
public static <T> T getProxy(Class<T> protocol, long clientVersion, InetSocketAddress addr, Configuration conf) throws IOException
From source file:cn.dayutianfei.hadoop.rpc.client.RPCProxyManager.java
License:Apache License
public VersionedProtocol createProxy(final String nodeName) throws IOException { LOG.debug("creating proxy for master: " + nodeName); String[] hostName_port = nodeName.split(":"); if (hostName_port.length != 2) { throw new RuntimeException("invalid node name format '" + nodeName + "' (It should be a host name with a port number devided by a ':')"); }//from w w w . j a v a 2 s . c o m final String hostName = hostName_port[0]; final String port = hostName_port[1]; final InetSocketAddress inetSocketAddress = new InetSocketAddress(hostName, Integer.parseInt(port)); VersionedProtocol proxy = RPC.getProxy(_handlerClass, 0L, inetSocketAddress, _conf); LOG.debug(String.format("Created a proxy %s for %s:%s %s", Proxy.getInvocationHandler(proxy), hostName, port, inetSocketAddress)); node2ProxyMap.put(nodeName, proxy); return proxy; }
From source file:com.chinamobile.bcbsp.comm.CommunicatorNew.java
License:Apache License
/** * Get Message Sending RPC Handler For Communication. * /* w ww.j ava2 s . co m*/ * @param partitionBucket * @return RPCCommunicationProtocol */ private RPCCommunicationProtocol getRPCHandler(int partitionBucket) { if (this.rpcCommHandlers.get(partitionBucket) != null) { return this.rpcCommHandlers.get(partitionBucket); } int partition = PartitionRule.getPartition(partitionBucket); String addrPort = getDstWorkerManagerNameAndPort(partition); String[] tmp = addrPort.split(":"); String hostname = tmp[0]; int portNum = Integer.parseInt(tmp[1]); try { RPCCommunicationProtocol rPCHandler = (RPCCommunicationProtocol) RPC.getProxy( RPCCommunicationProtocol.class, RPCCommunicationProtocol.protocolVersion, new InetSocketAddress(hostname, portNum), new Configuration()); // LOG.info("Test") this.rpcCommHandlers.put(partitionBucket, rPCHandler); return rPCHandler; } catch (Exception e) { LOG.error("<Request For RPC Handler Error> For " + " <Partition> " + "(" + partitionBucket + ")"); throw new RuntimeException( "<Request For RPC Handler Error> For " + " <Partition> " + "(" + partitionBucket + ")", e); } // return null; }
From source file:com.chinamobile.bcbsp.comm.CommunicatorNew.java
License:Apache License
/** * Get Message Sending RPC Handler For Communication. * /* w w w . j a va2 s .c o m*/ * @param partitionBucket * @return RPCCommunicationProtocol */ private RPCCommunicationProtocol getSGARPCHandler(int targetPartition) { if (this.rpcMirrorHandlers.get(targetPartition) != null) { return this.rpcMirrorHandlers.get(targetPartition); } String addrPort = getDstWorkerManagerNameAndPort(targetPartition); String[] tmp = addrPort.split(":"); String hostname = tmp[0]; int portNum = Integer.parseInt(tmp[1]); try { RPCCommunicationProtocol rPCHandler = (RPCCommunicationProtocol) RPC.getProxy( RPCCommunicationProtocol.class, RPCCommunicationProtocol.protocolVersion, new InetSocketAddress(hostname, portNum), new Configuration()); // LOG.info("Test") this.rpcMirrorHandlers.put(targetPartition, rPCHandler); return rPCHandler; } catch (Exception e) { LOG.error("<Request For SGA RPC Handler Error> For " + " <Partition> " + "(" + targetPartition + ")"); throw new RuntimeException( "<Request For RPC Handler Error> For " + " <Partition> " + "(" + targetPartition + ")", e); } // return null; }
From source file:com.chinamobile.bcbsp.workermanager.WorkerAgentForJob.java
License:Apache License
/** * Get WorkerAgent BSPJobID./*ww w .j a va2s . c o m*/ * * @param addr * InetSocketAddress * @return BSPJobID */ protected WorkerAgentInterface getWorkerAgentConnection(InetSocketAddress addr) { WorkerAgentInterface worker; synchronized (this.workers) { worker = workers.get(addr); if (worker == null) { try { worker = (WorkerAgentInterface) RPC.getProxy(WorkerAgentInterface.class, BSPRPCProtocolVersion.versionID, addr, this.conf); } catch (IOException e) { // LOG.error("[getWorkerAgentConnection]", e); throw new RuntimeException("WorkerAgentForJob " + "getWorkerAgentConnection exception", e); } this.workers.put(addr, worker); } } return worker; }
From source file:com.chinamobile.bcbsp.workermanager.WorkerManager.java
License:Apache License
@Override public void setStaffAgentAddress(StaffAttemptID staffID, String addr) { if (this.runningStaffs.containsKey(staffID)) { StaffInProgress sip = this.runningStaffs.get(staffID); String[] addrs = addr.split(":"); InetSocketAddress address = new InetSocketAddress(addrs[0], Integer.parseInt(addrs[1])); WorkerAgentForStaffInterface staffAgent = null; try {// w w w .ja v a2 s . c o m staffAgent = (WorkerAgentForStaffInterface) RPC.getProxy(WorkerAgentForStaffInterface.class, WorkerAgentForStaffInterface.versionID, address, this.conf); } catch (IOException e) { LOG.error("[WorkerManager] caught: ", e); } sip.setStaffAgent(staffAgent); } }
From source file:com.chinamobile.bcbsp.workermanager.WorkerManager.java
License:Apache License
@Override public void process(WatchedEvent event) { LOG.info("now in process"); LOG.info("event type is " + event.getType()); try {// ww w.ja v a 2 s . co m if (event.getType().toString().equals("NodeDeleted")) { LOG.info("in NodeDeleted"); if (bspzk != null) { if (bspzk.equaltoStat(Constants.BSPCONTROLLER_STANDBY_LEADER, true)) { String standControllerAddr = getData(Constants.BSPCONTROLLER_LEADER); InetSocketAddress newStandbyAddr = NetUtils.createSocketAddr(standControllerAddr); if (!this.standbyControllerAddr.equals(newStandbyAddr)) { this.bspControllerAddr = this.standbyControllerAddr; this.standbyControllerAddr = newStandbyAddr; this.controllerClient = (ControllerProtocol) RPC.getProxy(ControllerProtocol.class, BSPRPCProtocolVersion.versionID, this.bspControllerAddr, conf); this.standbyControllerClient = (ControllerProtocol) RPC.getProxy( ControllerProtocol.class, BSPRPCProtocolVersion.versionID, this.standbyControllerAddr, conf); } LOG.info("now the active is " + this.bspControllerAddr.toString() + "and the standby is " + this.standbyControllerAddr.toString()); } } } else if (event.getType().toString().equals("NodeDataChanged")) { // watch the standby bspzk.exists(Constants.BSPCONTROLLER_STANDBY_LEADER, true); // establish the communication link to standby bsp master this.standbyControllerClient = (ControllerProtocol) RPC.getProxy(ControllerProtocol.class, BSPRPCProtocolVersion.versionID, this.standbyControllerAddr, conf); LOG.info("bspControllerAddr = " + bspControllerAddr + " standbyControllerAddr = " + standbyControllerAddr); if (!this.standbyControllerClient.register(workerMangerStatus)) { LOG.error("There is a problem in establishing communication" + " link with BSPController"); throw new IOException( "There is a problem in establishing" + " communication link with BSPController."); } else { LOG.info("have registed to standby bsp master"); } } } catch (Exception e) { LOG.error("problem happened when register to standby controller " + e.toString()); } }
From source file:com.dasasian.chok.client.NodeProxyManager.java
License:Apache License
public VersionedProtocol createNodeProxy(final String nodeName) throws IOException { LOG.debug("creating proxy for node: " + nodeName); String[] hostName_port = nodeName.split(":"); if (hostName_port.length != 2) { throw new RuntimeException("invalid node name format '" + nodeName + "' (It should be a host name with a port number devided by a ':')"); }//from w w w. ja v a2 s. c om final String hostName = hostName_port[0]; final String port = hostName_port[1]; final InetSocketAddress inetSocketAddress = new InetSocketAddress(hostName, Integer.parseInt(port)); VersionedProtocol proxy = RPC.getProxy(serverClass, 0L, inetSocketAddress, hadoopConf); LOG.debug(String.format("Created a proxy %s for %s:%s %s", Proxy.getInvocationHandler(proxy), hostName, port, inetSocketAddress)); return proxy; }
From source file:com.github.hdl.tensorflow.yarn.app.api.impl.pb.client.TensorFlowClusterPBClientImpl.java
License:Apache License
public TensorFlowClusterPBClientImpl(long clientVersion, InetSocketAddress addr, Configuration conf) throws IOException { RPC.setProtocolEngine(conf, TensorFlowClusterPB.class, ProtobufRpcEngine.class); proxy = (TensorFlowClusterPB) RPC.getProxy(TensorFlowClusterPB.class, clientVersion, addr, conf); }
From source file:common.DataNode.java
License:Apache License
public static InterDatanodeProtocol createInterDataNodeProtocolProxy(DatanodeID datanodeid, Configuration conf) throws IOException { InetSocketAddress addr = NetUtils.createSocketAddr(datanodeid.getHost() + ":" + datanodeid.getIpcPort()); if (InterDatanodeProtocol.LOG.isDebugEnabled()) { InterDatanodeProtocol.LOG.info("InterDatanodeProtocol addr=" + addr); }/*w w w .ja v a 2s . c o m*/ return (InterDatanodeProtocol) RPC.getProxy(InterDatanodeProtocol.class, InterDatanodeProtocol.versionID, addr, conf); }
From source file:de.hpi.fgis.hdrs.Peer.java
License:Apache License
public static NodeProtocol getNodeProxy(Configuration conf, InetSocketAddress addr) throws IOException { return (NodeProtocol) RPC.getProxy(NodeProtocol.class, ProtocolVersion.versionID, addr, conf); }