Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupInfo


      byte[] tableName) {
    List<EntityGroupInfo> tableEntityGroups = new ArrayList<EntityGroupInfo>();
    // boundary needs to have table's name but entityGroupID 0 so that it is
    // sorted
    // before all table's entityGroups.
    EntityGroupInfo boundary = new EntityGroupInfo(tableName,  null, null,
        false, 0L);
    for (EntityGroupInfo egi : entityGroupAssignments.tailMap(boundary)
        .keySet()) {
      if(Bytes.equals(egi.getTableName(), tableName)) {
        tableEntityGroups.add(egi);
View Full Code Here


    }

    try {
      Pair<EntityGroupInfo, ServerName> p = FMetaReader
          .getEntityGroupAndLocation(server.getConfiguration(), entityGroupName);
      EntityGroupInfo egi = p == null ? null : p.getFirst();
      if (egi != null) {
        createEntityGroupState(egi);
      }
      return egi;
    } catch (IOException e) {
View Full Code Here

    // any iterator.
    while (!entityGroupSet.isEmpty() && !server.isStopped()
        && endTime > System.currentTimeMillis()) {
      Iterator<EntityGroupInfo> entityGroupInfoIterator = entityGroupSet.iterator();
      while (entityGroupInfoIterator.hasNext()) {
        EntityGroupInfo egi = entityGroupInfoIterator.next();
        EntityGroupState state = entityGroupStates.getEntityGroupState(egi);
        if ((!entityGroupStates.isEntityGroupInTransition(egi) && entityGroupStates
            .isEntityGroupAssigned(egi)) || state.isSplit() || state.isSplitting()) {
          entityGroupInfoIterator.remove();
        }
View Full Code Here

    List<ClientProtos.WriteResultProto> writeResultProtos = new ArrayList<ClientProtos.WriteResultProto>();
    List<UpdateAction> updateActions = plan.getActions();
    // if actions > 1. will commit by 2pc
    if (updateActions.size() == 1) {
      UpdateAction action = updateActions.get(0);
      EntityGroupInfo entityGroupInfo = action.getEntityGroupLocation()
          .getEntityGroupInfo();
      ServerName serverName = new ServerName(action.getEntityGroupLocation()
          .getHostname(), action.getEntityGroupLocation().getPort(),
          ServerName.NON_STARTCODE);
      try {
        if (workingOnLocalServer(server, serverName)) {
          ClientProtos.UpdateResponse response = server.update(
              entityGroupInfo.getEntityGroupName(), action);
          writeResultProtos.add(response.getResult());
        } else {
          ClientProtocol clientProtocol = connection.getClient(
              serverName.getHostname(), serverName.getPort());
          ClientProtos.UpdateResponse response = clientProtocol.update(null,
View Full Code Here

   */
  private Map<EntityGroupInfo, List<Action>> getActionMap(
      List<? extends Action> actions) {
    Map<EntityGroupInfo, List<Action>> actionMap = new HashMap<EntityGroupInfo, List<Action>>();
    for (Action action : actions) {
      EntityGroupInfo egi = action.getEntityGroupLocation()
          .getEntityGroupInfo();
      List<Action> egActions = actionMap.get(egi);
      if (egActions == null) {
        egActions = new ArrayList<Action>();
        actionMap.put(egi, egActions);
View Full Code Here

  public List<ClientProtos.WriteResultProto> execInsertPlan(InsertPlan plan)
      throws ServiceException {
    List<ClientProtos.WriteResultProto> writeResultProtos = new ArrayList<ClientProtos.WriteResultProto>();
    List<InsertAction> actions = plan.getActions();
    InsertAction action = actions.get(0);
    EntityGroupInfo entityGroupInfo = action.getEntityGroupLocation()
        .getEntityGroupInfo();
    ServerName serverName = new ServerName(action.getEntityGroupLocation()
        .getHostname(), action.getEntityGroupLocation().getPort(),
        ServerName.NON_STARTCODE);
    // if actions > 1. will commit by 2pc
    if (actions.size() == 1) {
      try {

        if (workingOnLocalServer(server, serverName)) {
          ClientProtos.InsertResponse response = server.insert(
              entityGroupInfo.getEntityGroupName(), action);
          writeResultProtos.add(response.getResult());
        } else {
          ClientProtocol clientProtocol = connection.getClient(
              serverName.getHostname(), serverName.getPort());
          ClientProtos.InsertResponse response = clientProtocol.insert(null,
View Full Code Here

    List<ClientProtos.WriteResultProto> writeResultProtos = new ArrayList<ClientProtos.WriteResultProto>();
    List<DeleteAction> actions = plan.getActions();
    // if actions > 1. will commit by 2pc
    if (actions.size() == 1) {
      DeleteAction action = actions.get(0);
      EntityGroupInfo entityGroupInfo = action.getEntityGroupLocation()
          .getEntityGroupInfo();
      ServerName serverName = new ServerName(action.getEntityGroupLocation()
          .getHostname(), action.getEntityGroupLocation().getPort(),
          ServerName.NON_STARTCODE);
      try {
        if (workingOnLocalServer(server, serverName)) {
          ClientProtos.DeleteResponse response = server.delete(
              entityGroupInfo.getEntityGroupName(), action);
          writeResultProtos.add(response.getResult());
        } else {
          ClientProtocol clientProtocol = connection.getClient(
              serverName.getHostname(), serverName.getPort());
          ClientProtos.DeleteResponse response = clientProtocol.delete(null,
View Full Code Here

      DMLTransactionPlan plan) throws ServiceException {
    List<ClientProtos.WriteResultProto> writeResultProtos = new ArrayList<ClientProtos.WriteResultProto>();
    List<TransactionAction> actions = plan.getActions();
    if (actions.size() == 1) {
      TransactionAction action = actions.get(0);
      EntityGroupInfo entityGroupInfo = action.getEntityGroupLocation()
          .getEntityGroupInfo();
      ServerName serverName = new ServerName(action.getEntityGroupLocation()
          .getHostname(), action.getEntityGroupLocation().getPort(),
          ServerName.NON_STARTCODE);
      try {
        if (workingOnLocalServer(server, serverName)) {
          ClientProtos.TransactionResponse response = server.transaction(
              entityGroupInfo.getEntityGroupName(), action);
          writeResultProtos.add(response.getResult());
        } else {
          ClientProtocol clientProtocol = connection.getClient(
              serverName.getHostname(), serverName.getPort());
          ClientProtos.TransactionResponse response = clientProtocol
View Full Code Here

    FServerManager serverManager = ((FMaster) this.server).getFServerManager();
    List<EntityGroupInfo> entityGroups = new ArrayList<EntityGroupInfo>();
    EntityGroupStates entityGroupStates = this.assignmentManager
        .getEntityGroupStates();
    for (Pair<EntityGroupInfo, ServerName> entityGroupLocation : entityGroupsInMeta) {
      EntityGroupInfo egi = entityGroupLocation.getFirst();
      ServerName sn = entityGroupLocation.getSecond();
      if (!entityGroupStates.isEntityGroupInTransition(egi)
          && !entityGroupStates.isEntityGroupAssigned(egi)) {
        if (this.retainAssignment && sn != null
            && serverManager.isServerOnline(sn)) {
          this.assignmentManager.addPlan(egi.getEncodedName(),
              new EntityGroupPlan(egi, null, sn));
        }
        entityGroups.add(egi);
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Skipping assign for the entityGroup " + egi
              + " during enable table " + egi.getTableNameAsString()
              + " because its already in tranition or assigned.");
        }
      }
    }
    return entityGroups;
View Full Code Here

        for (EntityGroupInfo entityGroup : entityGroups) {
          if (assignmentManager.getEntityGroupStates()
              .isEntityGroupInTransition(entityGroup)) {
            continue;
          }
          final EntityGroupInfo egi = entityGroup;
          pool.execute(Trace.wrap(new Runnable() {
            public void run() {
              assignmentManager.assign(egi, true);
            }
          }));
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.