public String locateTablet(String tableName, String splitName) { String tabletName = null; try { //${accumulo.VERSION.1.6}TabletLocator tc = TabletLocator.getLocator(instance, new Text(Tables.getTableId(instance, tableName))); // 1.6 change to getLocator for 1.6 ClientContext cc = new ClientContext(instance, new Credentials(principal, token), instance.getConfiguration()); // 1.7 // Change in API in 1.7 and 1.8 -- second parameter is String instead of Text String str = Tables.getTableId(instance, tableName); TabletLocator tc = getTabletLocator(cc, str); // use dynamic invocation to cross the API change org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation loc = //${accumulo.VERSION.1.6}tc.locateTablet(new Credentials(principal, token), new Text(splitName), false, false); // 1.6 tc.locateTablet(cc, new Text(splitName), false, false); // 1.7 tabletName = loc.tablet_location; log.debug("TableName="+tableName+", TABLET_NAME = "+tabletName); } catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) { log.warn("",e); e.printStackTrace(); } return tabletName; }
public MasterClientService.Client getMasterClient() throws TTransportException { //${accumulo.VERSION.1.6}return MasterClient.getConnection(getInstance()); // 1.6 return MasterClient.getConnection(new ClientContext(instance, new Credentials(principal, token), instance.getConfiguration())); // 1.7 }
public TabletClientService.Iface getTabletClient (String tserverAddress) throws TTransportException { com.google.common.net.HostAndPort address = AddressUtil.parseAddress(tserverAddress,false); //${accumulo.VERSION.1.6}return ThriftUtil.getTServerClient( tserverAddress, instance.getConfiguration()); // 1.6 return ThriftUtil.getTServerClient( address, new ClientContext(instance, new Credentials(principal, token), instance.getConfiguration())); // 1.7 }
private void checkTabletServerExists(ZooKeeperInstance inst, String userName, String password) throws ResourceException { ClientService.Client client = null; try { Pair<String,Client> pair = ServerClient.getConnection(new ClientContext(inst, new Credentials(userName, new PasswordToken(password)), inst.getConfiguration()), true, 10); client = pair.getSecond(); } catch (TTransportException e) { throw new ResourceException(AccumuloManagedConnectionFactory.UTIL.getString("no_tserver"), e); } finally { if (client != null) { ServerClient.close(client); } } }
private void checkTabletServerExists(ZooKeeperInstance inst, String userName, String password) throws ResourceException { ClientService.Client client = null; try { Pair<String,Client> pair = ServerClient.getConnection(new ClientContext(inst, new Credentials(userName, new PasswordToken(password)), inst.getConfiguration()), true, 10); client = pair.getSecond(); } catch (TTransportException e) { throw new ResourceException(AccumuloManagedConnectionFactory.UTIL.getString("no_tserver"), e); } finally { if (client != null) { ServerClient.close(client); } } }