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


Java ZKAssign.createNodeOffline方法代码示例

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


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

示例1: OpenRegion

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
private void OpenRegion(Server server, RegionServerServices rss,
    HTableDescriptor htd, HRegionInfo hri, OpenRegionCoordination coordination)
throws IOException, NodeExistsException, KeeperException, DeserializationException {
  // Create it OFFLINE node, which is what Master set before sending OPEN RPC
  ZKAssign.createNodeOffline(server.getZooKeeper(), hri, server.getServerName());

  OpenRegionCoordination.OpenRegionDetails ord =
    coordination.getDetailsForNonCoordinatedOpening();
  OpenRegionHandler openHandler =
    new OpenRegionHandler(server, rss, hri, htd, -1, coordination, ord);
  rss.getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);
  openHandler.process();
  // This parse is not used?
  RegionTransition.parseFrom(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, server.getServerName());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestCloseRegionHandler.java

示例2: testTransitionToFailedOpenFromOffline

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testTransitionToFailedOpenFromOffline() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = HTU.createMockRegionServerService(server.getServerName());
  // Create it OFFLINE, which is what it expects
  ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
  // Create the handler
  OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD) {

    @Override
    boolean transitionZookeeperOfflineToOpening(String encodedName, int versionOfOfflineNode) {
      return false;
    }
  };
  rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);

  handler.process();

  RegionTransition rt = RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
      TEST_HRI.getEncodedName()));
  assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:TestOpenRegionHandler.java

示例3: testFailedUpdateMeta

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的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

示例4: testMultipleOpen

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Test that we can send multiple openRegion to the region server.
 * This is used when:
 * - there is a SocketTimeout: in this case, the master does not know if the region server
 * received the request before the timeout.
 * - We have a socket error during the operation: same stuff: we don't know
 * - a master failover: if we find a znode in thz M_ZK_REGION_OFFLINE, we don't know if
 * the region server has received the query or not. Only solution to be efficient: re-ask
 * immediately.
 */
@Test(timeout = 60000)
public void testMultipleOpen() throws Exception {

  // We close
  closeNoZK();
  checkRegionIsClosed();

  // We reopen. We need a ZK node here, as a open is always triggered by a master.
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());

  // We're sending multiple requests in a row. The region server must handle this nicely.
  for (int i = 0; i < 10; i++) {
    AdminProtos.OpenRegionRequest orr = RequestConverter.buildOpenRegionRequest(getRS().getServerName(), hri, 0, null);
    AdminProtos.OpenRegionResponse responseOpen = getRS().openRegion(null, orr);
    Assert.assertTrue(responseOpen.getOpeningStateCount() == 1);

    AdminProtos.OpenRegionResponse.RegionOpeningState ors = responseOpen.getOpeningState(0);
    Assert.assertTrue("request " + i + " failed",
        ors.equals(AdminProtos.OpenRegionResponse.RegionOpeningState.OPENED) ||
            ors.equals(AdminProtos.OpenRegionResponse.RegionOpeningState.ALREADY_OPENED)
    );
  }

  checkRegionIsOpened();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:36,代码来源:TestRegionServerNoMaster.java

示例5: OpenRegion

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
private void OpenRegion(Server server, RegionServerServices rss,
    HTableDescriptor htd, HRegionInfo hri, OpenRegionCoordination coordination)
throws IOException, NodeExistsException, KeeperException, DeserializationException {
  // Create it OFFLINE node, which is what Master set before sending OPEN RPC
  ZKAssign.createNodeOffline(server.getZooKeeper(), hri, server.getServerName());

  OpenRegionCoordination.OpenRegionDetails ord =
    coordination.getDetailsForNonCoordinatedOpening();
  OpenRegionHandler openHandler =
    new OpenRegionHandler(server, rss, hri, htd, coordination, ord);
  rss.getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);
  openHandler.process();
  // This parse is not used?
  RegionTransition.parseFrom(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, server.getServerName());
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:19,代码来源:TestCloseRegionHandler.java

