Java 类org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table 实例源码

项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * Test verifies whether stale znodes of unknown tables as for the hbase:meta will be removed or
 * not.
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartShouldRemoveStaleZnodesOfUnknownTableAsForMeta()
    throws Exception {
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    TableName tableName = TableName.valueOf("dummyTable");
    // set table in enabling state.
    am.getTableStateManager().setTableState(tableName,
      Table.State.ENABLING);
    am.joinCluster();
    assertFalse("Table should not be present in zookeeper.",
      am.getTableStateManager().isTablePresent(tableName));
  } finally {
  }
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * Test the scenario when the master is in failover and trying to process a
 * region which is in Opening state on a dead RS. Master will force offline the
 * region and put it in transition. AM relies on SSH to reassign it.
 */
@Test(timeout = 60000)
public void testRegionInOpeningStateOnDeadRSWhileMasterFailover() throws IOException,
    KeeperException, ServiceException, CoordinatedStateException, InterruptedException {
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
    this.server, this.serverManager);
  ZKAssign.createNodeOffline(this.watcher, REGIONINFO, SERVERNAME_A);
  int version = ZKAssign.getVersion(this.watcher, REGIONINFO);
  ZKAssign.transitionNode(this.watcher, REGIONINFO, SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, version);
  RegionTransition rt = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_OPENING,
      REGIONINFO.getRegionName(), SERVERNAME_A, HConstants.EMPTY_BYTE_ARRAY);
  version = ZKAssign.getVersion(this.watcher, REGIONINFO);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(false);
  am.getRegionStates().logSplit(SERVERNAME_A); // Assume log splitting is done
  am.getRegionStates().createRegionState(REGIONINFO);
  am.gate.set(false);

  BaseCoordinatedStateManager cp = new ZkCoordinatedStateManager();
  cp.initialize(server);
  cp.start();

  OpenRegionCoordination orc = cp.getOpenRegionCoordination();
  ZkOpenRegionCoordination.ZkOpenRegionDetails zkOrd =
    new ZkOpenRegionCoordination.ZkOpenRegionDetails();
  zkOrd.setServerName(server.getServerName());
  zkOrd.setVersion(version);

  assertFalse(am.processRegionsInTransition(rt, REGIONINFO, orc, zkOrd));
  am.getTableStateManager().setTableState(REGIONINFO.getTable(), Table.State.ENABLED);
  processServerShutdownHandler(am, false);
  // Waiting for the assignment to get completed.
  while (!am.gate.get()) {
    Thread.sleep(10);
  }
  assertTrue("The region should be assigned immediately.", null != am.regionPlans.get(REGIONINFO
      .getEncodedName()));
  am.shutdown();
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * Test verifies whether stale znodes of unknown tables as for the hbase:meta will be removed or
 * not.
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test (timeout=180000)
public void testMasterRestartShouldRemoveStaleZnodesOfUnknownTableAsForMeta()
    throws Exception {
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);

  Whitebox.setInternalState(server, "metaTableLocator", Mockito.mock(MetaTableLocator.class));

  // Make it so we can get a catalogtracker from servermanager.. .needed
  // down in guts of server shutdown handler.
  Whitebox.setInternalState(server, "clusterConnection", am.getConnection());

  try {
    TableName tableName = TableName.valueOf("dummyTable");
    // set table in enabling state.
    am.getTableStateManager().setTableState(tableName,
      Table.State.ENABLING);
    am.joinCluster();
    assertFalse("Table should not be present in zookeeper.",
      am.getTableStateManager().isTablePresent(tableName));
  } finally {
    am.shutdown();
  }
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * When a region is in transition, if the region server opening the region goes down,
 * the region assignment takes a long time normally (waiting for timeout monitor to trigger assign).
 * This test is to make sure SSH reassigns it right away.
 */
