コード例 #1
0
  public void getLocalReplicaState(final OSDRequest rq, final xtreemfs_rwr_auth_stateRequest args) {
    master
        .getStorageStage()
        .internalGetReplicaState(
            rq.getFileId(),
            rq.getLocationList().getLocalReplica().getStripingPolicy(),
            0,
            new InternalGetReplicaStateCallback() {

              @Override
              public void getReplicaStateComplete(ReplicaStatus localState, ErrorResponse error) {
                if (error == null) {
                  master
                      .getRWReplicationStage()
                      .eventBackupReplicaReset(
                          rq.getFileId(),
                          args.getState(),
                          localState,
                          args.getFileCredentials(),
                          rq.getLocationList());
                  rq.sendSuccess(emptyResponse.getDefaultInstance(), null);
                } else {
                  sendResult(rq, null, error);
                }
              }
            });
  }
コード例 #2
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);
              }
            });
  }
コード例 #3
0
  public void sendResult(final OSDRequest rq, InternalObjectData response, ErrorResponse error) {

    if (error != null) {
      rq.sendError(error);
    } else {
      // only locally
      rq.sendSuccess(response.getMetadata(), response.getData());
    }
  }
コード例 #4
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);
    }
  }
  @Override
  public ErrorResponse parseRPCMessage(OSDRequest rq) {
    try {
      xtreemfs_rwr_auth_stateRequest rpcrq = (xtreemfs_rwr_auth_stateRequest) 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);
    }
  }
コード例 #6
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();
    }
  }
コード例 #7
0
 public void step2(
     final OSDRequest rq,
     xtreemfs_check_objectRequest args,
     ObjectInformation result,
     ErrorResponse error) {
   if (error != null) {
     rq.sendError(error);
   } else {
     if (rq.getLocationList().getLocalReplica().getOSDs().size() == 1) {
       // non-striped case
       nonStripedCheckObject(rq, args, result);
     } else {
       // striped read
       stripedCheckObject(rq, args, result);
     }
   }
 }
コード例 #8
0
  @Override
  public void startRequest(final OSDRequest rq) {
    final xtreemfs_rwr_auth_stateRequest args =
        (xtreemfs_rwr_auth_stateRequest) rq.getRequestArgs();

    if (Logging.isDebug()) {
      Logging.logMessage(
          Logging.LEVEL_DEBUG, this, "RWR auth state request for file %s", args.getFileId());
    }

    getLocalReplicaState(rq, args);
  }
  private void postInvalidation(final OSDRequest rq) {
    final String fileId = rq.getFileId();

    master
        .getStorageStage()
        .internalGetReplicaState(
            fileId,
            rq.getLocationList().getLocalReplica().getStripingPolicy(),
            0,
            new InternalGetReplicaStateCallback() {

              @Override
              public void getReplicaStateComplete(ReplicaStatus localState, ErrorResponse error) {

                if (error != null) {
                  rq.sendError(error);
                } else {
                  startFetch(rq, localState);
                }
              }
            });
  }
コード例 #10
0
  private void startFetch(final OSDRequest rq, final ReplicaStatus localState) {
    final String fileId = rq.getFileId();
    final XLocations xloc = rq.getLocationList();
    final xtreemfs_rwr_auth_stateRequest args =
        (xtreemfs_rwr_auth_stateRequest) rq.getRequestArgs();

    master
        .getRWReplicationStage()
        .fetchInvalidated(
            fileId,
            args.getState(),
            localState,
            args.getFileCredentials(),
            xloc,
            new RWReplicationCallback() {

              @Override
              public void success(long newObjectVersion) {
                rq.sendSuccess(emptyResponse.getDefaultInstance(), null);
              }

              @Override
              public void failed(ErrorResponse ex) {
                rq.sendError(ex);
              }

              @Override
              public void redirect(String redirectTo) {
                // Not used in fetchInvalidated
                rq.sendError(
                    ErrorUtils.getErrorResponse(
                        ErrorType.INTERNAL_SERVER_ERROR,
                        POSIXErrno.POSIX_ERROR_NONE,
                        "FetchInvalidated called the redirect method. This should never happen"));
              }
            },
            rq);
  }
コード例 #11
0
ファイル: ShutdownOperation.java プロジェクト: 2510/xtreemfs
  @Override
  public void startRequest(OSDRequest rq) {

    // check password to ensure that user is authorized
    Auth authData = rq.getRPCRequest().getHeader().getRequestHeader().getAuthData();
    if (master.getConfig().getAdminPassword().length() > 0
        && !master.getConfig().getAdminPassword().equals(authData.getAuthPasswd())) {
      rq.sendError(
          ErrorType.ERRNO,
          POSIXErrno.POSIX_ERROR_EACCES,
          "this operation requires an admin password");
      return;
    }

    try {
      rq.sendSuccess(null, null);
      Thread.sleep(100);
      master.asyncShutdown();
    } catch (Throwable thr) {
      Logging.logMessage(Logging.LEVEL_ERROR, this, "exception during shutdown");
      Logging.logError(Logging.LEVEL_ERROR, this, thr);
    }
  }
コード例 #12
0
  @Override
  public void startRequest(final OSDRequest rq) {
    final xtreemfs_rwr_auth_stateRequest args =
        (xtreemfs_rwr_auth_stateRequest) rq.getRequestArgs();

    master
        .getPreprocStage()
        .invalidateXLocSet(
            rq,
            args.getFileCredentials(),
            false,
            new InvalidateXLocSetCallback() {

              @Override
              public void invalidateComplete(LeaseState leaseState, ErrorResponse error) {
                if (error != null) {
                  rq.sendError(error);
                } else {
                  postInvalidation(rq);
                }
              }
            });
  }
コード例 #13
0
ファイル: ShutdownOperation.java プロジェクト: 2510/xtreemfs
  @Override
  public ErrorResponse parseRPCMessage(OSDRequest rq) {
    rq.setFileId("");

    return null;
  }
コード例 #14
0
 public void sendResponse(OSDRequest rq, InternalObjectData result) {
   rq.sendSuccess(result.getMetadata(), null);
 }