From 184cced513c5599d7b33c9124692fbcd2e6d338e Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Thu, 29 Nov 2018 08:35:02 -0800 Subject: [PATCH] HDDS-808. Simplify OMAction and DNAction classes used for AuditLogging. Contributed by Dinesh Chitlangia. --- .../apache/hadoop/ozone/audit/DNAction.java | 44 +++++++-------- .../hadoop/ozone/audit/DummyAction.java | 36 ++++++------- .../apache/hadoop/ozone/audit/OMAction.java | 54 +++++++++---------- 3 files changed, 58 insertions(+), 76 deletions(-) diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/DNAction.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/DNAction.java index ce34c46a32..1c87f2bdeb 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/DNAction.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/DNAction.java @@ -21,34 +21,28 @@ package org.apache.hadoop.ozone.audit; */ public enum DNAction implements AuditAction { - CREATE_CONTAINER("CREATE_CONTAINER"), - READ_CONTAINER("READ_CONTAINER"), - UPDATE_CONTAINER("UPDATE_CONTAINER"), - DELETE_CONTAINER("DELETE_CONTAINER"), - LIST_CONTAINER("LIST_CONTAINER"), - PUT_BLOCK("PUT_BLOCK"), - GET_BLOCK("GET_BLOCK"), - DELETE_BLOCK("DELETE_BLOCK"), - LIST_BLOCK("LIST_BLOCK"), - READ_CHUNK("READ_CHUNK"), - DELETE_CHUNK("DELETE_CHUNK"), - WRITE_CHUNK("WRITE_CHUNK"), - LIST_CHUNK("LIST_CHUNK"), - COMPACT_CHUNK("COMPACT_CHUNK"), - PUT_SMALL_FILE("PUT_SMALL_FILE"), - GET_SMALL_FILE("GET_SMALL_FILE"), - CLOSE_CONTAINER("CLOSE_CONTAINER"), - GET_COMMITTED_BLOCK_LENGTH("GET_COMMITTED_BLOCK_LENGTH"); - - private String action; - - DNAction(String action) { - this.action = action; - } + CREATE_CONTAINER, + READ_CONTAINER, + UPDATE_CONTAINER, + DELETE_CONTAINER, + LIST_CONTAINER, + PUT_BLOCK, + GET_BLOCK, + DELETE_BLOCK, + LIST_BLOCK, + READ_CHUNK, + DELETE_CHUNK, + WRITE_CHUNK, + LIST_CHUNK, + COMPACT_CHUNK, + PUT_SMALL_FILE, + GET_SMALL_FILE, + CLOSE_CONTAINER, + GET_COMMITTED_BLOCK_LENGTH; @Override public String getAction() { - return this.action; + return this.toString(); } } diff --git a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/DummyAction.java b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/DummyAction.java index 76cd39ad78..d2da3e632d 100644 --- a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/DummyAction.java +++ b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/DummyAction.java @@ -22,30 +22,24 @@ package org.apache.hadoop.ozone.audit; */ public enum DummyAction implements AuditAction { - CREATE_VOLUME("CREATE_VOLUME"), - CREATE_BUCKET("CREATE_BUCKET"), - CREATE_KEY("CREATE_KEY"), - READ_VOLUME("READ_VOLUME"), - READ_BUCKET("READ_BUCKET"), - READ_KEY("READ_BUCKET"), - UPDATE_VOLUME("UPDATE_VOLUME"), - UPDATE_BUCKET("UPDATE_BUCKET"), - UPDATE_KEY("UPDATE_KEY"), - DELETE_VOLUME("DELETE_VOLUME"), - DELETE_BUCKET("DELETE_BUCKET"), - DELETE_KEY("DELETE_KEY"), - SET_OWNER("SET_OWNER"), - SET_QUOTA("SET_QUOTA"); - - private final String action; - - DummyAction(String action) { - this.action = action; - } + CREATE_VOLUME, + CREATE_BUCKET, + CREATE_KEY, + READ_VOLUME, + READ_BUCKET, + READ_KEY, + UPDATE_VOLUME, + UPDATE_BUCKET, + UPDATE_KEY, + DELETE_VOLUME, + DELETE_BUCKET, + DELETE_KEY, + SET_OWNER, + SET_QUOTA; @Override public String getAction() { - return this.action; + return this.toString(); } } diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/audit/OMAction.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/audit/OMAction.java index 1d4d646239..879401415d 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/audit/OMAction.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/audit/OMAction.java @@ -23,40 +23,34 @@ package org.apache.hadoop.ozone.audit; public enum OMAction implements AuditAction { // WRITE Actions - ALLOCATE_BLOCK("ALLOCATE_BLOCK"), - ALLOCATE_KEY("ALLOCATE_KEY"), - COMMIT_KEY("COMMIT_KEY"), - CREATE_VOLUME("CREATE_VOLUME"), - CREATE_BUCKET("CREATE_BUCKET"), - CREATE_KEY("CREATE_KEY"), - DELETE_VOLUME("DELETE_VOLUME"), - DELETE_BUCKET("DELETE_BUCKET"), - DELETE_KEY("DELETE_KEY"), - RENAME_KEY("RENAME_KEY"), - SET_OWNER("SET_OWNER"), - SET_QUOTA("SET_QUOTA"), - UPDATE_VOLUME("UPDATE_VOLUME"), - UPDATE_BUCKET("UPDATE_BUCKET"), - UPDATE_KEY("UPDATE_KEY"), + ALLOCATE_BLOCK, + ALLOCATE_KEY, + COMMIT_KEY, + CREATE_VOLUME, + CREATE_BUCKET, + CREATE_KEY, + DELETE_VOLUME, + DELETE_BUCKET, + DELETE_KEY, + RENAME_KEY, + SET_OWNER, + SET_QUOTA, + UPDATE_VOLUME, + UPDATE_BUCKET, + UPDATE_KEY, // READ Actions - CHECK_VOLUME_ACCESS("CHECK_VOLUME_ACCESS"), - LIST_BUCKETS("LIST_BUCKETS"), - LIST_VOLUMES("LIST_VOLUMES"), - LIST_KEYS("LIST_KEYS"), - READ_VOLUME("READ_VOLUME"), - READ_BUCKET("READ_BUCKET"), - READ_KEY("READ_BUCKET"), - LIST_S3BUCKETS("LIST_S3BUCKETS"); - - private String action; - - OMAction(String action) { - this.action = action; - } + CHECK_VOLUME_ACCESS, + LIST_BUCKETS, + LIST_VOLUMES, + LIST_KEYS, + READ_VOLUME, + READ_BUCKET, + READ_KEY, + LIST_S3BUCKETS; @Override public String getAction() { - return this.action; + return this.toString(); } }