Search in sources :

Example 11 with Abortable

use of org.apache.hadoop.hbase.Abortable in project hbase by apache.

the class TestTableCFsUpdater method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    TEST_UTIL.startMiniZKCluster();
    Configuration conf = TEST_UTIL.getConfiguration();
    abortable = new Abortable() {

        @Override
        public void abort(String why, Throwable e) {
            LOG.info(why, e);
        }

        @Override
        public boolean isAborted() {
            return false;
        }
    };
    zkw = new ZooKeeperWatcher(conf, "TableCFs", abortable, true);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Abortable(org.apache.hadoop.hbase.Abortable) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) BeforeClass(org.junit.BeforeClass)

Example 12 with Abortable

use of org.apache.hadoop.hbase.Abortable in project hbase by apache.

the class TestMasterCoprocessorExceptionWithAbort method testExceptionFromCoprocessorWhenCreatingTable.

@Test(timeout = 30000)
public void testExceptionFromCoprocessorWhenCreatingTable() throws IOException {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    BuggyMasterObserver cp = (BuggyMasterObserver) host.findCoprocessor(BuggyMasterObserver.class.getName());
    assertFalse("No table created yet", cp.wasCreateTableCalled());
    // set a watch on the zookeeper /hbase/master node. If the master dies,
    // the node will be deleted.
    ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(), "unittest", new Abortable() {

        @Override
        public void abort(String why, Throwable e) {
            throw new RuntimeException("Fatal ZK error: " + why, e);
        }

        @Override
        public boolean isAborted() {
            return false;
        }
    });
    MasterTracker masterTracker = new MasterTracker(zkw, "/hbase/master", new Abortable() {

        @Override
        public void abort(String why, Throwable e) {
            throw new RuntimeException("Fatal ZK master tracker error, why=", e);
        }

        @Override
        public boolean isAborted() {
            return false;
        }
    });
    masterTracker.start();
    zkw.registerListener(masterTracker);
    // Test (part of the) output that should have be printed by master when it aborts:
    // (namely the part that shows the set of loaded coprocessors).
    // In this test, there is only a single coprocessor (BuggyMasterObserver).
    assertTrue(HMaster.getLoadedCoprocessors().contains(TestMasterCoprocessorExceptionWithAbort.BuggyMasterObserver.class.getName()));
    CreateTableThread createTableThread = new CreateTableThread(UTIL);
    // Attempting to create a table (using createTableThread above) triggers an NPE in BuggyMasterObserver.
    // Master will then abort and the /hbase/master zk node will be deleted.
    createTableThread.start();
    // Wait up to 30 seconds for master's /hbase/master zk node to go away after master aborts.
    for (int i = 0; i < 30; i++) {
        if (masterTracker.masterZKNodeWasDeleted == true) {
            break;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            fail("InterruptedException while waiting for master zk node to " + "be deleted.");
        }
    }
    assertTrue("Master aborted on coprocessor exception, as expected.", masterTracker.masterZKNodeWasDeleted);
    createTableThread.interrupt();
    try {
        createTableThread.join(1000);
    } catch (InterruptedException e) {
        assertTrue("Ignoring InterruptedException while waiting for " + " createTableThread.join().", true);
    }
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) Abortable(org.apache.hadoop.hbase.Abortable) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 13 with Abortable

use of org.apache.hadoop.hbase.Abortable in project hbase by apache.

the class TestMetaWithReplicas method setup.

