Package org.apache.hadoop.hbase.executor

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


      ServerName serverName)
  throws KeeperException, KeeperException.NodeExistsException {
    LOG.debug(zkw.prefix("Creating unassigned node for " +
      region.getEncodedName() + " in a CLOSING state"));

    RegionTransitionData data = new RegionTransitionData(
        EventType.M_ZK_REGION_CLOSING, region.getRegionName(), serverName);

    String node = getNodeName(zkw, region.getEncodedName());
    return ZKUtil.createAndWatch(zkw, node, data.getBytes());
  }
View Full Code Here


    byte [] existingBytes = ZKUtil.getDataNoWatch(zkw, node, stat);
    if (existingBytes == null) {
      // Node no longer exists.  Return -1. It means unsuccessful transition.
      return -1;
    }
    RegionTransitionData existingData =
      RegionTransitionData.fromBytes(existingBytes);

    // Verify it is the expected version
    if(expectedVersion != -1 && stat.getVersion() != expectedVersion) {
      LOG.warn(zkw.prefix("Attempt to transition the " +
        "unassigned node for " + encoded +
        " from " + beginState + " to " + endState + " failed, " +
        "the node existed but was version " + stat.getVersion() +
        " not the expected version " + expectedVersion));
        return -1;
    } else if (beginState.equals(EventType.M_ZK_REGION_OFFLINE)
        && endState.equals(EventType.RS_ZK_REGION_OPENING)
        && expectedVersion == -1 && stat.getVersion() != 0) {
      // the below check ensures that double assignment doesnot happen.
      // When the node is created for the first time then the expected version
      // that is passed will be -1 and the version in znode will be 0.
      // In all other cases the version in znode will be > 0.
      LOG.warn(zkw.prefix("Attempt to transition the " + "unassigned node for "
          + encoded + " from " + beginState + " to " + endState + " failed, "
          + "the node existed but was version " + stat.getVersion()
          + " not the expected version " + expectedVersion));
      return -1;
    }

    // Verify it is in expected state
    if(!existingData.getEventType().equals(beginState)) {
      LOG.warn(zkw.prefix("Attempt to transition the " +
        "unassigned node for " + encoded +
        " from " + beginState + " to " + endState + " failed, " +
        "the node existed but was in the state " + existingData.getEventType() +
        " set by the server " + serverName));
      return -1;
    }

    // Write new data, ensuring data has not changed since we last read it
    try {
      RegionTransitionData data = new RegionTransitionData(endState,
          region.getRegionName(), serverName, payload);
      if(!ZKUtil.setData(zkw, node, data.getBytes(), stat.getVersion())) {
        LOG.warn(zkw.prefix("Attempt to transition the " +
        "unassigned node for " + encoded +
        " from " + beginState + " to " + endState + " failed, " +
        "the node existed and was in the expected state but then when " +
        "setting data we got a version mismatch"));
View Full Code Here

      return false;
    } catch (KeeperException e) {
      throw e;
    }
    if (existingBytes == null) return false;
    RegionTransitionData existingData =
      RegionTransitionData.fromBytes(existingBytes);
    if (existingData.getEventType() == expectedState){
      return true;
    }
    return false;
  }
View Full Code Here

    region = enabledRegions.remove(0);
    regionsThatShouldBeOnline.add(region);
    ZKAssign.createNodeOffline(zkw, region, serverName);
    hrs.openRegion(region);
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw, region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        break;
      }
      Thread.sleep(100);
    }

    // Region of disable table was opened on RS
    region = disabledRegions.remove(0);
    regionsThatShouldBeOffline.add(region);
    ZKAssign.createNodeOffline(zkw, region, serverName);
    hrs.openRegion(region);
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw, region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        break;
      }
      Thread.sleep(100);
    }
