当前位置: 首页>>代码示例>>Java>>正文


Java EventType.equals方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.executor.EventType.equals方法的典型用法代码示例。如果您正苦于以下问题:Java EventType.equals方法的具体用法?Java EventType.equals怎么用?Java EventType.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.executor.EventType的用法示例。


在下文中一共展示了EventType.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processAlreadyOpenedRegion

import org.apache.hadoop.hbase.executor.EventType; //导入方法依赖的package包/类
private void processAlreadyOpenedRegion(HRegionInfo region, ServerName sn) {
  // Remove region from in-memory transition and unassigned node from ZK
  // While trying to enable the table the regions of the table were
  // already enabled.
  LOG.debug("ALREADY_OPENED " + region.getRegionNameAsString()
    + " to " + sn);
  String encodedName = region.getEncodedName();
  
  //If use ZkForAssignment, region already Opened event should not be handled, 
  //leave it to zk event. See HBase-14407.
  if(useZKForAssignment){
    String node = ZKAssign.getNodeName(watcher, encodedName);
    Stat stat = new Stat();
    try {
      byte[] existingBytes = ZKUtil.getDataNoWatch(watcher, node, stat);
      if(existingBytes!=null){
        RegionTransition rt= RegionTransition.parseFrom(existingBytes);
        EventType et = rt.getEventType();
        if (et.equals(EventType.RS_ZK_REGION_OPENED)) {
          LOG.debug("ALREADY_OPENED " + region.getRegionNameAsString()
            + " and node in "+et+" state");
          return;
        }
      }
    } catch (KeeperException ke) {
      LOG.warn("Unexpected ZK exception getData " + node
        + " node for the region " + encodedName, ke);
    } catch (DeserializationException e) {
      LOG.warn("Get RegionTransition from zk deserialization failed! ", e);
    }
    
    deleteNodeInStates(encodedName, "offline", sn, EventType.M_ZK_REGION_OFFLINE);
  }
  
  regionStates.regionOnline(region, sn);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:37,代码来源:AssignmentManager.java

示例2: deleteNode

import org.apache.hadoop.hbase.executor.EventType; //导入方法依赖的package包/类
/**
 * Deletes an existing unassigned node that is in the specified state for the
 * specified region.
 *
 * <p>If a node does not already exist for this region, a
 * {@link org.apache.zookeeper.KeeperException.NoNodeException} will be thrown.
 *
 * <p>No watcher is set whether this succeeds or not.
 *
 * <p>Returns false if the node was not in the proper state but did exist.
 *
 * <p>This method is used when a region finishes opening/closing.
 * The Master acknowledges completion
 * of the specified regions transition to being closed/opened.
 *
 * @param zkw zk reference
 * @param encodedRegionName region to be deleted from zk
 * @param expectedState state region must be in for delete to complete
 * @param serverName the expected region transition target server name
 * @param expectedVersion of the znode that is to be deleted.
 *        If expectedVersion need not be compared while deleting the znode
 *        pass -1
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NoNodeException if node does not exist
 */
public static boolean deleteNode(ZooKeeperWatcher zkw, String encodedRegionName,
    EventType expectedState, ServerName serverName, int expectedVersion)
throws KeeperException, KeeperException.NoNodeException {
  if (LOG.isTraceEnabled()) {
    LOG.trace(zkw.prefix("Deleting existing unassigned " +
      "node " + encodedRegionName + " in expected state " + expectedState));
  }
  String node = getNodeName(zkw, encodedRegionName);
  zkw.sync(node);
  Stat stat = new Stat();
  byte [] bytes = ZKUtil.getDataNoWatch(zkw, node, stat);
  if (bytes == null) {
    // If it came back null, node does not exist.
    throw KeeperException.create(Code.NONODE);
  }
  RegionTransition rt = getRegionTransition(bytes);
  EventType et = rt.getEventType();
  if (!et.equals(expectedState)) {
    LOG.warn(zkw.prefix("Attempting to delete unassigned node " + encodedRegionName + " in " +
      expectedState + " state but node is in " + et + " state"));
    return false;
  }
  // Verify the server transition happens on is not changed
  if (serverName != null && !rt.getServerName().equals(serverName)) {
    LOG.warn(zkw.prefix("Attempting to delete unassigned node " + encodedRegionName
      + " with target " + serverName + " but node has " + rt.getServerName()));
    return false;
  }
  if (expectedVersion != -1
      && stat.getVersion() != expectedVersion) {
    LOG.warn("The node " + encodedRegionName + " we are trying to delete is not" +
      " the expected one. Got a version mismatch");
    return false;
  }
  if(!ZKUtil.deleteNode(zkw, node, stat.getVersion())) {
    LOG.warn(zkw.prefix("Attempting to delete " +
        "unassigned node " + encodedRegionName + " in " + expectedState +
        " state but after verifying state, we got a version mismatch"));
    return false;
  }
  LOG.debug(zkw.prefix("Deleted unassigned node " +
      encodedRegionName + " in expected state " + expectedState));
  return true;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:70,代码来源:ZKAssign.java

示例3: confirmNodeOpening

import org.apache.hadoop.hbase.executor.EventType; //导入方法依赖的package包/类
/**
 * Confirm an existing unassigned node for the specified region which is
 * currently in the OPENING state to be still in the OPENING state on
 * the specified server.
 *
 * <p>If for some reason the check fails, the method returns -1. Otherwise,
 * the version of the node (same as the expected version) is returned.
 *
 * <p>This method can fail and return -1 for three different reasons:
 * <ul><li>Unassigned node for this region does not exist</li>
 * <li>Unassigned node for this region is not in OPENING state</li>
 * <li>After verifying OPENING state, the server name or the version of the
 * doesn't match)</li>
 * </ul>
 *
 * <p>Does not set any watches.
 *
 * <p>This method should only be used by a RegionServer when initiating an
 * open of a region after receiving an OPEN RPC from the Master.
 *
 * @param zkw zk reference
 * @param region region to be transitioned to opening
 * @param serverName server transition happens on
 * @return version of node after transition, -1 if unsuccessful transition
 * @throws KeeperException if unexpected zookeeper exception
 */
public static int confirmNodeOpening(ZooKeeperWatcher zkw,
    HRegionInfo region, ServerName serverName, int expectedVersion)
throws KeeperException {

  String encoded = region.getEncodedName();
  if(LOG.isDebugEnabled()) {
    LOG.debug(zkw.prefix("Attempting to retransition opening state of node " +
        HRegionInfo.prettyPrint(encoded)));
  }

  String node = getNodeName(zkw, encoded);
  zkw.sync(node);

  // Read existing data of the node
  Stat stat = new Stat();
  byte [] existingBytes = ZKUtil.getDataNoWatch(zkw, node, stat);
  if (existingBytes == null) {
    // Node no longer exists.  Return -1. It means unsuccessful transition.
    return -1;
  }
  RegionTransition rt = getRegionTransition(existingBytes);

  // Verify it is the expected version
  if (expectedVersion != -1 && stat.getVersion() != expectedVersion) {
    LOG.warn(zkw.prefix("Attempt to retransition the opening state of the " +
        "unassigned node for " + encoded + " failed, " +
        "the node existed but was version " + stat.getVersion() +
        " not the expected version " + expectedVersion));
    return -1;
  }

  // Verify it is in expected state
  EventType et = rt.getEventType();
  if (!et.equals(EventType.RS_ZK_REGION_OPENING)) {
    String existingServer = (rt.getServerName() == null)
        ? "<unknown>" : rt.getServerName().toString();
    LOG.warn(zkw.prefix("Attempt to retransition the opening state of the unassigned node for "
        + encoded + " failed, the node existed but was in the state " + et +
        " set by the server " + existingServer));
    return -1;
  }

  return expectedVersion;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:71,代码来源:ZKAssign.java

示例4: deleteNode

import org.apache.hadoop.hbase.executor.EventType; //导入方法依赖的package包/类
/**
 * Deletes an existing unassigned node that is in the specified state for the
 * specified region.
 *
 * <p>If a node does not already exist for this region, a
 * {@link NoNodeException} will be thrown.
 *
 * <p>No watcher is set whether this succeeds or not.
 *
 * <p>Returns false if the node was not in the proper state but did exist.
 *
 * <p>This method is used when a region finishes opening/closing.
 * The Master acknowledges completion
 * of the specified regions transition to being closed/opened.
 *
 * @param zkw zk reference
 * @param encodedRegionName region to be deleted from zk
 * @param expectedState state region must be in for delete to complete
 * @param serverName the expected region transition target server name
 * @param expectedVersion of the znode that is to be deleted.
 *        If expectedVersion need not be compared while deleting the znode
 *        pass -1
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NoNodeException if node does not exist
 */
public static boolean deleteNode(ZooKeeperWatcher zkw, String encodedRegionName,
    EventType expectedState, ServerName serverName, int expectedVersion)
throws KeeperException, KeeperException.NoNodeException {
  if (LOG.isTraceEnabled()) {
  	LOG.trace(zkw.prefix("Deleting existing unassigned " +
    "node " + encodedRegionName + " in expected state " + expectedState));
  }
  String node = getNodeName(zkw, encodedRegionName);
  zkw.sync(node);
  Stat stat = new Stat();
  byte [] bytes = ZKUtil.getDataNoWatch(zkw, node, stat);
  if (bytes == null) {
    // If it came back null, node does not exist.
    throw KeeperException.create(Code.NONODE);
  }
  RegionTransition rt = getRegionTransition(bytes);
  EventType et = rt.getEventType();
  if (!et.equals(expectedState)) {
    LOG.warn(zkw.prefix("Attempting to delete unassigned node " + encodedRegionName + " in " +
      expectedState + " state but node is in " + et + " state"));
    return false;
  }
  // Verify the server transition happens on is not changed
  if (serverName != null && !rt.getServerName().equals(serverName)) {
    LOG.warn(zkw.prefix("Attempting to delete unassigned node " + encodedRegionName
      + " with target " + serverName + " but node has " + rt.getServerName()));
    return false;
  }
  if (expectedVersion != -1
      && stat.getVersion() != expectedVersion) {
    LOG.warn("The node " + encodedRegionName + " we are trying to delete is not" +
      " the expected one. Got a version mismatch");
    return false;
  }
  if(!ZKUtil.deleteNode(zkw, node, stat.getVersion())) {
    LOG.warn(zkw.prefix("Attempting to delete " +
        "unassigned node " + encodedRegionName + " in " + expectedState +
        " state but after verifying state, we got a version mismatch"));
    return false;
  }
  LOG.debug(zkw.prefix("Deleted unassigned node " +
      encodedRegionName + " in expected state " + expectedState));
  return true;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:70,代码来源:ZKAssign.java


注:本文中的org.apache.hadoop.hbase.executor.EventType.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。