@Test (timeout=180000)
public void testSSHTimesOutOpeningRegionTransition()
    throws KeeperException, IOException, CoordinatedStateException, ServiceException {
  // Create an AM.
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  // adding region in pending open.
  RegionState state = new RegionState(REGIONINFO,
    State.OPENING, System.currentTimeMillis(), SERVERNAME_A);
  am.getRegionStates().regionOnline(REGIONINFO, SERVERNAME_B);
  am.getRegionStates().regionsInTransition.put(REGIONINFO.getEncodedName(), state);
  // adding region plan
  am.regionPlans.put(REGIONINFO.getEncodedName(),
    new RegionPlan(REGIONINFO, SERVERNAME_B, SERVERNAME_A));
  am.getTableStateManager().setTableState(REGIONINFO.getTable(),
    Table.State.ENABLED);

  try {
    am.assignInvoked = false;
    processServerShutdownHandler(am, false);
    assertTrue(am.assignInvoked);
  } finally {
    am.getRegionStates().regionsInTransition.remove(REGIONINFO.getEncodedName());
    am.regionPlans.remove(REGIONINFO.getEncodedName());
    am.shutdown();
  }
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * Test the scenario when the master is in failover and trying to process a
 * region which is in Opening state on a dead RS. Master will force offline the
 * region and put it in transition. AM relies on SSH to reassign it.
 */
@Test(timeout = 60000)
public void testRegionInOpeningStateOnDeadRSWhileMasterFailover() throws IOException,
    KeeperException, ServiceException, CoordinatedStateException, InterruptedException {
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
    this.server, this.serverManager);
  ZKAssign.createNodeOffline(this.watcher, REGIONINFO, SERVERNAME_A);
  int version = ZKAssign.getVersion(this.watcher, REGIONINFO);
  ZKAssign.transitionNode(this.watcher, REGIONINFO, SERVERNAME_A, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, version);
  RegionTransition rt = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_OPENING,
      REGIONINFO.getRegionName(), SERVERNAME_A, HConstants.EMPTY_BYTE_ARRAY);
  version = ZKAssign.getVersion(this.watcher, REGIONINFO);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(false);
  am.getRegionStates().logSplit(SERVERNAME_A); // Assume log splitting is done
  am.getRegionStates().createRegionState(REGIONINFO);
  am.gate.set(false);
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  assertFalse(am.processRegionsInTransition(rt, REGIONINFO, version));
  am.getTableStateManager().setTableState(REGIONINFO.getTable(),
    Table.State.ENABLED);
  processServerShutdownHandler(ct, am, false);
  // Waiting for the assignment to get completed.
  while (!am.gate.get()) {
    Thread.sleep(10);
  }
  assertTrue("The region should be assigned immediately.", null != am.regionPlans.get(REGIONINFO
      .getEncodedName()));
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLING);
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getTableStateManager().isTableState(REGIONINFO.getTable(),
          Table.State.ENABLED));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLED);
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * When a region is in transition, if the region server opening the region goes down,
 * the region assignment takes a long time normally (waiting for timeout monitor to trigger assign).
 * This test is to make sure SSH reassigns it right away.
 */
