コード例 #1
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));
    }
  }
コード例 #2
0
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   TEST_UTIL.getConfiguration().setClass(FConstants.REDO_IMPL, MemRedoLog.class, Redo.class);
   TEST_UTIL.startMiniCluster(3);
   admin = TEST_UTIL.getWaspAdmin();
 }