示例6: openRegion

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
private void openRegion(HRegionInfo hri) throws Exception {
  try {
    if (isRegionOpened(hri)) return;
  } catch (Exception e){}
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
  // first version is '0'
  AdminProtos.OpenRegionRequest orr = RequestConverter.buildOpenRegionRequest(
    getRS().getServerName(), hri, 0, null, null);
  AdminProtos.OpenRegionResponse responseOpen = getRS().getRSRpcServices().openRegion(null, orr);
  Assert.assertEquals(responseOpen.getOpeningStateCount(), 1);
  Assert.assertEquals(responseOpen.getOpeningState(0),
    AdminProtos.OpenRegionResponse.RegionOpeningState.OPENED);
  checkRegionIsOpened(hri);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestReplicasClient.java

示例7: createAndForceNodeToOpenedState

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Creates a znode with OPENED state.
 * @param TEST_UTIL
 * @param region
 * @param serverName
 * @return
 * @throws IOException
 * @throws org.apache.hadoop.hbase.ZooKeeperConnectionException
 * @throws KeeperException
 * @throws NodeExistsException
 */
public static ZooKeeperWatcher createAndForceNodeToOpenedState(
    HBaseTestingUtility TEST_UTIL, HRegion region,
    ServerName serverName) throws ZooKeeperConnectionException,
    IOException, KeeperException, NodeExistsException {
  ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL);
  ZKAssign.createNodeOffline(zkw, region.getRegionInfo(), serverName);
  int version = ZKAssign.transitionNodeOpening(zkw, region
      .getRegionInfo(), serverName);
  ZKAssign.transitionNodeOpened(zkw, region.getRegionInfo(), serverName,
      version);
  return zkw;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:HBaseTestingUtility.java

示例8: testRestartClusterAfterKill

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test (timeout=300000) public void testRestartClusterAfterKill()
throws Exception {
  UTIL.getConfiguration().setBoolean("hbase.assignment.usezk", true);
  UTIL.startMiniZKCluster();
  ZooKeeperWatcher zooKeeper =
    new ZooKeeperWatcher(UTIL.getConfiguration(), "cluster1", null, true);

  // create the unassigned region, throw up a region opened state for META
  String unassignedZNode = zooKeeper.assignmentZNode;
  ZKUtil.createAndFailSilent(zooKeeper, unassignedZNode);

  ServerName sn = ServerName.valueOf(HMaster.MASTER, 1, System.currentTimeMillis());

  ZKAssign.createNodeOffline(zooKeeper, HRegionInfo.FIRST_META_REGIONINFO, sn);

  LOG.debug("Created UNASSIGNED zNode for ROOT and hbase:meta regions in state " +
      EventType.M_ZK_REGION_OFFLINE);

  // start the HB cluster
  LOG.info("Starting HBase cluster...");
  UTIL.startMiniCluster(2);

  UTIL.createTable(TABLENAME, FAMILIES);
  LOG.info("Created a table, waiting for table to be available...");
  UTIL.waitTableAvailable(TABLENAME, 60*1000);

  LOG.info("Master deleted unassigned region and started up successfully.");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestRestartCluster.java

示例9: openRegion

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
public static void openRegion(HBaseTestingUtility HTU, HRegionServer rs, HRegionInfo hri)
    throws Exception {
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, rs.getServerName());
  // first version is '0'
  AdminProtos.OpenRegionRequest orr =
      RequestConverter.buildOpenRegionRequest(rs.getServerName(), hri, 0, null, null);
  AdminProtos.OpenRegionResponse responseOpen = rs.rpcServices.openRegion(null, orr);

  Assert.assertTrue(responseOpen.getOpeningStateCount() == 1);
  Assert.assertTrue(responseOpen.getOpeningState(0).
      equals(AdminProtos.OpenRegionResponse.RegionOpeningState.OPENED));


  checkRegionIsOpened(HTU, rs, hri);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TestRegionServerNoMaster.java

示例10: testMultipleOpen

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Test that we can send multiple openRegion to the region server.
 * This is used when:
 * - there is a SocketTimeout: in this case, the master does not know if the region server
 * received the request before the timeout.
 * - We have a socket error during the operation: same stuff: we don't know
 * - a master failover: if we find a znode in thz M_ZK_REGION_OFFLINE, we don't know if
 * the region server has received the query or not. Only solution to be efficient: re-ask
 * immediately.
 */
@Test(timeout = 60000)
public void testMultipleOpen() throws Exception {

  // We close
  closeRegionNoZK();
  checkRegionIsClosed(HTU, getRS(), hri);

  // We reopen. We need a ZK node here, as a open is always triggered by a master.
  ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());

  // We're sending multiple requests in a row. The region server must handle this nicely.
  for (int i = 0; i < 10; i++) {
    AdminProtos.OpenRegionRequest orr = RequestConverter.buildOpenRegionRequest(
      getRS().getServerName(), hri, 0, null, null);
    AdminProtos.OpenRegionResponse responseOpen = getRS().rpcServices.openRegion(null, orr);
    Assert.assertTrue(responseOpen.getOpeningStateCount() == 1);

    AdminProtos.OpenRegionResponse.RegionOpeningState ors = responseOpen.getOpeningState(0);
    Assert.assertTrue("request " + i + " failed",
        ors.equals(AdminProtos.OpenRegionResponse.RegionOpeningState.OPENED) ||
            ors.equals(AdminProtos.OpenRegionResponse.RegionOpeningState.ALREADY_OPENED)
    );
  }

  checkRegionIsOpened(HTU, getRS(), hri);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:37,代码来源:TestRegionServerNoMaster.java

示例11: testFailedOpenRegion

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testFailedOpenRegion() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = HTU.createMockRegionServerService();

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

  ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(server);
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(server.getServerName());

  // Create the handler
  OpenRegionHandler handler =
    new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD, -1,
      csm.getOpenRegionCoordination(), zkCrd) {
      @Override
      HRegion openRegion() {
        // Fake failure of opening a region due to an IOE, which is caught
        return null;
      }
  };
  rsServices.getRegionsInTransitionInRS().put(
    TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);
  handler.process();

  // Handler should have transitioned it to FAILED_OPEN
  RegionTransition rt = RegionTransition.parseFrom(
    ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName()));
  assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestOpenRegionHandler.java

