@Override public void close() throws Exception { client.close(); }
@OnStopped public final void closeClient() throws KuduException { if (kuduClient != null) { getLogger().debug("Closing KuduClient"); kuduClient.close(); kuduClient = null; } }
@Override public void close() throws Exception { kuduSession.close(); kuduClient.close(); }
void close() throws KuduException { session.close(); client.close(); }
@Override public Token obtainToken() throws Exception { try { if (UserGroupInformation.getCurrentUser().isFromKeytab()) { // If we're using a keytab, we're probably in cluster mode // can we rely on Spark already having logged in at least once? UserGroupInformation.getCurrentUser().reloginFromKeytab(); } KuduClient client = new KuduClient.KuduClientBuilder(kuduMasterAddresses).build(); byte[] token = client.exportAuthenticationCredentials(); client.close(); LOG.debug("Obtained new Kudu token for {}", kuduMasterAddresses); return SecurityUtils.createToken(token); } catch (Exception e) { LOG.error("Could not obtain new security token from {}", kuduMasterAddresses); throw e; } }
@After public void tearDown() throws IOException { if (client != null) { client.close(); } if (miniCluster != null) { miniCluster.shutdown(); } }
public int run(int numMappers, long numNodes, int numTablets, Path tmpOutput, Integer width, Integer wrapMultiplier) throws Exception { parser = new CommandLineParser(getConf()); client = parser.getClient(); try { int ret = runRandomInputGenerator(numMappers, numNodes, tmpOutput, width, wrapMultiplier); if (ret > 0) { return ret; } return runGenerator(numMappers, numNodes, numTablets, tmpOutput, width, wrapMultiplier); } finally { client.close(); client = null; } }
} finally { if (c != null) { c.close();
/** * Test that, if an externally-provided subject is used when the client * is created, the client will not attempt to refresh anything, and will * eventually fail with appropriate warnings in the log. */ @Test(timeout=300000) public void testExternallyProvidedSubjectExpires() throws Exception { startCluster(ImmutableSet.of(Option.SHORT_TOKENS_AND_TICKETS)); Subject subject = SecurityUtil.getSubjectFromTicketCacheOrNull(); Assert.assertNotNull(subject); try (Closeable c = cla.attach()) { // Create a client attached to our own subject. KuduClient newClient = createClientFromSubject(subject); // It should not get auto-refreshed. try { assertEventualAuthenticationFailure(newClient, "server requires authentication, but " + "client Kerberos credentials (TGT) have expired"); } finally { newClient.close(); } } Assert.assertThat(cla.getAppendedText(), CoreMatchers.containsString( "Using caller-provided subject with Kerberos principal test-admin@KRBTEST.COM.")); Assert.assertThat(cla.getAppendedText(), CoreMatchers.containsString( "Caller-provided Subject has a Kerberos ticket that is about to expire")); }
/** * Test that the client properly falls back to the old GetMasterRegistration * RPC when connecting to a master which does not support the new * ConnectToMaster RPC. */ @Test(timeout=60000) public void testFallbackConnectRpc() throws Exception { MiniKuduCluster cluster = new MiniKuduCluster.MiniKuduClusterBuilder() .addMasterServerFlag("--master_support_connect_to_master_rpc=0") .numMasterServers(1) .numTabletServers(0) .build(); KuduClient c = null; try { c = new KuduClient.KuduClientBuilder(cluster.getMasterAddressesAsString()) .build(); // Call some method which uses the master. This forces us to connect // and verifies that the fallback works. c.listTabletServers(); } finally { if (c != null) { c.close(); } cluster.shutdown(); } }