hadoop NoopAuditManagerS3A 源码

  • 2022-10-20
  • 浏览 (108)

haddop NoopAuditManagerS3A 代码


 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package org.apache.hadoop.fs.s3a.audit.impl;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.amazonaws.handlers.RequestHandler2;
import com.amazonaws.services.s3.transfer.Transfer;
import com.amazonaws.services.s3.transfer.internal.TransferStateChangeListener;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.fs.s3a.S3AFileStatus;
import org.apache.hadoop.fs.s3a.audit.AuditManagerS3A;
import org.apache.hadoop.fs.s3a.audit.AuditSpanS3A;
import org.apache.hadoop.fs.s3a.audit.OperationAuditor;
import org.apache.hadoop.fs.s3a.audit.OperationAuditorOptions;
import org.apache.hadoop.service.CompositeService;

import static org.apache.hadoop.fs.statistics.impl.IOStatisticsBinding.iostatisticsStore;

 * Simple No-op audit manager for use before a real
 * audit chain is set up, and for testing.
 * It does have the service lifecycle, so do
 * create a unique instance whenever used.
public class NoopAuditManagerS3A extends CompositeService
    implements AuditManagerS3A, NoopSpan.SpanActivationCallbacks {

  private static final NoopAuditor NOOP_AUDITOR =
      NoopAuditor.createAndStartNoopAuditor(new Configuration(), null);

   * The inner auditor.
  private final NoopAuditor auditor = NOOP_AUDITOR;

   * ID which is returned as a span ID in the audit event
   * callbacks.
  private final String id;

   * Constructor.
   * Will create and start a new instance of the auditor.
  public NoopAuditManagerS3A() {
    id = UUID.randomUUID().toString();

  protected void serviceInit(final Configuration conf) throws Exception {
    NoopAuditor audit = new NoopAuditor(this);
    final OperationAuditorOptions options =

  public String getSpanId() {
    return id;

  public String getOperationName() {
    return getName();

  public OperationAuditor getAuditor() {
    return auditor;

   * Unbonded span to use after deactivation.
  private AuditSpanS3A getUnbondedSpan() {
    return auditor.getUnbondedSpan();

  public AuditSpanS3A getActiveAuditSpan() {
    return NoopSpan.INSTANCE;

  public AuditSpanS3A createSpan(final String operation,
      @Nullable final String path1,
      @Nullable final String path2) throws IOException {
    return createNewSpan(operation, path1, path2);

  public List<RequestHandler2> createRequestHandlers() throws IOException {
    return new ArrayList<>();

  public TransferStateChangeListener createStateChangeListener() {
    return new TransferStateChangeListener() {
      public void transferStateChanged(final Transfer transfer,
          final Transfer.TransferState state) {

   * Forward to the auditor.
   * @param path path to check
   * @param status status of the path.
   * @param mode access mode.
   * @throws IOException failure
  public boolean checkAccess(final Path path,
      final S3AFileStatus status,
      final FsAction mode)
      throws IOException {
    return auditor.checkAccess(path, status, mode);

  public void activate(final AuditSpanS3A span) {
    /* no-op */

  public void deactivate(final AuditSpanS3A span) {

   * A static source of no-op spans, using the same span ID
   * source as managed spans.
   * @param name operation name.
   * @param path1 first path of operation
   * @param path2 second path of operation
   * @return a span for the audit
  public static AuditSpanS3A createNewSpan(
      final String name,
      final String path1,
      final String path2) {
    return NoopSpan.INSTANCE;


hadoop 源码目录


hadoop AbstractAuditSpanImpl 源码

hadoop AbstractOperationAuditor 源码

hadoop ActiveAuditManagerS3A 源码

hadoop LoggingAuditor 源码

hadoop NoopAuditor 源码

hadoop NoopSpan 源码

hadoop S3AInternalAuditConstants 源码

hadoop package-info 源码

0  赞