@Before
public void setup() throws Exception {
    TEST_UTIL.getConfiguration().setInt("zookeeper.session.timeout", 30000);
    TEST_UTIL.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3);
    TEST_UTIL.getConfiguration().setInt(StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, 1000);
    TEST_UTIL.startMiniCluster(3);
    // disable the balancer
    LoadBalancerTracker l = new LoadBalancerTracker(TEST_UTIL.getZooKeeperWatcher(), new Abortable() {

        boolean aborted = false;

        @Override
        public boolean isAborted() {
            return aborted;
        }

        @Override
        public void abort(String why, Throwable e) {
            aborted = true;
        }
    });
    l.setBalancerOn(false);
    for (int replicaId = 1; replicaId < 3; replicaId++) {
        HRegionInfo h = RegionReplicaUtil.getRegionInfoForReplica(HRegionInfo.FIRST_META_REGIONINFO, replicaId);
        TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().waitForAssignment(h);
    }
    LOG.debug("All meta replicas assigned");
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) LoadBalancerTracker(org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker) Abortable(org.apache.hadoop.hbase.Abortable) Before(org.junit.Before)

Example 14 with Abortable

use of org.apache.hadoop.hbase.Abortable in project hbase by apache.

the class TestMasterNoCluster method tearDown.

@After
public void tearDown() throws KeeperException, ZooKeeperConnectionException, IOException {
    // Make sure zk is clean before we run the next test.
    ZooKeeperWatcher zkw = new ZooKeeperWatcher(TESTUTIL.getConfiguration(), "@Before", new Abortable() {

        @Override
        public void abort(String why, Throwable e) {
            throw new RuntimeException(why, e);
        }

        @Override
        public boolean isAborted() {
            return false;
        }
    });
    ZKUtil.deleteNodeRecursively(zkw, zkw.znodePaths.baseZNode);
    zkw.close();
}
Also used : ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) Abortable(org.apache.hadoop.hbase.Abortable) After(org.junit.After)

Example 15 with Abortable

use of org.apache.hadoop.hbase.Abortable in project hbase by apache.

the class VerifyReplication method getPeerQuorumConfig.

private static Pair<ReplicationPeerConfig, Configuration> getPeerQuorumConfig(final Configuration conf) throws IOException {
    ZooKeeperWatcher localZKW = null;
    ReplicationPeerZKImpl peer = null;
    try {
        localZKW = new ZooKeeperWatcher(conf, "VerifyReplication", new Abortable() {

            @Override
            public void abort(String why, Throwable e) {
            }

            @Override
            public boolean isAborted() {
                return false;
            }
        });
        ReplicationPeers rp = ReplicationFactory.getReplicationPeers(localZKW, conf, localZKW);
        rp.init();
        Pair<ReplicationPeerConfig, Configuration> pair = rp.getPeerConf(peerId);
        if (pair == null) {
            throw new IOException("Couldn't get peer conf!");
        }
        return pair;
    } catch (ReplicationException e) {
        throw new IOException("An error occurred while trying to connect to the remove peer cluster", e);
    } finally {
        if (peer != null) {
            peer.close();
        }
        if (localZKW != null) {
            localZKW.close();
        }
    }
}
Also used : ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) Abortable(org.apache.hadoop.hbase.Abortable) ReplicationPeerZKImpl(org.apache.hadoop.hbase.replication.ReplicationPeerZKImpl) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) IOException(java.io.IOException) ReplicationPeers(org.apache.hadoop.hbase.replication.ReplicationPeers)

Aggregations

Abortable (org.apache.hadoop.hbase.Abortable)18 Test (org.junit.Test)12 Configuration (org.apache.hadoop.conf.Configuration)10 ExecutorService (java.util.concurrent.ExecutorService)7 Stoppable (org.apache.hadoop.hbase.Stoppable)7 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)7 StubAbortable (org.apache.phoenix.hbase.index.StubAbortable)7 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)6 HashMap (java.util.HashMap)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)5 Mutation (org.apache.hadoop.hbase.client.Mutation)5 Put (org.apache.hadoop.hbase.client.Put)5 ImmutableBytesPtr (org.apache.phoenix.hbase.index.util.ImmutableBytesPtr)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 IOException (java.io.IOException)3 Pair (org.apache.hadoop.hbase.util.Pair)3 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 MiniHBaseCluster (org.apache.hadoop.hbase.MiniHBaseCluster)2