本文整理匯總了Java中org.apache.hadoop.ipc.RPC.Server方法的典型用法代碼示例。如果您正苦於以下問題:Java RPC.Server方法的具體用法?Java RPC.Server怎麽用?Java RPC.Server使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.ipc.RPC
的用法示例。
在下文中一共展示了RPC.Server方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newRpcServer
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
private static RPC.Server newRpcServer(
RaftServerProtocol serverProtocol, final Configuration conf)
throws IOException {
final int handlerCount = HadoopConfigKeys.Ipc.handlers(conf);
final InetSocketAddress address = HadoopConfigKeys.Ipc.address(conf);
final BlockingService service
= RaftServerProtocolService.newReflectiveBlockingService(
new RaftServerProtocolServerSideTranslatorPB(serverProtocol));
RPC.setProtocolEngine(conf, RaftServerProtocolPB.class, ProtobufRpcEngineShaded.class);
return new RPC.Builder(conf)
.setProtocol(RaftServerProtocolPB.class)
.setInstance(service)
.setBindAddress(address.getHostName())
.setPort(address.getPort())
.setNumHandlers(handlerCount)
.setVerbose(false)
.build();
}
示例2: main
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
RPC.Server server = RPC.getServer(new DemoServiceImpl(),
conf.get("server.ip.name"),
conf.getInt("name:port", 8888),
3,
true,
conf);
server.start();
// server.stop();
}
示例3: createServer
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
private Server createServer(Class<?> pbProtocol, InetSocketAddress addr, Configuration conf,
SecretManager<? extends TokenIdentifier> secretManager, int numHandlers,
BlockingService blockingService, String portRangeConfig) throws IOException {
RPC.setProtocolEngine(conf, pbProtocol, ProtobufRpcEngine.class);
RPC.Server server = new RPC.Builder(conf).setProtocol(pbProtocol)
.setInstance(blockingService).setBindAddress(addr.getHostName())
.setPort(addr.getPort()).setNumHandlers(numHandlers).setVerbose(false)
.setSecretManager(secretManager).setPortRangeConfig(portRangeConfig)
.build();
LOG.info("Adding protocol "+pbProtocol.getCanonicalName()+" to the server");
server.addProtocol(RPC.RpcKind.RPC_PROTOCOL_BUFFER, pbProtocol, blockingService);
return server;
}
示例4: getLifelineRpcServer
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
/** Allow access to the lifeline RPC server for testing */
@VisibleForTesting
RPC.Server getLifelineRpcServer() {
return lifelineRpcServer;
}
示例5: getClientRpcServer
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
/** Allow access to the client RPC server for testing */
@VisibleForTesting
RPC.Server getClientRpcServer() {
return clientRpcServer;
}
示例6: getServiceRpcServer
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
/** Allow access to the service RPC server for testing */
@VisibleForTesting
RPC.Server getServiceRpcServer() {
return serviceRpcServer;
}
示例7: addPBProtocol
import org.apache.hadoop.ipc.RPC; //導入方法依賴的package包/類
/**
* Add protobuf based protocol to the {@link org.apache.hadoop.ipc.RPC.Server}
* @param conf configuration
* @param protocol Protocol interface
* @param service service that implements the protocol
* @param server RPC server to which the protocol & implementation is added to
* @throws IOException
*/
public static void addPBProtocol(Configuration conf, Class<?> protocol,
BlockingService service, RPC.Server server) throws IOException {
RPC.setProtocolEngine(conf, protocol, ProtobufRpcEngine.class);
server.addProtocol(RPC.RpcKind.RPC_PROTOCOL_BUFFER, protocol, service);
}