use of org.apache.hadoop.hive.llap.protocol.LlapProtocolBlockingPB in project hive by apache.
the class TestLlapDaemonProtocolServerImpl method testSimpleCall.
@Test(timeout = 10000)
public void testSimpleCall() throws ServiceException, IOException {
LlapDaemonConfiguration daemonConf = new LlapDaemonConfiguration();
int numHandlers = HiveConf.getIntVar(daemonConf, ConfVars.LLAP_DAEMON_RPC_NUM_HANDLERS);
ContainerRunner containerRunnerMock = mock(ContainerRunner.class);
LlapProtocolServerImpl server = new LlapProtocolServerImpl(null, numHandlers, containerRunnerMock, new AtomicReference<InetSocketAddress>(), new AtomicReference<InetSocketAddress>(), 0, 0, null);
when(containerRunnerMock.submitWork(any(SubmitWorkRequestProto.class))).thenReturn(SubmitWorkResponseProto.newBuilder().setSubmissionState(SubmissionStateProto.ACCEPTED).build());
try {
server.init(new Configuration());
server.start();
InetSocketAddress serverAddr = server.getBindAddress();
LlapProtocolBlockingPB client = new LlapProtocolClientImpl(new Configuration(), serverAddr.getHostName(), serverAddr.getPort(), null, null, null);
SubmitWorkResponseProto responseProto = client.submitWork(null, SubmitWorkRequestProto.newBuilder().setAmHost("amhost").setAmPort(2000).build());
assertEquals(responseProto.getSubmissionState().name(), SubmissionStateProto.ACCEPTED.name());
} finally {
server.stop();
}
}
use of org.apache.hadoop.hive.llap.protocol.LlapProtocolBlockingPB in project hive by apache.
the class LlapProtocolClientProxy method getProxy.
private LlapProtocolBlockingPB getProxy(final LlapNodeId nodeId) {
String hostId = getHostIdentifier(nodeId.getHostname(), nodeId.getPort());
LlapProtocolBlockingPB proxy = hostProxies.get(hostId);
if (proxy == null) {
if (llapToken == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating a client without a token for " + nodeId);
}
proxy = new LlapProtocolClientImpl(getConfig(), nodeId.getHostname(), nodeId.getPort(), null, retryPolicy, socketFactory);
} else {
final UserGroupInformation ugi = UserGroupInformation.createRemoteUser(llapTokenUser);
// Clone the token as we'd need to set the service to the one we are talking to.
Token<LlapTokenIdentifier> nodeToken = new Token<LlapTokenIdentifier>(llapToken);
SecurityUtil.setTokenService(nodeToken, NetUtils.createSocketAddrForHost(nodeId.getHostname(), nodeId.getPort()));
ugi.addToken(nodeToken);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating a client for " + nodeId + "; the token is " + nodeToken);
}
proxy = ugi.doAs(new PrivilegedAction<LlapProtocolBlockingPB>() {
@Override
public LlapProtocolBlockingPB run() {
return new LlapProtocolClientImpl(getConfig(), nodeId.getHostname(), nodeId.getPort(), ugi, retryPolicy, socketFactory);
}
});
}
LlapProtocolBlockingPB proxyOld = hostProxies.putIfAbsent(hostId, proxy);
if (proxyOld != null) {
// TODO Shutdown the new proxy.
proxy = proxyOld;
}
}
return proxy;
}
use of org.apache.hadoop.hive.llap.protocol.LlapProtocolBlockingPB in project hive by apache.
the class LlapProtocolClientImpl method createProxy.
public LlapProtocolBlockingPB createProxy() throws IOException {
RPC.setProtocolEngine(conf, LlapProtocolBlockingPB.class, ProtobufRpcEngine.class);
LOG.info("Creating protocol proxy as " + ugi);
if (ugi == null)
return createProxyInternal();
try {
return ugi.doAs(new PrivilegedExceptionAction<LlapProtocolBlockingPB>() {
@Override
public LlapProtocolBlockingPB run() throws IOException {
return createProxyInternal();
}
});
} catch (InterruptedException e) {
throw new IOException(e);
}
}
Aggregations