use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class MasterFailoverIT method test.
@Test
public void test() throws Exception {
Connector c = getConnector();
String[] names = getUniqueNames(2);
c.tableOperations().create(names[0]);
TestIngest.Opts opts = new TestIngest.Opts();
opts.setTableName(names[0]);
ClientConfiguration clientConf = cluster.getClientConfig();
if (clientConf.hasSasl()) {
opts.updateKerberosCredentials(clientConf);
} else {
opts.setPrincipal(getAdminPrincipal());
}
TestIngest.ingest(c, opts, new BatchWriterOpts());
ClusterControl control = cluster.getClusterControl();
control.stopAllServers(ServerType.MASTER);
// start up a new one
control.startAllServers(ServerType.MASTER);
// talk to it
c.tableOperations().rename(names[0], names[1]);
VerifyIngest.Opts vopts = new VerifyIngest.Opts();
vopts.setTableName(names[1]);
if (clientConf.hasSasl()) {
vopts.updateKerberosCredentials(clientConf);
} else {
vopts.setPrincipal(getAdminPrincipal());
}
VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class ReadWriteIT method sunnyDay.
@Test
public void sunnyDay() throws Exception {
// Start accumulo, create a table, insert some data, verify we can read it out.
// Shutdown cleanly.
log.debug("Starting Monitor");
cluster.getClusterControl().startAllServers(ServerType.MONITOR);
Connector connector = getConnector();
String tableName = getUniqueNames(1)[0];
ingest(connector, getCluster().getClientConfig(), getAdminPrincipal(), ROWS, COLS, 50, 0, tableName);
verify(connector, getCluster().getClientConfig(), getAdminPrincipal(), ROWS, COLS, 50, 0, tableName);
String monitorLocation = null;
while (null == monitorLocation) {
monitorLocation = MonitorUtil.getLocation(getConnector().getInstance());
if (null == monitorLocation) {
log.debug("Could not fetch monitor HTTP address from zookeeper");
Thread.sleep(2000);
}
}
String scheme = "http://";
if (getCluster() instanceof StandaloneAccumuloCluster) {
StandaloneAccumuloCluster standaloneCluster = (StandaloneAccumuloCluster) getCluster();
File accumuloSite = new File(standaloneCluster.getServerAccumuloConfDir(), "accumulo-site.xml");
if (accumuloSite.isFile()) {
Configuration conf = new Configuration(false);
conf.addResource(new Path(accumuloSite.toURI()));
String monitorSslKeystore = conf.get(Property.MONITOR_SSL_KEYSTORE.getKey());
if (null != monitorSslKeystore) {
log.info("Setting scheme to HTTPS since monitor ssl keystore configuration was observed in {}", accumuloSite);
scheme = "https://";
SSLContext ctx = SSLContext.getInstance("SSL");
TrustManager[] tm = new TrustManager[] { new TestTrustManager() };
ctx.init(new KeyManager[0], tm, new SecureRandom());
SSLContext.setDefault(ctx);
HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new TestHostnameVerifier());
}
} else {
log.info("{} is not a normal file, not checking for monitor running with SSL", accumuloSite);
}
}
URL url = new URL(scheme + monitorLocation);
log.debug("Fetching web page {}", url);
String result = FunctionalTestUtils.readAll(url.openStream());
assertTrue(result.length() > 100);
log.debug("Stopping accumulo cluster");
ClusterControl control = cluster.getClusterControl();
control.adminStopAll();
ZooReader zreader = new ZooReader(connector.getInstance().getZooKeepers(), connector.getInstance().getZooKeepersSessionTimeOut());
ZooCache zcache = new ZooCache(zreader, null);
byte[] masterLockData;
do {
masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(connector.getInstance()) + Constants.ZMASTER_LOCK, null);
if (null != masterLockData) {
log.info("Master lock is still held");
Thread.sleep(1000);
}
} while (null != masterLockData);
control.stopAllServers(ServerType.GARBAGE_COLLECTOR);
control.stopAllServers(ServerType.MONITOR);
control.stopAllServers(ServerType.TRACER);
log.debug("success!");
// Restarting everything
cluster.start();
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class StartIT method test.
@Test
public void test() throws Exception {
ClusterControl control = getCluster().getClusterControl();
assertNotEquals(0, control.exec(TestMain.class, new String[] { "exception" }));
assertEquals(0, control.exec(TestMain.class, new String[] { "success" }));
assertNotEquals(0, control.exec(TestMain.class, new String[0]));
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class RestartIT method restartMasterSplit.
@Test
public void restartMasterSplit() throws Exception {
Connector c = getConnector();
final String tableName = getUniqueNames(1)[0];
final AuthenticationToken token = getAdminToken();
final ClusterControl control = getCluster().getClusterControl();
VOPTS.setTableName(tableName);
c.tableOperations().create(tableName);
c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "5K");
final String[] args;
if (token instanceof PasswordToken) {
byte[] password = ((PasswordToken) token).getPassword();
args = new String[] { "-u", getAdminPrincipal(), "-p", new String(password, UTF_8), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", Integer.toString(VOPTS.rows), "--table", tableName };
OPTS.setPrincipal(getAdminPrincipal());
VOPTS.setPrincipal(getAdminPrincipal());
} else if (token instanceof KerberosToken) {
ClusterUser rootUser = getAdminUser();
args = new String[] { "-u", getAdminPrincipal(), "--keytab", rootUser.getKeytab().getAbsolutePath(), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", Integer.toString(VOPTS.rows), "--table", tableName };
ClientConfiguration clientConfig = cluster.getClientConfig();
OPTS.updateKerberosCredentials(clientConfig);
VOPTS.updateKerberosCredentials(clientConfig);
} else {
throw new RuntimeException("Unknown token");
}
Future<Integer> ret = svc.submit(new Callable<Integer>() {
@Override
public Integer call() {
try {
return control.exec(TestIngest.class, args);
} catch (Exception e) {
log.error("Error running TestIngest", e);
return -1;
}
}
});
control.stopAllServers(ServerType.MASTER);
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();
assertEquals(0, ret.get().intValue());
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
use of org.apache.accumulo.cluster.ClusterControl 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);
}
Aggregations