Package com.alibaba.wasp.fserver

Examples of com.alibaba.wasp.fserver.EntityGroup$InsurePut


    final Server server = new MockServer(WTU);
    final FServerServices rss = new MockFServerServices();

    FTable htd = TEST_FTD;
    final EntityGroupInfo egi = TEST_EGI;
    EntityGroup entityGroup = EntityGroup.createEntityGroup(egi,
        WTU.getConfiguration(), htd, rss);
    assertNotNull(entityGroup);
    try {
      OpenEntityGroupHandler handler = new OpenEntityGroupHandler(server, rss,
          egi, htd) {
        @Override
        EntityGroup openEntityGroup() {
          // Open entityGroup first, then remove znode as though it'd been
          // hijacked.
          EntityGroup entityGroup = super.openEntityGroup();

          // Don't actually open entityGroup BUT remove the znode as though it'd
          // been hijacked on us.
          ZooKeeperWatcher zkw = this.server.getZooKeeper();
          String node = ZKAssign.getNodeName(zkw, egi.getEncodedName());
View Full Code Here


    final Server server = new MockServer(WTU, false);
    final FServerServices rss = new MockFServerServices();
    FTable wtd = TEST_FTD;
    final EntityGroupInfo egi = new EntityGroupInfo(wtd.getTableName(),
        FConstants.EMPTY_END_ROW, FConstants.EMPTY_END_ROW);
    EntityGroup entityGroup = EntityGroup.createEntityGroup(egi,
        WTU.getConfiguration(), wtd, rss);
    try {
      assertNotNull(entityGroup);
      // Spy on the entityGroup so can throw exception when close is called.
      EntityGroup spy = Mockito.spy(entityGroup);
      final boolean abort = false;
      Mockito.when(spy.close(abort)).thenThrow(
          new RuntimeException("Mocked failed close!"));
      rss.addToOnlineEntityGroups(spy);
      assertFalse(server.isStopped());
      CloseEntityGroupHandler handler = new CloseEntityGroupHandler(server,
          rss, egi, false, false, -1, EventType.M_FSERVER_CLOSE_ENTITYGROUP);
View Full Code Here

  @Test
  public void testShouldCloseTheEntityGroupBasedOnTheEncodedEntityGroupName()
      throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestWASPCloseEntityGroup");
    createTableWithDefaultConf(TABLENAME);
    EntityGroup eg = null;
    FServer fs = TEST_UTIL.getFSForFirstEntityGroupInTable(TABLENAME);
    for (EntityGroup entityGroup : fs.getOnlineEntityGroups()) {
      eg = entityGroup;
      admin.closeEntityGroupWithEncodedEntityGroupName(entityGroup
          .getEntityGroupInfo().getEncodedName(), fs.getServerName()
View Full Code Here

  @Test
  public void testCloseEntityGroupIfInvalidEntityGroupNameIsPassed()
      throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestWASPCloseEntityGroup1");
    createTableWithDefaultConf(TABLENAME);
    EntityGroup eg = null;
    FServer fs = TEST_UTIL.getFSForFirstEntityGroupInTable(TABLENAME);
    for (EntityGroup entityGroup : fs.getOnlineEntityGroups()) {
      if (entityGroup.getEntityGroupNameAsString().contains(
          "TestWASPCloseEntityGroup1")) {
        eg = entityGroup;
View Full Code Here

  @Test
  public void testCloseEntityGroupThatFetchesTheEGIFromMeta() throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestWASPCloseEntityGroup2");
    createTableWithDefaultConf(TABLENAME);
    EntityGroup eg = null;
    FServer fs = TEST_UTIL.getFSForFirstEntityGroupInTable(TABLENAME);
    for (EntityGroup entityGroup : fs.getOnlineEntityGroups()) {
      if (entityGroup.getEntityGroupNameAsString().contains(
          "TestWASPCloseEntityGroup2")) {
        eg = entityGroup;
View Full Code Here

  @Test
  public void testCloseEntityGroupWhenEncodedEntityGroupNameIsNotGiven()
      throws Exception {
    byte[] TABLENAME = Bytes.toBytes("TestWASPCloseEntityGroup4");
    createTableWithDefaultConf(TABLENAME);
    EntityGroup eg = null;
    FServer fs = TEST_UTIL.getFSForFirstEntityGroupInTable(TABLENAME);

    for (EntityGroup entityGroup : fs.getOnlineEntityGroups()) {
      if (entityGroup.getEntityGroupNameAsString().contains(
          "TestWASPCloseEntityGroup4")) {
View Full Code Here

    String tableName = "testOpenedEntityGroupHandlerOnMasterRestart";
    MiniWaspCluster cluster = createEntityGroups(tableName);
    abortMaster(cluster);

    FServer entityGroupServer = cluster.getFServer(0);
    EntityGroup entityGroup = getEntityGroupBeingServed(cluster,
        entityGroupServer);

    // forcefully move a entityGroup to OPENED state in zk
    // Create a ZKW to use in the test
    zkw = WaspTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
View Full Code Here

  }

  @Test
  public void testShouldNotCompeleteOpenedEntityGroupSuccessfullyIfVersionMismatches()
      throws Exception {
    EntityGroup entityGroup = null;
    try {
      int testIndex = 0;
      TEST_UTIL.getHBaseTestingUtility().startMiniZKCluster();
      TEST_UTIL.getConfiguration().set(FConstants.ZOOKEEPER_QUORUM,
          TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM));
      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);
      AssignmentManager am = Mockito.mock(AssignmentManager.class);
      EntityGroupStates rsm = Mockito.mock(EntityGroupStates.class);
      Mockito.doReturn(rsm).when(am).getEntityGroupStates();
      when(rsm.isEntityGroupInTransition(egi)).thenReturn(false);
      when(rsm.getEntityGroupState(egi)).thenReturn(
          new EntityGroupState(entityGroup.getEntityGroupInfo(),
              EntityGroupState.State.OPEN, System.currentTimeMillis(), server
                  .getServerName()));
      // create a node with OPENED state
      zkw = WaspTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
          entityGroup, server.getServerName());
      when(am.getZKTable()).thenReturn(new ZKTable(zkw));
      Stat stat = new Stat();
      String nodeName = ZKAssign.getNodeName(zkw, entityGroup
          .getEntityGroupInfo().getEncodedName());
      ZKUtil.getDataAndWatch(zkw, nodeName, stat);

      // use the version for the OpenedEntityGroupHandler
      OpenedEntityGroupHandler handler = new OpenedEntityGroupHandler(server,
          am, entityGroup.getEntityGroupInfo(), server.getServerName(),
          stat.getVersion());
      // Once again overwrite the same znode so that the version changes.
      ZKAssign.transitionNode(zkw, entityGroup.getEntityGroupInfo(),
          server.getServerName(), EventType.FSERVER_ZK_ENTITYGROUP_OPENED,
          EventType.FSERVER_ZK_ENTITYGROUP_OPENED, stat.getVersion());

      // Should not invoke assignmentmanager.entityGroupOnline. If it is
      // invoked as per current mocking it will throw null pointer exception.
      boolean expectedException = false;
      try {
        handler.process();
      } catch (Exception e) {
        expectedException = true;
      }
      assertFalse("The process method should not throw any exception.",
          expectedException);
      List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
          zkw.assignmentZNode);
      String entityGroupName = znodes.get(0);
      assertEquals("The entityGroup should not be opened successfully.",
          entityGroupName, entityGroup.getEntityGroupInfo().getEncodedName());
    } finally {
      EntityGroup.closeEntityGroup(entityGroup);
      TEST_UTIL.getHBaseTestingUtility().shutdownMiniZKCluster();
    }
  }
View Full Code Here

  private EntityGroup getEntityGroupBeingServed(MiniWaspCluster cluster,
      FServer entityGroupServer) {
    Collection<EntityGroup> onlineEntityGroupsLocalContext = entityGroupServer
        .getOnlineEntityGroupsLocalContext();
    Iterator<EntityGroup> iterator = onlineEntityGroupsLocalContext.iterator();
    EntityGroup entityGroup = null;
    while (iterator.hasNext()) {
      entityGroup = iterator.next();
      break;
    }
    return entityGroup;
View Full Code Here

  public int getServerWith(byte[] entityGroupName) {
    int index = -1;
    int count = 0;
    for (JVMClusterUtil.FServerThread rst : getFServerThreads()) {
      FServer hrs = rst.getFServer();
      EntityGroup entityGroup = hrs.getOnlineEntityGroup(entityGroupName);
      if (entityGroup != null) {
        index = count;
        break;
      }
      count++;
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.fserver.EntityGroup$InsurePut

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.