Created
May 19, 2021 23:44
-
-
Save apurtell/596310d08b5ad75cd9677466d36360e4 to your computer and use it in GitHub Desktop.
Synchronized descriptive statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 760e6b2f07eb7a7dad9a7d94cf1a160ef41cb845 Mon Sep 17 00:00:00 2001 | |
From: Andrew Purtell <apurtell@apache.org> | |
Date: Wed, 19 May 2021 14:01:13 -0700 | |
Subject: [PATCH] REMOVE! Synchronized descriptive statistics | |
--- | |
.../hbase/regionserver/wal/WALCellCodec.java | 18 ++++++++++++++++++ | |
1 file changed, 18 insertions(+) | |
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java | |
index 31eccc7a18a..123c7ddf056 100644 | |
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java | |
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java | |
@@ -22,6 +22,7 @@ import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
+import org.apache.commons.math3.stat.descriptive.SynchronizedDescriptiveStatistics; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.hbase.Cell; | |
import org.apache.hadoop.hbase.HBaseInterfaceAudience; | |
@@ -63,6 +64,20 @@ public class WALCellCodec implements Codec { | |
protected final CompressionContext compression; | |
+ // TODO REMOVE REMOVE | |
+ static final SynchronizedDescriptiveStatistics statistics = | |
+ new SynchronizedDescriptiveStatistics(); | |
+ static { | |
+ Runtime.getRuntime().addShutdownHook(new Thread() { | |
+ @Override | |
+ public void run() { | |
+ System.out.println("*** WALCellCodec debug statistics:"); | |
+ System.out.println(statistics.toString()); | |
+ } | |
+ }); | |
+ } | |
+ // TODO REMOVE REMOVE | |
+ | |
/** | |
* <b>All subclasses must implement a no argument constructor</b> | |
*/ | |
@@ -233,6 +248,7 @@ public class WALCellCodec implements Codec { | |
@Override | |
public void write(Cell cell) throws IOException { | |
+ final long startNanos = System.nanoTime(); | |
// We first write the KeyValue infrastructure as VInts. | |
StreamUtils.writeRawVInt32(out, KeyValueUtil.keyLength(cell)); | |
StreamUtils.writeRawVInt32(out, cell.getValueLength()); | |
@@ -263,6 +279,8 @@ public class WALCellCodec implements Codec { | |
PrivateCellUtil.writeTags(out, cell, tagsLength); | |
} | |
} | |
+ final long endNanos = System.nanoTime(); | |
+ statistics.addValue(endNanos - startNanos); | |
} | |
private void writeCompressedValue(OutputStream out, Cell cell) throws IOException { | |
-- | |
2.31.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment