Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.RegionTransition


    am.regionOnline(REGIONINFO, SERVERNAME_A);
    // adding region in pending close.
    am.getRegionStates().updateRegionState(
      REGIONINFO, State.SPLITTING, SERVERNAME_A);
    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
    RegionTransition data = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_SPLITTING,
        REGIONINFO.getRegionName(), SERVERNAME_A);
    String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
    // create znode in M_ZK_REGION_CLOSING state.
    ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

    try {
      processServerShutdownHandler(ct, am, regionSplitDone);
      // check znode deleted or not.
      // In both cases the znode should be deleted.
View Full Code Here


    if (state == Table.State.DISABLING) {
      am.getZKTable().setDisablingTable(REGIONINFO.getTable());
    } else {
      am.getZKTable().setDisabledTable(REGIONINFO.getTable());
    }
    RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
        REGIONINFO.getRegionName(), SERVERNAME_A);
    // RegionTransitionData data = new
    // RegionTransitionData(EventType.M_ZK_REGION_CLOSING,
    // REGIONINFO.getRegionName(), SERVERNAME_A);
    String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
    // create znode in M_ZK_REGION_CLOSING state.
    ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

    try {
      processServerShutdownHandler(ct, am, false);
      // check znode deleted or not.
      // In both cases the znode should be deleted.
View Full Code Here

      this.server, this.serverManager);
    ZKAssign.createNodeOffline(this.watcher, REGIONINFO, SERVERNAME_A);
    int version = ZKAssign.getVersion(this.watcher, REGIONINFO);
    ZKAssign.transitionNode(this.watcher, REGIONINFO, SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, version);
    RegionTransition rt = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_OPENING,
        REGIONINFO.getRegionName(), SERVERNAME_A, HConstants.EMPTY_BYTE_ARRAY);
    version = ZKAssign.getVersion(this.watcher, REGIONINFO);
    Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(false);
    am.getRegionStates().logSplit(SERVERNAME_A); // Assume log splitting is done
    am.getRegionStates().createRegionState(REGIONINFO);
View Full Code Here

  // Copied from SplitTransaction rather than open the method over there in
  // the regionserver package.
  private static int createNodeSplitting(final ZooKeeperWatcher zkw,
      final HRegionInfo region, final ServerName serverName)
  throws KeeperException, IOException {
    RegionTransition rt =
      RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_SPLITTING,
        region.getRegionName(), serverName);

    String node = ZKAssign.getNodeName(zkw, region.getEncodedName());
    if (!ZKUtil.createEphemeralNodeAndWatch(zkw, node, rt.toByteArray())) {
      throw new IOException("Failed create of ephemeral " + node);
    }
    // Transition node from SPLITTING to SPLITTING and pick up version so we
    // can be sure this znode is ours; version is needed deleting.
    return transitionNodeSplitting(zkw, region, serverName, -1);
View Full Code Here

        byte [] data = ZKAssign.getDataNoWatch(zkw, node, stat);
        if (data == null) {
          throw new IOException("Data is null, merging node "
            + node + " no longer exists");
        }
        RegionTransition rt = RegionTransition.parseFrom(data);
        EventType et = rt.getEventType();
        if (et == RS_ZK_REGION_MERGING) {
          ServerName serverName = rt.getServerName();
          if (!serverName.equals(expectedServer)) {
            throw new IOException("Merging node " + node + " is for "
              + serverName + ", not us " + expectedServer);
          }
          byte [] payloadOfMerging = rt.getPayload();
          List<HRegionInfo> mergingRegions = HRegionInfo.parseDelimitedFrom(
            payloadOfMerging, 0, payloadOfMerging.length);
          assert mergingRegions.size() == 3;
          HRegionInfo a = mergingRegions.get(1);
          HRegionInfo b = mergingRegions.get(2);
View Full Code Here

      final ServerName serverName, final HRegionInfo a,
      final HRegionInfo b) throws KeeperException, IOException {
    LOG.debug(zkw.prefix("Creating ephemeral node for "
      + region.getEncodedName() + " in PENDING_MERGE state"));
    byte [] payload = HRegionInfo.toDelimitedByteArray(region, a, b);
    RegionTransition rt = RegionTransition.createRegionTransition(
      RS_ZK_REQUEST_REGION_MERGE, region.getRegionName(), serverName, payload);
    String node = ZKAssign.getNodeName(zkw, region.getEncodedName());
    if (!ZKUtil.createEphemeralNodeAndWatch(zkw, node, rt.toByteArray())) {
      throw new IOException("Failed create of ephemeral " + node);
    }
  }
View Full Code Here

      // Get daughters
      List<HRegion> daughters = checkAndGetDaughters(tableName);
      // Assert the ephemeral node is up in zk.
      String path = ZKAssign.getNodeName(TESTING_UTIL.getZooKeeperWatcher(),
        hri.getEncodedName());
      RegionTransition rt = null;
      Stat stats = null;
      // Wait till the znode moved to SPLIT
      for (int i=0; i<100; i++) {
        stats = TESTING_UTIL.getZooKeeperWatcher().getRecoverableZooKeeper().exists(path, false);
        rt = RegionTransition.parseFrom(ZKAssign.getData(TESTING_UTIL.getZooKeeperWatcher(),
          hri.getEncodedName()));
        if (rt.getEventType().equals(EventType.RS_ZK_REGION_SPLIT)) break;
        Thread.sleep(100);
      }
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats=" + stats);
      assertTrue(rt != null && rt.getEventType().equals(EventType.RS_ZK_REGION_SPLIT));
      // Now crash the server
      cluster.abortRegionServer(tableRegionIndex);
      waitUntilRegionServerDead();
      awaitDaughters(tableName, daughters.size());
View Full Code Here

      String path = ZKAssign.getNodeName(zkw, hri.getEncodedName());
      Stat stats = zkw.getRecoverableZooKeeper().exists(path, false);
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats="
          + stats);
      byte[] bytes = ZKAssign.getData(zkw, hri.getEncodedName());
      RegionTransition rtd = RegionTransition.parseFrom(bytes);
      // State could be SPLIT or SPLITTING.
      assertTrue(rtd.getEventType().equals(EventType.RS_ZK_REGION_SPLIT)
          || rtd.getEventType().equals(EventType.RS_ZK_REGION_SPLITTING));

      // abort and wait for new master.
      MockMasterWithoutCatalogJanitor master = abortAndWaitForMaster();

      this.admin = new HBaseAdmin(TESTING_UTIL.getConfiguration());
View Full Code Here

         new CloseRegionHandler(server, rss, hri, false, true,
         versionOfClosingNode+1);
       handler.process();
  
       // Handler should remain in M_ZK_REGION_CLOSING
       RegionTransition rt =
         RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName()));
       assertTrue(rt.getEventType().equals(EventType.M_ZK_REGION_CLOSING ));
     }
View Full Code Here

       CloseRegionHandler handler =
         new CloseRegionHandler(server, rss, hri, false, true,
         versionOfClosingNode);
       handler.process();
       // Handler should have transitioned it to RS_ZK_REGION_CLOSED
       RegionTransition rt = RegionTransition.parseFrom(
         ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName()));
       assertTrue(rt.getEventType().equals(EventType.RS_ZK_REGION_CLOSED));
     }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.RegionTransition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.