Class EndpointBase

java.lang.Object
org.apache.hadoop.ozone.s3.endpoint.EndpointBase
All Implemented Interfaces:
org.apache.hadoop.ozone.audit.Auditor
Direct Known Subclasses:
BucketEndpoint, ObjectEndpoint, RootEndpoint

public abstract class EndpointBase extends Object implements org.apache.hadoop.ozone.audit.Auditor
Basic helpers for all the REST endpoints.
  • Field Details

    • ETAG_CUSTOM

      protected static final String ETAG_CUSTOM
      See Also:
    • signatureInfo

      @Inject protected SignatureInfo signatureInfo
    • AUDIT

      protected static final org.apache.hadoop.ozone.audit.AuditLogger AUDIT
  • Constructor Details

    • EndpointBase

      public EndpointBase()
  • Method Details

    • getBucket

      protected org.apache.hadoop.ozone.client.OzoneBucket getBucket(org.apache.hadoop.ozone.client.OzoneVolume volume, String bucketName) throws OS3Exception, IOException
      Throws:
      OS3Exception
      IOException
    • initialization

      @PostConstruct public void initialization()
      Initializes the object post construction. Calls init() from any child classes to work around the issue of only one method can be annotated.
    • init

      public abstract void init()
    • getBucket

      protected org.apache.hadoop.ozone.client.OzoneBucket getBucket(String bucketName) throws OS3Exception, IOException
      Throws:
      OS3Exception
      IOException
    • getVolume

      protected org.apache.hadoop.ozone.client.OzoneVolume getVolume() throws IOException
      Throws:
      IOException
    • createS3Bucket

      protected String createS3Bucket(String bucketName) throws IOException, OS3Exception
      Create an S3Bucket, and also it creates mapping needed to access via ozone and S3.
      Parameters:
      bucketName -
      Returns:
      location of the S3Bucket.
      Throws:
      IOException
      OS3Exception
    • deleteS3Bucket

      protected void deleteS3Bucket(String s3BucketName) throws IOException, OS3Exception
      Deletes an s3 bucket and removes mapping of Ozone volume/bucket.
      Parameters:
      s3BucketName - - S3 Bucket Name.
      Throws:
      IOException - in case the bucket cannot be deleted.
      OS3Exception
    • listS3Buckets

      protected Iterator<? extends org.apache.hadoop.ozone.client.OzoneBucket> listS3Buckets(String prefix, Consumer<org.apache.hadoop.ozone.client.OzoneVolume> volumeProcessor) throws IOException, OS3Exception
      Returns Iterator to iterate over all buckets for a specific user. The result can be restricted using bucket prefix, will return all buckets if bucket prefix is null.
      Parameters:
      prefix - Bucket prefix to match
      volumeProcessor - Volume processor to operate on volume
      Returns:
      Iterator<OzoneBucket>
      Throws:
      IOException
      OS3Exception
    • listS3Buckets

      protected Iterator<? extends org.apache.hadoop.ozone.client.OzoneBucket> listS3Buckets(String prefix, String previousBucket, Consumer<org.apache.hadoop.ozone.client.OzoneVolume> volumeProcessor) throws IOException, OS3Exception
      Returns Iterator to iterate over all buckets after prevBucket for a specific user. If prevBucket is null it returns an iterator to iterate over all buckets for this user. The result can be restricted using bucket prefix, will return all buckets if bucket prefix is null.
      Parameters:
      prefix - Bucket prefix to match
      previousBucket - Buckets are listed after this bucket
      Returns:
      Iterator<OzoneBucket>
      Throws:
      IOException
      OS3Exception
    • getCustomMetadataFromHeaders

      protected Map<String,String> getCustomMetadataFromHeaders(javax.ws.rs.core.MultivaluedMap<String,String> requestHeaders) throws OS3Exception
      Throws:
      OS3Exception
    • addCustomMetadataHeaders

      protected void addCustomMetadataHeaders(javax.ws.rs.core.Response.ResponseBuilder responseBuilder, org.apache.hadoop.ozone.client.OzoneKey key)
    • getTaggingFromHeaders

      protected Map<String,String> getTaggingFromHeaders(javax.ws.rs.core.HttpHeaders httpHeaders) throws OS3Exception
      Throws:
      OS3Exception
    • validateAndGetTagging

      protected static <KV> Map<String,String> validateAndGetTagging(List<KV> tagList, Function<KV,String> getTagKey, Function<KV,String> getTagValue) throws OS3Exception
      Throws:
      OS3Exception
    • buildAuditMessageForSuccess

      public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForSuccess(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap)
      Specified by:
      buildAuditMessageForSuccess in interface org.apache.hadoop.ozone.audit.Auditor
    • buildAuditMessageForSuccess

      public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForSuccess(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap, org.apache.hadoop.ozone.audit.AuditLogger.PerformanceStringBuilder performance)
    • buildAuditMessageForFailure

      public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForFailure(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap, Throwable throwable)
      Specified by:
      buildAuditMessageForFailure in interface org.apache.hadoop.ozone.audit.Auditor
    • setClient

      public void setClient(org.apache.hadoop.ozone.client.OzoneClient ozoneClient)
    • setRequestIdentifier

      public void setRequestIdentifier(RequestIdentifier requestIdentifier)
    • setSignatureInfo

      public void setSignatureInfo(SignatureInfo signatureInfo)
    • getClient

      public org.apache.hadoop.ozone.client.OzoneClient getClient()
    • getClientProtocol

      protected org.apache.hadoop.ozone.client.protocol.ClientProtocol getClientProtocol()
    • getMetrics

      public S3GatewayMetrics getMetrics()
    • getAuditParameters

      protected Map<String,String> getAuditParameters()
    • auditWriteFailure

      protected void auditWriteFailure(org.apache.hadoop.ozone.audit.AuditAction action, Throwable ex)
    • auditReadFailure

      protected void auditReadFailure(org.apache.hadoop.ozone.audit.AuditAction action, Exception ex)
    • isAccessDenied

      protected boolean isAccessDenied(org.apache.hadoop.ozone.om.exceptions.OMException ex)