Package com.alibaba.wasp

Examples of com.alibaba.wasp.ServerName


      // Insert into zk a blocking znode, a znode of same name as entityGroup
      // so it gets in way of our splitting.

      ZooKeeperWatcher zkw = WaspTestingUtility
          .getZooKeeperWatcher(TESTING_UTIL);
      ZKAssign.createNodeClosing(zkw, egi, new ServerName("any.old.server",
          1234, -1));
      // Now try splitting.... should fail. And each should successfully
      // rollback.
      admin.split(egi.getEntityGroupNameAsString(), "3");
      admin.split(egi.getEntityGroupNameAsString(), "2");
View Full Code Here


          .getTableName()), Bytes.toBytes("A"), Bytes.toBytes("Z"));
      FMetaEditor.addEntityGroupToMeta(conf, egInfo);
      FMaster master = TEST_UTIL.getWaspCluster().getMaster();
      master.assignEntityGroup(egInfo);
      master.getAssignmentManager().waitForAssignment(egInfo);
      ServerName serverName = master.getAssignmentManager()
          .getEntityGroupStates().getFServerOfEntityGroup(egInfo);
      TEST_UTIL.assertEntityGroupOnServer(egInfo, serverName, 200);
    } finally {
      TEST_UTIL.deleteTable(Bytes.toBytes(table));
    }
View Full Code Here

    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) {
View Full Code Here

    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) {
View Full Code Here

public class TestDeadServer {
  @Test
  public void testIsDead() {
    DeadServer ds = new DeadServer();
    final ServerName hostname123 = new ServerName("127.0.0.1", 123, 3L);
    ds.add(hostname123);
    assertTrue(ds.areDeadServersInProgress());
    ds.finish(hostname123);
    assertFalse(ds.areDeadServersInProgress());
    final ServerName hostname1234 = new ServerName("127.0.0.2", 1234, 4L);
    ds.add(hostname1234);
    assertTrue(ds.areDeadServersInProgress());
    ds.finish(hostname1234);
    assertFalse(ds.areDeadServersInProgress());
    final ServerName hostname12345 = new ServerName("127.0.0.2", 12345, 4L);
    ds.add(hostname12345);
    assertTrue(ds.areDeadServersInProgress());
    ds.finish(hostname12345);
    assertFalse(ds.areDeadServersInProgress());

    // Already dead = 127.0.0.1,9090,112321
    // Coming back alive = 127.0.0.1,9090,223341

    final ServerName deadServer = new ServerName("127.0.0.1", 9090, 112321L);
    assertFalse(ds.cleanPreviousInstance(deadServer));
    ds.add(deadServer);
    assertTrue(ds.isDeadServer(deadServer));
    final ServerName deadServerHostComingAlive = new ServerName("127.0.0.1",
        9090, 112321L);
    assertTrue(ds.cleanPreviousInstance(deadServerHostComingAlive));
    assertFalse(ds.isDeadServer(deadServer));
    assertFalse(ds.cleanPreviousInstance(deadServerHostComingAlive));
  }
View Full Code Here

    // Mock a Server. Have it return a legit Configuration and ZooKeeperWatcher.
    // If abort is called, be sure to fail the test (don't just swallow it
    // silently as is mockito default).
    this.server = Mockito.mock(Server.class);
    Mockito.when(server.getServerName()).thenReturn(
        new ServerName("master,1,1"));
    Mockito.when(server.getConfiguration()).thenReturn(HTU.getConfiguration());
    HTU.getConfiguration().set(FConstants.ZOOKEEPER_QUORUM,
        HTU.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM));
    HTU.getConfiguration().set(FConstants.ZOOKEEPER_CLIENT_PORT,
        HTU.getConfiguration().get(HConstants.ZOOKEEPER_CLIENT_PORT));
View Full Code Here

      ZKUtil.deleteNode(zk, zk.clusterStateZNode);
    } catch (KeeperException.NoNodeException nne) {
    }

    // Create the master node with a dummy address
    ServerName master = new ServerName("localhost", 1,
        System.currentTimeMillis());
    // Should not have a master yet
    DummyMaster dummyMaster = new DummyMaster(zk, master);
    ClusterStatusTracker clusterStatusTracker = dummyMaster
        .getClusterStatusTracker();
