コード例 #1
0
  /** This tests offlining a entityGroup */
  @Test(timeout = 120000)
  public void testOfflineEntityGroup() throws Exception {
    String table = "testOfflineEntityGroup";
    try {
      EntityGroupInfo egInfo = createTableAndGetOneEntityGroup(table);

      EntityGroupStates entityGroupStates =
          TEST_UTIL.getWaspCluster().getMaster().getAssignmentManager().getEntityGroupStates();
      ServerName serverName = entityGroupStates.getFServerOfEntityGroup(egInfo);
      TEST_UTIL.assertEntityGroupOnServer(egInfo, serverName, 200);
      admin.offline(egInfo.getEntityGroupName());

      long timeoutTime = System.currentTimeMillis() + 800;
      while (true) {
        List<EntityGroupInfo> entityGroups =
            entityGroupStates.getEntityGroupsOfTable(Bytes.toBytes(table));
        if (!entityGroups.contains(egInfo)) break;
        long now = System.currentTimeMillis();
        if (now > timeoutTime) {
          fail("Failed to offline the entityGroup in time");
          break;
        }
        Thread.sleep(10);
      }
      EntityGroupState entityGroupState = entityGroupStates.getEntityGroupState(egInfo);
      assertTrue(entityGroupState.isOffline());
    } finally {
      TEST_UTIL.deleteTable(Bytes.toBytes(table));
    }
  }
コード例 #2
0
  /** This tests moving a entityGroup */
  @Test(timeout = 120000)
  public void testMoveEntityGroup() throws Exception {
    String table = "testMoveEntityGroup";
    try {
      EntityGroupInfo egInfo = createTableAndGetOneEntityGroup(table);

      EntityGroupStates entityGroupStates =
          TEST_UTIL.getWaspCluster().getMaster().getAssignmentManager().getEntityGroupStates();
      ServerName serverName = entityGroupStates.getFServerOfEntityGroup(egInfo);
      ServerName destServerName = null;
      for (int i = 0; i < 3; i++) {
        FServer destServer = TEST_UTIL.getWaspCluster().getFServer(i);
        if (!destServer.getServerName().equals(serverName)) {
          destServerName = destServer.getServerName();
          break;
        }
      }
      assertTrue(destServerName != null && !destServerName.equals(serverName));
      TEST_UTIL
          .getWaspAdmin()
          .move(egInfo.getEncodedNameAsBytes(), Bytes.toBytes(destServerName.getServerName()));

      long timeoutTime = System.currentTimeMillis() + 5000;
      while (true) {
        ServerName sn = entityGroupStates.getFServerOfEntityGroup(egInfo);
        if (sn != null && sn.equals(destServerName)) {
          TEST_UTIL.assertEntityGroupOnServer(egInfo, sn, 2000);
          break;
        }
        long now = System.currentTimeMillis();
        if (now > timeoutTime) {
          fail("Failed to move the entityGroup in time");
        }
        entityGroupStates.waitForUpdate(50);
      }

    } finally {
      TEST_UTIL.deleteTable(Bytes.toBytes(table));
    }
  }