示例12: testFailedUpdateMeta

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testFailedUpdateMeta() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = HTU.createMockRegionServerService();

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

  // Create the handler
  ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(server);
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(server.getServerName());

  OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD,
    -1, csm.getOpenRegionCoordination(), zkCrd) {
      @Override
      boolean updateMeta(final HRegion r, long masterSystemTime) {
        // Fake failure of updating META
        return false;
      }
  };
  rsServices.getRegionsInTransitionInRS().put(
    TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);
  handler.process();

  // Handler should have transitioned it to FAILED_OPEN
  RegionTransition rt = RegionTransition.parseFrom(
    ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName()));
  assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestOpenRegionHandler.java

示例13: testTransitionToFailedOpenEvenIfCleanupFails

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testTransitionToFailedOpenEvenIfCleanupFails() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = HTU.createMockRegionServerService();
  // Create it OFFLINE, which is what it expects
  ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
  // Create the handler
  ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(server);
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(server.getServerName());

  OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD,
    -1, csm.getOpenRegionCoordination(), zkCrd) {
    @Override
    boolean updateMeta(HRegion r, long masterSystemTime) {
      return false;
    };

    @Override
    void cleanupFailedOpen(HRegion region) throws IOException {
      throw new IOException("FileSystem got closed.");
    }
  };
  rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);
  try {
    handler.process();
  } catch (Exception e) {
    // Ignore the IOException that we have thrown from cleanupFailedOpen
  }
  RegionTransition rt = RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
      TEST_HRI.getEncodedName()));
  assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:TestOpenRegionHandler.java

示例14: testTransitionToFailedOpenFromOffline

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test
public void testTransitionToFailedOpenFromOffline() throws Exception {
  Server server = new MockServer(HTU);
  RegionServerServices rsServices = HTU.createMockRegionServerService(server.getServerName());
  // Create it OFFLINE, which is what it expects
  ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
  // Create the handler
  ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager();
  csm.initialize(server);
  csm.start();

  ZkOpenRegionCoordination.ZkOpenRegionDetails zkCrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkCrd.setServerName(server.getServerName());

  ZkOpenRegionCoordination openRegionCoordination =
    new ZkOpenRegionCoordination(csm, server.getZooKeeper()) {
    @Override
    public boolean transitionFromOfflineToOpening(HRegionInfo regionInfo,
                                                  OpenRegionDetails ord) {
      return false;
    }
  };

  OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD,
    -1, openRegionCoordination, zkCrd);
  rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);

  handler.process();

  RegionTransition rt = RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
      TEST_HRI.getEncodedName()));
  assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestOpenRegionHandler.java

示例15: createAndForceNodeToOpenedState

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Creates a znode with OPENED state.
 * @param TEST_UTIL
 * @param region
 * @param serverName
 * @return
 * @throws IOException
 * @throws ZooKeeperConnectionException
 * @throws KeeperException
 * @throws NodeExistsException
 */
public static ZooKeeperWatcher createAndForceNodeToOpenedState(
    HBaseTestingUtility TEST_UTIL, HRegion region,
    ServerName serverName) throws ZooKeeperConnectionException,
    IOException, KeeperException, NodeExistsException {
  ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL);
  ZKAssign.createNodeOffline(zkw, region.getRegionInfo(), serverName);
  int version = ZKAssign.transitionNodeOpening(zkw, region
      .getRegionInfo(), serverName);
  ZKAssign.transitionNodeOpened(zkw, region.getRegionInfo(), serverName,
      version);
  return zkw;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:24,代码来源:HBaseTestingUtility.java


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