From 83e77940c56f8cfd54b925eb07aa428d756ee2c7 Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Wed, 28 Aug 2019 11:29:09 -0500 Subject: [PATCH] HBASE-22943 Various procedures should not cache log trace level (#557) Signed-off-by: Peter Somogyi --- .../assignment/SplitTableRegionProcedure.java | 17 +---------------- .../procedure/CloneSnapshotProcedure.java | 17 +---------------- .../master/procedure/EnableTableProcedure.java | 18 +----------------- .../procedure/RestoreSnapshotProcedure.java | 18 +----------------- 4 files changed, 4 insertions(+), 66 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java index 9031f44b230..fc2017617a2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java @@ -92,7 +92,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.S public class SplitTableRegionProcedure extends AbstractStateMachineRegionProcedure { private static final Logger LOG = LoggerFactory.getLogger(SplitTableRegionProcedure.class); - private Boolean traceEnabled = null; private RegionInfo daughterOneRI; private RegionInfo daughterTwoRI; private byte[] bestSplitRow; @@ -341,9 +340,7 @@ public class SplitTableRegionProcedure @Override protected void rollbackState(final MasterProcedureEnv env, final SplitTableRegionState state) throws IOException, InterruptedException { - if (isTraceEnabled()) { - LOG.trace(this + " rollback state=" + state); - } + LOG.trace("{} rollback state={}", this, state); try { switch (state) { @@ -887,18 +884,6 @@ public class SplitTableRegionProcedure } } - /** - * The procedure could be restarted from a different machine. If the variable is null, we need to - * retrieve it. - * @return traceEnabled - */ - private boolean isTraceEnabled() { - if (traceEnabled == null) { - traceEnabled = LOG.isTraceEnabled(); - } - return traceEnabled; - } - @Override protected boolean abort(MasterProcedureEnv env) { // Abort means rollback. We can't rollback all steps. HBASE-18018 added abort to all diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CloneSnapshotProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CloneSnapshotProcedure.java index d351d675384..c569de2549f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CloneSnapshotProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CloneSnapshotProcedure.java @@ -78,8 +78,6 @@ public class CloneSnapshotProcedure // Monitor private MonitoredTask monitorStatus = null; - private Boolean traceEnabled = null; - /** * Constructor (for failover) */ @@ -130,9 +128,7 @@ public class CloneSnapshotProcedure @Override protected Flow executeFromState(final MasterProcedureEnv env, final CloneSnapshotState state) throws InterruptedException { - if (isTraceEnabled()) { - LOG.trace(this + " execute state=" + state); - } + LOG.trace("{} execute state={}", this, state); try { switch (state) { case CLONE_SNAPSHOT_PRE_OPERATION: @@ -519,15 +515,4 @@ public class CloneSnapshotProcedure metaChanges.updateMetaParentRegions(env.getMasterServices().getConnection(), newRegions); } - /** - * The procedure could be restarted from a different machine. If the variable is null, we need to - * retrieve it. - * @return traceEnabled - */ - private Boolean isTraceEnabled() { - if (traceEnabled == null) { - traceEnabled = LOG.isTraceEnabled(); - } - return traceEnabled; - } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java index 3994304d423..06d6a2cfc52 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.java @@ -52,8 +52,6 @@ public class EnableTableProcedure private TableName tableName; - private Boolean traceEnabled = null; - public EnableTableProcedure() { } @@ -80,9 +78,7 @@ public class EnableTableProcedure @Override protected Flow executeFromState(final MasterProcedureEnv env, final EnableTableState state) throws InterruptedException { - if (isTraceEnabled()) { - LOG.trace(this + " execute state=" + state); - } + LOG.trace("{} execute state={}", this, state); try { switch (state) { @@ -389,18 +385,6 @@ public class EnableTableProcedure runCoprocessorAction(env, state); } - /** - * The procedure could be restarted from a different machine. If the variable is null, we need to - * retrieve it. - * @return traceEnabled - */ - private Boolean isTraceEnabled() { - if (traceEnabled == null) { - traceEnabled = LOG.isTraceEnabled(); - } - return traceEnabled; - } - /** * Coprocessor Action. * @param env MasterProcedureEnv diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java index 80fc544736e..244711de20a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java @@ -77,8 +77,6 @@ public class RestoreSnapshotProcedure // Monitor private MonitoredTask monitorStatus = null; - private Boolean traceEnabled = null; - /** * Constructor (for failover) */ @@ -129,9 +127,7 @@ public class RestoreSnapshotProcedure @Override protected Flow executeFromState(final MasterProcedureEnv env, final RestoreSnapshotState state) throws InterruptedException { - if (isTraceEnabled()) { - LOG.trace(this + " execute state=" + state); - } + LOG.trace("{} execute state={}", this, state); // Make sure that the monitor status is set up getMonitorStatus(); @@ -549,16 +545,4 @@ public class RestoreSnapshotProcedure env.getMasterServices().getConfiguration()); } } - - /** - * The procedure could be restarted from a different machine. If the variable is null, we need to - * retrieve it. - * @return traceEnabled - */ - private Boolean isTraceEnabled() { - if (traceEnabled == null) { - traceEnabled = LOG.isTraceEnabled(); - } - return traceEnabled; - } }