Java Code Examples for org.apache.hadoop.hbase.Server#isStopped()

The following examples show how to use org.apache.hadoop.hbase.Server#isStopped() . 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: IndexSplitTransaction.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Perform time consuming opening of the daughter regions.
 * @param server Hosting server instance.  Can be null when testing (won't try
 * and update in zk if a null server)
 * @param services Used to online/offline regions.
 * @param a first daughter region
 * @param a second daughter region
 * @throws IOException If thrown, transaction failed.
 *          Call {@link #rollback(Server, RegionServerServices)}
 */
/* package */void openDaughters(final Server server,
    final RegionServerServices services, HRegion a, HRegion b)
    throws IOException {
  boolean stopped = server != null && server.isStopped();
  boolean stopping = services != null && services.isStopping();
  // TODO: Is this check needed here?
  if (stopped || stopping) {
    LOG.info("Not opening daughters " +
        b.getRegionInfo().getRegionNameAsString() +
        " and " +
        a.getRegionInfo().getRegionNameAsString() +
        " because stopping=" + stopping + ", stopped=" + stopped);
  } else {
    // Open daughters in parallel.
    DaughterOpener aOpener = new DaughterOpener(server, a);
    DaughterOpener bOpener = new DaughterOpener(server, b);
    aOpener.start();
    bOpener.start();
    try {
      aOpener.join();
      bOpener.join();
    } catch (InterruptedException e) {
      throw (InterruptedIOException)new InterruptedIOException().initCause(e);
    }
    if (aOpener.getException() != null) {
      throw new IOException("Failed " +
        aOpener.getName(), aOpener.getException());
    }
    if (bOpener.getException() != null) {
      throw new IOException("Failed " +
        bOpener.getName(), bOpener.getException());
    }
    if (services != null) {
      try {
        // add 2nd daughter first (see HBASE-4335)
        services.postOpenDeployTasks(b);
        // Should add it to OnlineRegions
        services.addToOnlineRegions(b);
        services.postOpenDeployTasks(a);
        services.addToOnlineRegions(a);
      } catch (KeeperException ke) {
        throw new IOException(ke);
      }
    }
  }
}
 
Example 2
Source File: IndexSplitTransaction.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Finish off split transaction, transition the zknode
 * @param server Hosting server instance.  Can be null when testing (won't try
 * and update in zk if a null server)
 * @param services Used to online/offline regions.
 * @param a first daughter region
 * @param a second daughter region
 * @throws IOException If thrown, transaction failed.
 *          Call {@link #rollback(Server, RegionServerServices)}
 */
/* package */void transitionZKNode(final Server server,
    final RegionServerServices services, HRegion a, HRegion b)
    throws IOException {
  // Tell master about split by updating zk.  If we fail, abort.
  if (server != null && server.getZooKeeper() != null) {
    try {
      this.znodeVersion = transitionSplittingNode(server.getZooKeeper(),
        parent.getRegionInfo(), a.getRegionInfo(), b.getRegionInfo(),
        server.getServerName(), this.znodeVersion,
        RS_ZK_REGION_SPLITTING, RS_ZK_REGION_SPLIT);

      int spins = 0;
      // Now wait for the master to process the split. We know it's done
      // when the znode is deleted. The reason we keep tickling the znode is
      // that it's possible for the master to miss an event.
      do {
        if (spins % 10 == 0) {
          LOG.debug("Still waiting on the master to process the split for " +
              this.parent.getRegionInfo().getEncodedName());
        }
        Thread.sleep(100);
        // When this returns -1 it means the znode doesn't exist
        this.znodeVersion = transitionSplittingNode(server.getZooKeeper(),
          parent.getRegionInfo(), a.getRegionInfo(), b.getRegionInfo(),
          server.getServerName(), this.znodeVersion,
          RS_ZK_REGION_SPLIT, RS_ZK_REGION_SPLIT);
        spins++;
      } while (this.znodeVersion != -1 && !server.isStopped()
          && !services.isStopping());
    } catch (Exception e) {
      if (e instanceof InterruptedException) {
        Thread.currentThread().interrupt();
      }
      throw new IOException("Failed telling master about split", e);
    }
  }

  // Coprocessor callback
  if (this.parent.getCoprocessorHost() != null) {
    this.parent.getCoprocessorHost().postSplit(a,b);
  }

  // Leaving here, the splitdir with its dross will be in place but since the
  // split was successful, just leave it; it'll be cleaned when parent is
  // deleted and cleaned up.
}