@Override
 public PreparedStatement getCreateStatement(Connection connection, Job job) throws SQLException {
   if (job == null || !(job instanceof PutFileRequest)) {
     throw new IllegalArgumentException("fr is not PutFileRequest");
   }
   PutFileRequest request = (PutFileRequest) job;
   TRetentionPolicy retentionPolicy = request.getRetentionPolicy();
   TAccessLatency accessLatency = request.getAccessLatency();
   return getPreparedStatement(
       connection,
       INSERT_SQL,
       request.getId(),
       request.getNextJobId(),
       request.getCreationTime(),
       request.getLifetime(),
       request.getState().getStateId(),
       request.getErrorMessage(),
       request.getSchedulerId(),
       request.getSchedulerTimeStamp(),
       0, // num of retries
       request.getLastStateTransitionTime(),
       request.getRequestId(),
       request.getStatusCodeString(),
       request.getSurlString(),
       request.getTurlString(),
       request.getFileId(),
       null, // parentFileId (unused)
       request.getSpaceReservationId(),
       request.getSize(),
       (retentionPolicy != null ? retentionPolicy.getValue() : null),
       (accessLatency != null ? accessLatency.getValue() : null));
 }
 private PreparedStatement getStatement(Connection connection, String query, Job job)
     throws SQLException {
   PutFileRequest request = (PutFileRequest) job;
   TRetentionPolicy retentionPolicy = request.getRetentionPolicy();
   TAccessLatency accessLatency = request.getAccessLatency();
   return getPreparedStatement(
       connection,
       query,
       request.getNextJobId(),
       request.getCreationTime(),
       request.getLifetime(),
       request.getState().getStateId(),
       request.getErrorMessage(),
       request.getSchedulerId(),
       request.getSchedulerTimeStamp(),
       0, // num of retries
       request.getLastStateTransitionTime(),
       request.getRequestId(),
       request.getStatusCodeString(),
       request.getSurlString(),
       request.getTurlString(),
       request.getFileId(),
       null, // parentFileId (unused)
       request.getSpaceReservationId(),
       request.getSize(),
       (retentionPolicy != null ? retentionPolicy.getValue() : null),
       (accessLatency != null ? accessLatency.getValue() : null),
       request.getId());
 }
Exemple #3
0
    @Override
    public void run() {
      try {
        PutFileRequest fr = Job.getJob(fileRequestJobId, PutFileRequest.class);

        try {
          String fileId = future.checkedGet();

          State state = fr.getState();
          switch (state) {
            case INPROGRESS:
              logger.trace("Storage info arrived for file {}.", fr.getSurlString());
              fr.setFileId(fileId);
              fr.saveJob(true);
              Scheduler.getScheduler(fr.getSchedulerId()).execute(fr);
              break;
            case CANCELED:
            case FAILED:
              fr.getStorage().abortPut(fr.getUser(), fileId, fr.getSurl(), fr.getErrorMessage());
              break;
            default:
              logger.error("Put request is in an unexpected state in callback: {}", state);
              fr.getStorage().abortPut(fr.getUser(), fileId, fr.getSurl(), fr.getErrorMessage());
              break;
          }
        } catch (SRMException e) {
          fr.setStateAndStatusCode(State.FAILED, e.getMessage(), e.getStatusCode());
        }
      } catch (IllegalStateTransition ist) {
        if (!ist.getFromState().isFinal()) {
          logger.error(ist.getMessage());
        }
      } catch (SRMInvalidRequestException e) {
        try {
          String fileId = future.checkedGet();
          SRM.getSRM()
              .getStorage()
              .abortPut(user, fileId, surl, "Request was aborted while being prepared.");
        } catch (SRMException ignored) {
        }
      }
    }