/**
   * Dummy Main method
   *
   * @param args
   */
  public static void main(String[] args) {
    InternalLoggerFactory.setDefaultFactory(new WaarpSlf4JLoggerFactory(null));
    if (logger == null) {
      logger = WaarpInternalLoggerFactory.getLogger(AbstractBusinessRequest.class);
    }
    if (!getParams(args)) {
      logger.error("Wrong initialization");
      if (DbConstant.admin != null && DbConstant.admin.isConnected) {
        DbConstant.admin.close();
      }
      ChannelUtils.stopLogger();
      System.exit(2);
    }

    Configuration.configuration.pipelineInit();
    NetworkTransaction networkTransaction = new NetworkTransaction();
    R66Future future = new R66Future(true);

    logger.info("Start Test of Transaction");
    long time1 = System.currentTimeMillis();

    @SuppressWarnings("unused")
    BusinessRequestPacket packet = new BusinessRequestPacket(classname + " " + classarg, 0);
    // XXX FIXME this has to be adapted
    /*
     * AbstractBusinessRequest transaction = new AbstractBusinessRequest(
     * AbstractBusinessRequest.class, future, rhost, networkTransaction, packet);
     * transaction.run(); future.awaitUninterruptibly();
     */
    long time2 = System.currentTimeMillis();
    logger.debug("Finish Business Request: " + future.isSuccess());
    long delay = time2 - time1;
    if (future.isSuccess()) {
      logger.info(
          "Business Request in status:\nSUCCESS"
              + "\n    <REMOTE>"
              + rhost
              + "</REMOTE>"
              + "\n    delay: "
              + delay);
    } else {
      logger.info(
          "Business Request in status:\nFAILURE"
              + "\n    <REMOTE>"
              + rhost
              + "</REMOTE>"
              + "\n    <ERROR>"
              + future.getCause()
              + "</ERROR>"
              + "\n    delay: "
              + delay);
      networkTransaction.closeAll();
      System.exit(ErrorCode.Unknown.ordinal());
    }
    networkTransaction.closeAll();
  }
Пример #2
0
 /**
  * This should be called when the server is shutting down, after stopping active requests if
  * possible.
  */
 public void stopInternalRunner() {
   isRunning = false;
   logger.info("Stopping Commander and Runner Tasks");
   scheduledFuture.cancel(false);
   scheduledExecutorService.shutdownNow();
   threadPoolExecutor.shutdownNow();
   networkTransaction.closeAll(false);
 }
Пример #3
0
  /** @param args */
  public static void main(String[] args) {
    InternalLoggerFactory.setDefaultFactory(new WaarpSlf4JLoggerFactory(null));
    if (logger == null) {
      logger = WaarpInternalLoggerFactory.getLogger(TestSendThroughClient.class);
    }
    if (!getParams(args, false)) {
      logger.error("Wrong initialization");
      if (DbConstant.admin != null && DbConstant.admin.isConnected) {
        DbConstant.admin.close();
      }
      System.exit(1);
    }
    Configuration.configuration.pipelineInit();
    NetworkTransaction networkTransaction = new NetworkTransaction();
    try {
      R66Future future = new R66Future(true);
      TestSendThroughClient transaction =
          new TestSendThroughClient(
              future, rhost, localFilename, rule, fileInfo, ismd5, block, networkTransaction);
      long time1 = System.currentTimeMillis();
      if (!transaction.initiateRequest()) {
        logger.error("Transfer in Error", future.getCause());
        return;
      }
      if (transaction.sendFile()) {
        transaction.finalizeRequest();
      } else {
        transaction.transferInError(null);
      }
      future.awaitUninterruptibly();

      long time2 = System.currentTimeMillis();
      long delay = time2 - time1;
      R66Result result = future.getResult();
      if (future.isSuccess()) {
        if (result.runner.getErrorInfo() == ErrorCode.Warning) {
          logger.warn(
              "Warning with Id: "
                  + result.runner.getSpecialId()
                  + " on file: "
                  + (result.file != null ? result.file.toString() : "no file")
                  + " delay: "
                  + delay);
        } else {
          logger.warn(
              "Success with Id: "
                  + result.runner.getSpecialId()
                  + " on Final file: "
                  + (result.file != null ? result.file.toString() : "no file")
                  + " delay: "
                  + delay);
        }
        if (nolog) {
          // In case of success, delete the runner
          try {
            result.runner.delete();
          } catch (WaarpDatabaseException e) {
            logger.warn("Cannot apply nolog to " + result.runner.toString(), e);
          }
        }
      } else {
        if (result == null || result.runner == null) {
          logger.warn("Transfer in Error with no Id", future.getCause());
          networkTransaction.closeAll();
          System.exit(1);
        }
        if (result.runner.getErrorInfo() == ErrorCode.Warning) {
          logger.warn(
              "Transfer in Warning with Id: " + result.runner.getSpecialId(), future.getCause());
          networkTransaction.closeAll();
          System.exit(result.code.ordinal());
        } else {
          logger.error(
              "Transfer in Error with Id: " + result.runner.getSpecialId(), future.getCause());
          networkTransaction.closeAll();
          System.exit(result.code.ordinal());
        }
      }
    } finally {
      networkTransaction.closeAll();
    }
  }