本文整理汇总了Java中org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService类的典型用法代码示例。如果您正苦于以下问题:Java HAServiceProtocolService类的具体用法?Java HAServiceProtocolService怎么用?Java HAServiceProtocolService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HAServiceProtocolService类属于org.apache.hadoop.ha.proto.HAServiceProtocolProtos包,在下文中一共展示了HAServiceProtocolService类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAndGetRPCServerAddress
import org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService; //导入依赖的package包/类
private InetSocketAddress startAndGetRPCServerAddress(InetSocketAddress serverAddress) {
Configuration conf = new Configuration();
try {
RPC.setProtocolEngine(conf,
HAServiceProtocolPB.class, ProtobufRpcEngine.class);
HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
new HAServiceProtocolServerSideTranslatorPB(new MockHAProtocolImpl());
BlockingService haPbService = HAServiceProtocolService
.newReflectiveBlockingService(haServiceProtocolXlator);
Server server = new RPC.Builder(conf)
.setProtocol(HAServiceProtocolPB.class)
.setInstance(haPbService)
.setBindAddress(serverAddress.getHostName())
.setPort(serverAddress.getPort()).build();
server.start();
return NetUtils.getConnectAddress(server);
} catch (IOException e) {
return null;
}
}
示例2: start
import org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService; //导入依赖的package包/类
public void start() throws IOException {
Configuration jtConf = new Configuration(conf);
String logicalName = HAUtil.getLogicalName(jtConf);
String jtId = HAUtil.getJobTrackerId(jtConf);
HAUtil.setGenericConf(jtConf, logicalName, jtId, HAUtil.JOB_TRACKER_SPECIFIC_KEYS);
// Login HA daemon, if auth is not kerberos login() is a NOP
InetSocketAddress addr = HAUtil.getJtHaRpcAddress(conf, jtId);
String localMachine = addr.getHostName();
UserGroupInformation.setConfiguration(conf);
SecurityUtil.login(conf, JobTracker.JT_KEYTAB_FILE, JobTracker.JT_USER_NAME, localMachine);
// To avoid the JT from doing a new login() as re-login seems to be destructive
JobTracker.loggedIn = true;
//Using a thread outside of all login context to start/stop the JT
//otherwise the credentials of the UGI making the RPC call to activate
//get in the way breaking things.
jtRunner = new JobTrackerRunner();
jtRunner.start();
this.proto = new JobTrackerHAServiceProtocol(jtConf, jtRunner);
RPC.setProtocolEngine(conf, HAServiceProtocolPB.class,
ProtobufRpcEngine.class);
HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
new HAServiceProtocolServerSideTranslatorPB(proto);
BlockingService haPbService = HAServiceProtocolService
.newReflectiveBlockingService(haServiceProtocolXlator);
WritableRpcEngine.ensureInitialized();
InetSocketAddress rpcAddr = HAUtil.getJtHaRpcAddress(conf);
this.rpcServer = RPC.getServer(HAServiceProtocolPB.class, haPbService,
rpcAddr.getHostName(), rpcAddr.getPort(), conf);
// set service-level authorization security policy
if (conf.getBoolean(
CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false)) {
rpcServer.refreshServiceAcl(conf, new MapReducePolicyProvider());
}
this.rpcServer.start();
// set port in config
int port = rpcServer.getListenerAddress().getPort();
HAUtil.setJtHaRpcAddress(conf, rpcAddr.getHostName() + ":" + port);
LOG.info("Started " + getClass().getSimpleName() + " on port " + port);
}