示例#1
0
  @Override
  public void startRequest(final OSDRequest rq) {
    final xtreemfs_check_objectRequest args = (xtreemfs_check_objectRequest) rq.getRequestArgs();

    if (args.getObjectNumber() < 0) {
      rq.sendError(ErrorType.ERRNO, POSIXErrno.POSIX_ERROR_EINVAL, "object number must be >= 0");
      return;
    }

    master
        .getStorageStage()
        .readObject(
            args.getFileId(),
            args.getObjectNumber(),
            rq.getLocationList().getLocalReplica().getStripingPolicy(),
            0,
            StorageLayout.FULL_OBJECT_LENGTH,
            rq.getCapability().getSnapConfig() == SnapConfig.SNAP_CONFIG_ACCESS_SNAP
                ? rq.getCapability().getSnapTimestamp()
                : 0,
            rq,
            new ReadObjectCallback() {

              @Override
              public void readComplete(ObjectInformation result, ErrorResponse error) {
                step2(rq, args, result, error);
              }
            });
  }
示例#2
0
  private void stripedCheckObjectAnalyzeGmax(
      final OSDRequest rq,
      final xtreemfs_check_objectRequest args,
      final ObjectInformation result,
      RPCResponse[] gmaxRPCs) {
    long maxObjNo = -1;
    long maxTruncate = -1;

    try {
      for (int i = 0; i < gmaxRPCs.length; i++) {
        InternalGmax gmax = (InternalGmax) gmaxRPCs[i].get();
        if ((gmax.getLastObjectId() > maxObjNo) && (gmax.getEpoch() >= maxTruncate)) {
          // found new max
          maxObjNo = gmax.getLastObjectId();
          maxTruncate = gmax.getEpoch();
        }
      }
      final boolean isLastObjectLocallyKnown = maxObjNo <= args.getObjectNumber();
      readFinish(rq, args, result, isLastObjectLocallyKnown);
      // and update gmax locally
      master.getStorageStage().receivedGMAX_ASYNC(args.getFileId(), maxTruncate, maxObjNo);
    } catch (Exception ex) {
      rq.sendInternalServerError(ex);
    } finally {
      for (RPCResponse r : gmaxRPCs) r.freeBuffers();
    }
  }
示例#3
0
  private void stripedCheckObject(
      final OSDRequest rq,
      final xtreemfs_check_objectRequest args,
      final ObjectInformation result) {
    // ObjectData data;
    final long objNo = args.getObjectNumber();
    final long lastKnownObject =
        Math.max(result.getLastLocalObjectNo(), result.getGlobalLastObjectNo());
    final boolean isLastObjectLocallyKnown = lastKnownObject <= objNo;
    // check if GMAX must be fetched to determin EOF
    if ((objNo > lastKnownObject)
        || (objNo == lastKnownObject)
            && (result.getData() != null)
            && (result.getData().remaining() < result.getStripeSize())) {
      try {
        final List<ServiceUUID> osds = rq.getLocationList().getLocalReplica().getOSDs();
        final RPCResponse[] gmaxRPCs = new RPCResponse[osds.size() - 1];
        int cnt = 0;
        for (ServiceUUID osd : osds) {
          if (!osd.equals(localUUID)) {
            gmaxRPCs[cnt++] =
                master
                    .getOSDClient()
                    .xtreemfs_internal_get_gmax(
                        osd.getAddress(),
                        RPCAuthentication.authNone,
                        RPCAuthentication.userService,
                        args.getFileCredentials(),
                        args.getFileId());
          }
        }
        this.waitForResponses(
            gmaxRPCs,
            new ResponsesListener() {

              @Override
              public void responsesAvailable() {
                stripedCheckObjectAnalyzeGmax(rq, args, result, gmaxRPCs);
              }
            });
      } catch (IOException ex) {
        rq.sendInternalServerError(ex);
        return;
      }
    } else {
      readFinish(rq, args, result, isLastObjectLocallyKnown);
    }
  }
示例#4
0
  @Override
  public ErrorResponse parseRPCMessage(OSDRequest rq) {
    try {
      xtreemfs_check_objectRequest rpcrq = (xtreemfs_check_objectRequest) rq.getRequestArgs();
      rq.setFileId(rpcrq.getFileId());
      rq.setCapability(new Capability(rpcrq.getFileCredentials().getXcap(), sharedSecret));
      rq.setLocationList(new XLocations(rpcrq.getFileCredentials().getXlocs(), localUUID));

      return null;
    } catch (InvalidXLocationsException ex) {
      return ErrorUtils.getErrorResponse(
          ErrorType.ERRNO, POSIXErrno.POSIX_ERROR_EINVAL, ex.toString());
    } catch (Throwable ex) {
      return ErrorUtils.getInternalServerError(ex);
    }
  }
示例#5
0
  private void nonStripedCheckObject(
      OSDRequest rq, xtreemfs_check_objectRequest args, ObjectInformation result) {

    final boolean isLastObjectOrEOF = result.getLastLocalObjectNo() <= args.getObjectNumber();
    readFinish(rq, args, result, isLastObjectOrEOF);
  }