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


Java ZKAssign.createOrForceNodeOffline方法代码示例

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


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

示例1: setOfflineInZooKeeper

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Set region as OFFLINED up in zookeeper
 *
 * @param state
 * @return the version of the offline node if setting of the OFFLINE node was
 *         successful, -1 otherwise.
 */
private int setOfflineInZooKeeper(final RegionState state, final ServerName destination) {
  if (!state.isClosed() && !state.isOffline()) {
    String msg = "Unexpected state : " + state + " .. Cannot transit it to OFFLINE.";
    this.server.abort(msg, new IllegalStateException(msg));
    return -1;
  }
  regionStates.updateRegionState(state.getRegion(), State.OFFLINE);
  int versionOfOfflineNode;
  try {
    // get the version after setting the znode to OFFLINE
    versionOfOfflineNode = ZKAssign.createOrForceNodeOffline(watcher,
      state.getRegion(), destination);
    if (versionOfOfflineNode == -1) {
      LOG.warn("Attempted to create/force node into OFFLINE state before "
          + "completing assignment but failed to do so for " + state);
      return -1;
    }
  } catch (KeeperException e) {
    server.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
    return -1;
  }
  return versionOfOfflineNode;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:AssignmentManager.java

示例2: forceOffline

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Put the region <code>hri</code> into an offline state up in zk.
 * @param hri
 * @param oldData
 * @throws KeeperException
 */
private void forceOffline(final HRegionInfo hri,
    final RegionTransitionData oldData)
throws KeeperException {
  // If was on dead server, its closed now.  Force to OFFLINE and then
  // handle it like a close; this will get it reassigned if appropriate
  LOG.debug("RIT " + hri.getEncodedName() + " in state=" +
    oldData.getEventType() + " was on deadserver; forcing offline");
  ZKAssign.createOrForceNodeOffline(this.watcher, hri,
    this.master.getServerName());
  addToRITandCallClose(hri, RegionState.State.OFFLINE, oldData);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:AssignmentManager.java

示例3: setOfflineInZooKeeper

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Set region as OFFLINED up in zookeeper
 * 
 * @param state
 * @param hijack
 *          - true if needs to be hijacked and reassigned, false otherwise.
 * @param regionAlreadyInTransitionException  
 *          - true if we need to retry assignment because of RegionAlreadyInTransitionException.       
 * @return the version of the offline node if setting of the OFFLINE node was
 *         successful, -1 otherwise.
 */
int setOfflineInZooKeeper(final RegionState state, boolean hijack,
    boolean regionAlreadyInTransitionException) {
  // In case of reassignment the current state in memory need not be
  // OFFLINE. 
  if (!hijack && !state.isClosed() && !state.isOffline()) {
    if (!regionAlreadyInTransitionException ) {
      LOG.warn("Unexpected state : " + state + " .. Cannot transit it to OFFLINE.");
      return -1;
    } 
    LOG.debug("Unexpected state : " + state
        + " but retrying to assign because RegionAlreadyInTransitionException.");
  }
  boolean allowZNodeCreation = false;
  // Under reassignment if the current state is PENDING_OPEN
  // or OPENING then refresh the in-memory state to PENDING_OPEN. This is
  // important because if the region was in 
  // RS_OPENING state for a long time the master will try to force the znode
  // to OFFLINE state meanwhile the RS could have opened the corresponding
  // region and the state in znode will be RS_ZK_REGION_OPENED.
  // For all other cases we can change the in-memory state to OFFLINE.
  if (hijack &&
      (state.getState().equals(RegionState.State.PENDING_OPEN) || 
          state.getState().equals(RegionState.State.OPENING))) {
    state.update(RegionState.State.PENDING_OPEN);
    allowZNodeCreation = false;
  } else {
    state.update(RegionState.State.OFFLINE);
    allowZNodeCreation = true;
  }
  int versionOfOfflineNode = -1;
  try {
    // get the version after setting the znode to OFFLINE
    versionOfOfflineNode = ZKAssign.createOrForceNodeOffline(master.getZooKeeper(), 
        state.getRegion(), this.master.getServerName(),
        hijack, allowZNodeCreation);
    if (versionOfOfflineNode == -1) {
      LOG.warn("Attempted to create/force node into OFFLINE state before "
          + "completing assignment but failed to do so for " + state);
      return -1;
    }
  } catch (KeeperException e) {
    master.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
    return -1;
  }
  return versionOfOfflineNode;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:58,代码来源:AssignmentManager.java

示例4: processDeadServersAndRecoverLostRegions

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Processes list of dead servers from result of META scan and regions in RIT
 * <p>
 * This is used for failover to recover the lost regions that belonged to
 * RegionServers which failed while there was no active master or regions 
 * that were in RIT.
 * <p>
 * 
 * @param deadServers
 *          The list of dead servers which failed while there was no active
 *          master. Can be null.
 * @param nodes
 *          The regions in RIT
 * @throws IOException
 * @throws KeeperException
 */
private void processDeadServersAndRecoverLostRegions(
    Map<ServerName, List<Pair<HRegionInfo, Result>>> deadServers,
    List<String> nodes) throws IOException, KeeperException {
  if (null != deadServers) {
    Set<ServerName> actualDeadServers = this.serverManager.getDeadServers();
    for (Map.Entry<ServerName, List<Pair<HRegionInfo, Result>>> deadServer : 
      deadServers.entrySet()) {
      // skip regions of dead servers because SSH will process regions during rs expiration.
      // see HBASE-5916
      if (actualDeadServers.contains(deadServer.getKey())) {
        for (Pair<HRegionInfo, Result> deadRegion : deadServer.getValue()) {
          HRegionInfo hri = deadRegion.getFirst();
          // Delete znode of region in transition if table is disabled or disabling. If a region
          // server went down during master initialization then SSH cannot handle the regions of
          // partially disabled tables because in memory region state information may not be
          // available with master.
          deleteNodeAndOfflineRegion(hri);
          nodes.remove(deadRegion.getFirst().getEncodedName());
        }
        continue;
      }
      List<Pair<HRegionInfo, Result>> regions = deadServer.getValue();
      for (Pair<HRegionInfo, Result> region : regions) {
        HRegionInfo regionInfo = region.getFirst();
        Result result = region.getSecond();
        // If region was in transition (was in zk) force it offline for
        // reassign
        try {
          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.getOrigin() != null && 
              serverManager.isServerOnline(data.getOrigin())) {
            LOG.info("The region " + regionInfo.getEncodedName()
                + "is being handled on " + data.getOrigin());
            continue;
          }
          // Process with existing RS shutdown code
          boolean assign = ServerShutdownHandler.processDeadRegion(
              regionInfo, result, this, this.catalogTracker);
          if (assign) {
            ZKAssign.createOrForceNodeOffline(watcher, regionInfo,
                master.getServerName());
            if (!nodes.contains(regionInfo.getEncodedName())) {
              nodes.add(regionInfo.getEncodedName());
            }
          }
        } catch (KeeperException.NoNodeException nne) {
          // This is fine
        }
      }
    }
  }

  if (!nodes.isEmpty()) {
    for (String encodedRegionName : nodes) {
      processRegionInTransition(encodedRegionName, null, deadServers);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:81,代码来源:AssignmentManager.java


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