From 60181640adc9bf25f85bbce68022afa8ce71de95 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Thu, 4 Jan 2024 19:04:20 +0000 Subject: [PATCH 01/11] Update SenderAndTargetSessionIdStrategy.java gc3 for CompositeKeyImpl --- .../SenderAndTargetSessionIdStrategy.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java index ab37d50cb2..f39189f89c 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java @@ -152,6 +152,10 @@ private static final class CompositeKeyImpl implements CompositeKey private final char[] remoteCompID; private final int hashCode; + private final String localCompIDStr; + private final String remoteCompIDStr; + private final String compositeKeyStr; + private CompositeKeyImpl( final char[] localCompID, final int localCompIDLength, @@ -161,6 +165,9 @@ private CompositeKeyImpl( this.localCompID = Arrays.copyOf(localCompID, localCompIDLength); this.remoteCompID = Arrays.copyOf(remoteCompID, remoteCompIDLength); hashCode = hash(this.localCompID, this.remoteCompID); + this.localCompIDStr=new String(this.localCompID); + this.remoteCompIDStr=new String(this.remoteCompID); + compositeKeyStr=compositKey(); } private CompositeKeyImpl(final byte[] localCompID, final byte[] remoteCompID) @@ -168,6 +175,9 @@ private CompositeKeyImpl(final byte[] localCompID, final byte[] remoteCompID) this.localCompID = CodecUtil.fromBytes(localCompID); this.remoteCompID = CodecUtil.fromBytes(remoteCompID); hashCode = hash(this.localCompID, this.remoteCompID); + this.localCompIDStr=new String(this.localCompID); + this.remoteCompIDStr=new String(this.remoteCompID); + compositeKeyStr=compositKey(); } private int hash(final char[] senderCompID, final char[] targetCompID) @@ -194,17 +204,22 @@ public boolean equals(final Object obj) return false; } - public String toString() + private String compositKey() { return "CompositeKey{" + - "localCompId=" + localCompId() + - ", remoteCompId=" + remoteCompId() + - '}'; + "localCompId=" + localCompId() + + ", remoteCompId=" + remoteCompId() + + '}'; + } + + public String toString() + { + return compositeKeyStr; } public String localCompId() { - return new String(localCompID); + return localCompIDStr; } public String localSubId() @@ -219,7 +234,7 @@ public String localLocationId() public String remoteCompId() { - return new String(remoteCompID); + return remoteCompIDStr; } public String remoteSubId() From 48d4b1194123277b7e094703ff7c766ab1de8211 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Thu, 4 Jan 2024 19:06:37 +0000 Subject: [PATCH 02/11] Update SenderTargetAndSubSessionIdStrategy.java gc3 for CompositeKeyImpl --- .../SenderTargetAndSubSessionIdStrategy.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java index de498edba9..cc984a77b2 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java @@ -164,6 +164,11 @@ private static final class CompositeKeyImpl implements CompositeKey private final char[] remoteCompID; private final int hashCode; + private final String localCompIDStr; + private final String localSubIDStr; + private final String remoteCompIDStr; + private final String compositeKeyStr; + private CompositeKeyImpl( final char[] localCompID, final int localCompIDLength, @@ -176,6 +181,10 @@ private CompositeKeyImpl( this.remoteCompID = Arrays.copyOf(remoteCompID, remoteCompIDLength); this.localSubID = Arrays.copyOf(localSubID, localSubIDLength); hashCode = hash(this.localCompID, this.localSubID, this.remoteCompID); + this.localCompIDStr=new String(this.localCompID); + this.localSubIDStr=new String(this.localSubID); + this.remoteCompIDStr=new String(this.remoteCompID); + compositeKeyStr=compositKey(); } private CompositeKeyImpl( @@ -187,6 +196,10 @@ private CompositeKeyImpl( this.localSubID = CodecUtil.fromBytes(localSubID); this.remoteCompID = CodecUtil.fromBytes(remoteCompID); hashCode = hash(this.localCompID, this.localSubID, this.remoteCompID); + this.localCompIDStr=new String(this.localCompID); + this.localSubIDStr=new String(this.localSubID); + this.remoteCompIDStr=new String(this.remoteCompID); + compositeKeyStr=compositKey(); } private int hash(final char[] localCompID, final char[] localSubID, final char[] remoteCompID) @@ -215,23 +228,28 @@ public boolean equals(final Object obj) return false; } - public String toString() + private String compositKey() { return "CompositeKey{" + - "localCompId=" + localCompId() + - ", localSubId=" + localSubId() + - ", remoteCompId=" + remoteCompId() + - '}'; + "localCompId=" + localCompId() + + ", localSubId=" + localSubId() + + ", remoteCompId=" + remoteCompId() + + '}'; + } + + public String toString() + { + return compositeKeyStr; } public String localCompId() { - return new String(localCompID); + return localCompIDStr; } public String localSubId() { - return new String(localSubID); + return localSubIDStr; } public String localLocationId() @@ -241,7 +259,7 @@ public String localLocationId() public String remoteCompId() { - return new String(remoteCompID); + return remoteCompIDStr; } public String remoteSubId() From 3837557d0575142c1577f2351bf04d7bb1d3b5c5 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Thu, 21 Mar 2024 21:44:14 +0000 Subject: [PATCH 03/11] Externalize Initial ConnectionId to EngineConfiguration ConnectionId to be deterministic --- .../artio/engine/EngineConfiguration.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/engine/EngineConfiguration.java b/artio-core/src/main/java/uk/co/real_logic/artio/engine/EngineConfiguration.java index 816f8c4f59..b8a0a11354 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/engine/EngineConfiguration.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/engine/EngineConfiguration.java @@ -235,6 +235,7 @@ public final class EngineConfiguration extends CommonConfiguration implements Au public static final int DEFAULT_INITIAL_SEQUENCE_INDEX = 0; public static final int DEFAULT_CANCEL_ON_DISCONNECT_TIMEOUT_WINDOW_IN_MS = 0; + public static final long DEFAULT_INITIAL_CONNECTION_ID = (long)(Math.random() * Long.MAX_VALUE); private String host = null; private int port; @@ -324,6 +325,7 @@ public final class EngineConfiguration extends CommonConfiguration implements Au private long timeIndexReplayFlushIntervalInNs = DEFAULT_TIME_INDEX_FLUSH_INTERVAL_IN_NS; private CancelOnDisconnectOption cancelOnDisconnectOption = DO_NOT_CANCEL_ON_DISCONNECT_OR_LOGOUT; private int cancelOnDisconnectTimeoutWindowInMs = DEFAULT_CANCEL_ON_DISCONNECT_TIMEOUT_WINDOW_IN_MS; + private long initialConnectionId = DEFAULT_INITIAL_CONNECTION_ID; private EngineReproductionConfiguration reproductionConfiguration; private ReproductionMessageHandler reproductionMessageHandler = (connectionId, bytes) -> @@ -1306,6 +1308,18 @@ public EngineConfiguration cancelOnDisconnectTimeoutWindowInMs(final int cancelO return this; } + /** + * Sets the initial connectionId to start with. + * + * @param initialConnectionId initial connection id + * @return this + */ + public EngineConfiguration initialConnectionId(final long initialConnectionId) + { + this.initialConnectionId = initialConnectionId; + return this; + } + // --------------------- // END SETTERS // --------------------- @@ -2063,6 +2077,11 @@ public int reproductionReplayStream() return reproductionReplayStream; } + public long initialConnectionId() + { + return initialConnectionId; + } + // --------------------- // END GETTERS // --------------------- From 21d36ed6c7b9d25fd63ff3aeeb0c6ead5796d76d Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Thu, 21 Mar 2024 21:47:14 +0000 Subject: [PATCH 04/11] Externalize Initial ConnectionId to EngineConfiguration ConnectionId to be deterministic --- .../main/java/uk/co/real_logic/artio/engine/framer/Framer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java b/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java index 51962f31c2..aa53bbfe2e 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java @@ -187,7 +187,7 @@ class Framer implements Agent, EngineEndPointHandler, ProtocolHandler private final DeadlineTimerWheel timerWheel; private final TimerEventHandler timerEventHandler; - private long nextConnectionId = (long)(Math.random() * Long.MAX_VALUE); + private long nextConnectionId; private FixPProtocol fixPProtocol; private AbstractFixPParser fixPParser; private AbstractFixPProxy fixPProxy; @@ -274,6 +274,7 @@ class Framer implements Agent, EngineEndPointHandler, ProtocolHandler this.acceptsFixP = configuration.acceptsFixP(); this.fixPContexts = fixPContexts; this.fixCounters = fixCounters; + this.nextConnectionId=configuration.initialConnectionId(); replyTimeoutInNs = TimeUnit.MILLISECONDS.toNanos(configuration.replyTimeoutInMs()); timerEventHandler = new TimerEventHandler(errorHandler); From 4e562b0085fb4b2ad597aeeb7b50469fd8cfaecd Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:29:53 +0100 Subject: [PATCH 05/11] Update Framer.java --- .../main/java/uk/co/real_logic/artio/engine/framer/Framer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java b/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java index aa53bbfe2e..120056130e 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/engine/framer/Framer.java @@ -274,7 +274,7 @@ class Framer implements Agent, EngineEndPointHandler, ProtocolHandler this.acceptsFixP = configuration.acceptsFixP(); this.fixPContexts = fixPContexts; this.fixCounters = fixCounters; - this.nextConnectionId=configuration.initialConnectionId(); + this.nextConnectionId = configuration.initialConnectionId(); replyTimeoutInNs = TimeUnit.MILLISECONDS.toNanos(configuration.replyTimeoutInMs()); timerEventHandler = new TimerEventHandler(errorHandler); From 8e6e83618efe7b262510cf902c1ad197f887ab47 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:30:57 +0100 Subject: [PATCH 06/11] Update SenderAndTargetSessionIdStrategy.java --- .../artio/session/SenderAndTargetSessionIdStrategy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java index f39189f89c..c80acee4f9 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java @@ -165,8 +165,8 @@ private CompositeKeyImpl( this.localCompID = Arrays.copyOf(localCompID, localCompIDLength); this.remoteCompID = Arrays.copyOf(remoteCompID, remoteCompIDLength); hashCode = hash(this.localCompID, this.remoteCompID); - this.localCompIDStr=new String(this.localCompID); - this.remoteCompIDStr=new String(this.remoteCompID); + this.localCompIDStr = new String(this.localCompID); + this.remoteCompIDStr = new String(this.remoteCompID); compositeKeyStr=compositKey(); } @@ -175,8 +175,8 @@ private CompositeKeyImpl(final byte[] localCompID, final byte[] remoteCompID) this.localCompID = CodecUtil.fromBytes(localCompID); this.remoteCompID = CodecUtil.fromBytes(remoteCompID); hashCode = hash(this.localCompID, this.remoteCompID); - this.localCompIDStr=new String(this.localCompID); - this.remoteCompIDStr=new String(this.remoteCompID); + this.localCompIDStr = new String(this.localCompID); + this.remoteCompIDStr = new String(this.remoteCompID); compositeKeyStr=compositKey(); } From 55fd9d319c087d745aa8eac339c4b69b12f335f7 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:32:04 +0100 Subject: [PATCH 07/11] Update SenderTargetAndSubSessionIdStrategy.java --- .../session/SenderTargetAndSubSessionIdStrategy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java index cc984a77b2..65b201e42a 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java @@ -181,10 +181,10 @@ private CompositeKeyImpl( this.remoteCompID = Arrays.copyOf(remoteCompID, remoteCompIDLength); this.localSubID = Arrays.copyOf(localSubID, localSubIDLength); hashCode = hash(this.localCompID, this.localSubID, this.remoteCompID); - this.localCompIDStr=new String(this.localCompID); - this.localSubIDStr=new String(this.localSubID); - this.remoteCompIDStr=new String(this.remoteCompID); - compositeKeyStr=compositKey(); + this.localCompIDStr = new String(this.localCompID); + this.localSubIDStr = new String(this.localSubID); + this.remoteCompIDStr = new String(this.remoteCompID); + compositeKeyStr = compositKey(); } private CompositeKeyImpl( From c05a3918d223a52f18d4faf5b47a155b39e9756f Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:33:44 +0100 Subject: [PATCH 08/11] Update SenderTargetAndSubSessionIdStrategy.java --- .../session/SenderTargetAndSubSessionIdStrategy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java index 65b201e42a..b93d963cbf 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java @@ -196,10 +196,10 @@ private CompositeKeyImpl( this.localSubID = CodecUtil.fromBytes(localSubID); this.remoteCompID = CodecUtil.fromBytes(remoteCompID); hashCode = hash(this.localCompID, this.localSubID, this.remoteCompID); - this.localCompIDStr=new String(this.localCompID); - this.localSubIDStr=new String(this.localSubID); - this.remoteCompIDStr=new String(this.remoteCompID); - compositeKeyStr=compositKey(); + this.localCompIDStr = new String(this.localCompID); + this.localSubIDStr = new String(this.localSubID); + this.remoteCompIDStr = new String(this.remoteCompID); + compositeKeyStr = compositKey(); } private int hash(final char[] localCompID, final char[] localSubID, final char[] remoteCompID) From 5f168f57a0ea18167dfad7fe7fb2fc07b9bc8fc7 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:34:47 +0100 Subject: [PATCH 09/11] Update SenderAndTargetSessionIdStrategy.java --- .../artio/session/SenderAndTargetSessionIdStrategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java index c80acee4f9..97caf84d8b 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java @@ -167,7 +167,7 @@ private CompositeKeyImpl( hashCode = hash(this.localCompID, this.remoteCompID); this.localCompIDStr = new String(this.localCompID); this.remoteCompIDStr = new String(this.remoteCompID); - compositeKeyStr=compositKey(); + compositeKeyStr = compositKey(); } private CompositeKeyImpl(final byte[] localCompID, final byte[] remoteCompID) @@ -177,7 +177,7 @@ private CompositeKeyImpl(final byte[] localCompID, final byte[] remoteCompID) hashCode = hash(this.localCompID, this.remoteCompID); this.localCompIDStr = new String(this.localCompID); this.remoteCompIDStr = new String(this.remoteCompID); - compositeKeyStr=compositKey(); + compositeKeyStr = compositKey(); } private int hash(final char[] senderCompID, final char[] targetCompID) From cf994a5fb779623e554af9cf75ae095a9ca7f7df Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:37:19 +0100 Subject: [PATCH 10/11] Update SenderTargetAndSubSessionIdStrategy.java --- .../session/SenderTargetAndSubSessionIdStrategy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java index b93d963cbf..048e2673be 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderTargetAndSubSessionIdStrategy.java @@ -231,10 +231,10 @@ public boolean equals(final Object obj) private String compositKey() { return "CompositeKey{" + - "localCompId=" + localCompId() + - ", localSubId=" + localSubId() + - ", remoteCompId=" + remoteCompId() + - '}'; + "localCompId=" + localCompId() + + ", localSubId=" + localSubId() + + ", remoteCompId=" + remoteCompId() + + '}'; } public String toString() From 40b1e1b06dcbe08b840613c27e24d92e6a3733a4 Mon Sep 17 00:00:00 2001 From: Michael Tan Date: Sat, 27 Apr 2024 23:39:58 +0100 Subject: [PATCH 11/11] Update SenderAndTargetSessionIdStrategy.java --- .../artio/session/SenderAndTargetSessionIdStrategy.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java index 97caf84d8b..d496a283f7 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/session/SenderAndTargetSessionIdStrategy.java @@ -207,9 +207,9 @@ public boolean equals(final Object obj) private String compositKey() { return "CompositeKey{" + - "localCompId=" + localCompId() + - ", remoteCompId=" + remoteCompId() + - '}'; + "localCompId=" + localCompId() + + ", remoteCompId=" + remoteCompId() + + '}'; } public String toString()