Search in sources :

Example 1 with LlapProtocolClientImpl

use of org.apache.hadoop.hive.llap.impl.LlapProtocolClientImpl 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();
    }
}
Also used : LlapDaemonConfiguration(org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration) ContainerRunner(org.apache.hadoop.hive.llap.daemon.ContainerRunner) LlapDaemonConfiguration(org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration) Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) SubmitWorkRequestProto(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SubmitWorkRequestProto) SubmitWorkResponseProto(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SubmitWorkResponseProto) LlapProtocolClientImpl(org.apache.hadoop.hive.llap.impl.LlapProtocolClientImpl) LlapProtocolBlockingPB(org.apache.hadoop.hive.llap.protocol.LlapProtocolBlockingPB) Test(org.junit.Test)

Example 2 with LlapProtocolClientImpl

use of org.apache.hadoop.hive.llap.impl.LlapProtocolClientImpl 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;
}
Also used : LlapTokenIdentifier(org.apache.hadoop.hive.llap.security.LlapTokenIdentifier) PrivilegedAction(java.security.PrivilegedAction) Token(org.apache.hadoop.security.token.Token) LlapProtocolClientImpl(org.apache.hadoop.hive.llap.impl.LlapProtocolClientImpl) LlapProtocolBlockingPB(org.apache.hadoop.hive.llap.protocol.LlapProtocolBlockingPB) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

LlapProtocolClientImpl (org.apache.hadoop.hive.llap.impl.LlapProtocolClientImpl)2 LlapProtocolBlockingPB (org.apache.hadoop.hive.llap.protocol.LlapProtocolBlockingPB)2 InetSocketAddress (java.net.InetSocketAddress)1 PrivilegedAction (java.security.PrivilegedAction)1 Configuration (org.apache.hadoop.conf.Configuration)1 LlapDaemonConfiguration (org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration)1 ContainerRunner (org.apache.hadoop.hive.llap.daemon.ContainerRunner)1 SubmitWorkRequestProto (org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SubmitWorkRequestProto)1 SubmitWorkResponseProto (org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SubmitWorkResponseProto)1 LlapTokenIdentifier (org.apache.hadoop.hive.llap.security.LlapTokenIdentifier)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 Token (org.apache.hadoop.security.token.Token)1 Test (org.junit.Test)1