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


Java ZKAssign.transitionNodeClosed方法代码示例

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


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

示例1: testBalanceOnMasterFailoverScenarioWithOpenedNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Test a balance going on at same time as a master failover
 *
 * @throws IOException
 * @throws KeeperException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithOpenedNode()
    throws IOException, KeeperException, InterruptedException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    Mocking.waitForRegionOfflineInRIT(am, REGIONINFO.getEncodedName());

    // Get the OFFLINE version id.  May have to wait some for it to happen.
    // OPENING below
    while (true) {
      int vid = ZKAssign.getVersion(this.watcher, REGIONINFO);
      if (vid != versionid) {
        versionid = vid;
        break;
      }
    }
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
      SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
      SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    am.gate.set(false);
    // Block here until our znode is cleared or until this test times out.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:54,代码来源:TestAssignmentManager.java

示例2: testBalanceOnMasterFailoverScenarioWithClosedNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithClosedNode()
    throws IOException, KeeperException, InterruptedException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    am.gate.set(false);
    Mocking.waitForRegionOfflineInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    while (true) {
      int vid = ZKAssign.getVersion(this.watcher, REGIONINFO);
      if (vid != versionid) {
        versionid = vid;
        break;
      }
    }
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
        SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
        SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);

    // Block here until our znode is cleared or until this test timesout.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:48,代码来源:TestAssignmentManager.java

示例3: testBalanceOnMasterFailoverScenarioWithOfflineNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithOfflineNode()
    throws IOException, KeeperException, InterruptedException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    Mocking.waitForRegionOfflineInRIT(am, REGIONINFO.getEncodedName());

    am.gate.set(false);
    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    while (true) {
      int vid = ZKAssign.getVersion(this.watcher, REGIONINFO);
      if (vid != versionid) {
        versionid = vid;
        break;
      }
    }
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
        SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
        SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    // Block here until our znode is cleared or until this test timesout.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:47,代码来源:TestAssignmentManager.java

示例4: testBalance

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Tests AssignmentManager balance function.  Runs a balance moving a region
 * from one server to another mocking regionserver responding over zk.
 * @throws IOException
 * @throws KeeperException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testBalance()
throws IOException, KeeperException, InterruptedException {
  // Create and startup an executor.  This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testBalanceExecutor");

  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
      .getConfiguration());
  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
      this.serverManager, ct, balancer, executor);
  try {
    // Make sure our new AM gets callbacks; once registered, can't unregister.
    // Thats ok because we make a new zk watcher for each test.
    this.watcher.registerListenerFirst(am);
    // Call the balance function but fake the region being online first at
    // SERVERNAME_A.  Create a balance plan.
    am.regionOnline(REGIONINFO, SERVERNAME_A);
    // Balance region from A to B.
    RegionPlan plan = new RegionPlan(REGIONINFO, SERVERNAME_A, SERVERNAME_B);
    am.balance(plan);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state.  This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    // AM is going to notice above CLOSED and queue up a new assign.  The
    // assign will go to open the region in the new location set by the
    // balancer.  The zk node will be OFFLINE waiting for regionserver to
    // transition it through OPENING, OPENED.  Wait till we see the RIT
    // before we proceed.
    Mocking.waitForRegionOfflineInRIT(am, REGIONINFO.getEncodedName());
    // Get current versionid else will fail on transition from OFFLINE to OPENING below
    while (true) {
      int vid = ZKAssign.getVersion(this.watcher, REGIONINFO);
      if (vid != versionid) {
        versionid = vid;
        break;
      }
    }
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
      SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid =
      ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO, SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    // Wait on the handler removing the OPENED znode.
    while(am.isRegionInTransition(REGIONINFO) != null) Threads.sleep(1);
  } finally {
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:74,代码来源:TestAssignmentManager.java

示例5: testBalanceOnMasterFailoverScenarioWithOpenedNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Test a balance going on at same time as a master failover
 *
 * @throws IOException
 * @throws KeeperException
 * @throws InterruptedException
 * @throws DeserializationException
 */
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithOpenedNode()
    throws IOException, KeeperException, InterruptedException, ServiceException,
    DeserializationException, CoordinatedStateException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // As part of the failover cleanup, the balancing region plan is removed.
    // So a random server will be used to open the region. For testing purpose,
    // let's assume it is going to open on server b:
    am.addPlan(REGIONINFO.getEncodedName(), new RegionPlan(REGIONINFO, null, SERVERNAME_B));

    Mocking.waitForRegionFailedToCloseAndSetToPendingClose(am, REGIONINFO);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
      SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
      SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    am.gate.set(false);
    // Block here until our znode is cleared or until this test times out.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:57,代码来源:TestAssignmentManager.java

示例6: testBalanceOnMasterFailoverScenarioWithClosedNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithClosedNode()
    throws IOException, KeeperException, InterruptedException, ServiceException,
      DeserializationException, CoordinatedStateException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // As part of the failover cleanup, the balancing region plan is removed.
    // So a random server will be used to open the region. For testing purpose,
    // let's assume it is going to open on server b:
    am.addPlan(REGIONINFO.getEncodedName(), new RegionPlan(REGIONINFO, null, SERVERNAME_B));

    Mocking.waitForRegionFailedToCloseAndSetToPendingClose(am, REGIONINFO);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    am.gate.set(false);
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
        SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
        SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);

    // Block here until our znode is cleared or until this test timesout.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:50,代码来源:TestAssignmentManager.java

