Package com.alibaba.wasp

Examples of com.alibaba.wasp.ServerName


   * Update a entityGroup state. If it is not splitting, it will be put in
   * transition if not already there.
   */
  public synchronized EntityGroupState updateEntityGroupState(
      final EntityGroupInfo egi, final EntityGroupState.State state, final ServerName serverName) {
    ServerName newServerName = serverName;
    if (serverName != null &&
        (state == EntityGroupState.State.CLOSED || state == EntityGroupState.State.OFFLINE)) {
      LOG.warn("Closed entityGroup " + egi + " still on "
        + serverName + "? Ignored, reset it to null");
      newServerName = null;
View Full Code Here


    EntityGroupState oldState = entityGroupStates.get(entityGroupName);
    if (oldState == null) {
      LOG.warn("Online a entityGroup not in EntityGroupStates: " + egi);
    } else {
      EntityGroupState.State state = oldState.getState();
      ServerName sn = oldState.getServerName();
      if (state != EntityGroupState.State.OPEN || sn == null || !sn.equals(serverName)) {
        LOG.debug("Online a entityGroup with current state=" + state
            + ", expected state=OPEN"
          + ", assigned to server: " + sn + " expected " + serverName);
      }
    }
    updateEntityGroupState(egi, EntityGroupState.State.OPEN, serverName);
    entityGroupsInTransition.remove(entityGroupName);

    ServerName oldServerName = entityGroupAssignments.put(egi, serverName);
    if (!serverName.equals(oldServerName)) {
      LOG.info("Onlined entityGroup " + egi + " on " + serverName);
      Set<EntityGroupInfo> entityGroups = serverHoldings.get(serverName);
      if (entityGroups == null) {
        entityGroups = new HashSet<EntityGroupInfo>();
View Full Code Here

    EntityGroupState oldState = entityGroupStates.get(entityGroupName);
    if (oldState == null) {
      LOG.warn("Offline a entityGroup not in EntityGroupStates: " + egi);
    } else {
      EntityGroupState.State state = oldState.getState();
      ServerName sn = oldState.getServerName();
      if (state != EntityGroupState.State.OFFLINE || sn != null) {
        LOG.debug("Offline a entityGroup with current state=" + state
            + ", expected state=OFFLINE"
          + ", assigned to server: " + sn + ", expected null");
      }
    }
    updateEntityGroupState(egi, EntityGroupState.State.OFFLINE);
    entityGroupsInTransition.remove(entityGroupName);

    ServerName oldServerName = entityGroupAssignments.remove(egi);
    if (oldServerName != null) {
      LOG.info("Offlined entityGroup " + egi + " from " + oldServerName);
      serverHoldings.get(oldServerName).remove(egi);
    }
  }
View Full Code Here

  protected synchronized double getAverageLoad() {
    int numServers = 0, totalLoad = 0;
    for (Map.Entry<ServerName, Set<EntityGroupInfo>> e : serverHoldings
        .entrySet()) {
      Set<EntityGroupInfo> entityGroups = e.getValue();
      ServerName serverName = e.getKey();
      int entityGroupCount = entityGroups.size();
      if (entityGroupCount > 0 || fserverManager.isServerOnline(serverName)) {
        totalLoad += entityGroupCount;
        numServers++;
      }
View Full Code Here

    // 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,
              RequestConverter.buildUpdateRequest(action));
          writeResultProtos.add(response.getResult());
        }
      } catch (ServiceException e) {
        if (e.getCause() != null && e.getCause() instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw e;
      } catch (Exception e) {
        if (e instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw new ServiceException(e);
      }
    } else if (updateActions.size() > 1) {
      Map<EntityGroupInfo, List<Action>> actionMap = getActionMap(plan
View Full Code Here

    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,
              RequestConverter.buildInsertRequest(action));
          writeResultProtos.add(response.getResult());
        }
      } catch (ServiceException e) {
        if (e.getCause() != null && e.getCause() instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw e;
      } catch (Exception e) {
        if (e instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw new ServiceException(e);
      }
    } else if (actions.size() > 1) {
      Map<EntityGroupInfo, List<Action>> actionMap = getActionMap(plan
View Full Code Here

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

    // 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,
              RequestConverter.buildDeleteRequest(action));
          writeResultProtos.add(response.getResult());
        }
      } catch (ServiceException e) {
        if (e.getCause() != null && e.getCause() instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw e;
      } catch (Exception e) {
        if (e instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw new ServiceException(e);
      }
    } else if (actions.size() > 1) {
      Map<EntityGroupInfo, List<Action>> actionMap = getActionMap(plan
View Full Code Here

    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
              .transaction(null,
                  RequestConverter.buildTransactionRequest(action));
          writeResultProtos.add(response.getResult());
        }
      } catch (ServiceException e) {
        if (e.getCause() != null && e.getCause() instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw e;
      } catch (Exception e) {
        if (e instanceof IOException) {
          connection.clearCaches(serverName.getHostAndPort());
        }
        throw new ServiceException(e);
      }
    } else {
      // TODO
View Full Code Here

    NavigableMap<EntityGroupInfo, ServerName> egiHserverMapping = FMetaScanner
        .allTableEntityGroups(server.getConfiguration(), tableName, false);

    List<EntityGroupInfo> reEntityGroups = new ArrayList<EntityGroupInfo>();
    for (EntityGroupInfo egi : entityGroups) {
      ServerName egLocation = egiHserverMapping.get(egi);

      // Skip the offlined split parent EntityGroup
      if (null == egLocation) {
        LOG.info("Skip " + egi);
        continue;
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.