Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupTransaction


    // This may fail if the SPLIT or SPLITTING znode gets cleaned up before we
    // can get data from it.
    byte[] data = ZKAssign.getData(watcher, path);
    if (data == null)
      return false;
    EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(data);
    switch (rt.getEventType()) {
    case FSERVER_ZK_ENTITYGROUP_SPLIT:
    case FSERVER_ZK_ENTITYGROUP_SPLITTING:
      result = true;
      break;
    default:
View Full Code Here


      byte[] data = ZKAssign.getDataNoWatch(watcher, node, stat);
      if (data == null) {
        LOG.warn("Data is null, node " + node + " no longer exists");
        return;
      }
      EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(data);
      EventType et = rt.getEventType();
      if (et == EventType.FSERVER_ZK_ENTITYGROUP_OPENED) {
        LOG.debug("EntityGroup has transitioned to OPENED, allowing "
            + "watched event handlers to process");
        return;
      } else if (et != EventType.FSERVER_ZK_ENTITYGROUP_OPENING
View Full Code Here

   *
   * @return whether the serverName currently hosts the entityGroup
   */
  private boolean isCarryingEntityGroup(ServerName serverName,
      EntityGroupInfo egInfo) {
    EntityGroupTransaction rt = null;
    try {
      byte[] data = ZKAssign.getData(watcher, egInfo.getEncodedName());
      // This call can legitimately come by null
      rt = data == null ? null : EntityGroupTransaction.parseFrom(data);
    } catch (KeeperException e) {
      server.abort("Exception reading unassigned node for entityGroup="
          + egInfo.getEncodedName(), e);
    } catch (DeserializationException e) {
      server.abort("Exception parsing unassigned node for entityGroup="
          + egInfo.getEncodedName(), e);
    }

    ServerName addressFromZK = rt != null ? rt.getServerName() : null;
    if (addressFromZK != null) {
      // if we get something from ZK, we will use the data
      boolean matchZK = (addressFromZK != null && addressFromZK
          .equals(serverName));
      LOG.debug("based on ZK, current entityGroup="
View Full Code Here

      // Assert the ephemeral node is up in zk.
      String path = ZKAssign.getNodeName(zkw, egi.getEncodedName());
      Stat stats = zkw.getRecoverableZooKeeper().exists(path, false);
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats="
          + stats);
      EntityGroupTransaction rtd = EntityGroupTransaction.parseFrom(ZKAssign
          .getData(zkw, egi.getEncodedName()));
      // State could be SPLIT or SPLITTING.
      assertTrue(rtd.getEventType().equals(
          EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLIT)
          || rtd.getEventType().equals(
              EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLITTING));
      // Now crash the server
      cluster.abortFServer(tableEntityGroupIndex);
      waitUntilFServerDead();
      awaitDaughters(tableName, daughters.size());
View Full Code Here

      // Assert the ephemeral node is up in zk.
      String path = ZKAssign.getNodeName(zkw, egi.getEncodedName());
      Stat stats = zkw.getRecoverableZooKeeper().exists(path, false);
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats="
          + stats);
      EntityGroupTransaction rtd = EntityGroupTransaction.parseFrom(ZKAssign
          .getData(zkw, egi.getEncodedName()));
      // State could be SPLIT or SPLITTING.
      assertTrue(rtd.getEventType().equals(
          EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLIT)
          || rtd.getEventType().equals(
              EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLITTING));

      // abort and wait for new master.
      FMaster master = abortAndWaitForMaster();
View Full Code Here

      }
    };
    handler.process();

    // Handler should have transitioned it to FAILED_OPEN
    EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
        .getData(server.getZooKeeper(), TEST_EGI.getEncodedName()));
    assertEquals(EventType.FSERVER_ZK_ENTITYGROUP_FAILED_OPEN,
        rt.getEventType());
  }
View Full Code Here

      }
    };
    handler.process();

    // Handler should have transitioned it to FAILED_OPEN
    EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
        .getData(server.getZooKeeper(), TEST_EGI.getEncodedName()));
    assertEquals(EventType.FSERVER_ZK_ENTITYGROUP_FAILED_OPEN,
        rt.getEventType());
  }
View Full Code Here

    CloseEntityGroupHandler handler = new CloseEntityGroupHandler(server, rss,
        egi, false, true, versionOfClosingNode + 1,
        EventType.M_FSERVER_CLOSE_ENTITYGROUP);
    handler.process();

    EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
        .getData(server.getZooKeeper(), egi.getEncodedName()));
    assertTrue(rt.getEventType().equals(EventType.M_ZK_ENTITYGROUP_CLOSING));
  }
View Full Code Here

        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

      return false;
    } catch (KeeperException e) {
      throw e;
    }
    if (existingBytes == null) return false;
    EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(existingBytes);
    return rt.getEventType().equals(expectedState);
  }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.EntityGroupTransaction

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.