Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupInfo


  public void testCloseEntityGroup() throws IOException, NodeExistsException,
      KeeperException, DeserializationException {
    final Server server = new MockServer(WTU);
    final MockFServerServices rss = new MockFServerServices();
    FTable htd = TEST_FTD;
    EntityGroupInfo egi = TEST_EGI;
    openEntityGroup(server, rss, htd, egi);
    int versionOfClosingNode = ZKAssign.createNodeClosing(
        server.getZooKeeper(), egi, server.getServerName());
    CloseEntityGroupHandler handler = new CloseEntityGroupHandler(server, rss,
        egi, false, true, versionOfClosingNode,
        EventType.M_FSERVER_CLOSE_ENTITYGROUP);
    handler.process();
    EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
        .getData(server.getZooKeeper(), egi.getEncodedName()));
    assertTrue(rt.getEventType()
        .equals(EventType.FSERVER_ZK_ENTITYGROUP_CLOSED));
  }
View Full Code Here


    TEST_UTIL.startMiniCluster(1);
  }

  @Before
  public void setup() throws Exception {
    EntityGroupInfo entityGroupInfo = new EntityGroupInfo(
        Bytes.toBytes(TABLE_NAME), STARTROW, ENDROW);
    this.parent = createEntityGroup(entityGroupInfo);
    TEST_UTIL.getConfiguration().setBoolean("wasp.testing.nocluster", true);
  }
View Full Code Here

   * interfere with each other. This allows us to use just a single ZK cluster
   * for the whole suite.
   */
  @Before
  public void setupEGI() {
    TEST_EGI = new EntityGroupInfo(Bytes.toBytes(TEST_FTD.getTableName()),
        Bytes.toBytes(testIndex), Bytes.toBytes(testIndex + 1));
    testIndex++;
  }
View Full Code Here

      TEST_UTIL.getConfiguration().set(FConstants.ZOOKEEPER_CLIENT_PORT,
          TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_CLIENT_PORT));
      final Server server = new MockServer(TEST_UTIL);
      FTable htd = FMetaTestUtil
          .makeTable("testShouldNotCompeleteOpenedEntityGroupSuccessfullyIfVersionMismatches");
      EntityGroupInfo egi = new EntityGroupInfo(Bytes.toBytes(htd
          .getTableName()), Bytes.toBytes(testIndex),
          Bytes.toBytes(testIndex + 1));
      entityGroup = EntityGroup.createEntityGroup(egi,
          TEST_UTIL.getConfiguration(), htd, null);
      assertNotNull(entityGroup);
View Full Code Here

  public void testAssignEntityGroup() throws Exception {
    String table = "testAssignEntityGroup";
    try {
      FTable desc = FMetaTestUtil.makeTable(table);
      admin.createTable(desc);
      EntityGroupInfo egInfo = new EntityGroupInfo(Bytes.toBytes(desc
          .getTableName()), Bytes.toBytes("A"), Bytes.toBytes("Z"));
      FMetaEditor.addEntityGroupToMeta(conf, egInfo);
      FMaster master = TEST_UTIL.getWaspCluster().getMaster();
      master.assignEntityGroup(egInfo);
      master.getAssignmentManager().waitForAssignment(egInfo);
View Full Code Here

   */
  @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));
View Full Code Here

   */
  @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);
View Full Code Here

  @Test
  public void testContainsRange() {
    FTable table = new FTable();
    table.setTableName("testtable");
    EntityGroupInfo egi = new EntityGroupInfo(Bytes.toBytes(table
        .getTableName()), Bytes.toBytes("a"), Bytes.toBytes("g"));
    // Single row range at start of entityGroup
    assertTrue(egi.containsRange(Bytes.toBytes("a"), Bytes.toBytes("a")));
    // Fully contained range
    assertTrue(egi.containsRange(Bytes.toBytes("b"), Bytes.toBytes("c")));
    // Range overlapping start of entityGroup
    assertTrue(egi.containsRange(Bytes.toBytes("a"), Bytes.toBytes("c")));
    // Fully contained single-row range
    assertTrue(egi.containsRange(Bytes.toBytes("c"), Bytes.toBytes("c")));
    // Range that overlaps end key and hence doesn't fit
    assertFalse(egi.containsRange(Bytes.toBytes("a"), Bytes.toBytes("g")));
    // Single row range on end key
    assertFalse(egi.containsRange(Bytes.toBytes("g"), Bytes.toBytes("g")));
    // Single row range entirely outside
    assertFalse(egi.containsRange(Bytes.toBytes("z"), Bytes.toBytes("z")));

    // Degenerate range
    try {
      egi.containsRange(Bytes.toBytes("z"), Bytes.toBytes("a"));
      fail("Invalid range did not throw IAE");
    } catch (IllegalArgumentException iae) {
    }
  }
View Full Code Here

  @Test
  public void testLastEntityGroupCompare() {
    FTable table = new FTable();
    table.setTableName("testtable");
    EntityGroupInfo egip = new EntityGroupInfo(Bytes.toBytes(table
        .getTableName()), Bytes.toBytes("a"), new byte[0]);
    EntityGroupInfo egic = new EntityGroupInfo(Bytes.toBytes(table
        .getTableName()), Bytes.toBytes("a"), Bytes.toBytes("b"));
    assertTrue(egip.compareTo(egic) > 0);
  }
View Full Code Here

  @Test
  public void testComparator() {
    byte[] tablename = Bytes.toBytes("comparatorTablename");
    byte[] empty = new byte[0];
    EntityGroupInfo older = new EntityGroupInfo(tablename, empty, empty, false,
        0L);
    EntityGroupInfo newer = new EntityGroupInfo(tablename, empty, empty, false,
        1L);
    assertTrue(older.compareTo(newer) < 0);
    assertTrue(newer.compareTo(older) > 0);
    assertTrue(older.compareTo(older) == 0);
    assertTrue(newer.compareTo(newer) == 0);
  }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.EntityGroupInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.