From 0e9dbaf5d8f59b98361f18c7642eb82cd9e18389 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 13 Jan 2015 18:49:43 +0000 Subject: [PATCH 01/13] HCOLL-293 now reading the version from the resource file "map.version" --- pom.xml | 24 +++++++++++++++++-- .../openhft/chronicle/map/BuildVersion.java | 24 +++++++++++++++---- src/main/resources/map.version | 1 + 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/map.version diff --git a/pom.xml b/pom.xml index cc7f90f96..f1ddf6934 100644 --- a/pom.xml +++ b/pom.xml @@ -17,13 +17,15 @@ ~ limitations under the License. --> - + net.openhft java-parent-pom 1.1.2 - + 4.0.0 @@ -141,6 +143,24 @@ + + + + src/main/resources + true + + **/map.version + + + + src/main/resources + false + + **/map.version + + + + diff --git a/src/main/java/net/openhft/chronicle/map/BuildVersion.java b/src/main/java/net/openhft/chronicle/map/BuildVersion.java index f1539d072..1912296a7 100644 --- a/src/main/java/net/openhft/chronicle/map/BuildVersion.java +++ b/src/main/java/net/openhft/chronicle/map/BuildVersion.java @@ -21,16 +21,14 @@ package net.openhft.chronicle.map; import shaded.org.apache.maven.model.Model; import shaded.org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import java.io.File; -import java.io.FileReader; -import java.io.Reader; +import java.io.*; /** * gets the version of the current build */ class BuildVersion { - private static String version = null; + private static String version = null; /** * @return version of ChronicleMap being used, or NULL if its not known @@ -41,7 +39,23 @@ class BuildVersion { return version; } - // the best way to get the version is to read it from the manifest + try { + // the best way to get the version is to read the map.version file + InputStream resource = BuildVersion.class.getClassLoader().getResourceAsStream("map" + + ".version"); + BufferedReader in = new BufferedReader(new InputStreamReader(resource)); + + version = in.readLine().trim(); + if (!"${project.version}".equals(version())) + return version; + + return version; + } catch (Exception e) { + // do nothing + } + + + // another way to get the version is to read it from the manifest final String versionFromManifest = getVersionFromManifest(); if (versionFromManifest != null) { diff --git a/src/main/resources/map.version b/src/main/resources/map.version new file mode 100644 index 000000000..f2ab45c3b --- /dev/null +++ b/src/main/resources/map.version @@ -0,0 +1 @@ +${project.version} \ No newline at end of file From a779e9d21ea643fc61d6fc8e0f4da76832dfc3f9 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 13 Jan 2015 18:54:30 +0000 Subject: [PATCH 02/13] added - @Ignore("causing issues on windows") --- src/test/java/net/openhft/chronicle/map/MapByNameTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/net/openhft/chronicle/map/MapByNameTest.java b/src/test/java/net/openhft/chronicle/map/MapByNameTest.java index 6ac2e3b72..44924b1c1 100644 --- a/src/test/java/net/openhft/chronicle/map/MapByNameTest.java +++ b/src/test/java/net/openhft/chronicle/map/MapByNameTest.java @@ -87,6 +87,7 @@ public class MapByNameTest { ChronicleMap myMap2 = mapByName.from("myMap"); } + @Ignore("causing issues on windows") @Test public void testReplicationHubSerialization() throws IOException, InterruptedException, TimeoutException { From efeab000793dcfca2ab71cac1c5bda246ff79e6a Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 14 Jan 2015 10:52:41 +0000 Subject: [PATCH 03/13] HCOLL-294 reduced object creation in the TcpReplication Selector --- .../java/net/openhft/chronicle/map/TcpReplicator.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index 9a3eebdfe..7d1f5aa84 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -273,14 +273,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo * @throws IOException */ private int select() throws IOException { - - // spin loop 100000 times - for (int i = 0; i < SPIN_LOOP_COUNT; i++) { - final int keys = selector.selectNow(); - if (keys != 0) - return keys; - } - return selector.select(selectorTimeout); } From f285ab2756760fdc81868c4396e444aaa9ed19fa Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 14 Jan 2015 11:29:37 +0000 Subject: [PATCH 04/13] HCOLL-294 changed back to a spin loop but this time only for 10ms --- .../openhft/chronicle/map/TcpReplicator.java | 20 ++++++++++++++----- .../chronicle/map/TcpReplicationSoakTest.java | 1 - 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index 7d1f5aa84..db4bc6c30 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -70,7 +70,8 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo private static final byte NOT_SET = (byte) HEARTBEAT.ordinal(); private static final Logger LOG = LoggerFactory.getLogger(TcpReplicator.class.getName()); private static final int BUFFER_SIZE = 0x100000; // 1MB - private static final int SPIN_LOOP_COUNT = 100000; + private static final int SPIN_LOOP_COUNT = 10; + public static final int SPIN_LOOP_TIME_IN_MILLIS = 100; private final SelectionKey[] selectionKeysStore = new SelectionKey[Byte.MAX_VALUE + 1]; // used to instruct the selector thread to set OP_WRITE on a key correlated by the bit index // in the bitset @@ -269,10 +270,19 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo /** * spin loops 100000 times first before calling the selector with timeout * - * @return + * @return The number of keys, possibly zero, whose ready-operation sets were updated * @throws IOException */ private int select() throws IOException { + + long start = System.currentTimeMillis(); + + while (System.currentTimeMillis() < start + SPIN_LOOP_TIME_IN_MILLIS) { + final int keys = selector.selectNow(); + if (keys != 0) + return keys; + } + return selector.select(selectorTimeout); } @@ -1624,7 +1634,7 @@ class StatelessServerConnector { final Function function = (Function) reader.readObject(); try { Object result = map.getMapped(key, function); - writeObject(writer,result); + writeObject(writer, result); } catch (Throwable e) { LOG.info("", e); return sendException(writer, sizeLocation, e); @@ -1641,7 +1651,7 @@ class StatelessServerConnector { final UnaryOperator unaryOperator = (UnaryOperator) reader.readObject(); try { Object result = map.putMapped(key, unaryOperator); - writeObject(writer,result); + writeObject(writer, result); } catch (Throwable e) { LOG.info("", e); return sendException(writer, sizeLocation, e); @@ -1748,7 +1758,7 @@ class StatelessServerConnector { final long remaining = writer.in().remaining(); try { String result = map.persistedDataVersion(); - writeObject(writer,result); + writeObject(writer, result); } catch (Throwable e) { return sendException(writer, sizeLocation, e); } diff --git a/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java b/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java index 7b1aaee1e..13a4bbf25 100644 --- a/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java +++ b/src/test/java/net/openhft/chronicle/map/TcpReplicationSoakTest.java @@ -96,7 +96,6 @@ public class TcpReplicationSoakTest { } - @Ignore @Test public void testSoakTestWithRandomData() throws IOException, InterruptedException { try { From b681f93a49e6830b3e7144474d6329056ab93245 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 14 Jan 2015 11:38:53 +0000 Subject: [PATCH 05/13] HCOLL-294 changed to SPIN_LOOP_TIME_IN_MILLIS = 10; --- src/main/java/net/openhft/chronicle/map/TcpReplicator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index db4bc6c30..4dc238c45 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -70,8 +70,8 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo private static final byte NOT_SET = (byte) HEARTBEAT.ordinal(); private static final Logger LOG = LoggerFactory.getLogger(TcpReplicator.class.getName()); private static final int BUFFER_SIZE = 0x100000; // 1MB - private static final int SPIN_LOOP_COUNT = 10; - public static final int SPIN_LOOP_TIME_IN_MILLIS = 100; + + public static final int SPIN_LOOP_TIME_IN_MILLIS = 10; private final SelectionKey[] selectionKeysStore = new SelectionKey[Byte.MAX_VALUE + 1]; // used to instruct the selector thread to set OP_WRITE on a key correlated by the bit index // in the bitset From f9b412303c0895cd59eafea5e159247d8b4b1518 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 14 Jan 2015 13:26:48 +0000 Subject: [PATCH 06/13] HCOLL-294 changed back to SPIN_LOOP_TIME_IN_NONOSECONDS --- src/main/java/net/openhft/chronicle/map/TcpReplicator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index 4dc238c45..bc3d29419 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -39,6 +39,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.*; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import static java.nio.channels.SelectionKey.*; @@ -71,7 +72,7 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo private static final Logger LOG = LoggerFactory.getLogger(TcpReplicator.class.getName()); private static final int BUFFER_SIZE = 0x100000; // 1MB - public static final int SPIN_LOOP_TIME_IN_MILLIS = 10; + public static final long SPIN_LOOP_TIME_IN_NONOSECONDS = TimeUnit.MICROSECONDS.toNanos(500); private final SelectionKey[] selectionKeysStore = new SelectionKey[Byte.MAX_VALUE + 1]; // used to instruct the selector thread to set OP_WRITE on a key correlated by the bit index // in the bitset @@ -275,9 +276,9 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo */ private int select() throws IOException { - long start = System.currentTimeMillis(); + long start = System.nanoTime(); - while (System.currentTimeMillis() < start + SPIN_LOOP_TIME_IN_MILLIS) { + while (System.nanoTime() < start + SPIN_LOOP_TIME_IN_NONOSECONDS) { final int keys = selector.selectNow(); if (keys != 0) return keys; From bd85053ed816f98ad28c79899187bd6940eccfe6 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 14 Jan 2015 13:35:22 +0000 Subject: [PATCH 07/13] HCOLL-294 updated to net.openhft lang 6.4.22 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f1ddf6934..30bc57bd3 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ net.openhft lang - 6.4.22-SNAPSHOT + 6.4.22 From 1f63ec37ee314a389365b7261f93c05bac6add8e Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 14 Jan 2015 13:47:12 +0000 Subject: [PATCH 08/13] [maven-release-plugin] prepare release chronicle-map-2.0.22rc3 --- pom.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 30bc57bd3..d77a2c6f2 100644 --- a/pom.xml +++ b/pom.xml @@ -17,20 +17,18 @@ ~ limitations under the License. --> - + net.openhft java-parent-pom 1.1.2 - + 4.0.0 chronicle-map - 2.0.22rc3-SNAPSHOT + 2.0.22rc3 OpenHFT/Chronicle-Map Chronicle-Map @@ -217,7 +215,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git - master + chronicle-map-2.0.22rc3 From 5e9123e08e357f1aa221e3f93ff9644d885a32c2 Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 14 Jan 2015 13:47:17 +0000 Subject: [PATCH 09/13] [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 d77a2c6f2..2c555f8c8 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.22rc3 + 2.0.22rc4-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -215,7 +215,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git - chronicle-map-2.0.22rc3 + master From 6360efddd6c53baa0922003c470193ab21390078 Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 14 Jan 2015 14:03:57 +0000 Subject: [PATCH 10/13] [maven-release-plugin] prepare release chronicle-map-2.0.22rc4 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2c555f8c8..09c1633f1 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.22rc4-SNAPSHOT + 2.0.22rc4 OpenHFT/Chronicle-Map Chronicle-Map @@ -215,7 +215,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git - master + chronicle-map-2.0.22rc4 From 7ccf7a5836299fb31910af6b8cc1359856580227 Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 14 Jan 2015 14:04:01 +0000 Subject: [PATCH 11/13] [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 09c1633f1..80c44f787 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.22rc4 + 2.0.22rc5-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -215,7 +215,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git - chronicle-map-2.0.22rc4 + master From 17f4cae50bb0257a0ba522147b1d97314d3eea25 Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 14 Jan 2015 14:16:30 +0000 Subject: [PATCH 12/13] [maven-release-plugin] prepare release chronicle-map-2.0.22rc5 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 80c44f787..cc81290fc 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.22rc5-SNAPSHOT + 2.0.22rc5 OpenHFT/Chronicle-Map Chronicle-Map @@ -215,7 +215,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git - master + chronicle-map-2.0.22rc5 From fa078b427a7aabf7255afc73816523c619edf7a1 Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 14 Jan 2015 14:16:34 +0000 Subject: [PATCH 13/13] [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 cc81290fc..3ecf14d14 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.22rc5 + 2.0.22rc6-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -215,7 +215,7 @@ scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git scm:git:git@github.com:OpenHFT/Chronicle-Map.git - chronicle-map-2.0.22rc5 + master