View Full Code Here

    region = enabledRegions.remove(0);
    regionsThatShouldBeOnline.add(region);
    ZKAssign.createNodeOffline(zkw, region, deadServerName);
    hrsDead.openRegion(region);
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw, region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        break;
      }
      Thread.sleep(100);
    }
    LOG.debug("\n\nRegion of enabled table was OPENED on dead RS\n" +
        region + "\n\n");

    // Region of disabled table was opened on dead RS
    region = disabledRegions.remove(0);
    regionsThatShouldBeOffline.add(region);
    ZKAssign.createNodeOffline(zkw, region, deadServerName);
    hrsDead.openRegion(region);
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw, region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        break;
      }
      Thread.sleep(100);
    }
    LOG.debug("\n\nRegion of disabled table was OPENED on dead RS\n" +
        region + "\n\n");

    /*
     * ZK = NONE
     */

    // Region of enabled table was open at steady-state on dead RS
    region = enabledRegions.remove(0);
    regionsThatShouldBeOnline.add(region);
    ZKAssign.createNodeOffline(zkw, region, deadServerName);
    hrsDead.openRegion(region);
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw, region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        ZKAssign.deleteOpenedNode(zkw, region.getEncodedName());
        break;
      }
      Thread.sleep(100);
    }
    LOG.debug("\n\nRegion of enabled table was open at steady-state on dead RS"
        + "\n" + region + "\n\n");

    // Region of disabled table was open at steady-state on dead RS
    region = disabledRegions.remove(0);
    regionsThatShouldBeOffline.add(region);
    ZKAssign.createNodeOffline(zkw, region, deadServerName);
    hrsDead.openRegion(region);
    while (true) {
      RegionTransitionData rtd = ZKAssign.getData(zkw, region.getEncodedName());
      if (rtd != null && rtd.getEventType() == EventType.RS_ZK_REGION_OPENED) {
        ZKAssign.deleteOpenedNode(zkw, region.getEncodedName());
        break;
      }
      Thread.sleep(100);
    }
View Full Code Here

  boolean processRegionInTransition(final String encodedRegionName,
      final HRegionInfo regionInfo,
      final Map<String, List<Pair<HRegionInfo,Result>>> deadServers)
  throws KeeperException, IOException {
    Stat stat = new Stat();
    RegionTransitionData data = ZKAssign.getDataAndWatch(watcher,
        encodedRegionName, stat);
    if (data == null) return false;
    HRegionInfo hri = regionInfo;
    if (hri == null) {
      Pair<HRegionInfo, HServerAddress> p =
        MetaReader.getRegion(catalogTracker, data.getRegionName());
      if (p == null) return false;
      hri = p.getFirst();
    }
    processRegionsInTransition(data, hri, deadServers, stat.getVersion());
    return true;
View Full Code Here

  public void nodeCreated(String path) {
    if(path.startsWith(watcher.assignmentZNode)) {
      synchronized(regionsInTransition) {
        try {
          Stat stat = new Stat();
          RegionTransitionData data = ZKAssign.getDataAndWatch(watcher, path,
              stat);
          if(data == null) {
            return;
          }
          handleRegion(data, stat.getVersion());
View Full Code Here

  public void nodeDataChanged(String path) {
    if(path.startsWith(watcher.assignmentZNode)) {
      synchronized(regionsInTransition) {
        try {
          Stat stat = new Stat();
          RegionTransitionData data = ZKAssign.getDataAndWatch(watcher, path,
              stat);
          if(data == null) {
            return;
          }
          handleRegion(data, stat.getVersion());
View Full Code Here

        try {
          //Process with existing RS shutdown code 
          boolean assign =
            ServerShutdownHandler.processDeadRegion(regionInfo, result, this,
              this.catalogTracker);
          RegionTransitionData data = ZKAssign.getData(watcher, regionInfo.getEncodedName());
         
          //If zk node of this region has been updated by a live server,
          //we consider that this region is being handled.
          //So we should skip it and process it in processRegionsInTransition.
          if (data != null && data.getServerName() != null &&
            serverManager.isServerOnline(data.getServerName())){
              LOG.info("The region " + regionInfo.getEncodedName() +
                "is being handled on " + data.getServerName());
            continue;
          }
          if (assign) {
            ZKAssign.createOrForceNodeOffline(watcher, regionInfo,
              master.getServerName());
View Full Code Here

    regionOffline(parent);
    // Remove any CLOSING node, if exists, due to race between master & rs
    // for close & split.  Not putting into regionOffline method because it is
    // called from various locations.
    try {
      RegionTransitionData node = ZKAssign.getDataNoWatch(this.watcher,
        parent.getEncodedName(), null);
      if (node != null) {
        if (node.getEventType().equals(EventType.RS_ZK_REGION_CLOSING)) {
          ZKAssign.deleteClosingNode(this.watcher, parent);
        } else {
          LOG.warn("Split report has RIT node (shouldnt have one): " +
            parent + " node: " + node);
        }
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.