Skip to content

Commit

Permalink
Remove the dual write option for request/response (tuple) output
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Presley <[email protected]>
  • Loading branch information
sumobrian committed Nov 12, 2023
1 parent b9dd32e commit 0de0a3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.opensearch.migrations.replay.datatypes.UniqueSourceRequestKey;

import java.io.IOException;
import java.io.OutputStream;
import java.io.SequenceInputStream;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
Expand Down Expand Up @@ -55,11 +54,9 @@ public void close() {
}

public static class TupleToFileWriter implements Consumer<SourceTargetCaptureTuple> {
OutputStream outputStream;
Logger tupleLogger = LogManager.getLogger("OutputTupleJsonLogger");

public TupleToFileWriter(OutputStream outputStream){
this.outputStream = outputStream;
public TupleToFileWriter(){

Check warning on line 59 in TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/SourceTargetCaptureTuple.java

View check run for this annotation

Codecov / codecov/patch

TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/SourceTargetCaptureTuple.java#L59

Added line #L59 was not covered by tests
}

private JSONObject jsonFromHttpDataUnsafe(List<byte[]> data) throws IOException {
Expand Down Expand Up @@ -169,8 +166,6 @@ public void accept(SourceTargetCaptureTuple triple) {
JSONObject jsonObject = toJSONObject(triple);

tupleLogger.info(jsonObject.toString());
outputStream.write((jsonObject.toString()+"\n").getBytes(StandardCharsets.UTF_8));
outputStream.flush();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@
import software.amazon.awssdk.regions.Region;

import javax.net.ssl.SSLException;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.net.URI;
import java.time.Duration;
Expand Down Expand Up @@ -224,12 +221,6 @@ static class Parameters {
arity=1,
description = "input file to read the request/response traces for the source cluster")
String inputFilename;
@Parameter(required = false,
names = {"-o", "--output"},
arity=1,
description = "output file to hold the request/response traces for the source and target cluster")
String outputFilename;

@Parameter(required = false,
names = {"-t", PACKET_TIMEOUT_SECONDS_PARAMETER_NAME},
arity = 1,
Expand Down Expand Up @@ -325,17 +316,15 @@ public static void main(String[] args)
return;
}

try (OutputStream outputStream = params.outputFilename == null ? System.out :
new FileOutputStream(params.outputFilename, true);
var bufferedOutputStream = new BufferedOutputStream(outputStream);
try (
var blockingTrafficStream = TrafficCaptureSourceFactory.createTrafficCaptureSource(params,
Duration.ofSeconds(params.lookaheadTimeSeconds));
var authTransformer = buildAuthTransformerFactory(params))
{
var tr = new TrafficReplayer(uri, params.transformerConfig, authTransformer,
params.allowInsecureConnections, params.numClientThreads, params.maxConcurrentRequests);
setupShutdownHookForReplayer(tr);
var tupleWriter = new SourceTargetCaptureTuple.TupleToFileWriter(bufferedOutputStream);
var tupleWriter = new SourceTargetCaptureTuple.TupleToFileWriter();

Check warning on line 327 in TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayer.java

View check run for this annotation

Codecov / codecov/patch

TrafficCapture/trafficReplayer/src/main/java/org/opensearch/migrations/replay/TrafficReplayer.java#L327

Added line #L327 was not covered by tests
var timeShifter = new TimeShifter(params.speedupFactor);
tr.setupRunAndWaitForReplayWithShutdownChecks(Duration.ofSeconds(params.observedPacketConnectionTimeout),
blockingTrafficStream, timeShifter, tupleWriter);
Expand Down

0 comments on commit 0de0a3e

Please sign in to comment.