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


Java EventType类代码示例

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


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

示例1: verifyRegionState

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * Verifies that the specified region is in the specified state in ZooKeeper.
 * <p>
 * Returns true if region is in transition and in the specified state in
 * ZooKeeper.  Returns false if the region does not exist in ZK or is in
 * a different state.
 * <p>
 * Method synchronizes() with ZK so will yield an up-to-date result but is
 * a slow read.
 * @param zkw
 * @param region
 * @param expectedState
 * @return true if region exists and is in expected state
 */
public static boolean verifyRegionState(ZooKeeperWatcher zkw,
    HRegionInfo region, EventType expectedState)
throws KeeperException {
  String encoded = region.getEncodedName();

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

  // Read existing data of the node
  byte [] existingBytes = null;
  try {
    existingBytes = ZKUtil.getDataAndWatch(zkw, node);
  } catch (KeeperException.NoNodeException nne) {
    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;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:40,代码来源:ZKAssign.java

示例2: nodeChildrenChanged

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * New unassigned node has been created.
 *
 * <p>This happens when an RS begins the OPENING, SPLITTING or CLOSING of a
 * region by creating a znode.
 *
 * <p>When this happens we must:
 * <ol>
 *   <li>Watch the node for further children changed events</li>
 *   <li>Watch all new children for changed events</li>
 * </ol>
 */
@Override
public void nodeChildrenChanged(String path) {
  if(path.equals(watcher.assignmentZNode)) {
    try {
      List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(watcher,
          watcher.assignmentZNode);
      if (children != null) {
        Stat stat = new Stat();
        for (String child : children) {
          stat.setVersion(0);
          RegionTransitionData data = ZKAssign.getDataAndWatch(watcher,
              ZKUtil.joinZNode(watcher.assignmentZNode, child), stat);
          // See HBASE-7551, handle splitting here as well, in case we miss the node change event
          if (stat.getVersion() > 0 && data.getEventType() == EventType.RS_ZK_REGION_SPLITTING) {
            handleRegion(data, stat.getVersion());
          }
        }
      }
    } catch(KeeperException e) {
      master.abort("Unexpected ZK exception reading unassigned children", e);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:36,代码来源:AssignmentManager.java

示例3: isSplitOrSplitting

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * @param path
 * @return True if znode is in SPLIT or SPLITTING state.
 * @throws KeeperException Can happen if the znode went away in meantime.
 */
private boolean isSplitOrSplitting(final String path) throws KeeperException {
  boolean result = false;
  // This may fail if the SPLIT or SPLITTING znode gets cleaned up before we
  // can get data from it.
  RegionTransitionData data = ZKAssign.getData(master.getZooKeeper(), path);
  EventType evt = data.getEventType();
  switch (evt) {
  case RS_ZK_REGION_SPLIT:
  case RS_ZK_REGION_SPLITTING:
    result = true;
    break;
  default:
    break;
  }
  return result;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:22,代码来源:AssignmentManager.java

示例4: transitionZookeeperOfflineToOpening

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * Transition ZK node from OFFLINE to OPENING. The master will get a callback and will know that
 * the region is now ours.
 * @param hri HRegionInfo whose znode we are updating
 * @param versionOfOfflineNode Version Of OfflineNode that needs to be compared before changing
 *          the node's state from OFFLINE
 * @throws IOException
 */
int transitionZookeeperOfflineToOpening(final HRegionInfo hri, int versionOfOfflineNode)
    throws IOException {
  // TODO: should also handle transition from CLOSED?
  int version = -1;
  try {
    // Initialize the znode version.
    version =
        ZKAssign.transitionNode(this.zooKeeper, hri, this.getServerName(),
          EventType.M_ZK_REGION_OFFLINE, EventType.RS_ZK_REGION_OPENING, versionOfOfflineNode);
  } catch (KeeperException e) {
    LOG.error("Error transition from OFFLINE to OPENING for region=" + hri.getEncodedName(), e);
  }
  if (version == -1) {
    // TODO: Fix this sloppyness. The exception should be coming off zk
    // directly, not an
    // intepretation at this high-level (-1 when we call transitionNode can
    // mean many things).
    throw new IOException("Failed transition from OFFLINE to OPENING for region="
        + hri.getEncodedName());
  }
  return version;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:31,代码来源:HRegionServer.java

示例5: readFields

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
  // the event type byte
  eventType = EventType.values()[in.readShort()];
  // the timestamp
  stamp = in.readLong();
  // the encoded name of the region being transitioned
  regionName = Bytes.readByteArray(in);
  // remaining fields are optional so prefixed with boolean
  // the name of the regionserver sending the data
  if (in.readBoolean()) {
    byte [] versionedBytes = Bytes.readByteArray(in);
    this.origin = ServerName.parseVersionedServerName(versionedBytes);
  }
  if (in.readBoolean()) {
    this.payload = Bytes.readByteArray(in);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:19,代码来源:RegionTransitionData.java

示例6: modifyTable

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * Modify table is async so wait on completion of the table operation in master.
 * @param tableName
 * @param htd
 * @throws IOException
 */
private void modifyTable(final byte [] tableName, final HTableDescriptor htd)
throws IOException {
  MasterServices services = TEST_UTIL.getMiniHBaseCluster().getMaster();
  ExecutorService executor = services.getExecutorService();
  AtomicBoolean done = new AtomicBoolean(false);
  executor.registerListener(EventType.C_M_MODIFY_TABLE, new DoneListener(done));
  this.admin.modifyTable(tableName, htd);
  while (!done.get()) {
    synchronized (done) {
      try {
        done.wait(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  executor.unregisterListener(EventType.C_M_MODIFY_TABLE);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:25,代码来源:TestAdmin.java

示例7: testCloseRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
@Test (timeout=300000) public void testCloseRegion()
throws Exception {
  LOG.info("Running testCloseRegion");
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  LOG.info("Number of region servers = " + cluster.getLiveRegionServerThreads().size());

  int rsIdx = 0;
  HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(rsIdx);
  HRegionInfo hri = getNonMetaRegion(regionServer.getOnlineRegions());
  LOG.debug("Asking RS to close region " + hri.getRegionNameAsString());

  AtomicBoolean closeEventProcessed = new AtomicBoolean(false);
  EventHandlerListener listener =
    new CloseRegionEventListener(hri.getRegionNameAsString(),
        closeEventProcessed);
  cluster.getMaster().executorService.registerListener(EventType.RS_ZK_REGION_CLOSED, listener);

  cluster.getMaster().assignmentManager.unassign(hri);

  while (!closeEventProcessed.get()) {
    Threads.sleep(100);
  }
  LOG.info("Done with testCloseRegion");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:25,代码来源:TestZKBasedOpenCloseRegion.java

示例8: createNodeSplitting

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * Creates a new ephemeral node in the SPLITTING state for the specified region.
 * Create it ephemeral in case regionserver dies mid-split.
 *
 * <p>Does not transition nodes from other states.  If a node already exists
 * for this region, a {@link NodeExistsException} will be thrown.
 *
 * @param zkw zk reference
 * @param region region to be created as offline
 * @param serverName server event originates from
 * @return Version of znode created.
 * @throws KeeperException
 * @throws IOException
 */
// 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 {
  RegionTransitionData data =
    new RegionTransitionData(EventType.RS_ZK_REGION_SPLITTING,
      region.getRegionName(), serverName);

  String node = ZKAssign.getNodeName(zkw, region.getEncodedName());
  if (!ZKUtil.createEphemeralNodeAndWatch(zkw, node, data.getBytes())) {
    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);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:32,代码来源:TestAssignmentManager.java

示例9: OpenRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
private void OpenRegion(Server server, RegionServerServices rss,
      HTableDescriptor htd, HRegionInfo hri)
      throws IOException, NodeExistsException, KeeperException {
      // Create it OFFLINE node, which is what Master set before sending OPEN RPC


  ZKAssign.createNodeOffline(server.getZooKeeper(), hri, server.getServerName());
  int version = ZKAssign.transitionNodeOpening(server.getZooKeeper(), hri, server.getServerName());
  OpenRegionHandler openHandler = new OpenRegionHandler(server, rss, hri, htd, version);
  openHandler.process();
  RegionTransitionData data = ZKAssign.getData(server.getZooKeeper(), hri.getEncodedName());

  // delete the node, which is what Master do after the region is opened
  ZKAssign.deleteNode(server.getZooKeeper(), hri.getEncodedName(),
    EventType.RS_ZK_REGION_OPENED);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:17,代码来源:TestCloseRegionHandler.java

示例10: testFailedOpenRegion

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
@Test
public void testFailedOpenRegion() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = new MockRegionServerServices();

  // Create it OFFLINE, which is what it expects
  ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
  ZKAssign.transitionNodeOpening(server.getZooKeeper(), TEST_HRI, server.getServerName());

  // Create the handler
  OpenRegionHandler handler =
    new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
      @Override
      HRegion openRegion() {
        // Fake failure of opening a region due to an IOE, which is caught
        return null;
      }
  };
  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());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:TestOpenRegionHandler.java

示例11: testFailedUpdateMeta

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
@Test
public void testFailedUpdateMeta() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = new MockRegionServerServices();

  // Create it OFFLINE, which is what it expects
  ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
  ZKAssign.transitionNodeOpening(server.getZooKeeper(), TEST_HRI, server.getServerName());
  // Create the handler
  OpenRegionHandler handler =
    new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {
      @Override
      boolean updateMeta(final HRegion r) {
        // Fake failure of updating META
        return false;
      }
  };
  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());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:25,代码来源:TestOpenRegionHandler.java

示例12: transitionZookeeperOfflineToOpening

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * Transition ZK node from OFFLINE to OPENING. The master will get a callback
 * and will know that the region is now ours.
 *
 * @param hri
 *          HRegionInfo whose znode we are updating
 * @param versionOfOfflineNode
 *          Version Of OfflineNode that needs to be compared before changing
 *          the node's state from OFFLINE
 * @throws IOException
 */
int transitionZookeeperOfflineToOpening(final HRegionInfo hri, int versionOfOfflineNode)
    throws IOException {
  // TODO: should also handle transition from CLOSED?
  int version = -1;
  try {
    // Initialize the znode version.
    version = ZKAssign.transitionNode(this.zooKeeper, hri, this.getServerName(),
        EventType.M_ZK_REGION_OFFLINE, EventType.RS_ZK_REGION_OPENING, versionOfOfflineNode);
  } catch (KeeperException e) {
    LOG.error("Error transition from OFFLINE to OPENING for region=" + hri.getEncodedName(), e);
  }
  if (version == -1) {
    // TODO: Fix this sloppyness. The exception should be coming off zk
    // directly, not an
    // intepretation at this high-level (-1 when we call transitionNode can
    // mean many things).
    throw new IOException("Failed transition from OFFLINE to OPENING for region="
        + hri.getEncodedName());
  }
  return version;
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:33,代码来源:HRegionServer.java

示例13: createNodeSplitting

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
/**
 * Creates a new ephemeral node in the SPLITTING state for the specified region.
 * Create it ephemeral in case regionserver dies mid-split.
 *
 * <p>Does not transition nodes from other states.  If a node already exists
 * for this region, a {@link NodeExistsException} will be thrown.
 *
 * @param zkw zk reference
 * @param region region to be created as offline
 * @param serverName server event originates from
 * @return Version of znode created.
 * @throws KeeperException 
 * @throws IOException 
 */
private static int createNodeSplitting(final ZooKeeperWatcher zkw,
    final HRegionInfo region, final ServerName serverName)
throws KeeperException, IOException {
  LOG.debug(zkw.prefix("Creating ephemeral node for " +
    region.getEncodedName() + " in SPLITTING state"));
  RegionTransitionData data =
    new RegionTransitionData(EventType.RS_ZK_REGION_SPLITTING,
      region.getRegionName(), serverName);

  String node = ZKAssign.getNodeName(zkw, region.getEncodedName());
  if (!ZKUtil.createEphemeralNodeAndWatch(zkw, node, data.getBytes())) {
    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);
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:32,代码来源:SplitTransaction.java

示例14: createNodeOffline

import org.apache.hadoop.hbase.executor.EventHandler.EventType; //导入依赖的package包/类
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());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:11,代码来源:ZKAssign.java

示例15: deleteNode

import org.apache.hadoop.hbase.executor.EventHandler.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 regionName region to be deleted from zk
 * @param expectedState state region must be in for delete to complete
 * @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 regionName,
    EventType expectedState, int expectedVersion)
throws KeeperException, KeeperException.NoNodeException {
  LOG.debug(zkw.prefix("Deleting existing unassigned " +
    "node for " + regionName + " that is in expected state " + expectedState));
  String node = getNodeName(zkw, regionName);
  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);
  }
  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" +
      " 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 " + regionName + " in " + expectedState +
        " state but after verifying state, we got a version mismatch"));
    return false;
  }
  LOG.debug(zkw.prefix("Successfully deleted unassigned node for region " +
      regionName + " in expected state " + expectedState));
  return true;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:61,代码来源:ZKAssign.java


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