From 238d51572eefd75e3f9c5f862bfafbe801dc7bf4 Mon Sep 17 00:00:00 2001 From: Artem Ananev Date: Thu, 28 Mar 2024 13:58:41 -0700 Subject: [PATCH] Disabled teacher pull send task Signed-off-by: Artem Ananev --- .../merkle/synchronization/streams/AsyncInputStream.java | 2 +- .../internal/reconnect/PullVirtualTreeResponse.java | 6 +++--- .../reconnect/TeacherPullVirtualTreeReceiveTask.java | 6 ++++-- .../internal/reconnect/TeacherPullVirtualTreeView.java | 9 ++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/merkle/synchronization/streams/AsyncInputStream.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/merkle/synchronization/streams/AsyncInputStream.java index 79c229bf02d8..7f76be4bd107 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/merkle/synchronization/streams/AsyncInputStream.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/merkle/synchronization/streams/AsyncInputStream.java @@ -140,7 +140,7 @@ private void run() { anticipatedMessages.getAndUpdate((final int value) -> value == 0 ? 0 : (value - 1)); if (previous == 0) { - Thread.onSpinWait(); + MILLISECONDS.sleep(1); continue; } diff --git a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/PullVirtualTreeResponse.java b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/PullVirtualTreeResponse.java index 4c73d9cd7de9..555b838a478b 100644 --- a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/PullVirtualTreeResponse.java +++ b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/PullVirtualTreeResponse.java @@ -56,11 +56,11 @@ public PullVirtualTreeResponse() { /** * This constructor is used by the teacher to create new responses. */ - public PullVirtualTreeResponse(final VirtualTeacherTreeView teacherView, final long path, final Hash hash) { + public PullVirtualTreeResponse(final VirtualTeacherTreeView teacherView, final PullVirtualTreeRequest request) { this.teacherView = teacherView; this.learnerView = null; - this.path = path; - this.hash = hash; + this.path = request.getPath(); + this.hash = request.getHash(); } /** diff --git a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeReceiveTask.java b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeReceiveTask.java index 64561c549b8c..8919c3b000f8 100644 --- a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeReceiveTask.java +++ b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeReceiveTask.java @@ -109,7 +109,7 @@ private void rateLimit() throws InterruptedException { * This thread is responsible for sending lessons (and nested queries) to the learner. */ private void run() { - try { + try (out) { while (true) { rateLimit(); final PullVirtualTreeRequest request = new PullVirtualTreeRequest(view); @@ -120,7 +120,9 @@ private void run() { logger.info(RECONNECT.getMarker(), "Teacher receiver is complete as requested by the learner"); break; } - view.registerRequest(request); +// view.registerRequest(request); + final PullVirtualTreeResponse response = new PullVirtualTreeResponse(view, request); + out.sendAsync(response); } // logger.info(RECONNECT.getMarker(), "TOREMOVE Teacher receive done"); // System.err.println("TOREMOVE Teacher receive done"); diff --git a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeView.java b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeView.java index 46b6daae46a5..a33fd81b2086 100644 --- a/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeView.java +++ b/platform-sdk/swirlds-virtualmap/src/main/java/com/swirlds/virtualmap/internal/reconnect/TeacherPullVirtualTreeView.java @@ -122,9 +122,9 @@ public void startTeacherTasks( final TeacherPullVirtualTreeReceiveTask teacherReceiveTask = new TeacherPullVirtualTreeReceiveTask( time, reconnectConfig, workGroup, inputStream, out, this, allRequestsReceived); teacherReceiveTask.exec(); - final TeacherPullVirtualTreeSendTask teacherSendTask = new TeacherPullVirtualTreeSendTask( - reconnectConfig, workGroup, out, this, allRequestsReceived); - teacherSendTask.exec(); +// final TeacherPullVirtualTreeSendTask teacherSendTask = new TeacherPullVirtualTreeSendTask( +// reconnectConfig, workGroup, out, this, allRequestsReceived); +// teacherSendTask.exec(); } private boolean isLeaf(final long path) { @@ -153,8 +153,7 @@ public Hash loadHash(final long path) { @Override public void registerRequest(final PullVirtualTreeRequest request) { - responses.addLast(new PullVirtualTreeResponse( - TeacherPullVirtualTreeView.this, request.getPath(), request.getHash())); + responses.addLast(new PullVirtualTreeResponse(this, request)); } @Override