Exemple #1
0
 /**
  * Contacts a region server and waits up to hbase.hbck.close.timeout ms (default 120s) to close
  * the region. This bypasses the active hmaster.
  */
 public static void closeRegionSilentlyAndWait(
     HBaseAdmin admin, ServerName server, HRegionInfo region)
     throws IOException, InterruptedException {
   HConnection connection = admin.getConnection();
   AdminService.BlockingInterface rs = connection.getAdmin(server);
   try {
     ProtobufUtil.closeRegion(rs, server, region.getRegionName(), false);
   } catch (IOException e) {
     LOG.warn("Exception when closing region: " + region.getRegionNameAsString(), e);
   }
   long timeout = admin.getConfiguration().getLong("hbase.hbck.close.timeout", 120000);
   long expiration = timeout + System.currentTimeMillis();
   while (System.currentTimeMillis() < expiration) {
     try {
       HRegionInfo rsRegion = ProtobufUtil.getRegionInfo(rs, region.getRegionName());
       if (rsRegion == null) return;
     } catch (IOException ioe) {
       return;
     }
     Thread.sleep(1000);
   }
   throw new IOException("Region " + region + " failed to close within" + " timeout " + timeout);
 }