Skip to content

Commit ed61044

Browse files
committed
HBASE-24646 Set the log level for ScheduledChore to INFO in HBTU (#1987)
Signed-off-by: Viraj Jasani <vjasani@apache.org> Signed-off-by: stack <stack@apache.org>
1 parent 0fe8594 commit ed61044

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
import java.util.concurrent.ScheduledThreadPoolExecutor;
2222
import java.util.concurrent.TimeUnit;
23-
2423
import org.apache.yetus.audience.InterfaceAudience;
2524
import org.slf4j.Logger;
2625
import org.slf4j.LoggerFactory;
26+
2727
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
2828

2929
/**
@@ -169,11 +169,11 @@ public void run() {
169169
updateTimeTrackingBeforeRun();
170170
if (missedStartTime() && isScheduled()) {
171171
onChoreMissedStartTime();
172-
if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " missed its start time");
172+
LOG.info("Chore: {} missed its start time", getName());
173173
} else if (stopper.isStopped() || !isScheduled()) {
174174
cancel(false);
175175
cleanup();
176-
if (LOG.isInfoEnabled()) LOG.info("Chore: " + getName() + " was stopped");
176+
LOG.info("Chore: {} was stopped", getName());
177177
} else {
178178
try {
179179
// TODO: Histogram metrics per chore name.
@@ -193,7 +193,7 @@ public void run() {
193193
TimeUnit.NANOSECONDS.toMillis(end - start));
194194
}
195195
} catch (Throwable t) {
196-
if (LOG.isErrorEnabled()) LOG.error("Caught error", t);
196+
LOG.error("Caught error", t);
197197
if (this.stopper.isStopped()) {
198198
cancel(false);
199199
cleanup();

hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,9 @@ public MiniDFSCluster startMiniDFSCluster(int servers, final String racks[], St
662662
EditLogFileOutputStream.setShouldSkipFsyncForTesting(true);
663663

664664
// Error level to skip some warnings specific to the minicluster. See HBASE-4709
665-
org.apache.log4j.Logger.getLogger(org.apache.hadoop.metrics2.util.MBeans.class).
666-
setLevel(org.apache.log4j.Level.ERROR);
667-
org.apache.log4j.Logger.getLogger(org.apache.hadoop.metrics2.impl.MetricsSystemImpl.class).
668-
setLevel(org.apache.log4j.Level.ERROR);
665+
Log4jUtils.setLogLevel(org.apache.hadoop.metrics2.util.MBeans.class.getName(), "ERROR");
666+
Log4jUtils.setLogLevel(org.apache.hadoop.metrics2.impl.MetricsSystemImpl.class.getName(),
667+
"ERROR");
669668

670669
TraceUtil.initTracer(conf);
671670

@@ -689,6 +688,10 @@ public MiniDFSCluster startMiniDFSCluster(int servers, final String racks[], St
689688

690689
public MiniDFSCluster startMiniDFSClusterForTestWAL(int namenodePort) throws IOException {
691690
createDirsAndSetProperties();
691+
// Error level to skip some warnings specific to the minicluster. See HBASE-4709
692+
Log4jUtils.setLogLevel(org.apache.hadoop.metrics2.util.MBeans.class.getName(), "ERROR");
693+
Log4jUtils.setLogLevel(org.apache.hadoop.metrics2.impl.MetricsSystemImpl.class.getName(),
694+
"ERROR");
692695
dfsCluster = new MiniDFSCluster(namenodePort, conf, 5, false, true, true, null,
693696
null, null, null);
694697
return dfsCluster;
@@ -1142,16 +1145,15 @@ public MiniHBaseCluster startMiniCluster(StartMiniClusterOption option) throws E
11421145
}
11431146

11441147
/**
1145-
* Starts up mini hbase cluster.
1146-
* Usually you won't want this. You'll usually want {@link #startMiniCluster()}.
1147-
* This is useful when doing stepped startup of clusters.
1148+
* Starts up mini hbase cluster. Usually you won't want this. You'll usually want
1149+
* {@link #startMiniCluster()}. This is useful when doing stepped startup of clusters.
11481150
* @return Reference to the hbase mini hbase cluster.
11491151
* @see #startMiniCluster(StartMiniClusterOption)
11501152
* @see #shutdownMiniHBaseCluster()
11511153
*/
11521154
public MiniHBaseCluster startMiniHBaseCluster(StartMiniClusterOption option)
1153-
throws IOException, InterruptedException {
1154-
// Now do the mini hbase cluster. Set the hbase.rootdir in config.
1155+
throws IOException, InterruptedException {
1156+
// Now do the mini hbase cluster. Set the hbase.rootdir in config.
11551157
createRootDir(option.isCreateRootDir());
11561158
if (option.isCreateWALDir()) {
11571159
createWALRootDir();
@@ -1169,22 +1171,26 @@ public MiniHBaseCluster startMiniHBaseCluster(StartMiniClusterOption option)
11691171
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, option.getNumRegionServers());
11701172
}
11711173

1174+
// Avoid log flooded with chore execution time, see HBASE-24646 for more details.
1175+
Log4jUtils.setLogLevel(org.apache.hadoop.hbase.ScheduledChore.class.getName(), "INFO");
1176+
11721177
Configuration c = new Configuration(this.conf);
11731178
TraceUtil.initTracer(c);
1174-
this.hbaseCluster =
1175-
new MiniHBaseCluster(c, option.getNumMasters(), option.getNumAlwaysStandByMasters(),
1176-
option.getNumRegionServers(), option.getRsPorts(), option.getMasterClass(),
1177-
option.getRsClass());
1179+
this.hbaseCluster = new MiniHBaseCluster(c, option.getNumMasters(),
1180+
option.getNumAlwaysStandByMasters(), option.getNumRegionServers(), option.getRsPorts(),
1181+
option.getMasterClass(), option.getRsClass());
11781182
// Populate the master address configuration from mini cluster configuration.
11791183
conf.set(HConstants.MASTER_ADDRS_KEY, MasterRegistry.getMasterAddr(c));
11801184
// Don't leave here till we've done a successful scan of the hbase:meta
1181-
Table t = getConnection().getTable(TableName.META_TABLE_NAME);
1182-
ResultScanner s = t.getScanner(new Scan());
1183-
while (s.next() != null) {
1184-
continue;
1185+
try (Table t = getConnection().getTable(TableName.META_TABLE_NAME);
1186+
ResultScanner s = t.getScanner(new Scan())) {
1187+
for (;;) {
1188+
if (s.next() == null) {
1189+
break;
1190+
}
1191+
}
11851192
}
1186-
s.close();
1187-
t.close();
1193+
11881194

11891195
getAdmin(); // create immediately the hbaseAdmin
11901196
LOG.info("Minicluster is up; activeMaster={}", getHBaseCluster().getMaster());

0 commit comments

Comments
 (0)