From 03cc633755b4118bd8674e4693729dd9134951aa Mon Sep 17 00:00:00 2001 From: Greg Schohn Date: Wed, 20 Nov 2024 18:48:55 -0500 Subject: [PATCH 1/2] Move TrackedFuture and OnlineRadixSorter to common coreUtils package Signed-off-by: Greg Schohn --- .../util => utils}/TrackedFutureJsonFormatter.java | 0 .../migrations/replay/GenerateRandomNestedJsonObject.java | 2 +- .../migrations/replay/TestCapturePacketToHttpHandler.java | 4 ++-- .../java/org/opensearch/migrations/replay/TestUtils.java | 2 +- .../opensearch/migrations/utils}/FutureTransformer.java | 4 +--- .../opensearch/migrations/utils}/OnlineRadixSorter.java | 5 +---- .../opensearch/migrations/utils}/TextTrackedFuture.java | 2 +- .../org/opensearch/migrations/utils}/TrackedFuture.java | 6 +----- .../migrations/utils}/TrackedFutureStringFormatter.java | 2 +- .../opensearch/migrations/PruferTreeGeneratorTest.java | 1 + .../migrations/utils}/OnlineRadixSorterTest.java | 4 ++++ .../migrations/utils}/TextTrackedFutureTest.java | 8 ++++++-- .../opensearch/migrations/utils}/TrackedFutureTest.java | 3 +++ .../utils}/OnlineRadixSorterForIntegratedKeys.java | 3 +++ .../opensearch/migrations/utils}/PruferTreeGenerator.java | 0 15 files changed, 26 insertions(+), 20 deletions(-) rename TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/{replay/util => utils}/TrackedFutureJsonFormatter.java (100%) rename {TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes => coreUtilities/src/main/java/org/opensearch/migrations/utils}/FutureTransformer.java (71%) rename {TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util => coreUtilities/src/main/java/org/opensearch/migrations/utils}/OnlineRadixSorter.java (97%) rename {TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util => coreUtilities/src/main/java/org/opensearch/migrations/utils}/TextTrackedFuture.java (97%) rename {TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util => coreUtilities/src/main/java/org/opensearch/migrations/utils}/TrackedFuture.java (97%) rename {TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util => coreUtilities/src/main/java/org/opensearch/migrations/utils}/TrackedFutureStringFormatter.java (96%) rename {TrafficCapture/trafficReplayer => coreUtilities}/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java (97%) rename {TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util => coreUtilities/src/test/java/org/opensearch/migrations/utils}/OnlineRadixSorterTest.java (94%) rename {TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util => coreUtilities/src/test/java/org/opensearch/migrations/utils}/TextTrackedFutureTest.java (94%) rename {TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util => coreUtilities/src/test/java/org/opensearch/migrations/utils}/TrackedFutureTest.java (93%) rename {TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/util => coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils}/OnlineRadixSorterForIntegratedKeys.java (90%) rename {TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations => coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils}/PruferTreeGenerator.java (100%) diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFutureJsonFormatter.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/utils/TrackedFutureJsonFormatter.java similarity index 100% rename from TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFutureJsonFormatter.java rename to TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/utils/TrackedFutureJsonFormatter.java diff --git a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/GenerateRandomNestedJsonObject.java b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/GenerateRandomNestedJsonObject.java index 29886bba3..5dac9951f 100644 --- a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/GenerateRandomNestedJsonObject.java +++ b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/GenerateRandomNestedJsonObject.java @@ -9,7 +9,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.opensearch.migrations.PruferTreeGenerator; +import org.opensearch.migrations.utils.PruferTreeGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestCapturePacketToHttpHandler.java b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestCapturePacketToHttpHandler.java index c78a03342..aba31e5e0 100644 --- a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestCapturePacketToHttpHandler.java +++ b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestCapturePacketToHttpHandler.java @@ -8,8 +8,8 @@ import java.util.concurrent.atomic.AtomicInteger; import org.opensearch.migrations.replay.datahandlers.IPacketFinalizingConsumer; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import lombok.Getter; diff --git a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java index a72338536..655ce8307 100644 --- a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java +++ b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java @@ -18,7 +18,7 @@ import org.opensearch.migrations.Utils; import org.opensearch.migrations.replay.datahandlers.IPacketConsumer; import org.opensearch.migrations.replay.datahandlers.http.HttpJsonTransformingConsumer; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import org.opensearch.migrations.tracing.TestContext; import org.opensearch.migrations.transform.IAuthTransformerFactory; import org.opensearch.migrations.transform.IJsonTransformer; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/FutureTransformer.java b/coreUtilities/src/main/java/org/opensearch/migrations/utils/FutureTransformer.java similarity index 71% rename from TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/FutureTransformer.java rename to coreUtilities/src/main/java/org/opensearch/migrations/utils/FutureTransformer.java index b5ebb7e94..1895d2d00 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/FutureTransformer.java +++ b/coreUtilities/src/main/java/org/opensearch/migrations/utils/FutureTransformer.java @@ -1,9 +1,7 @@ -package org.opensearch.migrations.replay.datatypes; +package org.opensearch.migrations.utils; import java.util.function.Function; -import org.opensearch.migrations.replay.util.TrackedFuture; - /** * This is a function rather than just a supplier so that the future returned can be * chained to its logical parent dependency. diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OnlineRadixSorter.java b/coreUtilities/src/main/java/org/opensearch/migrations/utils/OnlineRadixSorter.java similarity index 97% rename from TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OnlineRadixSorter.java rename to coreUtilities/src/main/java/org/opensearch/migrations/utils/OnlineRadixSorter.java index a6eaafc57..74dd2142b 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OnlineRadixSorter.java +++ b/coreUtilities/src/main/java/org/opensearch/migrations/utils/OnlineRadixSorter.java @@ -1,4 +1,4 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.Optional; import java.util.SortedMap; @@ -6,9 +6,6 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.IntStream; -import org.opensearch.migrations.replay.datatypes.FutureTransformer; -import org.opensearch.migrations.utils.SequentialSpanCompressingReducer; - import lombok.AllArgsConstructor; import lombok.Getter; import lombok.extern.slf4j.Slf4j; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TextTrackedFuture.java b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TextTrackedFuture.java similarity index 97% rename from TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TextTrackedFuture.java rename to coreUtilities/src/main/java/org/opensearch/migrations/utils/TextTrackedFuture.java index 71950e7e9..6fe2e9f77 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TextTrackedFuture.java +++ b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TextTrackedFuture.java @@ -1,4 +1,4 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.Arrays; import java.util.concurrent.CompletableFuture; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFuture.java b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFuture.java similarity index 97% rename from TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFuture.java rename to coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFuture.java index 7412d31d1..5d8cf4d07 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFuture.java +++ b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFuture.java @@ -1,4 +1,4 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.time.Duration; import java.util.Optional; @@ -244,8 +244,4 @@ public String toString() { public String formatAsString(@NonNull Function, String> resultFormatter) { return TrackedFutureStringFormatter.format(this, resultFormatter); } - - public String formatAsJson(@NonNull Function, String> resultFormatter) { - return TrackedFutureJsonFormatter.format(this, resultFormatter); - } } diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFutureStringFormatter.java b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureStringFormatter.java similarity index 96% rename from TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFutureStringFormatter.java rename to coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureStringFormatter.java index 06bff5caf..662418d41 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/TrackedFutureStringFormatter.java +++ b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureStringFormatter.java @@ -1,4 +1,4 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.Optional; import java.util.function.Function; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java similarity index 97% rename from TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java rename to coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java index 3cbe7346a..ba02b40ce 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java @@ -8,6 +8,7 @@ import java.util.stream.IntStream; import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; +import org.opensearch.migrations.utils.PruferTreeGenerator; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/OnlineRadixSorterTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java similarity index 94% rename from TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/OnlineRadixSorterTest.java rename to coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java index 42bd67190..a95e1c65e 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/OnlineRadixSorterTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java @@ -6,6 +6,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.opensearch.migrations.utils.OnlineRadixSorter; +import org.opensearch.migrations.utils.OnlineRadixSorterForIntegratedKeys; +import org.opensearch.migrations.utils.TrackedFuture; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/TextTrackedFutureTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java similarity index 94% rename from TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/TextTrackedFutureTest.java rename to coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java index d6db04138..b4a144521 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/TextTrackedFutureTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java @@ -5,6 +5,10 @@ import java.util.concurrent.TimeUnit; import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFutureJsonFormatter; +import org.opensearch.migrations.utils.TrackedFutureStringFormatter; import lombok.SneakyThrows; import org.junit.jupiter.api.Assertions; @@ -175,7 +179,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"1\"}]", - stcf3.formatAsJson(TextTrackedFutureTest::formatCompletableFuture) + TrackedFutureJsonFormatter.format(stcf3, TextTrackedFutureTest::formatCompletableFuture) ); // A is clipped because of grandparent culling @@ -192,7 +196,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id2 + ",\"label\":\"B\",\"value\":\"11\"}]", - stcf3.formatAsJson(TextTrackedFutureTest::formatCompletableFuture) + TrackedFutureJsonFormatter.format(stcf3, TextTrackedFutureTest::formatCompletableFuture) ); } diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/TrackedFutureTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java similarity index 93% rename from TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/TrackedFutureTest.java rename to coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java index 4f5898212..e2024474b 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/TrackedFutureTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java @@ -2,6 +2,9 @@ import java.util.concurrent.Semaphore; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; + import lombok.Lombok; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; diff --git a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/util/OnlineRadixSorterForIntegratedKeys.java b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java similarity index 90% rename from TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/util/OnlineRadixSorterForIntegratedKeys.java rename to coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java index 6baf03bef..4fa67c0e8 100644 --- a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/util/OnlineRadixSorterForIntegratedKeys.java +++ b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java @@ -2,6 +2,9 @@ import java.util.function.ToIntFunction; +import org.opensearch.migrations.utils.OnlineRadixSorter; +import org.opensearch.migrations.utils.TrackedFuture; + import lombok.extern.slf4j.Slf4j; /** diff --git a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/PruferTreeGenerator.java b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/PruferTreeGenerator.java similarity index 100% rename from TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/PruferTreeGenerator.java rename to coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/PruferTreeGenerator.java From a198072907c7dcaf7294ad5f83b13a081770fedc Mon Sep 17 00:00:00 2001 From: Greg Schohn Date: Wed, 20 Nov 2024 23:23:41 -0500 Subject: [PATCH 2/2] Move tests and test fixtures for concurrency utils from the replayer to coreUtilities. Followup to the last commit. Signed-off-by: Greg Schohn --- .../migrations/NettyFutureBinders.java | 4 +- .../replay/ClientConnectionPool.java | 4 +- .../migrations/replay/ReplayEngine.java | 2 +- .../replay/RequestSenderOrchestrator.java | 4 +- .../replay/RequestTransformerAndSender.java | 4 +- .../migrations/replay/TrafficReplayer.java | 2 +- .../replay/TrafficReplayerCore.java | 4 +- .../replay/TrafficReplayerTopLevel.java | 4 +- .../replay/datahandlers/IPacketConsumer.java | 2 +- .../IPacketFinalizingConsumer.java | 2 +- .../NettyPacketToHttpConsumer.java | 4 +- .../TransformedPacketReceiver.java | 2 +- .../http/HttpJsonTransformingConsumer.java | 4 +- ...ttySendByteBufsToPacketHandlerHandler.java | 4 +- .../replay/datatypes/ChannelTask.java | 2 + .../datatypes/ConnectionReplaySession.java | 6 +-- .../TimeToResponseFulfillmentFutureMap.java | 4 +- .../replay/http/retries/DefaultRetry.java | 4 +- .../http/retries/IRetryVisitorFactory.java | 2 +- .../http/retries/NoRetryEvaluatorFactory.java | 4 +- .../http/retries/OpenSearchDefaultRetry.java | 4 +- .../http/retries/RequestRetryEvaluator.java | 2 +- .../RetryCollectingVisitorFactory.java | 4 +- .../replay/util/ActiveContextMonitor.java | 1 + .../replay/util/OrderedWorkerTracker.java | 1 + .../utils/TrackedFutureJsonFormatter.java | 45 +--------------- .../replay/RequestSenderOrchestratorTest.java | 4 +- .../NettyPacketToHttpConsumerTest.java | 2 +- .../HttpJsonTransformingConsumerTest.java | 2 +- .../replay/http/retries/HttpRetryTest.java | 4 +- .../retries/OpenSearchDefaultRetryTest.java | 2 +- .../transform/HeaderTransformerTest.java | 2 +- .../replay/util/ActiveContextMonitorTest.java | 1 + .../migrations/replay/TestUtils.java | 2 +- coreUtilities/build.gradle | 4 +- .../utils/TrackedFutureMapConverter.java | 51 +++++++++++++++++++ .../migrations/PruferTreeGeneratorTest.java | 2 - .../utils/OnlineRadixSorterTest.java | 6 +-- .../utils/TextTrackedFutureTest.java | 46 ++++++++++------- .../migrations/utils/TrackedFutureTest.java | 5 +- .../OnlineRadixSorterForIntegratedKeys.java | 5 +- .../migrations/utils/PruferTreeGenerator.java | 2 +- 42 files changed, 138 insertions(+), 127 deletions(-) create mode 100644 coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureMapConverter.java diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/NettyFutureBinders.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/NettyFutureBinders.java index b82939617..072d91edc 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/NettyFutureBinders.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/NettyFutureBinders.java @@ -7,8 +7,8 @@ import java.util.function.Function; import java.util.function.Supplier; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.channel.EventLoop; import io.netty.util.concurrent.Future; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ClientConnectionPool.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ClientConnectionPool.java index 6be5780f3..0b0b2023d 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ClientConnectionPool.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ClientConnectionPool.java @@ -7,8 +7,8 @@ import org.opensearch.migrations.NettyFutureBinders; import org.opensearch.migrations.replay.datatypes.ConnectionReplaySession; import org.opensearch.migrations.replay.tracing.IReplayContexts; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ReplayEngine.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ReplayEngine.java index 8517617d4..898680593 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ReplayEngine.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/ReplayEngine.java @@ -10,7 +10,7 @@ import org.opensearch.migrations.replay.datatypes.IndexedChannelInteraction; import org.opensearch.migrations.replay.tracing.IReplayContexts; import org.opensearch.migrations.replay.traffic.source.BufferedFlowController; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.util.concurrent.ScheduledFuture; import lombok.extern.slf4j.Slf4j; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestSenderOrchestrator.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestSenderOrchestrator.java index f501a523a..110cb9957 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestSenderOrchestrator.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestSenderOrchestrator.java @@ -21,8 +21,8 @@ import org.opensearch.migrations.replay.datatypes.UniqueReplayerRequestKey; import org.opensearch.migrations.replay.tracing.IReplayContexts; import org.opensearch.migrations.replay.util.RefSafeHolder; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.channel.EventLoop; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestTransformerAndSender.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestTransformerAndSender.java index c375d994c..2aba945b2 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestTransformerAndSender.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/RequestTransformerAndSender.java @@ -11,8 +11,8 @@ import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; import org.opensearch.migrations.replay.http.retries.IRetryVisitorFactory; import org.opensearch.migrations.replay.tracing.IReplayContexts; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.Unpooled; import lombok.AllArgsConstructor; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayer.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayer.java index 4a167257a..e50824839 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayer.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayer.java @@ -15,7 +15,6 @@ import org.opensearch.migrations.replay.traffic.source.TrafficStreamLimiter; import org.opensearch.migrations.replay.util.ActiveContextMonitor; import org.opensearch.migrations.replay.util.OrderedWorkerTracker; -import org.opensearch.migrations.replay.util.TrackedFutureJsonFormatter; import org.opensearch.migrations.tracing.ActiveContextTracker; import org.opensearch.migrations.tracing.ActiveContextTrackerByActivityType; import org.opensearch.migrations.tracing.CompositeContextTracker; @@ -28,6 +27,7 @@ import org.opensearch.migrations.transform.TransformerConfigUtils; import org.opensearch.migrations.transform.TransformerParams; import org.opensearch.migrations.utils.ProcessHelpers; +import org.opensearch.migrations.utils.TrackedFutureJsonFormatter; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerCore.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerCore.java index ef9761d79..6cc3a76dd 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerCore.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerCore.java @@ -23,11 +23,11 @@ import org.opensearch.migrations.replay.traffic.source.ITrafficCaptureSource; import org.opensearch.migrations.replay.traffic.source.ITrafficStreamWithKey; import org.opensearch.migrations.replay.traffic.source.TrafficStreamLimiter; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.trafficcapture.protos.TrafficStreamUtils; import org.opensearch.migrations.transform.IAuthTransformerFactory; import org.opensearch.migrations.transform.IJsonTransformer; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import lombok.AllArgsConstructor; import lombok.Lombok; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerTopLevel.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerTopLevel.java index 56770800a..74c533ce6 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerTopLevel.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayerTopLevel.java @@ -23,10 +23,10 @@ import org.opensearch.migrations.replay.tracing.IRootReplayerContext; import org.opensearch.migrations.replay.traffic.source.BlockingTrafficSource; import org.opensearch.migrations.replay.traffic.source.TrafficStreamLimiter; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.transform.IAuthTransformerFactory; import org.opensearch.migrations.transform.IJsonTransformer; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketConsumer.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketConsumer.java index c0c484a87..697d4ed4d 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketConsumer.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketConsumer.java @@ -1,6 +1,6 @@ package org.opensearch.migrations.replay.datahandlers; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketFinalizingConsumer.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketFinalizingConsumer.java index 53e381a7f..1cbfcb71b 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketFinalizingConsumer.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/IPacketFinalizingConsumer.java @@ -1,6 +1,6 @@ package org.opensearch.migrations.replay.datahandlers; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; /** * This class consumes arrays of bytes or ByteBufs, potentially asynchronously, diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumer.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumer.java index 3dfc2054c..69b3b2b90 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumer.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumer.java @@ -19,10 +19,10 @@ import org.opensearch.migrations.replay.netty.BacksideHttpWatcherHandler; import org.opensearch.migrations.replay.netty.BacksideSnifferHandler; import org.opensearch.migrations.replay.tracing.IReplayContexts; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.tracing.IScopedInstrumentationAttributes; import org.opensearch.migrations.tracing.IWithTypedEnclosingScope; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ByteBuf; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/TransformedPacketReceiver.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/TransformedPacketReceiver.java index 86a707cfa..eec3ab6f7 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/TransformedPacketReceiver.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/TransformedPacketReceiver.java @@ -1,7 +1,7 @@ package org.opensearch.migrations.replay.datahandlers; import org.opensearch.migrations.replay.datatypes.ByteBufList; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumer.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumer.java index c83f466ab..8c2dca816 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumer.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumer.java @@ -11,10 +11,10 @@ import org.opensearch.migrations.replay.datatypes.HttpRequestTransformationStatus; import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; import org.opensearch.migrations.replay.tracing.IReplayContexts; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.transform.IAuthTransformerFactory; import org.opensearch.migrations.transform.IJsonTransformer; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.channel.embedded.EmbeddedChannel; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/NettySendByteBufsToPacketHandlerHandler.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/NettySendByteBufsToPacketHandlerHandler.java index e470ef02e..436dfee0f 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/NettySendByteBufsToPacketHandlerHandler.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datahandlers/http/NettySendByteBufsToPacketHandlerHandler.java @@ -7,8 +7,8 @@ import org.opensearch.migrations.replay.datatypes.HttpRequestTransformationStatus; import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; import org.opensearch.migrations.replay.tracing.IReplayContexts; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ChannelTask.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ChannelTask.java index e45ead7a3..9cb4c5400 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ChannelTask.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ChannelTask.java @@ -1,5 +1,7 @@ package org.opensearch.migrations.replay.datatypes; +import org.opensearch.migrations.utils.FutureTransformer; + import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ConnectionReplaySession.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ConnectionReplaySession.java index 909fd263e..1402fbfdb 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ConnectionReplaySession.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/ConnectionReplaySession.java @@ -3,9 +3,9 @@ import java.util.function.BiFunction; import org.opensearch.migrations.replay.tracing.IReplayContexts; -import org.opensearch.migrations.replay.util.OnlineRadixSorter; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.OnlineRadixSorter; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.channel.ChannelFuture; import io.netty.channel.EventLoop; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/TimeToResponseFulfillmentFutureMap.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/TimeToResponseFulfillmentFutureMap.java index 5fdfa85f9..2ab967106 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/TimeToResponseFulfillmentFutureMap.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/datatypes/TimeToResponseFulfillmentFutureMap.java @@ -5,8 +5,8 @@ import java.util.Deque; import java.util.StringJoiner; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; public class TimeToResponseFulfillmentFutureMap { diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/DefaultRetry.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/DefaultRetry.java index dcf1ca62d..e0f99f1a8 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/DefaultRetry.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/DefaultRetry.java @@ -8,8 +8,8 @@ import org.opensearch.migrations.replay.HttpByteBufFormatter; import org.opensearch.migrations.replay.IRequestResponsePacketPair; import org.opensearch.migrations.replay.RequestSenderOrchestrator; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.handler.codec.http.HttpResponse; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/IRetryVisitorFactory.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/IRetryVisitorFactory.java index fa9593012..3d0b92f41 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/IRetryVisitorFactory.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/IRetryVisitorFactory.java @@ -4,7 +4,7 @@ import org.opensearch.migrations.replay.RequestSenderOrchestrator; import org.opensearch.migrations.replay.datatypes.ByteBufList; import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; public interface IRetryVisitorFactory { RequestSenderOrchestrator.RetryVisitor diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/NoRetryEvaluatorFactory.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/NoRetryEvaluatorFactory.java index 6ac766252..7ff72d34f 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/NoRetryEvaluatorFactory.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/NoRetryEvaluatorFactory.java @@ -5,8 +5,8 @@ import org.opensearch.migrations.replay.RequestSenderOrchestrator; import org.opensearch.migrations.replay.datatypes.ByteBufList; import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetry.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetry.java index d90d75781..9401fabd6 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetry.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetry.java @@ -9,8 +9,8 @@ import org.opensearch.migrations.replay.HttpByteBufFormatter; import org.opensearch.migrations.replay.IRequestResponsePacketPair; import org.opensearch.migrations.replay.RequestSenderOrchestrator; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RequestRetryEvaluator.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RequestRetryEvaluator.java index 4c9f3efe9..379ce550e 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RequestRetryEvaluator.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RequestRetryEvaluator.java @@ -5,7 +5,7 @@ import org.opensearch.migrations.replay.AggregatedRawResponse; import org.opensearch.migrations.replay.IRequestResponsePacketPair; import org.opensearch.migrations.replay.RequestSenderOrchestrator; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RetryCollectingVisitorFactory.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RetryCollectingVisitorFactory.java index 0be084929..040456c99 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RetryCollectingVisitorFactory.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/http/retries/RetryCollectingVisitorFactory.java @@ -7,8 +7,8 @@ import org.opensearch.migrations.replay.TransformedTargetRequestAndResponseList; import org.opensearch.migrations.replay.datatypes.ByteBufList; import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; public class RetryCollectingVisitorFactory implements IRetryVisitorFactory { private final RequestRetryEvaluator shouldRetry; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/ActiveContextMonitor.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/ActiveContextMonitor.java index 98ceda5dc..8216e932b 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/ActiveContextMonitor.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/ActiveContextMonitor.java @@ -23,6 +23,7 @@ import org.opensearch.migrations.tracing.ActiveContextTracker; import org.opensearch.migrations.tracing.ActiveContextTrackerByActivityType; import org.opensearch.migrations.tracing.IScopedInstrumentationAttributes; +import org.opensearch.migrations.utils.TrackedFuture; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OrderedWorkerTracker.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OrderedWorkerTracker.java index c32a887aa..3f6c96753 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OrderedWorkerTracker.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/util/OrderedWorkerTracker.java @@ -8,6 +8,7 @@ import org.opensearch.migrations.replay.TrafficReplayerTopLevel; import org.opensearch.migrations.replay.datatypes.UniqueReplayerRequestKey; +import org.opensearch.migrations.utils.TrackedFuture; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/utils/TrackedFutureJsonFormatter.java b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/utils/TrackedFutureJsonFormatter.java index 26f778269..31c9968f8 100644 --- a/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/utils/TrackedFutureJsonFormatter.java +++ b/TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/utils/TrackedFutureJsonFormatter.java @@ -1,16 +1,10 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.Lombok; import lombok.NonNull; -import lombok.SneakyThrows; public class TrackedFutureJsonFormatter { @@ -27,44 +21,9 @@ public static String format( @NonNull Function, String> resultFormatter ) { try { - return objectMapper.writeValueAsString(makeJson(tf, resultFormatter)); + return objectMapper.writeValueAsString(TrackedFutureMapConverter.makeJson(tf, resultFormatter)); } catch (Exception e) { throw Lombok.sneakyThrow(e); } } - - public static List makeJson( - TrackedFuture tf, - @NonNull Function, String> resultFormatter - ) { - return tf.walkParentsAsStream() - .map(kvp -> jsonFormatFutureWithDiagnostics(kvp, resultFormatter)) - .collect(Collectors.toList()); - } - - @SneakyThrows - protected static Map jsonFormatFutureWithDiagnostics( - @NonNull TrackedFuture tf, - @NonNull Function, String> resultFormatter - ) { - var diagnosticInfo = tf.diagnosticSupplier.get(); - var isDone = tf.isDone(); - var map = new LinkedHashMap(); - map.put("idHash", System.identityHashCode(tf)); - map.put("label", diagnosticInfo); - if (isDone) { - map.put("value", Optional.ofNullable(resultFormatter.apply(tf)).orElse("^")); - } else { - var innerResult = Optional.ofNullable(tf.innerComposedPendingCompletableFutureReference) - .map(r -> (TrackedFuture) r.get()) - .map(df -> makeJson(df, resultFormatter)) - .orElse(null); - if (innerResult == null) { - map.put("value", "…"); - } else { - map.put("pending", innerResult); - } - } - return map; - } } diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/RequestSenderOrchestratorTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/RequestSenderOrchestratorTest.java index e5b8140ad..0af9c4cf8 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/RequestSenderOrchestratorTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/RequestSenderOrchestratorTest.java @@ -21,11 +21,11 @@ import org.opensearch.migrations.replay.http.retries.NoRetryEvaluatorFactory; import org.opensearch.migrations.replay.util.NettyUtils; import org.opensearch.migrations.replay.util.RefSafeHolder; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.testutils.SimpleHttpServer; import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; import org.opensearch.migrations.tracing.InstrumentationTest; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumerTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumerTest.java index e0b4eeb8d..9ef1f3bed 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumerTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/NettyPacketToHttpConsumerTest.java @@ -26,7 +26,6 @@ import org.opensearch.migrations.replay.datatypes.ConnectionReplaySession; import org.opensearch.migrations.replay.http.retries.NoRetryEvaluatorFactory; import org.opensearch.migrations.replay.traffic.source.BufferedFlowController; -import org.opensearch.migrations.replay.util.TextTrackedFuture; import org.opensearch.migrations.testutils.HttpRequest; import org.opensearch.migrations.testutils.SimpleHttpClientForTesting; import org.opensearch.migrations.testutils.SimpleHttpResponse; @@ -35,6 +34,7 @@ import org.opensearch.migrations.tracing.InstrumentationTest; import org.opensearch.migrations.tracing.TestContext; import org.opensearch.migrations.transform.TransformationLoader; +import org.opensearch.migrations.utils.TextTrackedFuture; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.handler.codec.http.HttpHeaderNames; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumerTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumerTest.java index 7e106b433..8dcf6ba49 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumerTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/datahandlers/http/HttpJsonTransformingConsumerTest.java @@ -16,7 +16,6 @@ import org.opensearch.migrations.replay.TestCapturePacketToHttpHandler; import org.opensearch.migrations.replay.TestUtils; import org.opensearch.migrations.replay.datatypes.HttpRequestTransformationStatus; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; import org.opensearch.migrations.tracing.InstrumentationTest; import org.opensearch.migrations.transform.IJsonTransformer; @@ -24,6 +23,7 @@ import org.opensearch.migrations.transform.JsonKeysForHttpMessage; import org.opensearch.migrations.transform.RemovingAuthTransformerFactory; import org.opensearch.migrations.transform.TransformationLoader; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/HttpRetryTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/HttpRetryTest.java index dacc7fec3..42562e00b 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/HttpRetryTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/HttpRetryTest.java @@ -18,8 +18,6 @@ import org.opensearch.migrations.replay.datatypes.ByteBufList; import org.opensearch.migrations.replay.datatypes.HttpRequestTransformationStatus; import org.opensearch.migrations.replay.datatypes.TransformedOutputAndResult; -import org.opensearch.migrations.replay.util.TextTrackedFuture; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.testutils.SharedDockerImageNames; import org.opensearch.migrations.testutils.SimpleHttpResponse; import org.opensearch.migrations.testutils.SimpleHttpServer; @@ -27,6 +25,8 @@ import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; import org.opensearch.migrations.tracing.InMemoryInstrumentationBundle; import org.opensearch.migrations.tracing.TestContext; +import org.opensearch.migrations.utils.TextTrackedFuture; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.Unpooled; import io.netty.util.concurrent.DefaultThreadFactory; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetryTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetryTest.java index 0b78e1fa6..2888cfd54 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetryTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/http/retries/OpenSearchDefaultRetryTest.java @@ -11,7 +11,7 @@ import org.opensearch.migrations.replay.AggregatedRawResponse; import org.opensearch.migrations.replay.HttpByteBufFormatter; import org.opensearch.migrations.replay.RequestSenderOrchestrator; -import org.opensearch.migrations.replay.util.TextTrackedFuture; +import org.opensearch.migrations.utils.TextTrackedFuture; import io.netty.buffer.Unpooled; import org.junit.jupiter.api.Assertions; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/transform/HeaderTransformerTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/transform/HeaderTransformerTest.java index 2ac621929..f56a4777f 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/transform/HeaderTransformerTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/transform/HeaderTransformerTest.java @@ -15,11 +15,11 @@ import org.opensearch.migrations.replay.TestUtils; import org.opensearch.migrations.replay.datahandlers.http.HttpJsonTransformingConsumer; import org.opensearch.migrations.replay.datatypes.HttpRequestTransformationStatus; -import org.opensearch.migrations.replay.util.TrackedFuture; import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; import org.opensearch.migrations.tracing.InstrumentationTest; import org.opensearch.migrations.transform.StaticAuthTransformerFactory; import org.opensearch.migrations.transform.TransformationLoader; +import org.opensearch.migrations.utils.TrackedFuture; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; diff --git a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/ActiveContextMonitorTest.java b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/ActiveContextMonitorTest.java index 7f7507c64..5ff398ef2 100644 --- a/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/ActiveContextMonitorTest.java +++ b/TrafficCapture/trafficReplayer/src/test/java/org/opensearch/migrations/replay/util/ActiveContextMonitorTest.java @@ -15,6 +15,7 @@ import org.opensearch.migrations.tracing.CompositeContextTracker; import org.opensearch.migrations.tracing.IScopedInstrumentationAttributes; import org.opensearch.migrations.tracing.TestContext; +import org.opensearch.migrations.utils.TrackedFuture; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; diff --git a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java index 655ce8307..f8409eaa0 100644 --- a/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java +++ b/TrafficCapture/trafficReplayer/src/testFixtures/java/org/opensearch/migrations/replay/TestUtils.java @@ -18,10 +18,10 @@ import org.opensearch.migrations.Utils; import org.opensearch.migrations.replay.datahandlers.IPacketConsumer; import org.opensearch.migrations.replay.datahandlers.http.HttpJsonTransformingConsumer; -import org.opensearch.migrations.utils.TrackedFuture; import org.opensearch.migrations.tracing.TestContext; import org.opensearch.migrations.transform.IAuthTransformerFactory; import org.opensearch.migrations.transform.IJsonTransformer; +import org.opensearch.migrations.utils.TrackedFuture; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; diff --git a/coreUtilities/build.gradle b/coreUtilities/build.gradle index 8494c3f30..1c95ddce1 100644 --- a/coreUtilities/build.gradle +++ b/coreUtilities/build.gradle @@ -48,8 +48,8 @@ dependencies { implementation group: 'io.opentelemetry', name: 'opentelemetry-exporter-otlp' implementation group: 'io.opentelemetry.semconv', name: 'opentelemetry-semconv' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core' + testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind' + testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-core' testImplementation group: 'org.mockito', name: 'mockito-core' testImplementation group: 'org.hamcrest', name: 'hamcrest' diff --git a/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureMapConverter.java b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureMapConverter.java new file mode 100644 index 000000000..417ddaa04 --- /dev/null +++ b/coreUtilities/src/main/java/org/opensearch/migrations/utils/TrackedFutureMapConverter.java @@ -0,0 +1,51 @@ +package org.opensearch.migrations.utils; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +import lombok.NonNull; +import lombok.SneakyThrows; + +public class TrackedFutureMapConverter { + + private TrackedFutureMapConverter() {} + + public static List makeJson( + TrackedFuture tf, + @NonNull Function, String> resultFormatter + ) { + return tf.walkParentsAsStream() + .map(kvp -> jsonFormatFutureWithDiagnostics(kvp, resultFormatter)) + .collect(Collectors.toList()); + } + + @SneakyThrows + protected static Map jsonFormatFutureWithDiagnostics( + @NonNull TrackedFuture tf, + @NonNull Function, String> resultFormatter + ) { + var diagnosticInfo = tf.diagnosticSupplier.get(); + var isDone = tf.isDone(); + var map = new LinkedHashMap(); + map.put("idHash", System.identityHashCode(tf)); + map.put("label", diagnosticInfo); + if (isDone) { + map.put("value", Optional.ofNullable(resultFormatter.apply(tf)).orElse("^")); + } else { + var innerResult = Optional.ofNullable(tf.innerComposedPendingCompletableFutureReference) + .map(r -> (TrackedFuture) r.get()) + .map(df -> makeJson(df, resultFormatter)) + .orElse(null); + if (innerResult == null) { + map.put("value", "…"); + } else { + map.put("pending", innerResult); + } + } + return map; + } +} diff --git a/coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java index ba02b40ce..3006f8e97 100644 --- a/coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/PruferTreeGeneratorTest.java @@ -7,14 +7,12 @@ import java.util.Random; import java.util.stream.IntStream; -import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; import org.opensearch.migrations.utils.PruferTreeGenerator; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -@WrapWithNettyLeakDetection(disableLeakChecks = true) public class PruferTreeGeneratorTest { @Test diff --git a/coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java index a95e1c65e..cb4a33d25 100644 --- a/coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/utils/OnlineRadixSorterTest.java @@ -1,4 +1,4 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.ArrayList; import java.util.HashMap; @@ -6,10 +6,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.opensearch.migrations.utils.OnlineRadixSorter; -import org.opensearch.migrations.utils.OnlineRadixSorterForIntegratedKeys; -import org.opensearch.migrations.utils.TrackedFuture; - import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java index b4a144521..c5847f28d 100644 --- a/coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TextTrackedFutureTest.java @@ -1,21 +1,18 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.function.Function; -import org.opensearch.migrations.testutils.WrapWithNettyLeakDetection; -import org.opensearch.migrations.utils.TextTrackedFuture; -import org.opensearch.migrations.utils.TrackedFuture; -import org.opensearch.migrations.utils.TrackedFutureJsonFormatter; -import org.opensearch.migrations.utils.TrackedFutureStringFormatter; - +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.NonNull; import lombok.SneakyThrows; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -@WrapWithNettyLeakDetection(disableLeakChecks = true) class TextTrackedFutureTest { + private final static ObjectMapper objectMapper = new ObjectMapper(); @SneakyThrows private static void sneakyWait(CompletableFuture o) { o.get(5, TimeUnit.MINUTES); @@ -63,7 +60,7 @@ public void futureWithThreeStages() throws Exception { Assertions.assertEquals( "[{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"…\"}]", - TrackedFutureJsonFormatter.format(stcf1) + format(stcf1) ); Assertions.assertEquals( "[" @@ -73,7 +70,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"…\"}]", - TrackedFutureJsonFormatter.format(stcf2) + format(stcf2) ); Assertions.assertEquals( "[" @@ -86,7 +83,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"…\"}]", - TrackedFutureJsonFormatter.format(stcf3) + format(stcf3) ); notifyAndWaitForGet(stcf1, notifier1); @@ -103,7 +100,7 @@ public void futureWithThreeStages() throws Exception { Assertions.assertEquals( "[{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"^\"}]", - TrackedFutureJsonFormatter.format(stcf1) + format(stcf1) ); Assertions.assertEquals( "[" @@ -113,7 +110,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"^\"}]", - TrackedFutureJsonFormatter.format(stcf2) + format(stcf2) ); Assertions.assertEquals( "[" @@ -126,7 +123,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"^\"}]", - TrackedFutureJsonFormatter.format(stcf3) + format(stcf3) ); notifyAndWaitForGet(stcf2, notifier2); @@ -143,7 +140,7 @@ public void futureWithThreeStages() throws Exception { Assertions.assertEquals( "[{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"^\"}]", - TrackedFutureJsonFormatter.format(stcf1) + format(stcf1) ); Assertions.assertEquals( "[" @@ -153,7 +150,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"^\"}]", - TrackedFutureJsonFormatter.format(stcf2) + format(stcf2) ); Assertions.assertEquals( "[" @@ -166,7 +163,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"^\"}]", - TrackedFutureJsonFormatter.format(stcf3) + format(stcf3) ); Assertions.assertEquals( "[" @@ -179,7 +176,7 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id1 + ",\"label\":\"A\",\"value\":\"1\"}]", - TrackedFutureJsonFormatter.format(stcf3, TextTrackedFutureTest::formatCompletableFuture) + format(stcf3, TextTrackedFutureTest::formatCompletableFuture) ); // A is clipped because of grandparent culling @@ -196,10 +193,21 @@ public void futureWithThreeStages() throws Exception { + "{\"idHash\":" + id2 + ",\"label\":\"B\",\"value\":\"11\"}]", - TrackedFutureJsonFormatter.format(stcf3, TextTrackedFutureTest::formatCompletableFuture) + format(stcf3, TextTrackedFutureTest::formatCompletableFuture) ); } + @SneakyThrows + private String format(TrackedFuture tf) { + return objectMapper.writeValueAsString(TrackedFutureMapConverter.makeJson(tf, x -> null)); + } + + @SneakyThrows + private static String format(TrackedFuture tf, + @NonNull Function, String> resultFormatter) { + return objectMapper.writeValueAsString(TrackedFutureMapConverter.makeJson(tf, resultFormatter)); + } + public static String formatCompletableFuture(TrackedFuture cf) { try { return "" + cf.get(); diff --git a/coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java index e2024474b..6c740c10a 100644 --- a/coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java +++ b/coreUtilities/src/test/java/org/opensearch/migrations/utils/TrackedFutureTest.java @@ -1,10 +1,7 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.concurrent.Semaphore; -import org.opensearch.migrations.utils.TextTrackedFuture; -import org.opensearch.migrations.utils.TrackedFuture; - import lombok.Lombok; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; diff --git a/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java index 4fa67c0e8..03fe43fdf 100644 --- a/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java +++ b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/OnlineRadixSorterForIntegratedKeys.java @@ -1,10 +1,7 @@ -package org.opensearch.migrations.replay.util; +package org.opensearch.migrations.utils; import java.util.function.ToIntFunction; -import org.opensearch.migrations.utils.OnlineRadixSorter; -import org.opensearch.migrations.utils.TrackedFuture; - import lombok.extern.slf4j.Slf4j; /** diff --git a/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/PruferTreeGenerator.java b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/PruferTreeGenerator.java index b0b2b07c4..2dff8dee3 100644 --- a/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/PruferTreeGenerator.java +++ b/coreUtilities/src/testFixtures/java/org/opensearch/migrations/utils/PruferTreeGenerator.java @@ -1,4 +1,4 @@ -package org.opensearch.migrations; +package org.opensearch.migrations.utils; import java.util.ArrayList; import java.util.Arrays;