This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new 923758c9f8 Log BCFile read/seek calls, FileSystem ops, and S3 API
calls (#6677)
923758c9f8 is described below
commit 923758c9f85035f14d28593ebd7594168e0b4141
Author: Dave Marion <[email protected]>
AuthorDate: Fri Dec 4 08:40:59 2026 -0500
Log BCFile read/seek calls, FileSystem ops, and S3 API calls (#6677)
Added the ability to track seek and read calls on the
underlying FSDataInputStream from BCFile. This will allow
users to get a better understanding of their calls performing IO.
Co-authored-by: Keith Turner <[email protected]>
---
assemble/conf/log4j2-service.properties | 29 ++++++++
assemble/conf/log4j2.properties | 31 ++++++++
.../accumulo/core/client/rfile/RFileScanner.java | 6 ++
.../accumulo/core/client/rfile/RFileWriter.java | 6 ++
.../file/blockfile/impl/CachableBlockFile.java | 9 ++-
.../accumulo/core/file/rfile/bcfile/BCFile.java | 21 ++++--
.../core/file/rfile/bcfile/PrintBCInfo.java | 4 +-
.../file/streams/LoggingFilterInputStream.java | 86 +++++++++++++++++++++
.../streams/LoggingSeekableDataInputStream.java | 35 +++++++++
.../core/logging/FileOperationsLogger.java | 87 ++++++++++++++++++++++
.../java/org/apache/accumulo/core/util/Timer.java | 3 +
.../org/apache/accumulo/server/ServerContext.java | 2 +
12 files changed, 308 insertions(+), 11 deletions(-)
diff --git a/assemble/conf/log4j2-service.properties
b/assemble/conf/log4j2-service.properties
index f96e472252..e784eb4504 100644
--- a/assemble/conf/log4j2-service.properties
+++ b/assemble/conf/log4j2-service.properties
@@ -86,6 +86,35 @@ logger.accumulo.level = debug
#logger.audit.additivity = false
#logger.audit.appenderRef.audit.ref = AuditLogFiles
+# uncomment for low level File Operations logging
+#appender.fileops.type = RollingFile
+#appender.fileops.name = FileOpsLogFiles
+#appender.fileops.fileName = ${filename}.file-ops
+#appender.fileops.filePattern = ${filename}-%d{yyyy-MM-dd}-%i.file-ops.gz
+#appender.fileops.layout.type = PatternLayout
+#appender.fileops.layout.pattern = %d{ISO8601} Thread[%T] [%-8c{2}] %-5p: %m%n
+#appender.fileops.policies.type = Policies
+#appender.fileops.policies.time.type = TimeBasedTriggeringPolicy
+#appender.fileops.policies.time.interval = 1
+#appender.fileops.policies.time.modulate = true
+#appender.fileops.policies.size.type = SizeBasedTriggeringPolicy
+#appender.fileops.policies.size.size=512MB
+#appender.fileops.strategy.type = DefaultRolloverStrategy
+#appender.fileops.strategy.max = 10
+#
+#logger.fileops.name = org.apache.accumulo.file_ops
+## logging is only enabled if level is set to trace
+#logger.fileops.level = trace
+#logger.fileops.additivity = false
+#logger.fileops.appenderRef.fileops.ref = FileOpsLogFiles
+#
+# See
https://hadoop.apache.org/docs/current/hadoop-aws/tools/hadoop-aws/auditing.html
+#logger.s3aAudit.name = org.apache.hadoop.fs.s3a.audit.impl.LoggingAuditor
+## logging is only enabled if level is set to debug
+#logger.s3aAudit.level = debug
+#logger.s3aAudit.additivity = false
+#logger.s3aAudit.appenderRef.s3aAudit.ref = FileOpsLogFiles
+
rootLogger.level = info
rootLogger.appenderRef.console.ref = STDERR
rootLogger.appenderRef.rolling.ref = LogFiles
diff --git a/assemble/conf/log4j2.properties b/assemble/conf/log4j2.properties
index c216ad1690..c55861a2a6 100644
--- a/assemble/conf/log4j2.properties
+++ b/assemble/conf/log4j2.properties
@@ -41,5 +41,36 @@ logger.shell.level = info
logger.zookeeper.name = org.apache.zookeeper
logger.zookeeper.level = error
+# uncomment for low level File Operations logging
+#appender.fileops.type = RollingFile
+#appender.fileops.name = FileOpsLogFiles
+#appender.fileops.fileName = ${filename}.file-ops
+#appender.fileops.filePattern = ${filename}-%d{yyyy-MM-dd}-%i.file-ops.gz
+#appender.fileops.layout.type = PatternLayout
+#appender.fileops.layout.pattern = %d{ISO8601} Thread[%T] [%-8c{2}] %-5p: %m%n
+#appender.fileops.policies.type = Policies
+#appender.fileops.policies.time.type = TimeBasedTriggeringPolicy
+#appender.fileops.policies.time.interval = 1
+#appender.fileops.policies.time.modulate = true
+#appender.fileops.policies.size.type = SizeBasedTriggeringPolicy
+#appender.fileops.policies.size.size=512MB
+#appender.fileops.strategy.type = DefaultRolloverStrategy
+#appender.fileops.strategy.max = 10
+#
+#
+#logger.fileops.name = org.apache.accumulo.file_ops
+## logging is only enabled if level is set to trace
+#logger.fileops.level = trace
+#logger.fileops.additivity = false
+#logger.fileops.appenderRef.fileops.ref = FileOpsLogFiles
+#
+# See
https://hadoop.apache.org/docs/current/hadoop-aws/tools/hadoop-aws/auditing.html
+#logger.s3aAudit.name = org.apache.hadoop.fs.s3a.audit.impl.LoggingAuditor
+## logging is only enabled if level is set to debug
+#logger.s3aAudit.level = debug
+#logger.s3aAudit.additivity = false
+#logger.s3aAudit.appenderRef.s3aAudit.ref = FileOpsLogFiles
+
+
rootLogger.level = info
rootLogger.appenderRef.console.ref = STDERR
diff --git
a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java
b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java
index f926a4fffc..b37912c8fd 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.concurrent.NotThreadSafe;
@@ -65,6 +67,7 @@ import
org.apache.accumulo.core.iteratorsImpl.IteratorConfigUtil;
import org.apache.accumulo.core.iteratorsImpl.system.MultiIterator;
import org.apache.accumulo.core.iteratorsImpl.system.MultiShuffledIterator;
import org.apache.accumulo.core.iteratorsImpl.system.SystemIteratorUtil;
+import org.apache.accumulo.core.logging.FileOperationsLogger;
import org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.spi.cache.BlockCache;
@@ -126,6 +129,7 @@ class RFileScanner extends ScannerOptions implements
Scanner {
private long readaheadThreshold = 3;
private final AccumuloConfiguration tableConf;
private final CryptoService cryptoService;
+ private final ScheduledExecutorService executor =
Executors.newScheduledThreadPool(1);
static class Opts {
InputArgs in;
@@ -180,6 +184,7 @@ class RFileScanner extends ScannerOptions implements
Scanner {
}
this.cryptoService =
CryptoFactoryLoader.getServiceForClient(CryptoEnvironment.Scope.TABLE,
opts.tableConfig);
+ FileOperationsLogger.startLoggingFileSystemMetrics(executor);
}
@Override
@@ -348,6 +353,7 @@ class RFileScanner extends ScannerOptions implements
Scanner {
@Override
public void close() {
+ executor.shutdownNow();
try {
for (RFileSource source : opts.in.getSources()) {
source.getInputStream().close();
diff --git
a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
index a8e98481ee..ee89b5e629 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileWriter.java
@@ -24,6 +24,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.data.ArrayByteSequence;
@@ -32,6 +34,7 @@ import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.LoadPlan;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.file.FileSKVWriter;
+import org.apache.accumulo.core.logging.FileOperationsLogger;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.commons.collections4.map.LRUMap;
@@ -97,11 +100,13 @@ public class RFileWriter implements AutoCloseable {
private final LoadPlanCollector loadPlanCollector;
private boolean startedLG;
private boolean startedDefaultLG;
+ private final ScheduledExecutorService executor =
Executors.newScheduledThreadPool(1);
RFileWriter(FileSKVWriter fileSKVWriter, int visCacheSize, LoadPlanCollector
loadPlanCollector) {
this.writer = fileSKVWriter;
this.validVisibilities = new LRUMap<>(visCacheSize);
this.loadPlanCollector = loadPlanCollector;
+ FileOperationsLogger.startLoggingFileSystemMetrics(executor);
}
private void _startNewLocalityGroup(String name, Set<ByteSequence>
columnFamilies)
@@ -256,6 +261,7 @@ public class RFileWriter implements AutoCloseable {
@Override
public void close() throws IOException {
+ executor.shutdownNow();
try {
writer.close();
} finally {
diff --git
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
index 191c260c0b..bfe6b847e7 100644
---
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
+++
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
@@ -207,11 +207,12 @@ public class CachableBlockFile {
byte[] serializedMetadata = cachedMetadataSupplier.get();
if (serializedMetadata == null) {
if (fileLenCache == null) {
- tmpReader = new BCFile.Reader(fsIn, lengthSupplier.get(), conf,
cryptoService);
+ tmpReader =
+ new BCFile.Reader(cacheId, fsIn, lengthSupplier.get(), conf,
cryptoService);
} else {
long len = getCachedFileLen();
try {
- tmpReader = new BCFile.Reader(fsIn, len, conf, cryptoService);
+ tmpReader = new BCFile.Reader(cacheId, fsIn, len, conf,
cryptoService);
} catch (Exception e) {
log.debug("Failed to open {}, clearing file length cache and
retrying", cacheId, e);
fileLenCache.invalidate(cacheId);
@@ -219,11 +220,11 @@ public class CachableBlockFile {
if (tmpReader == null) {
len = getCachedFileLen();
- tmpReader = new BCFile.Reader(fsIn, len, conf, cryptoService);
+ tmpReader = new BCFile.Reader(cacheId, fsIn, len, conf,
cryptoService);
}
}
} else {
- tmpReader = new BCFile.Reader(serializedMetadata, fsIn, conf,
cryptoService);
+ tmpReader = new BCFile.Reader(cacheId, serializedMetadata, fsIn,
conf, cryptoService);
}
} catch (IOException | RuntimeException e) {
fsIn.close();
diff --git
a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
index 31f32d64ae..cc27e70589 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
@@ -38,8 +38,11 @@ import org.apache.accumulo.core.crypto.CryptoEnvironmentImpl;
import org.apache.accumulo.core.crypto.CryptoUtils;
import org.apache.accumulo.core.file.rfile.bcfile.Utils.Version;
import org.apache.accumulo.core.file.streams.BoundedRangeFileInputStream;
+import org.apache.accumulo.core.file.streams.LoggingFilterInputStream;
+import org.apache.accumulo.core.file.streams.LoggingSeekableDataInputStream;
import org.apache.accumulo.core.file.streams.RateLimitedOutputStream;
import org.apache.accumulo.core.file.streams.SeekableDataInputStream;
+import org.apache.accumulo.core.logging.FileOperationsLogger;
import org.apache.accumulo.core.spi.crypto.CryptoEnvironment;
import org.apache.accumulo.core.spi.crypto.CryptoEnvironment.Scope;
import org.apache.accumulo.core.spi.crypto.CryptoService;
@@ -65,6 +68,7 @@ import org.apache.hadoop.io.compress.Decompressor;
* be used for other block-compressed file implementation.
*/
public final class BCFile {
+
// the current version of BCFile impl, increment them (major or minor) made
// enough changes
/**
@@ -613,9 +617,12 @@ public final class BCFile {
}
}
- public <InputStreamType extends InputStream & Seekable>
Reader(InputStreamType fin,
+ public <InputStreamType extends InputStream & Seekable> Reader(String
file, InputStreamType fin,
long fileLength, Configuration conf, CryptoService cryptoService)
throws IOException {
- this.in = new SeekableDataInputStream(fin);
+
+ this.in = FileOperationsLogger.isEnabled()
+ ? new LoggingSeekableDataInputStream(new
LoggingFilterInputStream(fin, file))
+ : new SeekableDataInputStream(fin);
this.conf = conf;
// Move the cursor to grab the version and the magic first
@@ -668,9 +675,13 @@ public final class BCFile {
}
}
- public <InputStreamType extends InputStream & Seekable> Reader(byte[]
serializedMetadata,
- InputStreamType fin, Configuration conf, CryptoService cryptoService)
throws IOException {
- this.in = new SeekableDataInputStream(fin);
+ public <InputStreamType extends InputStream & Seekable> Reader(String file,
+ byte[] serializedMetadata, InputStreamType fin, Configuration conf,
+ CryptoService cryptoService) throws IOException {
+
+ this.in = FileOperationsLogger.isEnabled()
+ ? new LoggingSeekableDataInputStream(new
LoggingFilterInputStream(fin, file))
+ : new SeekableDataInputStream(fin);
this.conf = conf;
ByteArrayInputStream bais = new ByteArrayInputStream(serializedMetadata);
diff --git
a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java
b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java
index cf26aadac8..b0a86050bf 100644
---
a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java
+++
b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintBCInfo.java
@@ -51,8 +51,8 @@ public class PrintBCInfo {
public void printMetaBlockInfo() throws IOException {
FileStatus status = fs.getFileStatus(path);
- try (FSDataInputStream fsin = FileOperations.openFile(fs, path, status);
- BCFile.Reader bcfr = new BCFile.Reader(fsin, status.getLen(), conf,
cryptoService)) {
+ try (FSDataInputStream fsin = FileOperations.openFile(fs, path, status);
BCFile.Reader bcfr =
+ new BCFile.Reader(path.toString(), fsin, status.getLen(), conf,
cryptoService)) {
Set<Entry<String,MetaIndexEntry>> es = bcfr.metaIndex.index.entrySet();
diff --git
a/core/src/main/java/org/apache/accumulo/core/file/streams/LoggingFilterInputStream.java
b/core/src/main/java/org/apache/accumulo/core/file/streams/LoggingFilterInputStream.java
new file mode 100644
index 0000000000..7ba9c0ed38
--- /dev/null
+++
b/core/src/main/java/org/apache/accumulo/core/file/streams/LoggingFilterInputStream.java
@@ -0,0 +1,86 @@
+/*
+ * 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
+ *
+ * https://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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.file.streams;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.logging.FileOperationsLogger;
+import org.apache.accumulo.core.util.Timer;
+import org.apache.hadoop.fs.Seekable;
+
+public class LoggingFilterInputStream extends FilterInputStream implements
Seekable {
+
+ private final Timer methodTimer = Timer.startNew();
+ private final String file;
+
+ public <StreamType extends InputStream & Seekable>
LoggingFilterInputStream(StreamType in,
+ String file) {
+ super(in);
+ this.file = file;
+ }
+
+ @Override
+ public int read() throws IOException {
+ methodTimer.restart();
+ int read = super.read();
+ FileOperationsLogger.readCalled(file, read < 0 ? read : 1,
+ methodTimer.elapsed(TimeUnit.NANOSECONDS));
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ methodTimer.restart();
+ int read = super.read(b);
+ FileOperationsLogger.readCalled(file, read,
methodTimer.elapsed(TimeUnit.NANOSECONDS));
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ methodTimer.restart();
+ int read = super.read(b, off, len);
+ FileOperationsLogger.readCalled(file, read,
methodTimer.elapsed(TimeUnit.NANOSECONDS));
+ return read;
+ }
+
+ @Override
+ public void seek(long pos) throws IOException {
+ methodTimer.restart();
+ ((Seekable) in).seek(pos);
+ FileOperationsLogger.seekCalled(file, pos,
methodTimer.elapsed(TimeUnit.NANOSECONDS));
+ }
+
+ @Override
+ public long getPos() throws IOException {
+ return ((Seekable) in).getPos();
+ }
+
+ @Override
+ public boolean seekToNewSource(long targetPos) throws IOException {
+ methodTimer.restart();
+ boolean newSource = ((Seekable) in).seekToNewSource(targetPos);
+ FileOperationsLogger.seekCalled(file, targetPos,
methodTimer.elapsed(TimeUnit.NANOSECONDS));
+ return newSource;
+ }
+
+}
diff --git
a/core/src/main/java/org/apache/accumulo/core/file/streams/LoggingSeekableDataInputStream.java
b/core/src/main/java/org/apache/accumulo/core/file/streams/LoggingSeekableDataInputStream.java
new file mode 100644
index 0000000000..7e8e43665e
--- /dev/null
+++
b/core/src/main/java/org/apache/accumulo/core/file/streams/LoggingSeekableDataInputStream.java
@@ -0,0 +1,35 @@
+/*
+ * 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
+ *
+ * https://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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.file.streams;
+
+import java.io.DataInputStream;
+
+import org.apache.hadoop.fs.Seekable;
+
+/**
+ * A wrapper converting a {@link Seekable} {@code InputStream} into a {@code
Seekable}
+ * {@link DataInputStream} that increments seek and read Timers. This is
intended to be used for
+ * testing only.
+ */
+public class LoggingSeekableDataInputStream extends SeekableDataInputStream {
+
+ public LoggingSeekableDataInputStream(LoggingFilterInputStream stream) {
+ super(stream);
+ }
+}
diff --git
a/core/src/main/java/org/apache/accumulo/core/logging/FileOperationsLogger.java
b/core/src/main/java/org/apache/accumulo/core/logging/FileOperationsLogger.java
new file mode 100644
index 0000000000..b62d630a71
--- /dev/null
+++
b/core/src/main/java/org/apache/accumulo/core/logging/FileOperationsLogger.java
@@ -0,0 +1,87 @@
+/*
+ * 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
+ *
+ * https://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, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.logging;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.StorageStatistics;
+import org.apache.hadoop.fs.StorageStatistics.LongStatistic;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FileOperationsLogger {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Logging.PREFIX +
"file_ops");
+
+ private static final AtomicBoolean TASK_SUBMITTED = new AtomicBoolean(false);
+
+ public static boolean isEnabled() {
+ return LOG.isTraceEnabled();
+ }
+
+ public static void seekCalled(String file, long position, long nanos) {
+ if (!isEnabled()) {
+ return;
+ }
+ LOG.trace("BCFile: {} seek to position {}, took {} ns", file, position,
nanos);
+ }
+
+ public static void readCalled(String file, int numBytes, long nanos) {
+ if (!isEnabled()) {
+ return;
+ }
+ LOG.trace("BCFile: {} read {} bytes, took {} ns", file, numBytes, nanos);
+ }
+
+ public static synchronized void
startLoggingFileSystemMetrics(ScheduledExecutorService ex) {
+ if (TASK_SUBMITTED.compareAndSet(false, true)) {
+ @SuppressWarnings("unused")
+ var unused = ex.scheduleWithFixedDelay(() -> {
+ logFilesystemMetrics();
+ }, 5, 5, TimeUnit.SECONDS);
+ }
+ }
+
+ private static void logFilesystemMetrics() {
+ if (!isEnabled()) {
+ return;
+ }
+ StorageStatistics stats =
FileSystem.getGlobalStorageStatistics().get("DFSOpsCountStatistics");
+ if (stats != null) {
+ Map<String,Long> dfsStats = new TreeMap<>();
+ Iterator<LongStatistic> ops = stats.getLongStatistics();
+ while (ops.hasNext()) {
+ LongStatistic op = ops.next();
+ Long value = op.getValue();
+ if (value > 0) {
+ dfsStats.put(op.getName(), value);
+ }
+ }
+ if (!dfsStats.isEmpty()) {
+ LOG.trace("Global DFS Metrics: {}", dfsStats);
+ }
+ }
+ }
+}
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Timer.java
b/core/src/main/java/org/apache/accumulo/core/util/Timer.java
index e0ace84c4a..a4b04235e1 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Timer.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Timer.java
@@ -85,6 +85,9 @@ public final class Timer {
* @return the elapsed time in the specified TimeUnit.
*/
public long elapsed(TimeUnit unit) {
+ if (unit == TimeUnit.NANOSECONDS) {
+ return getElapsedNanos();
+ }
return unit.convert(getElapsedNanos(), TimeUnit.NANOSECONDS);
}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
index 12feff1371..c666e32396 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
@@ -53,6 +53,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.zookeeper.ZooReader;
import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
+import org.apache.accumulo.core.logging.FileOperationsLogger;
import org.apache.accumulo.core.metadata.schema.Ample;
import org.apache.accumulo.core.metrics.MetricsInfo;
import org.apache.accumulo.core.rpc.SslConnectionParams;
@@ -134,6 +135,7 @@ public class ServerContext extends ClientContext {
metricsInfoSupplier = memoize(() -> new MetricsInfoImpl(this));
thriftTransportPool =
memoize(() ->
ThriftTransportPool.startNew(this::getTransportPoolMaxAgeMillis, true));
+
FileOperationsLogger.startLoggingFileSystemMetrics(sharedScheduledThreadPool.get());
}
/**