Esempio n. 1
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) {
        }
      }
    }
Esempio n. 2
0
  private SrmRmdirResponse srmRmdir() throws SRMException {
    URI surl = URI.create(request.getSURL().toString());
    String path = getPath(surl);

    /* If surl is a prefix to any active upload, then we report the directory as
     * non-empty. This is not strictly required by the SRM spec, however S2 tests
     * (usecase.RmdirBeingPutInto) check for this behaviour.
     */
    for (PutFileRequest putFileRequest : Job.getActiveJobs(PutFileRequest.class)) {
      String requestPath = getPath(putFileRequest.getSurl());
      if (path.equals(requestPath)) {
        throw new SRMInvalidPathException("Not a directory");
      }
      if (requestPath.startsWith(path)) {
        throw new SRMNonEmptyDirectoryException("Directory is not empty");
      }
    }

    storage.removeDirectory(user, surl, request.getRecursive() != null && request.getRecursive());
    return new SrmRmdirResponse(new TReturnStatus(TStatusCode.SRM_SUCCESS, null));
  }