use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class RestartIT method shutdownDuringCompactingSplitting.
@Test
public void shutdownDuringCompactingSplitting() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
VOPTS.setTableName(tableName);
ClientConfiguration clientConfig = cluster.getClientConfig();
if (clientConfig.hasSasl()) {
OPTS.updateKerberosCredentials(clientConfig);
VOPTS.updateKerberosCredentials(clientConfig);
} else {
OPTS.setPrincipal(getAdminPrincipal());
VOPTS.setPrincipal(getAdminPrincipal());
}
c.tableOperations().create(tableName);
c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K");
String splitThreshold = null;
for (Entry<String, String> entry : c.tableOperations().getProperties(tableName)) {
if (entry.getKey().equals(Property.TABLE_SPLIT_THRESHOLD.getKey())) {
splitThreshold = entry.getValue();
break;
}
}
Assert.assertNotNull(splitThreshold);
try {
c.tableOperations().setProperty(MetadataTable.NAME, Property.TABLE_SPLIT_THRESHOLD.getKey(), "20K");
TestIngest.Opts opts = new TestIngest.Opts();
opts.setTableName(tableName);
if (clientConfig.hasSasl()) {
opts.updateKerberosCredentials(clientConfig);
} else {
opts.setPrincipal(getAdminPrincipal());
}
TestIngest.ingest(c, opts, BWOPTS);
c.tableOperations().flush(tableName, null, null, false);
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
getCluster().stop();
} finally {
if (getClusterType() == ClusterType.STANDALONE) {
getCluster().start();
c.tableOperations().setProperty(MetadataTable.NAME, Property.TABLE_SPLIT_THRESHOLD.getKey(), splitThreshold);
}
}
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class RestartIT method restartMasterRecovery.
@Test
public void restartMasterRecovery() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
OPTS.setTableName(tableName);
VOPTS.setTableName(tableName);
ClientConfiguration clientConfig = cluster.getClientConfig();
if (clientConfig.hasSasl()) {
OPTS.updateKerberosCredentials(clientConfig);
VOPTS.updateKerberosCredentials(clientConfig);
} else {
OPTS.setPrincipal(getAdminPrincipal());
VOPTS.setPrincipal(getAdminPrincipal());
}
TestIngest.ingest(c, OPTS, BWOPTS);
ClusterControl control = getCluster().getClusterControl();
// TODO implement a kill all too?
// cluster.stop() would also stop ZooKeeper
control.stopAllServers(ServerType.MASTER);
control.stopAllServers(ServerType.TRACER);
control.stopAllServers(ServerType.TABLET_SERVER);
control.stopAllServers(ServerType.GARBAGE_COLLECTOR);
control.stopAllServers(ServerType.MONITOR);
ZooReader zreader = new ZooReader(c.getInstance().getZooKeepers(), c.getInstance().getZooKeepersSessionTimeOut());
ZooCache zcache = new ZooCache(zreader, null);
byte[] masterLockData;
do {
masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null);
if (null != masterLockData) {
log.info("Master lock is still held");
Thread.sleep(1000);
}
} while (null != masterLockData);
cluster.start();
sleepUninterruptibly(5, TimeUnit.MILLISECONDS);
control.stopAllServers(ServerType.MASTER);
masterLockData = new byte[0];
do {
masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null);
if (null != masterLockData) {
log.info("Master lock is still held");
Thread.sleep(1000);
}
} while (null != masterLockData);
cluster.start();
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class Shell method setInstance.
/**
* Sets the instance used by the shell based on the given options.
*
* @param options
* shell options
*/
protected void setInstance(ShellOptionsJC options) {
// should only be one set of instance options set
instance = null;
if (options.isFake()) {
instance = DeprecationUtil.makeMockInstance("fake");
} else {
String instanceName, hosts;
if (options.isHdfsZooInstance()) {
instanceName = hosts = null;
} else if (options.getZooKeeperInstance().size() > 0) {
List<String> zkOpts = options.getZooKeeperInstance();
instanceName = zkOpts.get(0);
hosts = zkOpts.get(1);
} else {
instanceName = options.getZooKeeperInstanceName();
hosts = options.getZooKeeperHosts();
}
final ClientConfiguration clientConf;
try {
clientConf = options.getClientConfiguration();
} catch (ConfigurationException | FileNotFoundException e) {
throw new IllegalArgumentException("Unable to load client config from " + options.getClientConfigFile(), e);
}
instance = getZooInstance(instanceName, hosts, clientConf);
}
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ShellOptionsJC method getClientConfiguration.
public ClientConfiguration getClientConfiguration() throws ConfigurationException, FileNotFoundException {
ClientConfiguration clientConfig = clientConfigFile == null ? ClientConfiguration.loadDefault() : ClientConfiguration.fromFile(new File(getClientConfigFile()));
if (useSsl()) {
clientConfig.setProperty(ClientProperty.INSTANCE_RPC_SSL_ENABLED, "true");
}
if (useSasl()) {
clientConfig.setProperty(ClientProperty.INSTANCE_RPC_SASL_ENABLED, "true");
}
if (!getZooKeeperInstance().isEmpty()) {
List<String> zkOpts = getZooKeeperInstance();
String instanceName = zkOpts.get(0);
String hosts = zkOpts.get(1);
clientConfig.setProperty(ClientProperty.INSTANCE_ZK_HOST, hosts);
clientConfig.setProperty(ClientProperty.INSTANCE_NAME, instanceName);
}
// If the user provided the hosts, set the ZK for tracing too
if (null != zooKeeperHosts && !zooKeeperHosts.isEmpty()) {
clientConfig.setProperty(ClientProperty.INSTANCE_ZK_HOST, zooKeeperHosts);
}
if (null != zooKeeperInstanceName && !zooKeeperInstanceName.isEmpty()) {
clientConfig.setProperty(ClientProperty.INSTANCE_NAME, zooKeeperInstanceName);
}
// Automatically try to add in the proper ZK from accumulo-site for backwards compat.
if (!clientConfig.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) {
AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
clientConfig.withZkHosts(siteConf.get(Property.INSTANCE_ZK_HOST));
}
return clientConfig;
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class ShellOptionsJC method getUsername.
public String getUsername() throws Exception {
if (null == username) {
final ClientConfiguration clientConf = getClientConfiguration();
if (Boolean.parseBoolean(clientConf.get(ClientProperty.INSTANCE_RPC_SASL_ENABLED))) {
if (!UserGroupInformation.isSecurityEnabled()) {
throw new RuntimeException("Kerberos security is not enabled");
}
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
username = ugi.getUserName();
} else {
username = System.getProperty("user.name", "root");
}
}
return username;
}
Aggregations