[
https://issues.apache.org/jira/browse/HDFS-16660?focusedWorklogId=791206&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-791206
]
ASF GitHub Bot logged work on HDFS-16660:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 15/Jul/22 01:15
Start Date: 15/Jul/22 01:15
Worklog Time Spent: 10m
Work Description: goiri commented on code in PR #4561:
URL: https://github.com/apache/hadoop/pull/4561#discussion_r921726293
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##########
@@ -394,46 +352,39 @@ public ListenableFuture<Void> sendEdits(
ListenableFuture<Void> ret = null;
try {
- ret = singleThreadExecutor.submit(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- throwIfOutOfSync();
-
- long rpcSendTimeNanos = System.nanoTime();
- try {
- getProxy().journal(createReqInfo(),
- segmentTxId, firstTxnId, numTxns, data);
- } catch (IOException e) {
- QuorumJournalManager.LOG.warn(
- "Remote journal " + IPCLoggerChannel.this + " failed to " +
- "write txns " + firstTxnId + "-" + (firstTxnId + numTxns - 1) +
- ". Will try to write to this JN again after the next " +
- "log roll.", e);
- synchronized (IPCLoggerChannel.this) {
- outOfSync = true;
- }
- throw e;
- } finally {
- long now = System.nanoTime();
- long rpcTime = TimeUnit.MICROSECONDS.convert(
- now - rpcSendTimeNanos, TimeUnit.NANOSECONDS);
- long endToEndTime = TimeUnit.MICROSECONDS.convert(
- now - submitNanos, TimeUnit.NANOSECONDS);
- metrics.addWriteEndToEndLatency(endToEndTime);
- metrics.addWriteRpcLatency(rpcTime);
- if (rpcTime / 1000 > WARN_JOURNAL_MILLIS_THRESHOLD) {
- QuorumJournalManager.LOG.warn(
- "Took " + (rpcTime / 1000) + "ms to send a batch of " +
- numTxns + " edits (" + data.length + " bytes) to " +
- "remote journal " + IPCLoggerChannel.this);
- }
- }
+ ret = singleThreadExecutor.submit(() -> {
+ throwIfOutOfSync();
+
+ long rpcSendTimeNanos = System.nanoTime();
+ try {
+ getProxy().journal(createReqInfo(), segmentTxId, firstTxnId,
numTxns, data);
+ } catch (IOException e) {
+ QuorumJournalManager.LOG.warn("Remote journal {} failed to write
txns {}-{}."
+ + " Will try to write to this JN again after the next log
roll.",
+ IPCLoggerChannel.this, firstTxnId, (firstTxnId + numTxns - 1),
e);
synchronized (IPCLoggerChannel.this) {
- highestAckedTxId = firstTxnId + numTxns - 1;
- lastAckNanos = submitNanos;
+ outOfSync = true;
}
- return null;
+ throw e;
+ } finally {
+ long now = System.nanoTime();
+ long rpcTime = TimeUnit.MICROSECONDS.convert(
+ now - rpcSendTimeNanos, TimeUnit.NANOSECONDS);
+ long endToEndTime = TimeUnit.MICROSECONDS.convert(
Review Comment:
endToEndTimeMs?
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##########
@@ -394,46 +352,39 @@ public ListenableFuture<Void> sendEdits(
ListenableFuture<Void> ret = null;
try {
- ret = singleThreadExecutor.submit(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- throwIfOutOfSync();
-
- long rpcSendTimeNanos = System.nanoTime();
- try {
- getProxy().journal(createReqInfo(),
- segmentTxId, firstTxnId, numTxns, data);
- } catch (IOException e) {
- QuorumJournalManager.LOG.warn(
- "Remote journal " + IPCLoggerChannel.this + " failed to " +
- "write txns " + firstTxnId + "-" + (firstTxnId + numTxns - 1) +
- ". Will try to write to this JN again after the next " +
- "log roll.", e);
- synchronized (IPCLoggerChannel.this) {
- outOfSync = true;
- }
- throw e;
- } finally {
- long now = System.nanoTime();
- long rpcTime = TimeUnit.MICROSECONDS.convert(
- now - rpcSendTimeNanos, TimeUnit.NANOSECONDS);
- long endToEndTime = TimeUnit.MICROSECONDS.convert(
- now - submitNanos, TimeUnit.NANOSECONDS);
- metrics.addWriteEndToEndLatency(endToEndTime);
- metrics.addWriteRpcLatency(rpcTime);
- if (rpcTime / 1000 > WARN_JOURNAL_MILLIS_THRESHOLD) {
- QuorumJournalManager.LOG.warn(
- "Took " + (rpcTime / 1000) + "ms to send a batch of " +
- numTxns + " edits (" + data.length + " bytes) to " +
- "remote journal " + IPCLoggerChannel.this);
- }
- }
+ ret = singleThreadExecutor.submit(() -> {
+ throwIfOutOfSync();
+
+ long rpcSendTimeNanos = System.nanoTime();
+ try {
+ getProxy().journal(createReqInfo(), segmentTxId, firstTxnId,
numTxns, data);
+ } catch (IOException e) {
+ QuorumJournalManager.LOG.warn("Remote journal {} failed to write
txns {}-{}."
+ + " Will try to write to this JN again after the next log
roll.",
+ IPCLoggerChannel.this, firstTxnId, (firstTxnId + numTxns - 1),
e);
synchronized (IPCLoggerChannel.this) {
- highestAckedTxId = firstTxnId + numTxns - 1;
- lastAckNanos = submitNanos;
+ outOfSync = true;
}
- return null;
+ throw e;
+ } finally {
+ long now = System.nanoTime();
+ long rpcTime = TimeUnit.MICROSECONDS.convert(
Review Comment:
rpcTimeMs?
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##########
@@ -394,46 +352,39 @@ public ListenableFuture<Void> sendEdits(
ListenableFuture<Void> ret = null;
try {
- ret = singleThreadExecutor.submit(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- throwIfOutOfSync();
-
- long rpcSendTimeNanos = System.nanoTime();
- try {
- getProxy().journal(createReqInfo(),
- segmentTxId, firstTxnId, numTxns, data);
- } catch (IOException e) {
- QuorumJournalManager.LOG.warn(
- "Remote journal " + IPCLoggerChannel.this + " failed to " +
- "write txns " + firstTxnId + "-" + (firstTxnId + numTxns - 1) +
- ". Will try to write to this JN again after the next " +
- "log roll.", e);
- synchronized (IPCLoggerChannel.this) {
- outOfSync = true;
- }
- throw e;
- } finally {
- long now = System.nanoTime();
- long rpcTime = TimeUnit.MICROSECONDS.convert(
- now - rpcSendTimeNanos, TimeUnit.NANOSECONDS);
- long endToEndTime = TimeUnit.MICROSECONDS.convert(
- now - submitNanos, TimeUnit.NANOSECONDS);
- metrics.addWriteEndToEndLatency(endToEndTime);
- metrics.addWriteRpcLatency(rpcTime);
- if (rpcTime / 1000 > WARN_JOURNAL_MILLIS_THRESHOLD) {
- QuorumJournalManager.LOG.warn(
- "Took " + (rpcTime / 1000) + "ms to send a batch of " +
- numTxns + " edits (" + data.length + " bytes) to " +
- "remote journal " + IPCLoggerChannel.this);
- }
- }
+ ret = singleThreadExecutor.submit(() -> {
+ throwIfOutOfSync();
+
+ long rpcSendTimeNanos = System.nanoTime();
+ try {
+ getProxy().journal(createReqInfo(), segmentTxId, firstTxnId,
numTxns, data);
+ } catch (IOException e) {
+ QuorumJournalManager.LOG.warn("Remote journal {} failed to write
txns {}-{}."
+ + " Will try to write to this JN again after the next log
roll.",
+ IPCLoggerChannel.this, firstTxnId, (firstTxnId + numTxns - 1),
e);
synchronized (IPCLoggerChannel.this) {
- highestAckedTxId = firstTxnId + numTxns - 1;
- lastAckNanos = submitNanos;
+ outOfSync = true;
}
- return null;
+ throw e;
+ } finally {
+ long now = System.nanoTime();
+ long rpcTime = TimeUnit.MICROSECONDS.convert(
Review Comment:
It looks like rpcTimeMicros actually; add the unit in either case.
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##########
@@ -394,46 +352,39 @@ public ListenableFuture<Void> sendEdits(
ListenableFuture<Void> ret = null;
try {
- ret = singleThreadExecutor.submit(new Callable<Void>() {
- @Override
- public Void call() throws IOException {
- throwIfOutOfSync();
-
- long rpcSendTimeNanos = System.nanoTime();
- try {
- getProxy().journal(createReqInfo(),
- segmentTxId, firstTxnId, numTxns, data);
- } catch (IOException e) {
- QuorumJournalManager.LOG.warn(
- "Remote journal " + IPCLoggerChannel.this + " failed to " +
- "write txns " + firstTxnId + "-" + (firstTxnId + numTxns - 1) +
- ". Will try to write to this JN again after the next " +
- "log roll.", e);
- synchronized (IPCLoggerChannel.this) {
- outOfSync = true;
- }
- throw e;
- } finally {
- long now = System.nanoTime();
- long rpcTime = TimeUnit.MICROSECONDS.convert(
- now - rpcSendTimeNanos, TimeUnit.NANOSECONDS);
- long endToEndTime = TimeUnit.MICROSECONDS.convert(
- now - submitNanos, TimeUnit.NANOSECONDS);
- metrics.addWriteEndToEndLatency(endToEndTime);
- metrics.addWriteRpcLatency(rpcTime);
- if (rpcTime / 1000 > WARN_JOURNAL_MILLIS_THRESHOLD) {
- QuorumJournalManager.LOG.warn(
- "Took " + (rpcTime / 1000) + "ms to send a batch of " +
- numTxns + " edits (" + data.length + " bytes) to " +
- "remote journal " + IPCLoggerChannel.this);
- }
- }
+ ret = singleThreadExecutor.submit(() -> {
+ throwIfOutOfSync();
+
+ long rpcSendTimeNanos = System.nanoTime();
+ try {
+ getProxy().journal(createReqInfo(), segmentTxId, firstTxnId,
numTxns, data);
+ } catch (IOException e) {
+ QuorumJournalManager.LOG.warn("Remote journal {} failed to write
txns {}-{}."
+ + " Will try to write to this JN again after the next log
roll.",
+ IPCLoggerChannel.this, firstTxnId, (firstTxnId + numTxns - 1),
e);
synchronized (IPCLoggerChannel.this) {
- highestAckedTxId = firstTxnId + numTxns - 1;
- lastAckNanos = submitNanos;
+ outOfSync = true;
}
- return null;
+ throw e;
+ } finally {
+ long now = System.nanoTime();
Review Comment:
nowNs
Issue Time Tracking
-------------------
Worklog Id: (was: 791206)
Time Spent: 1h (was: 50m)
> Improve Code With Lambda in IPCLoggerChannel class
> --------------------------------------------------
>
> Key: HDFS-16660
> URL: https://issues.apache.org/jira/browse/HDFS-16660
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: ZanderXu
> Assignee: ZanderXu
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Improve Code With Lambda in IPCLoggerChannel class
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]