View Full Code Here

      ZKUtil.deleteNode(zk, zk.clusterStateZNode);
    } catch (KeeperException.NoNodeException nne) {
    }

    // Create the master node with a dummy address
    ServerName firstMasterAddress = new ServerName("localhost", 1,
        System.currentTimeMillis());
    ServerName secondMasterAddress = new ServerName("localhost", 2,
        System.currentTimeMillis());

    // Should not have a master yet
    DummyMaster ms1 = new DummyMaster(zk, firstMasterAddress);
    ActiveMasterManager activeMasterManager = ms1.getActiveMasterManager();
View Full Code Here

   * @throws org.apache.zookeeper.KeeperException
   * @throws java.io.IOException
   */
  private void assertMaster(ZooKeeperWatcher zk, ServerName expectedAddress)
      throws KeeperException, IOException {
    ServerName readAddress = MasterAddressTracker.getMasterAddress(zk);
    assertNotNull(readAddress);
    assertTrue(expectedAddress.equals(readAddress));
  }
View Full Code Here

    for (int i = 0; i < egis.size(); i++) {
      fMetaService.updateEntityGroupLocation(egis.get(i), egLocations[i]);
    }
    for (int i = 0; i < egis.size(); i++) {
      // getEntityGroupLocation
      ServerName sn = fMetaService.getEntityGroupLocation(egis.get(i));
      assertEquals(sn.compareTo(egLocations[i]), 0);
    }

    for (int i = 0; i < egis.size(); i++) {
      // getEntityGroupsAndLocations
      Pair<EntityGroupInfo, ServerName> pair = fMetaService
          .getEntityGroupAndLocation(egis.get(i).getEntityGroupName());
      assertEquals(pair.getFirst().compareTo(egis.get(i)), 0);
      assertEquals(pair.getSecond().compareTo(egLocations[i]), 0);
    }

    Set<String> disabledTables = new HashSet<String>();
    // fullScan
    Map<EntityGroupInfo, ServerName> entityGroups = fMetaService.fullScan(
        disabledTables, false);
    assertEquals(entityGroups.size(), egis.size());
    for (int i = 0; i < egis.size(); i++) {
      ServerName sn = entityGroups.get(egis.get(i));
      assertEquals(sn.compareTo(egLocations[i]), 0);
    }

    // getOfflineSplitParents
    Map<EntityGroupInfo, Result> offlineSplitParents = fMetaService
        .getOfflineSplitParents();
    assertEquals(offlineSplitParents.size(), 0);

    // getServerUserEntityGroups
    NavigableMap<EntityGroupInfo, Result> egR = fMetaService
        .getServerUserEntityGroups(egLocations[0]);
    assertEquals(1, egR.size());
    {
      Result r = egR.get(egis.get(0));
      byte[] infoValue = r.getValue(FConstants.CATALOG_FAMILY,
          FConstants.EGINFO);
      byte[] locationValue = r.getValue(FConstants.CATALOG_FAMILY,
          FConstants.EGLOCATION);
      EntityGroupInfo key = EntityGroupInfo.parseFromOrNull(infoValue);
      ServerName value = ServerName.convert(locationValue);
      assertEquals(key.compareTo(egis.get(0)), 0);
      assertEquals(value.compareTo(egLocations[0]), 0);
    }

    // getTableEntityGroupsAndLocations
    List<Pair<EntityGroupInfo, ServerName>> entityGroupInfos = fMetaService
        .getTableEntityGroupsAndLocations(Bytes.toBytes(tableName), false);
    entityGroups = new TreeMap<EntityGroupInfo, ServerName>();
    for (Pair<EntityGroupInfo, ServerName> pair : entityGroupInfos) {
      entityGroups.put(pair.getFirst(), pair.getSecond());
    }
    for (int i = 0; i < egis.size(); i++) {
      ServerName sn = entityGroups.get(egis.get(i));
      assertEquals(sn.compareTo(egLocations[i]), 0);
    }
    fMetaService.dropTable(FMetaTestUtil.User.getTableName());
  }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.ServerName

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.