示例7: testBalanceOnMasterFailoverScenarioWithOfflineNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithOfflineNode()
    throws IOException, KeeperException, InterruptedException, ServiceException,
    DeserializationException, CoordinatedStateException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // As part of the failover cleanup, the balancing region plan is removed.
    // So a random server will be used to open the region. For testing purpose,
    // let's assume it is going to open on server b:
    am.addPlan(REGIONINFO.getEncodedName(), new RegionPlan(REGIONINFO, null, SERVERNAME_B));

    Mocking.waitForRegionFailedToCloseAndSetToPendingClose(am, REGIONINFO);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    am.gate.set(false);
    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
        SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
        SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    // Block here until our znode is cleared or until this test timesout.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:49,代码来源:TestAssignmentManager.java

示例8: testBalance

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Tests AssignmentManager balance function.  Runs a balance moving a region
 * from one server to another mocking regionserver responding over zk.
 * @throws IOException
 * @throws KeeperException
 * @throws DeserializationException
 */
@Test (timeout=180000)
public void testBalance() throws IOException, KeeperException, DeserializationException,
    InterruptedException, CoordinatedStateException {
  // Create and startup an executor.  This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testBalanceExecutor");

  // We need a mocked catalog tracker.
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
      .getConfiguration());
  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, balancer, executor, null, master.getTableLockManager());
  am.failoverCleanupDone.set(true);
  try {
    // Make sure our new AM gets callbacks; once registered, can't unregister.
    // Thats ok because we make a new zk watcher for each test.
    this.watcher.registerListenerFirst(am);
    // Call the balance function but fake the region being online first at
    // SERVERNAME_A.  Create a balance plan.
    am.regionOnline(REGIONINFO, SERVERNAME_A);
    // Balance region from A to B.
    RegionPlan plan = new RegionPlan(REGIONINFO, SERVERNAME_A, SERVERNAME_B);
    am.balance(plan);

    RegionStates regionStates = am.getRegionStates();
    // Must be failed to close since the server is fake
    assertTrue(regionStates.isRegionInTransition(REGIONINFO)
      && regionStates.isRegionInState(REGIONINFO, State.FAILED_CLOSE));
    // Move it back to pending_close
    regionStates.updateRegionState(REGIONINFO, State.PENDING_CLOSE);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state.  This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    // AM is going to notice above CLOSED and queue up a new assign.  The
    // assign will go to open the region in the new location set by the
    // balancer.  The zk node will be OFFLINE waiting for regionserver to
    // transition it through OPENING, OPENED.  Wait till we see the OFFLINE
    // zk node before we proceed.
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
      SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid =
      ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO, SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    // Wait on the handler removing the OPENED znode.
    while(regionStates.isRegionInTransition(REGIONINFO)) Threads.sleep(1);
  } finally {
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:76,代码来源:TestAssignmentManager.java

示例9: testBalanceOnMasterFailoverScenarioWithOpenedNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Test a balance going on at same time as a master failover
 *
 * @throws IOException
 * @throws KeeperException
 * @throws InterruptedException
 * @throws DeserializationException
 */
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithOpenedNode()
throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // As part of the failover cleanup, the balancing region plan is removed.
    // So a random server will be used to open the region. For testing purpose,
    // let's assume it is going to open on server b:
    am.addPlan(REGIONINFO.getEncodedName(), new RegionPlan(REGIONINFO, null, SERVERNAME_B));

    Mocking.waitForRegionFailedToCloseAndSetToPendingClose(am, REGIONINFO);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
      SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
      SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    am.gate.set(false);
    // Block here until our znode is cleared or until this test times out.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:56,代码来源:TestAssignmentManager.java

示例10: testBalanceOnMasterFailoverScenarioWithClosedNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithClosedNode()
throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // As part of the failover cleanup, the balancing region plan is removed.
    // So a random server will be used to open the region. For testing purpose,
    // let's assume it is going to open on server b:
    am.addPlan(REGIONINFO.getEncodedName(), new RegionPlan(REGIONINFO, null, SERVERNAME_B));

    Mocking.waitForRegionFailedToCloseAndSetToPendingClose(am, REGIONINFO);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    am.gate.set(false);
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
        SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
        SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);

    // Block here until our znode is cleared or until this test timesout.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:49,代码来源:TestAssignmentManager.java

