Пример #1
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();
    }
  }
Пример #2
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);
    }
  }