S3Guard { public static void logS3GuardDisabled(Logger logger, String warnLevelStr, String bucket) throws ExitUtil.ExitException, IllegalArgumentException { final DisabledWarnLevel warnLevel; try { warnLevel = DisabledWarnLevel.valueOf(warnLevelStr.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(UNKNOWN_WARN_LEVEL + warnLevelStr, e); } String text = String.format(DISABLED_LOG_MSG, bucket); switch (warnLevel) { case SILENT: logger.debug(text); break; case INFORM: logger.info(text); break; case WARN: logger.warn(text); break; case FAIL: logger.error(text); throw new ExitUtil.ExitException(EXIT_BAD_CONFIGURATION, text); default: throw new IllegalArgumentException(UNKNOWN_WARN_LEVEL + warnLevelStr); } } private  S3Guard(); @Retries.OnceTranslated static MetadataStore getMetadataStore(FileSystem fs,
      ITtlTimeProvider ttlTimeProvider); @RetryTranslated static boolean refreshEntry(
      MetadataStore metadataStore,
      PathMetadata pm,
      S3AFileStatus s3AFileStatus,
      ITtlTimeProvider timeProvider); @RetryTranslated static S3AFileStatus putAndReturn(MetadataStore ms,
      S3AFileStatus status,
      ITtlTimeProvider timeProvider); @RetryTranslated static S3AFileStatus putAndReturn(
      final MetadataStore ms,
      final S3AFileStatus status,
      final ITtlTimeProvider timeProvider,
      @Nullable final BulkOperationState operationState); @RetryTranslated static void putAuthDirectoryMarker(
      final MetadataStore ms,
      final S3AFileStatus status,
      final ITtlTimeProvider timeProvider,
      @Nullable final BulkOperationState operationState); static BulkOperationState initiateBulkWrite(
      @Nullable final MetadataStore metastore,
      final BulkOperationState.OperationType operation,
      final Path path); static S3AFileStatus[] dirMetaToStatuses(DirListingMetadata dirMeta); static RemoteIterator<S3AFileStatus> dirListingUnion(
          MetadataStore ms, Path path,
          RemoteIterator<S3AFileStatus> backingStatuses,
          DirListingMetadata dirMeta, boolean isAuthoritative,
          ITtlTimeProvider timeProvider,
          Function<S3AFileStatus[], RemoteIterator<S3AFileStatus>> toStatusItr); static boolean isNullMetadataStore(MetadataStore ms); @Deprecated @Retries.OnceExceptionsSwallowed static void makeDirsOrdered(MetadataStore ms, List<Path> dirs,
      String owner, boolean authoritative, ITtlTimeProvider timeProvider); static void addMoveDir(MetadataStore ms, Collection<Path> srcPaths,
      Collection<PathMetadata> dstMetas, Path srcPath, Path dstPath,
      String owner); static void addMoveFile(MetadataStore ms, Collection<Path> srcPaths,
      Collection<PathMetadata> dstMetas, Path srcPath, Path dstPath,
      long size, long blockSize, String owner, String eTag, String versionId); static void addMoveAncestors(MetadataStore ms,
      Collection<Path> srcPaths, Collection<PathMetadata> dstMetas,
      Path srcRoot, Path srcPath, Path dstPath, String owner); @Retries.RetryTranslated static void addAncestors(
      final MetadataStore metadataStore,
      final Path qualifiedPath,
      final ITtlTimeProvider timeProvider,
      @Nullable final BulkOperationState operationState); static void assertQualified(Path p); static void assertQualified(Path...paths); static void putWithTtl(MetadataStore ms,
      DirListingMetadata dirMeta,
      final List<Path> unchangedEntries,
      final ITtlTimeProvider timeProvider,
      @Nullable final BulkOperationState operationState); static void putWithTtl(MetadataStore ms, PathMetadata fileMeta,
      @Nullable ITtlTimeProvider timeProvider,
      @Nullable final BulkOperationState operationState); static void putWithTtl(MetadataStore ms,
      Collection<? extends PathMetadata> fileMetas,
      @Nullable ITtlTimeProvider timeProvider,
      @Nullable final BulkOperationState operationState); static PathMetadata getWithTtl(MetadataStore ms, Path path,
      @Nullable ITtlTimeProvider timeProvider,
      final boolean needEmptyDirectoryFlag,
      final boolean allowAuthoritative); @RetryTranslated static DirListingMetadata listChildrenWithTtl(MetadataStore ms,
      Path path,
      @Nullable ITtlTimeProvider timeProvider,
      boolean allowAuthoritative); static Collection<String> getAuthoritativePaths(S3AFileSystem fs); static boolean allowAuthoritative(Path p, S3AFileSystem fs,
      boolean authMetadataStore, Collection<String> authPaths); static void logS3GuardDisabled(Logger logger, String warnLevelStr,
      String bucket); @InterfaceAudience.Private
  @InterfaceStability.Unstable
  @VisibleForTesting
  static final String S3GUARD_DDB_CLIENT_FACTORY_IMPL; @VisibleForTesting
  static final boolean DIR_MERGE_UPDATES_ALL_RECORDS_NONAUTH; @VisibleForTesting
  static final String DISABLED_LOG_MSG; static final String UNKNOWN_WARN_LEVEL; }
@Test public void testLogS3GuardDisabled() throws Exception { final Logger localLogger = LoggerFactory.getLogger( TestS3Guard.class.toString() + UUID.randomUUID()); S3Guard.logS3GuardDisabled(localLogger, S3Guard.DisabledWarnLevel.SILENT.toString(), "bucket"); S3Guard.logS3GuardDisabled(localLogger, S3Guard.DisabledWarnLevel.INFORM.toString(), "bucket"); S3Guard.logS3GuardDisabled(localLogger, S3Guard.DisabledWarnLevel.WARN.toString(), "bucket"); S3Guard.logS3GuardDisabled(localLogger, S3Guard.DisabledWarnLevel.WARN.toString() .toLowerCase(Locale.US), "bucket"); ExitUtil.ExitException ex = LambdaTestUtils.intercept( ExitUtil.ExitException.class, String.format(S3Guard.DISABLED_LOG_MSG, "bucket"), () -> S3Guard.logS3GuardDisabled( localLogger, S3Guard.DisabledWarnLevel.FAIL.toString(), "bucket")); if (ex.getExitCode() != LauncherExitCodes.EXIT_BAD_CONFIGURATION) { throw ex; } LambdaTestUtils.intercept(IllegalArgumentException.class, S3Guard.UNKNOWN_WARN_LEVEL, () -> S3Guard.logS3GuardDisabled( localLogger, "FOO_BAR_LEVEL", "bucket")); }