@Test
public void testSSHTimesOutOpeningRegionTransition()
    throws KeeperException, IOException, CoordinatedStateException, ServiceException {
  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  // Create an AM.
  AssignmentManagerWithExtrasForTesting am =
    setUpMockedAssignmentManager(this.server, this.serverManager);
  // adding region in pending open.
  RegionState state = new RegionState(REGIONINFO,
    State.OPENING, System.currentTimeMillis(), SERVERNAME_A);
  am.getRegionStates().regionOnline(REGIONINFO, SERVERNAME_B);
  am.getRegionStates().regionsInTransition.put(REGIONINFO.getEncodedName(), state);
  // adding region plan
  am.regionPlans.put(REGIONINFO.getEncodedName(),
    new RegionPlan(REGIONINFO, SERVERNAME_B, SERVERNAME_A));
  am.getTableStateManager().setTableState(REGIONINFO.getTable(),
    Table.State.ENABLED);

  try {
    am.assignInvoked = false;
    processServerShutdownHandler(ct, am, false);
    assertTrue(am.assignInvoked);
  } finally {
    am.getRegionStates().regionsInTransition.remove(REGIONINFO.getEncodedName());
    am.regionPlans.remove(REGIONINFO.getEncodedName());
  }
}
项目:pbase    文件:TestAssignmentManager.java   
private void testCaseWithSplitRegionPartial(boolean regionSplitDone) throws KeeperException,
    IOException, InterruptedException,
  CoordinatedStateException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenSplitRegionInProgress");
  // We need a mocked catalog tracker.
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
    this.server, this.serverManager);
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(
    REGIONINFO, State.SPLITTING, SERVERNAME_A);
  am.getTableStateManager().setTableState(REGIONINFO.getTable(),
    Table.State.ENABLED);
  RegionTransition data = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_SPLITTING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(am, regionSplitDone);
    // check znode deleted or not.
    // In both cases the znode should be deleted.

    if (regionSplitDone) {
      assertFalse("Region state of region in SPLITTING should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    } else {
      while (!am.assignInvoked) {
        Thread.sleep(1);
      }
      assertTrue("Assign should be invoked.", am.assignInvoked);
    }
  } finally {
    REGIONINFO.setOffline(false);
    REGIONINFO.setSplit(false);
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:pbase    文件:TestAssignmentManager.java   
private void testCaseWithPartiallyDisabledState(Table.State state) throws KeeperException,
    IOException, CoordinatedStateException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenDisableTableInProgress");
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, balancer, executor, null, master.getTableLockManager());
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(REGIONINFO, State.PENDING_CLOSE);
  if (state == Table.State.DISABLING) {
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.DISABLING);
  } else {
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.DISABLED);
  }
  RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  // RegionTransitionData data = new
  // RegionTransitionData(EventType.M_ZK_REGION_CLOSING,
  // REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(am, false);
    // check znode deleted or not.
    // In both cases the znode should be deleted.
    assertTrue("The znode should be deleted.", ZKUtil.checkExists(this.watcher, node) == -1);
    // check whether in rit or not. In the DISABLING case also the below
    // assert will be true but the piece of code added for HBASE-5927 will not
    // do that.
    if (state == Table.State.DISABLED) {
      assertFalse("Region state of region in pending close should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    }
  } finally {
    am.setEnabledTable(REGIONINFO.getTable());
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test (timeout=180000)
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);

  Whitebox.setInternalState(server, "metaTableLocator", Mockito.mock(MetaTableLocator.class));

  // Make it so we can get a catalogtracker from servermanager.. .needed
  // down in guts of server shutdown handler.
  Whitebox.setInternalState(server, "clusterConnection", am.getConnection());

  try {
    // set table in enabling state.
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLING);
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getTableStateManager().isTableState(REGIONINFO.getTable(),
          Table.State.ENABLED));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLED);
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:HIndex    文件:TestAssignmentManager.java   
private void testCaseWithPartiallyDisabledState(Table.State state) throws KeeperException,
    IOException, NodeExistsException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenDisableTableInProgress");
  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, ct, balancer, executor, null, master.getTableLockManager());
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(REGIONINFO, State.PENDING_CLOSE);
  if (state == Table.State.DISABLING) {
    am.getZKTable().setDisablingTable(REGIONINFO.getTable());
  } else {
    am.getZKTable().setDisabledTable(REGIONINFO.getTable());
  }
  RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  // RegionTransitionData data = new
  // RegionTransitionData(EventType.M_ZK_REGION_CLOSING,
  // REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(ct, am, false);
    // check znode deleted or not.
    // In both cases the znode should be deleted.
    assertTrue("The znode should be deleted.", ZKUtil.checkExists(this.watcher, node) == -1);
    // check whether in rit or not. In the DISABLING case also the below
    // assert will be true but the piece of code added for HBASE-5927 will not
    // do that.
    if (state == Table.State.DISABLED) {
      assertFalse("Region state of region in pending close should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    }
  } finally {
    am.setEnabledTable(REGIONINFO.getTable());
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:PyroDB    文件:TestAssignmentManager.java   
private void testCaseWithSplitRegionPartial(boolean regionSplitDone) throws KeeperException,
    IOException, InterruptedException,
  CoordinatedStateException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenSplitRegionInProgress");
  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
    this.server, this.serverManager);
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(
    REGIONINFO, State.SPLITTING, SERVERNAME_A);
  am.getTableStateManager().setTableState(REGIONINFO.getTable(),
    Table.State.ENABLED);
  RegionTransition data = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_SPLITTING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(ct, am, regionSplitDone);
    // check znode deleted or not.
    // In both cases the znode should be deleted.

    if (regionSplitDone) {
      assertFalse("Region state of region in SPLITTING should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    } else {
      while (!am.assignInvoked) {
        Thread.sleep(1);
      }
      assertTrue("Assign should be invoked.", am.assignInvoked);
    }
  } finally {
    REGIONINFO.setOffline(false);
    REGIONINFO.setSplit(false);
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:PyroDB    文件:TestAssignmentManager.java   
private void testCaseWithPartiallyDisabledState(Table.State state) throws KeeperException,
    IOException, CoordinatedStateException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenDisableTableInProgress");
  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, ct, balancer, executor, null, master.getTableLockManager());
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(REGIONINFO, State.PENDING_CLOSE);
  if (state == Table.State.DISABLING) {
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.DISABLING);
  } else {
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.DISABLED);
  }
  RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  // RegionTransitionData data = new
  // RegionTransitionData(EventType.M_ZK_REGION_CLOSING,
  // REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(ct, am, false);
    // check znode deleted or not.
    // In both cases the znode should be deleted.
    assertTrue("The znode should be deleted.", ZKUtil.checkExists(this.watcher, node) == -1);
    // check whether in rit or not. In the DISABLING case also the below
    // assert will be true but the piece of code added for HBASE-5927 will not
    // do that.
    if (state == Table.State.DISABLED) {
      assertFalse("Region state of region in pending close should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    }
  } finally {
    am.setEnabledTable(REGIONINFO.getTable());
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:c5    文件:TestAssignmentManager.java   
private void testCaseWithPartiallyDisabledState(Table.State state) throws KeeperException,
    IOException, NodeExistsException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenDisableTableInProgress");
  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, ct, balancer, executor, null, master.getTableLockManager());
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(REGIONINFO, State.PENDING_CLOSE);
  if (state == Table.State.DISABLING) {
    am.getZKTable().setDisablingTable(REGIONINFO.getTable());
  } else {
    am.getZKTable().setDisabledTable(REGIONINFO.getTable());
  }
  RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  // RegionTransitionData data = new
  // RegionTransitionData(EventType.M_ZK_REGION_CLOSING,
  // REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(ct, am, false);
    // check znode deleted or not.
    // In both cases the znode should be deleted.
    assertTrue("The znode should be deleted.", ZKUtil.checkExists(this.watcher, node) == -1);
    // check whether in rit or not. In the DISABLING case also the below
    // assert will be true but the piece of code added for HBASE-5927 will not
    // do that.
    if (state == Table.State.DISABLED) {
      assertFalse("Region state of region in pending close should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    }
  } finally {
    am.setEnabledTable(REGIONINFO.getTable());
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:DominoHBase    文件:TestAssignmentManager.java   
private void testCaseWithPartiallyDisabledState(Table.State state) throws KeeperException,
    IOException, NodeExistsException, ServiceException {
  // Create and startup an executor. This is used by AssignmentManager
  // handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("testSSHWhenDisableTableInProgress");
  // We need a mocked catalog tracker.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  ZKAssign.deleteAllNodes(this.watcher);

  // Create an AM.
  AssignmentManager am = new AssignmentManager(this.server,
    this.serverManager, ct, balancer, executor, null);
  // adding region to regions and servers maps.
  am.regionOnline(REGIONINFO, SERVERNAME_A);
  // adding region in pending close.
  am.getRegionStates().updateRegionState(REGIONINFO, State.PENDING_CLOSE);
  if (state == Table.State.DISABLING) {
    am.getZKTable().setDisablingTable(REGIONINFO.getTableNameAsString());
  } else {
    am.getZKTable().setDisabledTable(REGIONINFO.getTableNameAsString());
  }
  RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
      REGIONINFO.getRegionName(), SERVERNAME_A);
  // RegionTransitionData data = new
  // RegionTransitionData(EventType.M_ZK_REGION_CLOSING,
  // REGIONINFO.getRegionName(), SERVERNAME_A);
  String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
  // create znode in M_ZK_REGION_CLOSING state.
  ZKUtil.createAndWatch(this.watcher, node, data.toByteArray());

  try {
    processServerShutdownHandler(ct, am, false);
    // check znode deleted or not.
    // In both cases the znode should be deleted.
    assertTrue("The znode should be deleted.", ZKUtil.checkExists(this.watcher, node) == -1);
    // check whether in rit or not. In the DISABLING case also the below
    // assert will be true but the piece of code added for HBASE-5927 will not
    // do that.
    if (state == Table.State.DISABLED) {
      assertFalse("Region state of region in pending close should be removed from rit.",
          am.getRegionStates().isRegionsInTransition());
    }
  } finally {
    am.setEnabledTable(REGIONINFO.getTableNameAsString());
    executor.shutdown();
    am.shutdown();
    // Clean up all znodes
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * To test closed region handler to remove rit and delete corresponding znode
 * if region in pending close or closing while processing shutdown of a region
 * server.(HBASE-5927).
 *
 * @throws KeeperException
 * @throws IOException
 * @throws ServiceException
 */
@Test (timeout=180000)
public void testSSHWhenDisableTableInProgress() throws KeeperException, IOException,
  CoordinatedStateException, ServiceException {
  testCaseWithPartiallyDisabledState(Table.State.DISABLING);
  testCaseWithPartiallyDisabledState(Table.State.DISABLED);
}
项目:HIndex    文件:TestAssignmentManager.java   
/**
 * To test closed region handler to remove rit and delete corresponding znode
 * if region in pending close or closing while processing shutdown of a region
 * server.(HBASE-5927).
 *
 * @throws KeeperException
 * @throws IOException
 * @throws ServiceException
 */
@Test
public void testSSHWhenDisableTableInProgress() throws KeeperException, IOException,
    ServiceException {
  testCaseWithPartiallyDisabledState(Table.State.DISABLING);
  testCaseWithPartiallyDisabledState(Table.State.DISABLED);
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * To test closed region handler to remove rit and delete corresponding znode
 * if region in pending close or closing while processing shutdown of a region
 * server.(HBASE-5927).
 *
 * @throws KeeperException
 * @throws IOException
 * @throws ServiceException
 */
@Test
public void testSSHWhenDisableTableInProgress() throws KeeperException, IOException,
  CoordinatedStateException, ServiceException {
  testCaseWithPartiallyDisabledState(Table.State.DISABLING);
  testCaseWithPartiallyDisabledState(Table.State.DISABLED);
}
项目:c5    文件:TestAssignmentManager.java   
/**
 * To test closed region handler to remove rit and delete corresponding znode
 * if region in pending close or closing while processing shutdown of a region
 * server.(HBASE-5927).
 *
 * @throws KeeperException
 * @throws IOException
 * @throws ServiceException
 */
@Test
public void testSSHWhenDisableTableInProgress() throws KeeperException, IOException,
    ServiceException {
  testCaseWithPartiallyDisabledState(Table.State.DISABLING);
  testCaseWithPartiallyDisabledState(Table.State.DISABLED);
}
项目:DominoHBase    文件:TestAssignmentManager.java   
/**
 * To test closed region handler to remove rit and delete corresponding znode
 * if region in pending close or closing while processing shutdown of a region
 * server.(HBASE-5927).
 * 
 * @throws KeeperException
 * @throws IOException
 * @throws ServiceException
 */
@Test
public void testSSHWhenDisableTableInProgress() throws KeeperException, IOException,
    ServiceException {
  testCaseWithPartiallyDisabledState(Table.State.DISABLING);
  testCaseWithPartiallyDisabledState(Table.State.DISABLED);
}