示例11: testBalanceOnMasterFailoverScenarioWithOfflineNode

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testBalanceOnMasterFailoverScenarioWithOfflineNode()
throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  try {
    createRegionPlanAndBalance(am, SERVERNAME_A, SERVERNAME_B, REGIONINFO);
    startFakeFailedOverMasterAssignmentManager(am, this.watcher);
    while (!am.processRITInvoked) Thread.sleep(1);
    // As part of the failover cleanup, the balancing region plan is removed.
    // So a random server will be used to open the region. For testing purpose,
    // let's assume it is going to open on server b:
    am.addPlan(REGIONINFO.getEncodedName(), new RegionPlan(REGIONINFO, null, SERVERNAME_B));

    Mocking.waitForRegionFailedToCloseAndSetToPendingClose(am, REGIONINFO);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state. This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    am.gate.set(false);
    // Get current versionid else will fail on transition from OFFLINE to
    // OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
        SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
        EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid = ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO,
        SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    // Block here until our znode is cleared or until this test timesout.
    ZKAssign.blockUntilNoRIT(watcher);
  } finally {
    am.getExecutorService().shutdown();
    am.shutdown();
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:48,代码来源:TestAssignmentManager.java

示例12: testBalance

import org.apache.hadoop.hbase.zookeeper.ZKAssign; //导入方法依赖的package包/类
/**
 * Tests AssignmentManager balance function.  Runs a balance moving a region
 * from one server to another mocking regionserver responding over zk.
 * @throws IOException
 * @throws KeeperException
 * @throws DeserializationException
 */
@Test
public void testBalance()
  throws IOException, KeeperException, DeserializationException, InterruptedException {
  // Create and startup an executor.  This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testBalanceExecutor");

  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server
      .getConfiguration());
  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, ct, balancer, executor, null, master.getTableLockManager());
  am.failoverCleanupDone.set(true);
  try {
    // Make sure our new AM gets callbacks; once registered, can't unregister.
    // Thats ok because we make a new zk watcher for each test.
    this.watcher.registerListenerFirst(am);
    // Call the balance function but fake the region being online first at
    // SERVERNAME_A.  Create a balance plan.
    am.regionOnline(REGIONINFO, SERVERNAME_A);
    // Balance region from A to B.
    RegionPlan plan = new RegionPlan(REGIONINFO, SERVERNAME_A, SERVERNAME_B);
    am.balance(plan);

    RegionStates regionStates = am.getRegionStates();
    // Must be failed to close since the server is fake
    assertTrue(regionStates.isRegionInTransition(REGIONINFO)
      && regionStates.isRegionInState(REGIONINFO, State.FAILED_CLOSE));
    // Move it back to pending_close
    regionStates.updateRegionState(REGIONINFO, State.PENDING_CLOSE);

    // Now fake the region closing successfully over on the regionserver; the
    // regionserver will have set the region in CLOSED state.  This will
    // trigger callback into AM. The below zk close call is from the RS close
    // region handler duplicated here because its down deep in a private
    // method hard to expose.
    int versionid =
      ZKAssign.transitionNodeClosed(this.watcher, REGIONINFO, SERVERNAME_A, -1);
    assertNotSame(versionid, -1);
    // AM is going to notice above CLOSED and queue up a new assign.  The
    // assign will go to open the region in the new location set by the
    // balancer.  The zk node will be OFFLINE waiting for regionserver to
    // transition it through OPENING, OPENED.  Wait till we see the OFFLINE
    // zk node before we proceed.
    Mocking.waitForRegionPendingOpenInRIT(am, REGIONINFO.getEncodedName());

    // Get current versionid else will fail on transition from OFFLINE to OPENING below
    versionid = ZKAssign.getVersion(this.watcher, REGIONINFO);
    assertNotSame(-1, versionid);
    // This uglyness below is what the openregionhandler on RS side does.
    versionid = ZKAssign.transitionNode(server.getZooKeeper(), REGIONINFO,
      SERVERNAME_B, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, versionid);
    assertNotSame(-1, versionid);
    // Move znode from OPENING to OPENED as RS does on successful open.
    versionid =
      ZKAssign.transitionNodeOpened(this.watcher, REGIONINFO, SERVERNAME_B, versionid);
    assertNotSame(-1, versionid);
    // Wait on the handler removing the OPENED znode.
    while(regionStates.isRegionInTransition(REGIONINFO)) Threads.sleep(1);
  } finally {
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:77,代码来源:TestAssignmentManager.java


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