From 6302515a507ce298d7f5ed87fb7e71b4710a0d4c Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Fri, 19 Jan 2018 09:31:09 +0000 Subject: [PATCH 01/20] Updating to bom version 1.15.46 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c60bc570d9..f53c9a8c87 100755 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ net.openhft chronicle-bom - 1.15.45-SNAPSHOT + 1.15.46 pom import From df590909b92cb29a5f98df73fc7525477fe6343f Mon Sep 17 00:00:00 2001 From: epickrram Date: Fri, 19 Jan 2018 09:48:26 +0000 Subject: [PATCH 02/20] Revert "Updating to bom version 1.15.46" This reverts commit 6302515a507ce298d7f5ed87fb7e71b4710a0d4c. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f53c9a8c87..c60bc570d9 100755 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ net.openhft chronicle-bom - 1.15.46 + 1.15.45-SNAPSHOT pom import From 6027eb371eb4d9068118cc2b097bcd2aff1900af Mon Sep 17 00:00:00 2001 From: epickrram Date: Fri, 19 Jan 2018 10:04:19 +0000 Subject: [PATCH 03/20] update bom version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c60bc570d9..f53c9a8c87 100755 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ net.openhft chronicle-bom - 1.15.45-SNAPSHOT + 1.15.46 pom import From 67642621b12f6cbb86d133165237e4ceec9dd10e Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Fri, 19 Jan 2018 10:13:12 +0000 Subject: [PATCH 04/20] [maven-release-plugin] prepare release chronicle-wire-1.10.10 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f53c9a8c87..99cfa51799 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.10-SNAPSHOT + 1.10.10 OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - master + chronicle-wire-1.10.10 From 161302a984cd89e11cb5405cee699df82794d45a Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Fri, 19 Jan 2018 10:13:18 +0000 Subject: [PATCH 05/20] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 99cfa51799..6dffea191d 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.10 + 1.10.11-SNAPSHOT OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - chronicle-wire-1.10.10 + master From 30b82f680ffcaf663913320621698852b71a02fb Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Fri, 19 Jan 2018 12:19:14 +0000 Subject: [PATCH 06/20] https://github.com/ChronicleEnterprise/Chronicle-Services/issues/24 Added support for config to the replication service --- src/main/java/net/openhft/chronicle/wire/TextWire.java | 1 + .../java/net/openhft/chronicle/wire/VanillaMethodReader.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/net/openhft/chronicle/wire/TextWire.java b/src/main/java/net/openhft/chronicle/wire/TextWire.java index 38919fadf6..c6bf6f300d 100755 --- a/src/main/java/net/openhft/chronicle/wire/TextWire.java +++ b/src/main/java/net/openhft/chronicle/wire/TextWire.java @@ -258,6 +258,7 @@ public DocumentContext readingDocument() { return readContext; } + protected void initReadContext() { if (readContext == null) readContext = new TextReadDocumentContext(this); diff --git a/src/main/java/net/openhft/chronicle/wire/VanillaMethodReader.java b/src/main/java/net/openhft/chronicle/wire/VanillaMethodReader.java index 33de98f97a..f137bfe623 100755 --- a/src/main/java/net/openhft/chronicle/wire/VanillaMethodReader.java +++ b/src/main/java/net/openhft/chronicle/wire/VanillaMethodReader.java @@ -360,6 +360,7 @@ private void invoke(Object o, @NotNull Method m, Object[] args) throws IllegalAc */ public boolean readOne() { for (; ; ) { + try (DocumentContext context = in.readingDocument()) { if (!context.isPresent()) return false; From 104d7a979d106f2bf261f9f7becf61f5d355b1a8 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Sun, 21 Jan 2018 10:08:04 +0000 Subject: [PATCH 07/20] Standardise .gitignore across projects --- .gitignore | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) mode change 100755 => 100644 .gitignore diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index e0ff71942d..bc0ad52f13 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,52 @@ -# Package Files # +### How to update +# This is copied from OpenHFT/.gitignore +# update the original and run OpenHFT/update_gitignore.sh + +### Compiled class file +*.class + +### Package Files +*.jar *.war *.ear -# IntelliJ +### Log file +*.log + +### IntelliJ *.iml *.ipr *.iws .idea +.attach_pid* -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +### Virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* -# Eclipse +### Maven template +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties + +### Eclipse template +*.pydevproject +.metadata +.gradle +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties .classpath .project .settings/ +.loadpath -# maven -target - -.attach_pid* +### Queue files +*.cq4t +*.cq4 From b256f5a1e4b22c7d758ed8582106e837c0a77025 Mon Sep 17 00:00:00 2001 From: epickrram Date: Mon, 22 Jan 2018 11:33:56 +0000 Subject: [PATCH 08/20] Ensure that meta-data entries are correctly handled when storing pid in header for #61 --- .../net/openhft/chronicle/wire/Wires.java | 2 +- .../StoreWritingProcessInHeaderTest.java | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/wire/Wires.java b/src/main/java/net/openhft/chronicle/wire/Wires.java index 1114b6a14e..343f98bc2d 100755 --- a/src/main/java/net/openhft/chronicle/wire/Wires.java +++ b/src/main/java/net/openhft/chronicle/wire/Wires.java @@ -65,7 +65,7 @@ public enum Wires { public static final int UNKNOWN_LENGTH = 0x0; public static final int MAX_LENGTH = (1 << 30) - 1; private static final boolean ENCODE_PID_IN_HEADER = Boolean.getBoolean("wire.encodePidInHeader"); - private static final int PID_MASK = 0b01111111_11111111_11111111_11111111; + private static final int PID_MASK = 0b00111111_11111111_11111111_11111111; private static final int INVERSE_PID_MASK = ~PID_MASK; // value to use when the message is not ready and of an unknown length diff --git a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java index 5b31645107..10d104b18e 100644 --- a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java +++ b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java @@ -8,6 +8,7 @@ import net.openhft.chronicle.wire.Wires; import org.junit.After; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,10 +28,12 @@ public final class StoreWritingProcessInHeaderTest { private final NativeBytes bytes; private final Wire wire; + private final WireType wireType; public StoreWritingProcessInHeaderTest(final String name, final WireType wireType) { bytes = Bytes.allocateElasticDirect(); wire = wireType.apply(bytes); + this.wireType = wireType; } @Parameterized.Parameters(name = "{0}") @@ -52,7 +55,6 @@ public void shouldEncodePid() { @Test public void shouldStoreWritingProcessIdInHeader() throws TimeoutException, EOFException { final long position = wire.writeHeaderOfUnknownLength(1, TimeUnit.SECONDS, null, null); - final int header = wire.bytes().readVolatileInt(position); assertThat(Wires.isNotComplete(header), is(true)); assertThat(header, is(Wires.addMaskedPidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH))); @@ -60,6 +62,22 @@ public void shouldStoreWritingProcessIdInHeader() throws TimeoutException, EOFEx assertThat(Wires.extractPidFromHeader(header), is(OS.getProcessId())); } + @Test + public void shouldWorkWithMetaDataEntries() throws TimeoutException, EOFException { + Assume.assumeTrue(wireType != WireType.READ_ANY); + + final long position = wire.writeHeaderOfUnknownLength(1, TimeUnit.SECONDS, null, null); + final int header = wire.bytes().readVolatileInt(position); + // simulate meta-data indicator in header + wire.bytes().writeInt(position, header | Wires.META_DATA); + final int updatedHeader = wire.bytes().readVolatileInt(position); + assertThat(Wires.isNotComplete(updatedHeader), is(true)); + assertThat(updatedHeader, is(Wires.addMaskedPidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH | Wires.META_DATA))); + assertThat(Wires.removeMaskedPidFromHeader(updatedHeader), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH | Wires.META_DATA)); + assertThat(Wires.extractPidFromHeader(updatedHeader), is(OS.getProcessId())); + assertThat(Wires.isNotComplete(updatedHeader), is(true)); + } + @After public void tearDown() { bytes.release(); From 0ba94d77fe73fe032073490dcf92ea14ce1fceb2 Mon Sep 17 00:00:00 2001 From: epickrram Date: Mon, 22 Jan 2018 12:52:27 +0000 Subject: [PATCH 09/20] Tidy --- .../wire/monitoring/StoreWritingProcessInHeaderTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java index 10d104b18e..65365c6059 100644 --- a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java +++ b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java @@ -8,7 +8,6 @@ import net.openhft.chronicle.wire.Wires; import org.junit.After; import org.junit.AfterClass; -import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,10 +21,10 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeTrue; @RunWith(Parameterized.class) public final class StoreWritingProcessInHeaderTest { - private final NativeBytes bytes; private final Wire wire; private final WireType wireType; @@ -64,7 +63,7 @@ public void shouldStoreWritingProcessIdInHeader() throws TimeoutException, EOFEx @Test public void shouldWorkWithMetaDataEntries() throws TimeoutException, EOFException { - Assume.assumeTrue(wireType != WireType.READ_ANY); + assumeTrue(wireType != WireType.READ_ANY); final long position = wire.writeHeaderOfUnknownLength(1, TimeUnit.SECONDS, null, null); final int header = wire.bytes().readVolatileInt(position); @@ -85,7 +84,7 @@ public void tearDown() { @BeforeClass public static void enableFeature() { - System.setProperty("wire.encodePidInHeader", Boolean.TRUE.toString()); + System.setProperty("wire.encodePidInHeader", Boolean.FALSE.toString()); } @AfterClass From bf5c1e79969d0b335bba2e022d48718d9ca48e71 Mon Sep 17 00:00:00 2001 From: epickrram Date: Mon, 22 Jan 2018 14:45:04 +0000 Subject: [PATCH 10/20] Flip flag in test. --- .../wire/monitoring/StoreWritingProcessInHeaderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java index 65365c6059..747353c6c2 100644 --- a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java +++ b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java @@ -84,7 +84,7 @@ public void tearDown() { @BeforeClass public static void enableFeature() { - System.setProperty("wire.encodePidInHeader", Boolean.FALSE.toString()); + System.setProperty("wire.encodePidInHeader", Boolean.TRUE.toString()); } @AfterClass From ada415fbbf65ecdbc815b10ee023fa3880fa7936 Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 01:53:50 +0000 Subject: [PATCH 11/20] [maven-release-plugin] prepare release chronicle-wire-1.10.11 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6dffea191d..ad2842bb56 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.11-SNAPSHOT + 1.10.11 OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - master + chronicle-wire-1.10.11 From 3fd6a4ce631ab7dfa8d719084f5497ccd0b443e2 Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 01:53:56 +0000 Subject: [PATCH 12/20] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ad2842bb56..4bed1e2914 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.11 + 1.10.12-SNAPSHOT OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - chronicle-wire-1.10.11 + master From c513c3439defa2e27f3f2fbe5ab516c43e82f72c Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 05:21:09 +0000 Subject: [PATCH 13/20] Updating to bom version 1.15.56 --- microbenchmarks/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microbenchmarks/pom.xml b/microbenchmarks/pom.xml index d00fbaa098..f631951041 100755 --- a/microbenchmarks/pom.xml +++ b/microbenchmarks/pom.xml @@ -42,7 +42,7 @@ net.openhft chronicle-bom - 1.15.39-SNAPSHOT + 1.15.56 pom import diff --git a/pom.xml b/pom.xml index 4bed1e2914..73b286404f 100755 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ net.openhft chronicle-bom - 1.15.46 + 1.15.56 pom import From af9727d27715fe65fc3a3bb96be04536896208db Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 05:23:39 +0000 Subject: [PATCH 14/20] [maven-release-plugin] prepare release chronicle-wire-1.10.12 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 73b286404f..f8aeca5483 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.12-SNAPSHOT + 1.10.12 OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - master + chronicle-wire-1.10.12 From bf88f5dbb569f3e4ddc6ee47a49175e6f0444fac Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 05:23:45 +0000 Subject: [PATCH 15/20] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f8aeca5483..89c9c17d0a 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.12 + 1.10.13-SNAPSHOT OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - chronicle-wire-1.10.12 + master From 4f8f85c76e8b33a42d8756aed3716579932ea8d3 Mon Sep 17 00:00:00 2001 From: epickrram Date: Tue, 23 Jan 2018 09:11:29 +0000 Subject: [PATCH 16/20] process id -> thread id in #61 --- .../openhft/chronicle/wire/AbstractWire.java | 6 ++-- .../net/openhft/chronicle/wire/Wires.java | 23 +++++++------- .../StoreWritingProcessInHeaderTest.java | 30 +++++++++---------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/wire/AbstractWire.java b/src/main/java/net/openhft/chronicle/wire/AbstractWire.java index 5e71c679c2..0bdfb530ee 100755 --- a/src/main/java/net/openhft/chronicle/wire/AbstractWire.java +++ b/src/main/java/net/openhft/chronicle/wire/AbstractWire.java @@ -428,7 +428,7 @@ private long tryWriteHeader0(int length, int safeLength) { throw new IllegalArgumentException(); long pos = bytes.writePosition(); - final int value = Wires.addMaskedPidToHeader(NOT_COMPLETE | length); + final int value = Wires.addMaskedTidToHeader(NOT_COMPLETE | length); if (bytes.compareAndSwapInt(pos, 0, value)) { int maxlen = length == UNKNOWN_LENGTH ? safeLength : length; @@ -451,7 +451,7 @@ private long writeHeader0(int length, int safeLength, long timeout, TimeUnit tim // System.out.println(Thread.currentThread()+" wh0 pos: "+pos+" hdr "+(int) headerNumber); try { - final int value = Wires.addMaskedPidToHeader(NOT_COMPLETE | length); + final int value = Wires.addMaskedTidToHeader(NOT_COMPLETE | length); for (; ; ) { if (bytes.compareAndSwapInt(pos, 0, value)) { @@ -516,7 +516,7 @@ public void updateHeader(final long position, final boolean metaData) throws Str long pos = bytes.writePosition(); int actualLength = Maths.toUInt31(pos - position - 4); - int expectedHeader = Wires.addMaskedPidToHeader(NOT_COMPLETE | UNKNOWN_LENGTH); + int expectedHeader = Wires.addMaskedTidToHeader(NOT_COMPLETE | UNKNOWN_LENGTH); int header = actualLength; if (metaData) header |= META_DATA; if (header == UNKNOWN_LENGTH) diff --git a/src/main/java/net/openhft/chronicle/wire/Wires.java b/src/main/java/net/openhft/chronicle/wire/Wires.java index 343f98bc2d..90bf3a6ce1 100755 --- a/src/main/java/net/openhft/chronicle/wire/Wires.java +++ b/src/main/java/net/openhft/chronicle/wire/Wires.java @@ -16,6 +16,7 @@ package net.openhft.chronicle.wire; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.bytes.Bytes; import net.openhft.chronicle.bytes.BytesStore; import net.openhft.chronicle.bytes.VanillaBytes; @@ -64,9 +65,9 @@ public enum Wires { public static final int META_DATA = 1 << 30; public static final int UNKNOWN_LENGTH = 0x0; public static final int MAX_LENGTH = (1 << 30) - 1; - private static final boolean ENCODE_PID_IN_HEADER = Boolean.getBoolean("wire.encodePidInHeader"); - private static final int PID_MASK = 0b00111111_11111111_11111111_11111111; - private static final int INVERSE_PID_MASK = ~PID_MASK; + private static final boolean ENCODE_TID_IN_HEADER = Boolean.getBoolean("wire.encodeTidInHeader"); + private static final int TID_MASK = 0b00111111_11111111_11111111_11111111; + private static final int INVERSE_TID_MASK = ~TID_MASK; // value to use when the message is not ready and of an unknown length public static final int NOT_COMPLETE_UNKNOWN_LENGTH = NOT_COMPLETE | UNKNOWN_LENGTH; @@ -189,8 +190,8 @@ public static StringBuilder acquireStringBuilder() { } public static int lengthOf(int len) { - if (isNotComplete(len) && ENCODE_PID_IN_HEADER) { - return Wires.removeMaskedPidFromHeader(len) & LENGTH_MASK; + if (isNotComplete(len) && ENCODE_TID_IN_HEADER) { + return Wires.removeMaskedTidFromHeader(len) & LENGTH_MASK; } final int len0 = len & LENGTH_MASK; // if (len0 > 1 << 20) @@ -391,16 +392,16 @@ public static void reset(@NotNull Object o) { wm.reset(o); } - public static int addMaskedPidToHeader(final int header) { - return ENCODE_PID_IN_HEADER ? header | (PID_MASK & OS.getProcessId()) : header; + public static int addMaskedTidToHeader(final int header) { + return ENCODE_TID_IN_HEADER ? header | (TID_MASK & Affinity.getThreadId()) : header; } - public static int removeMaskedPidFromHeader(final int header) { - return header & INVERSE_PID_MASK; + public static int removeMaskedTidFromHeader(final int header) { + return header & INVERSE_TID_MASK; } - public static int extractPidFromHeader(final int header) { - return header & PID_MASK; + public static int extractTidFromHeader(final int header) { + return header & TID_MASK; } static final ClassLocal> MARSHALLABLE_FUNCTION = ClassLocal.withInitial(tClass -> { diff --git a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java index 747353c6c2..fce69802a2 100644 --- a/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java +++ b/src/test/java/net/openhft/chronicle/wire/monitoring/StoreWritingProcessInHeaderTest.java @@ -1,8 +1,8 @@ package net.openhft.chronicle.wire.monitoring; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.bytes.Bytes; import net.openhft.chronicle.bytes.NativeBytes; -import net.openhft.chronicle.core.OS; import net.openhft.chronicle.wire.Wire; import net.openhft.chronicle.wire.WireType; import net.openhft.chronicle.wire.Wires; @@ -42,13 +42,13 @@ public static Object[][] parameters() { @Test public void shouldEncodePid() { - final int pid = OS.getProcessId(); - final int headerWithPid = Wires.addMaskedPidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH); + final int tid = Affinity.getThreadId(); + final int headerWithTid = Wires.addMaskedTidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH); - assertThat(Wires.isNotComplete(headerWithPid), is(true)); - assertThat(headerWithPid, is(not(Wires.NOT_COMPLETE_UNKNOWN_LENGTH))); - assertThat(Wires.extractPidFromHeader(headerWithPid), is(pid)); - assertThat(Wires.removeMaskedPidFromHeader(headerWithPid), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH)); + assertThat(Wires.isNotComplete(headerWithTid), is(true)); + assertThat(headerWithTid, is(not(Wires.NOT_COMPLETE_UNKNOWN_LENGTH))); + assertThat(Wires.extractTidFromHeader(headerWithTid), is(tid)); + assertThat(Wires.removeMaskedTidFromHeader(headerWithTid), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH)); } @Test @@ -56,9 +56,9 @@ public void shouldStoreWritingProcessIdInHeader() throws TimeoutException, EOFEx final long position = wire.writeHeaderOfUnknownLength(1, TimeUnit.SECONDS, null, null); final int header = wire.bytes().readVolatileInt(position); assertThat(Wires.isNotComplete(header), is(true)); - assertThat(header, is(Wires.addMaskedPidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH))); - assertThat(Wires.removeMaskedPidFromHeader(header), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH)); - assertThat(Wires.extractPidFromHeader(header), is(OS.getProcessId())); + assertThat(header, is(Wires.addMaskedTidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH))); + assertThat(Wires.removeMaskedTidFromHeader(header), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH)); + assertThat(Wires.extractTidFromHeader(header), is(Affinity.getThreadId())); } @Test @@ -71,9 +71,9 @@ public void shouldWorkWithMetaDataEntries() throws TimeoutException, EOFExceptio wire.bytes().writeInt(position, header | Wires.META_DATA); final int updatedHeader = wire.bytes().readVolatileInt(position); assertThat(Wires.isNotComplete(updatedHeader), is(true)); - assertThat(updatedHeader, is(Wires.addMaskedPidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH | Wires.META_DATA))); - assertThat(Wires.removeMaskedPidFromHeader(updatedHeader), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH | Wires.META_DATA)); - assertThat(Wires.extractPidFromHeader(updatedHeader), is(OS.getProcessId())); + assertThat(updatedHeader, is(Wires.addMaskedTidToHeader(Wires.NOT_COMPLETE_UNKNOWN_LENGTH | Wires.META_DATA))); + assertThat(Wires.removeMaskedTidFromHeader(updatedHeader), is(Wires.NOT_COMPLETE_UNKNOWN_LENGTH | Wires.META_DATA)); + assertThat(Wires.extractTidFromHeader(updatedHeader), is(Affinity.getThreadId())); assertThat(Wires.isNotComplete(updatedHeader), is(true)); } @@ -84,12 +84,12 @@ public void tearDown() { @BeforeClass public static void enableFeature() { - System.setProperty("wire.encodePidInHeader", Boolean.TRUE.toString()); + System.setProperty("wire.encodeTidInHeader", Boolean.TRUE.toString()); } @AfterClass public static void disableFeature() { - System.setProperty("wire.encodePidInHeader", Boolean.FALSE.toString()); + System.setProperty("wire.encodeTidInHeader", Boolean.FALSE.toString()); } private static Object[][] toParams(final WireType[] values) { From 7fdb0130284040e853466ea8a5ebea5492dcaab5 Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 09:33:58 +0000 Subject: [PATCH 17/20] [maven-release-plugin] prepare release chronicle-wire-1.10.13 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 89c9c17d0a..9c96454781 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.13-SNAPSHOT + 1.10.13 OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - master + chronicle-wire-1.10.13 From d6bc94a132dba7bda4833417a4f1e3f2e0b057e5 Mon Sep 17 00:00:00 2001 From: teamcity_hft Date: Tue, 23 Jan 2018 09:34:06 +0000 Subject: [PATCH 18/20] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9c96454781..2bb7c5f241 100755 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 chronicle-wire - 1.10.13 + 1.10.14-SNAPSHOT OpenHFT/Chronicle-Wire Chronicle-Wire bundle @@ -227,7 +227,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git scm:git:git@github.com:OpenHFT/Chronicle-Wire.git - chronicle-wire-1.10.13 + master From 4bfa5e24f503ec947cdc736796b295b449bbe21f Mon Sep 17 00:00:00 2001 From: epickrram Date: Tue, 23 Jan 2018 15:00:12 +0000 Subject: [PATCH 19/20] Improve debug message when method-id is not found. Fixes #62 --- .../wire/VanillaMethodReaderBuilder.java | 5 ++- .../chronicle/wire/VanillaWireParser.java | 2 +- .../chronicle/wire/VanillaWireParserTest.java | 35 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/test/java/net/openhft/chronicle/wire/VanillaWireParserTest.java diff --git a/src/main/java/net/openhft/chronicle/wire/VanillaMethodReaderBuilder.java b/src/main/java/net/openhft/chronicle/wire/VanillaMethodReaderBuilder.java index b482f9d26b..d8924acd36 100755 --- a/src/main/java/net/openhft/chronicle/wire/VanillaMethodReaderBuilder.java +++ b/src/main/java/net/openhft/chronicle/wire/VanillaMethodReaderBuilder.java @@ -35,7 +35,10 @@ else if (VanillaMethodReader.LOGGER.isDebugEnabled()) @NotNull private static String errorMsg(CharSequence s, MessageHistory history, long sourceIndex) { - return "Unknown method-name='" + s + "' from " + history.lastSourceId() + " at " + Long.toHexString(sourceIndex) + " ~ " + (int) sourceIndex; + + final String identifierType = s.length() != 0 && Character.isDigit(s.charAt(0)) ? "@MethodId" : "method-name"; + return "Unknown " + identifierType + "='" + s + "' from " + history.lastSourceId() + " at " + + Long.toHexString(sourceIndex) + " ~ " + (int) sourceIndex; } public boolean ignoreDefaults() { diff --git a/src/main/java/net/openhft/chronicle/wire/VanillaWireParser.java b/src/main/java/net/openhft/chronicle/wire/VanillaWireParser.java index 50bf3f5188..b41e51515c 100644 --- a/src/main/java/net/openhft/chronicle/wire/VanillaWireParser.java +++ b/src/main/java/net/openhft/chronicle/wire/VanillaWireParser.java @@ -69,7 +69,7 @@ public void parseOne(@NotNull WireIn wireIn, O out) { lastParslet = parslet; } - private int parseInt(CharSequence sb) { + private static int parseInt(CharSequence sb) { int acc = 0; for (int i = 0; i < sb.length(); ++i) { char ch = sb.charAt(i); diff --git a/src/test/java/net/openhft/chronicle/wire/VanillaWireParserTest.java b/src/test/java/net/openhft/chronicle/wire/VanillaWireParserTest.java new file mode 100644 index 0000000000..e080b25bc7 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/wire/VanillaWireParserTest.java @@ -0,0 +1,35 @@ +package net.openhft.chronicle.wire; + +import net.openhft.chronicle.bytes.Bytes; +import net.openhft.chronicle.bytes.MethodId; +import net.openhft.chronicle.bytes.MethodReader; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class VanillaWireParserTest { + + @Test + public void shouldDetermineMethodNamesFromMethodIds() { + final BinaryWire wire = new BinaryWire(Bytes.allocateElasticDirect()); + final Speaker speaker = + wire.methodWriterBuilder(Speaker.class).useMethodIds(true).build(); + speaker.say("hello"); + + final MethodReader reader = new VanillaMethodReaderBuilder(wire).build(impl()); + assertTrue(reader.readOne()); + } + + interface Speaker { + @MethodId(7) + void say(final String message); + } + + interface Listener { + void hear(final String message); + } + + private static Listener impl() { + return m -> {}; + } +} \ No newline at end of file From e10c2be13d26513c6731b918b83edd02ef90969a Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 24 Jan 2018 16:43:08 +0000 Subject: [PATCH 20/20] corrected typo --- src/main/java/net/openhft/chronicle/wire/AbstractWire.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/openhft/chronicle/wire/AbstractWire.java b/src/main/java/net/openhft/chronicle/wire/AbstractWire.java index 0bdfb530ee..39f8f14aee 100755 --- a/src/main/java/net/openhft/chronicle/wire/AbstractWire.java +++ b/src/main/java/net/openhft/chronicle/wire/AbstractWire.java @@ -334,7 +334,7 @@ public long writeHeaderOfUnknownLength(final int safeLength, final long timeout, * this would be done much in the same way that we store the index, containing both the cycle and seq number ), * or to put it another way, this LongValue will store the end of the lastPosition in the same place that the index stores it’s cycle number. *

- * When ever we store the lastPostion, we should also store the seqAndLastPosition. + * When ever we store the lastPosition, we should also store the seqAndLastPosition. *

* so to get the the lastPosition and the sequence number of the approximate end of the queue, first we read the lastPosition, * then we read the seqAndLastPosition, if the last bits of the lastPosition, match the higher bits of seqAndLastPosition