示例#1
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");
  }
示例#2
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;
  }