Java Code Examples for org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread#join()

The following examples show how to use org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread#join() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSerialReplicationFailover.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testKillRS() throws Exception {
  TableName tableName = TableName.valueOf(name.getMethodName());
  UTIL.getAdmin().createTable(
    TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder
      .newBuilder(CF).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build()).build());
  UTIL.waitTableAvailable(tableName);
  try (Table table = UTIL.getConnection().getTable(tableName)) {
    for (int i = 0; i < 100; i++) {
      table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
    }
  }
  RegionServerThread thread = UTIL.getMiniHBaseCluster().getRegionServerThreads().stream()
    .filter(t -> !t.getRegionServer().getRegions(tableName).isEmpty()).findFirst().get();
  thread.getRegionServer().abort("for testing");
  thread.join();
  try (Table table = UTIL.getConnection().getTable(tableName)) {
    for (int i = 100; i < 200; i++) {
      table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
    }
  }
  enablePeerAndWaitUntilReplicationDone(200);
  checkOrder(200);
}
 
Example 2
Source File: TestRegionServerCrashDisableWAL.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws InterruptedException, IOException {
  HMaster master = UTIL.getMiniHBaseCluster().stopMaster(0).getMaster();
  // Shutdown master before shutting down rs
  UTIL.waitFor(30000, () -> !master.isAlive());
  RegionServerThread thread = null;
  for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
    if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) {
      thread = t;
      break;
    }
  }
  // shutdown rs
  thread.getRegionServer().abort("For testing");
  thread.join();
  // restart master
  UTIL.getMiniHBaseCluster().startMaster();
  // make sure that we can schedule a SCP for the crashed server which WAL is disabled and bring
  // the region online.
  try (Table table =
    UTIL.getConnection().getTableBuilder(TABLE_NAME, null).setOperationTimeout(30000).build()) {
    table.put(new Put(Bytes.toBytes(1)).addColumn(CF, CQ, Bytes.toBytes(1)));
    assertEquals(1, Bytes.toInt(table.get(new Get(Bytes.toBytes(1))).getValue(CF, CQ)));
  }
}
 
Example 3
Source File: TestShutdownWhileWALBroken.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
  UTIL.createMultiRegionTable(TABLE_NAME, CF);
  try (Table table = UTIL.getConnection().getTable(TABLE_NAME)) {
    UTIL.loadTable(table, CF);
  }
  int numRegions = UTIL.getMiniHBaseCluster().getRegions(TABLE_NAME).size();
  RegionServerThread rst0 = UTIL.getMiniHBaseCluster().getRegionServerThreads().get(0);
  RegionServerThread rst1 = UTIL.getMiniHBaseCluster().getRegionServerThreads().get(1);
  HRegionServer liveRS;
  RegionServerThread toKillRSThread;
  if (rst1.getRegionServer().getRegions(TableName.META_TABLE_NAME).isEmpty()) {
    liveRS = rst0.getRegionServer();
    toKillRSThread = rst1;
  } else {
    liveRS = rst1.getRegionServer();
    toKillRSThread = rst0;
  }
  assertTrue(liveRS.getRegions(TABLE_NAME).size() < numRegions);
  UTIL.expireSession(toKillRSThread.getRegionServer().getZooKeeper(), false);
  UTIL.waitFor(30000, new ExplainingPredicate<Exception>() {

    @Override
    public boolean evaluate() throws Exception {
      return liveRS.getRegions(TABLE_NAME).size() == numRegions;
    }

    @Override
    public String explainFailure() throws Exception {
      return "Failover is not finished yet";
    }
  });
  toKillRSThread.getRegionServer().stop("Stop for test");
  // make sure that we can successfully quit
  toKillRSThread.join();
}
 
Example 4
Source File: TestShutdownWithNoRegionServer.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
public void test() throws InterruptedException {
  RegionServerThread t = UTIL.getMiniHBaseCluster().stopRegionServer(0);
  t.join();
}
 
Example 5
Source File: TestProcedurePriority.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
public void test() throws Exception {
  RegionServerThread rsWithMetaThread = UTIL.getMiniHBaseCluster().getRegionServerThreads()
    .stream().filter(t -> !t.getRegionServer().getRegions(TableName.META_TABLE_NAME).isEmpty())
    .findAny().get();
  HRegionServer rsNoMeta = UTIL.getOtherRegionServer(rsWithMetaThread.getRegionServer());
  FAIL = true;
  UTIL.getMiniHBaseCluster().killRegionServer(rsNoMeta.getServerName());
  // wait until all the worker thread are stuck, which means that the stuck checker will start to
  // add new worker thread.
  ProcedureExecutor<?> executor =
    UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
  UTIL.waitFor(60000, new ExplainingPredicate<Exception>() {

    @Override
    public boolean evaluate() throws Exception {
      return executor.getWorkerThreadCount() > CORE_POOL_SIZE;
    }

    @Override
    public String explainFailure() throws Exception {
      return "Stuck checker does not add new worker thread";
    }
  });
  UTIL.getMiniHBaseCluster().killRegionServer(rsWithMetaThread.getRegionServer().getServerName());
  rsWithMetaThread.join();
  FAIL = false;
  // verify that the cluster is back
  UTIL.waitUntilNoRegionsInTransition(480000);
  for (int i = 0; i < TABLE_COUNT; i++) {
    try (Table table = UTIL.getConnection().getTable(TableName.valueOf(TABLE_NAME_PREFIX + i))) {
      table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
    }
  }
  UTIL.waitFor(60000, new ExplainingPredicate<Exception>() {

    @Override
    public boolean evaluate() throws Exception {
      return executor.getWorkerThreadCount() == CORE_POOL_SIZE;
    }

    @Override
    public String explainFailure() throws Exception {
      return "The new workers do not timeout";
    }
  });
}