KuduConnection(Config config, byte[] token) { client = new KuduClient.KuduClientBuilder(config.getString(CONNECTION_CONFIG_NAME)).build(); if (token != null) { client.importAuthenticationCredentials(token); } session = client.newSession(); session.setFlushMode(SessionConfiguration.FlushMode.AUTO_FLUSH_BACKGROUND); session.setMutationBufferSpace(10000); session.setIgnoreAllDuplicateRows(KuduUtils.doesInsertIgnoreDuplicates(config)); }
/** * Test that a client is able to connect to masters using valid tokens * after all masters were killed and restarted, and before a leader is * elected. Leader election time is configured to be long enough using * '--leader_failure_max_missed_heartbeat_periods'. */ @Test public void testConnectToNonLeaderMasters() throws Exception { startCluster(ImmutableSet.of(Option.LONG_LEADER_ELECTION)); System.err.println("=> started cluster"); byte[] authnData = client.exportAuthenticationCredentials(); System.err.println("=> exported auth"); assertNotNull(authnData); String oldTicketCache = System.getProperty(SecurityUtil.KUDU_TICKETCACHE_PROPERTY); System.clearProperty(SecurityUtil.KUDU_TICKETCACHE_PROPERTY); try { KuduClient newClient = createClient(); newClient.importAuthenticationCredentials(authnData); System.err.println("=> imported auth"); miniCluster.killAllMasterServers(); miniCluster.startAllMasterServers(); newClient.listTabletServers(); System.err.println("=> listTabletServers"); } finally { System.setProperty(SecurityUtil.KUDU_TICKETCACHE_PROPERTY, oldTicketCache); } }
try { final KuduClient newClient = createClient(); newClient.importAuthenticationCredentials(authnData);
try { KuduClient newClient = createClient(); newClient.importAuthenticationCredentials(authnData);
newClient.importAuthenticationCredentials(authnData); KuduTable table = newClient.createTable(TABLE_NAME, getBasicSchema(), getBasicCreateTableOptions());
Client.AuthenticationCredentialsPB credentials = Client.AuthenticationCredentialsPB.newBuilder().setRealUser("token-user").build(); client.importAuthenticationCredentials(credentials.toByteArray()); client.listTabletServers();