Package org.apache.hadoop.hbase.executor

Examples of org.apache.hadoop.hbase.executor.RegionTransitionData


        }
    };
    handler.process();

    // Handler should have transitioned it to FAILED_OPEN
    RegionTransitionData data =
      ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName());
    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, data.getEventType());
  }
View Full Code Here


        }
    };
    handler.process();

    // Handler should have transitioned it to FAILED_OPEN
    RegionTransitionData data =
      ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName());
    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, data.getEventType());
  }
View Full Code Here

      ZKAssign.createNodeOffline(zkw, region, serverName);
      hrs.openRegion(region);

      int iTimes = 0;
      while (true) {
        RegionTransitionData rtd = ZKAssign.getData(zkw,
            region.getEncodedName());
        if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
          break;
        }
        Thread.sleep(100);
        iTimes++;
        if (iTimes >= REGION_ONLINE_TIMEOUT) {
View Full Code Here

      String path = ZKAssign.getNodeName(t.getConnection().getZooKeeperWatcher(),
        hri.getEncodedName());
      Stat stats =
        t.getConnection().getZooKeeperWatcher().getRecoverableZooKeeper().exists(path, false);
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats=" + stats);
      RegionTransitionData rtd =
        ZKAssign.getData(t.getConnection().getZooKeeperWatcher(),
          hri.getEncodedName());
      // State could be SPLIT or SPLITTING.
      assertTrue(rtd.getEventType().equals(EventType.RS_ZK_REGION_SPLIT) ||
        rtd.getEventType().equals(EventType.RS_ZK_REGION_SPLITTING));
      // Now crash the server
      cluster.abortRegionServer(tableRegionIndex);
      waitUntilRegionServerDead();

      // Wait till regions are back on line again.
View Full Code Here

          .getZooKeeperWatcher(), hri.getEncodedName());
      Stat stats = t.getConnection().getZooKeeperWatcher()
          .getRecoverableZooKeeper().exists(path, false);
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats="
          + stats);
      RegionTransitionData rtd = ZKAssign.getData(t.getConnection()
          .getZooKeeperWatcher(), hri.getEncodedName());
      // 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();
View Full Code Here

  public static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
      ServerName serverName, final EventType event)
  throws KeeperException, KeeperException.NodeExistsException {
    LOG.debug(zkw.prefix("Creating unassigned node for " +
      region.getEncodedName() + " in OFFLINE state"));
    RegionTransitionData data = new RegionTransitionData(event,
      region.getRegionName(), serverName);
    String node = getNodeName(zkw, region.getEncodedName());
    ZKUtil.createAndWatch(zkw, node, data.getBytes());
  }
View Full Code Here

      HRegionInfo region, ServerName serverName,
      final AsyncCallback.StringCallback cb, final Object ctx)
  throws KeeperException {
    LOG.debug(zkw.prefix("Async create of unassigned node for " +
      region.getEncodedName() + " with OFFLINE state"));
    RegionTransitionData data = new RegionTransitionData(
        EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
    String node = getNodeName(zkw, region.getEncodedName());
    ZKUtil.asyncCreate(zkw, node, data.getBytes(), cb, ctx);
  }
View Full Code Here

  public static void forceNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
      ServerName serverName)
  throws KeeperException, KeeperException.NoNodeException {
    LOG.debug(zkw.prefix("Forcing existing unassigned node for " +
      region.getEncodedName() + " to OFFLINE state"));
    RegionTransitionData data = new RegionTransitionData(
        EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
    String node = getNodeName(zkw, region.getEncodedName());
    ZKUtil.setData(zkw, node, data.getBytes());
  }
View Full Code Here

      HRegionInfo region, ServerName serverName,
      boolean hijack, boolean allowCreation)
  throws KeeperException {
    LOG.debug(zkw.prefix("Creating (or updating) unassigned node for " +
      region.getEncodedName() + " with OFFLINE state"));
    RegionTransitionData data = new RegionTransitionData(
        EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
    String node = getNodeName(zkw, region.getEncodedName());
    Stat stat = new Stat();
    zkw.sync(node);
    int version = ZKUtil.checkExists(zkw, node);
    if (version == -1) {
      // While trying to transit a node to OFFLINE that was in previously in
      // OPENING state but before it could transit to OFFLINE state if RS had
      // opened the region then the Master deletes the assigned region znode.
      // In that case the znode will not exist. So we should not
      // create the znode again which will lead to double assignment.
      if (hijack && !allowCreation) {
        return -1;
      }
      return ZKUtil.createAndWatch(zkw, node, data.getBytes());
    } else {
      RegionTransitionData curDataInZNode = ZKAssign.getDataNoWatch(zkw, region
          .getEncodedName(), stat);
      // Do not move the node to OFFLINE if znode is in any of the following
      // state.
      // Because these are already executed states.
      if (hijack && null != curDataInZNode) {
        EventType eventType = curDataInZNode.getEventType();
        if (eventType.equals(EventType.M_ZK_REGION_CLOSING)
            || eventType.equals(EventType.RS_ZK_REGION_CLOSED)
            || eventType.equals(EventType.RS_ZK_REGION_OPENED)) {
          return -1;
        }
      }

      boolean setData = false;
      try {
        setData = ZKUtil.setData(zkw, node, data.getBytes(), version);
        // Setdata throws KeeperException which aborts the Master. So we are
        // catching it here.
        // If just before setting the znode to OFFLINE if the RS has made any
        // change to the
        // znode state then we need to return -1.
      } catch (KeeperException kpe) {
        LOG.info("Version mismatch while setting the node to OFFLINE state.");
        return -1;
      }
      if (!setData) {
        return -1;
      } else {
        // We successfully forced to OFFLINE, reset watch and handle if
        // the state changed in between our set and the watch
        RegionTransitionData curData =
          ZKAssign.getData(zkw, region.getEncodedName());
        if (curData.getEventType() != data.getEventType()) {
          // state changed, need to process
          return -1;
        }
      }
    }
View Full Code Here

    byte [] bytes = ZKUtil.getDataNoWatch(zkw, node, stat);
    if (bytes == null) {
      // If it came back null, node does not exist.
      throw KeeperException.create(Code.NONODE);
    }
    RegionTransitionData data = RegionTransitionData.fromBytes(bytes);
    if (!data.getEventType().equals(expectedState)) {
      LOG.warn(zkw.prefix("Attempting to delete unassigned " +
        "node " + regionName + " in " + expectedState +
        " state but node is in " + data.getEventType() + " state"));
      return false;
    }
    if (expectedVersion != -1
        && stat.getVersion() != expectedVersion) {
      LOG.warn("The node " + regionName + " we are trying to delete is not" +
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.executor.RegionTransitionData

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.