Search in sources :

Example 16 with ClientInfo

use of org.apache.accumulo.core.clientImpl.ClientInfo in project accumulo by apache.

the class RestartIT method restartManagerSplit.

@Test
public void restartManagerSplit() throws Exception {
    try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
        final String tableName = getUniqueNames(1)[0];
        final ClusterControl control = getCluster().getClusterControl();
        c.tableOperations().create(tableName);
        c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "5K");
        VerifyParams params = new VerifyParams(getClientProps(), tableName, 10_000);
        Future<Integer> ret = svc.submit(() -> {
            try {
                return control.exec(TestIngest.class, new String[] { "-c", cluster.getClientPropsPath(), "--rows", "" + params.rows, "--table", tableName });
            } catch (Exception e) {
                log.error("Error running TestIngest", e);
                return -1;
            }
        });
        control.stopAllServers(ServerType.MANAGER);
        ClientInfo info = ClientInfo.from(c.properties());
        ZooReader zreader = new ZooReader(info.getZooKeepers(), info.getZooKeepersSessionTimeOut());
        ZooCache zcache = new ZooCache(zreader, null);
        var zLockPath = ServiceLock.path(ZooUtil.getRoot(c.instanceOperations().getInstanceId()) + Constants.ZMANAGER_LOCK);
        byte[] managerLockData;
        do {
            managerLockData = ServiceLock.getLockData(zcache, zLockPath, null);
            if (managerLockData != null) {
                log.info("Manager lock is still held");
                Thread.sleep(1000);
            }
        } while (managerLockData != null);
        cluster.start();
        assertEquals(0, ret.get().intValue());
        VerifyIngest.verifyIngest(c, params);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) VerifyParams(org.apache.accumulo.test.VerifyIngest.VerifyParams) ClientInfo(org.apache.accumulo.core.clientImpl.ClientInfo) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache) IOException(java.io.IOException) ClusterControl(org.apache.accumulo.cluster.ClusterControl) Test(org.junit.Test)

Example 17 with ClientInfo

use of org.apache.accumulo.core.clientImpl.ClientInfo in project accumulo by apache.

the class RestartIT method restartManagerRecovery.

@Test
public void restartManagerRecovery() throws Exception {
    try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
        String tableName = getUniqueNames(1)[0];
        c.tableOperations().create(tableName);
        VerifyParams params = new VerifyParams(getClientProps(), tableName, 10_000);
        TestIngest.ingest(c, params);
        ClusterControl control = getCluster().getClusterControl();
        // TODO implement a kill all too?
        // cluster.stop() would also stop ZooKeeper
        control.stopAllServers(ServerType.MANAGER);
        control.stopAllServers(ServerType.TABLET_SERVER);
        control.stopAllServers(ServerType.GARBAGE_COLLECTOR);
        control.stopAllServers(ServerType.MONITOR);
        ClientInfo info = ClientInfo.from(c.properties());
        ZooReader zreader = new ZooReader(info.getZooKeepers(), info.getZooKeepersSessionTimeOut());
        ZooCache zcache = new ZooCache(zreader, null);
        var zLockPath = ServiceLock.path(ZooUtil.getRoot(c.instanceOperations().getInstanceId()) + Constants.ZMANAGER_LOCK);
        byte[] managerLockData;
        do {
            managerLockData = ServiceLock.getLockData(zcache, zLockPath, null);
            if (managerLockData != null) {
                log.info("Manager lock is still held");
                Thread.sleep(1000);
            }
        } while (managerLockData != null);
        cluster.start();
        sleepUninterruptibly(5, TimeUnit.MILLISECONDS);
        control.stopAllServers(ServerType.MANAGER);
        managerLockData = new byte[0];
        do {
            managerLockData = ServiceLock.getLockData(zcache, zLockPath, null);
            if (managerLockData != null) {
                log.info("Manager lock is still held");
                Thread.sleep(1000);
            }
        } while (managerLockData != null);
        cluster.start();
        VerifyIngest.verifyIngest(c, params);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) VerifyParams(org.apache.accumulo.test.VerifyIngest.VerifyParams) ClientInfo(org.apache.accumulo.core.clientImpl.ClientInfo) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache) ClusterControl(org.apache.accumulo.cluster.ClusterControl) Test(org.junit.Test)

Aggregations

ClientInfo (org.apache.accumulo.core.clientImpl.ClientInfo)17 Test (org.junit.Test)13 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)11 Properties (java.util.Properties)5 Text (org.apache.hadoop.io.Text)5 ClusterControl (org.apache.accumulo.cluster.ClusterControl)3 ZooCache (org.apache.accumulo.fate.zookeeper.ZooCache)3 ZooReader (org.apache.accumulo.fate.zookeeper.ZooReader)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 IOException (java.io.IOException)2 ClusterUser (org.apache.accumulo.cluster.ClusterUser)2 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)2 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)2 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)2 Mutation (org.apache.accumulo.core.data.Mutation)2 Range (org.apache.accumulo.core.data.Range)2 Authorizations (org.apache.accumulo.core.security.Authorizations)2 Pair (org.apache.accumulo.core.util.Pair)2 ServerContext (org.apache.accumulo.server.ServerContext)2 VerifyParams (org.apache.accumulo.test.VerifyIngest.VerifyParams)2