[GitHub] [hadoop] goiri commented on a diff in pull request #4561: HDFS-16660. Improve Code With Lambda in IPCLoggerChannel class

2022-07-14 Thread GitBox


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 sendEdits(
 
 ListenableFuture ret = null;
 try {
-  ret = singleThreadExecutor.submit(new Callable() {
-@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 sendEdits(
 
 ListenableFuture ret = null;
 try {
-  ret = singleThreadExecutor.submit(new Callable() {
-@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(), 

[GitHub] [hadoop] goiri commented on a diff in pull request #4561: HDFS-16660. Improve Code With Lambda in IPCLoggerChannel class

2022-07-13 Thread GitBox


goiri commented on code in PR #4561:
URL: https://github.com/apache/hadoop/pull/4561#discussion_r920606905


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##
@@ -394,46 +361,43 @@ public ListenableFuture sendEdits(
 
 ListenableFuture ret = null;
 try {
-  ret = singleThreadExecutor.submit(new Callable() {
-@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(

Review Comment:
   Use {}



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] goiri commented on a diff in pull request #4561: HDFS-16660. Improve Code With Lambda in IPCLoggerChannel class

2022-07-13 Thread GitBox


goiri commented on code in PR #4561:
URL: https://github.com/apache/hadoop/pull/4561#discussion_r920333291


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##
@@ -346,36 +324,25 @@ public void run() {
 
   @Override
   public ListenableFuture isFormatted() {
-return singleThreadExecutor.submit(new Callable() {
-  @Override
-  public Boolean call() throws IOException {
-return getProxy().isFormatted(journalId, nameServiceId);
-  }
-});
+return singleThreadExecutor.submit(

Review Comment:
   Fits in one line



##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/IPCLoggerChannel.java:
##
@@ -346,36 +324,25 @@ public void run() {
 
   @Override
   public ListenableFuture isFormatted() {
-return singleThreadExecutor.submit(new Callable() {
-  @Override
-  public Boolean call() throws IOException {
-return getProxy().isFormatted(journalId, nameServiceId);
-  }
-});
+return singleThreadExecutor.submit(
+() -> getProxy().isFormatted(journalId, nameServiceId));
   }
 
   @Override
   public ListenableFuture getJournalState() {
-return singleThreadExecutor.submit(new 
Callable() {
-  @Override
-  public GetJournalStateResponseProto call() throws IOException {
-GetJournalStateResponseProto ret =
-getProxy().getJournalState(journalId, nameServiceId);
-constructHttpServerURI(ret);
-return ret;
-  }
+return singleThreadExecutor.submit(() -> {
+  GetJournalStateResponseProto ret =

Review Comment:
   Fits in one line



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org