Exemplo n.º 1
0
  public CommandResponse doRemergeque(CommandRequest request) throws ImproperUsageException {
    String slave;
    if (request.hasArgument()) {
      slave = request.getArgument().toLowerCase();
    } else {
      slave = "all";
    }

    ArrayList<String> arr = new ArrayList<String>();

    for (RemoteSlave rslave : GlobalContext.getGlobalContext().getSlaveManager().getSlaves()) {
      if (!rslave.getName().contains(slave) && !slave.equals("all")) {
        continue;
      }

      int size = rslave.doRemergequeue();
      if (!rslave.isOnline()) {
        arr.add(rslave.getName() + " is offline");
      } else if (!rslave.isRemerging()) {
        arr.add(rslave.getName() + " remergeque is complete");
      } else if (size > 0) {
        arr.add(rslave.getName() + " remergeque size is " + size);
      } else {
        arr.add(rslave.getName() + " remergeque size is 0 but remerge is ongoing");
      }
    }
    arr.add("Total commit:" + CommitManager.getCommitManager().getQueueSize());

    CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK");
    for (String str : arr) {
      response.addComment(str);
    }

    return response;
  }
Exemplo n.º 2
0
  public CommandResponse doSITE_REMERGE(CommandRequest request) {
    if (!request.hasArgument()) {
      return StandardCommandManager.genericResponse("RESPONSE_501_SYNTAX_ERROR");
    }

    RemoteSlave rslave;

    try {
      rslave =
          GlobalContext.getGlobalContext().getSlaveManager().getRemoteSlave(request.getArgument());
    } catch (ObjectNotFoundException e) {
      return new CommandResponse(200, "No such slave");
    }

    if (!rslave.isAvailable()) {
      return new CommandResponse(200, "Slave is still merging from initial connect");
    }

    if (rslave.isRemerging()) {
      return new CommandResponse(200, "Slave is still remerging by a previous remerge command");
    }

    boolean CRCRemerge =
        GlobalContext.getConfig()
            .getMainProperties()
            .getProperty("crc.remerge.mode", "true")
            .equals("true");
    rslave.setRemerging(true);
    try {
      rslave.fetchResponse(
          SlaveManager.getBasicIssuer()
              .issueRemergeToSlave(
                  rslave,
                  request.getCurrentDirectory().getPath(),
                  false,
                  0L,
                  0L,
                  false,
                  CRCRemerge),
          0);
    } catch (RemoteIOException e) {
      rslave.setOffline("IOException during remerge()");

      return new CommandResponse(200, "IOException during remerge()");
    } catch (SlaveUnavailableException e) {
      rslave.setOffline("Slave Unavailable during remerge()");

      return new CommandResponse(200, "Slave Unavailable during remerge()");
    } finally {
      String message = ("Remerge queueprocess finished");
      GlobalContext.getEventService().publishAsync(new SlaveEvent("MSGSLAVE", message, rslave));
      rslave.setRemerging(false);
    }

    return StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK");
  }
Exemplo n.º 3
0
  private CommandResponse addSlaveStatus(
      CommandRequest request, CommandResponse response, boolean showMore, RemoteSlave rslave) {
    Session session = request.getSession();
    if (showMore) {
      response.addComment(rslave.moreInfo());
    }

    ReplacerEnvironment env = new ReplacerEnvironment();
    env.add("slavename", rslave.getName());
    try {
      env.add("slaveip", rslave.getPASVIP());
    } catch (SlaveUnavailableException e) {
      env.add("slaveip", "OFFLINE");
    }

    if (rslave.isOnline()) {
      if (!rslave.isAvailable()) {
        response.addComment(
            session.jprintf(_bundle, _keyPrefix + "slave.remerging", env, request.getUser()));
      } else {
        try {
          SlaveStatus status = rslave.getSlaveStatus();
          fillEnvWithSlaveStatus(env, status);
          env.add("status", rslave.isRemerging() ? "REMERGING" : "ONLINE");
          response.addComment(
              session.jprintf(_bundle, _keyPrefix + "slave.online", env, request.getUser()));
        } catch (SlaveUnavailableException e) {
          // should never happen since we tested slave status w/ isOnline and isAvaiable.
          throw new RuntimeException(
              "There's a bug somewhere in the code, the slave was available now it isn't.", e);
        }
      }
    } else {
      response.addComment(
          session.jprintf(_bundle, _keyPrefix + "slave.offline", env, request.getUser()));
    }
    return response;
  }