From e9523152079d0165261dc65fca13648946642617 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:19:37 +0100 Subject: [PATCH 01/13] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 768c406d7..6615be83a 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,16 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C * [Identifier](https://github.com/OpenHFT/Chronicle-Map#identifier) * [Port](https://github.com/OpenHFT/Chronicle-Map#port) * [Heart Beat Interval](https://github.com/OpenHFT/Chronicle-Map#heart-beat-interval) - * [Clustering](https://github.com/OpenHFT/Chronicle-Map#cluster) +* [Clustering](https://github.com/OpenHFT/Chronicle-Map#cluster) + +#### Miscellaneous + * [Known Issues](https://github.com/OpenHFT/Chronicle-Map#known-issues) * [Stackoverflow](http://stackoverflow.com/tags/chronicle/info) * [Development Tasks - JIRA] (https://higherfrequencytrading.atlassian.net/browse/HCOLL) * [Use Case Which include Chronicle Map] (http://openhft.net/products/chronicle-engine/) - + * [JavaDoc] (http://openhft.github.io/Chronicle-Map/apidocs/) + * #### Examples * [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map#example--replicating-data-between-process-on-different-servers) From 431b667e3f20a92c6bdfb16ca07d12d301ccb6b5 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:19:51 +0100 Subject: [PATCH 02/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6615be83a..e475f208b 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C * [Development Tasks - JIRA] (https://higherfrequencytrading.atlassian.net/browse/HCOLL) * [Use Case Which include Chronicle Map] (http://openhft.net/products/chronicle-engine/) * [JavaDoc] (http://openhft.github.io/Chronicle-Map/apidocs/) - * + #### Examples * [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map#example--replicating-data-between-process-on-different-servers) From 1adcc3a631a291b18018dfa519450c76f403ac30 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:20:29 +0100 Subject: [PATCH 03/13] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e475f208b..5e1bb2bba 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C * [Stackoverflow](http://stackoverflow.com/tags/chronicle/info) * [Development Tasks - JIRA] (https://higherfrequencytrading.atlassian.net/browse/HCOLL) * [Use Case Which include Chronicle Map] (http://openhft.net/products/chronicle-engine/) - * [JavaDoc] (http://openhft.github.io/Chronicle-Map/apidocs/) #### Examples From c8f9c31dbdd9ed45812be7ce7ba1c3ae9fcedb2c Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:37:24 +0100 Subject: [PATCH 04/13] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 5e1bb2bba..b94458266 100644 --- a/README.md +++ b/README.md @@ -596,6 +596,45 @@ will run out of space between 1 and 2 million entries. You should set the .entries(..) and .entrySize(..) to those you require. +# Example :Simple Hello World + +This simple chronicle map, works just like ConcurrentHashMap but stores its data off-heap. If you want to use Chronicle Map to share data between java process you should look at the next exampl + +``` java +Map map = ChronicleMapBuilder.of(Integer.class, + CharSequence.class).create(); + +map.put(1, "hello world"); +System.out.println(map.get(1)); + +``` + +# Example : Sharing the map on two ( or more ) processes on the same machine + +Lets assume that we had two server, lets call them server1 and server2, if we wished to share a map +between them, this is how we could set it up + +``` java + +// --- RUN ON ONE JAVA PROCESS ( BUT ON THE SAME SERVER ) +{ + File file = new File("a-new-file-on-your-sever"); + Map map1 = ChronicleMapBuilder.of(Integer.class, + CharSequence.class).create(file); // this has to be the same file as used by map 2 + map1.put(1, "hello world"); +} + +// --- RUN ON THE OTHER JAVA PROCESS ( BUT ON THE SAME SERVER ) +{ + File file = new File("a-new-file-on-your-sever"); // this has to be the same file as used by map 1 + Map map1 = ChronicleMapBuilder.of(Integer.class, + CharSequence.class).create(file); + + System.out.println(map1.get(1)); +} +``` + + # Example : Replicating data between process on different servers via TCP Lets assume that we had two server, lets call them server1 and server2, if we wished to share a map From 52e28e8b4f9f9e06b263c0f3f370da9d06668080 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:40:44 +0100 Subject: [PATCH 05/13] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b94458266..34e0455ab 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,9 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C * [Use Case Which include Chronicle Map] (http://openhft.net/products/chronicle-engine/) #### Examples - -* [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map#example--replicating-data-between-process-on-different-servers) +*[Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) +*[Sharing the map on two ( or more ) processes on the same machine](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) +* [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-via-tcp) * [Replicating data between process on different servers with UDP] (https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-using-udp) From c36b34de8bdd56b46c448c837bcefd8e6d31cdd6 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:41:24 +0100 Subject: [PATCH 06/13] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 34e0455ab..cd2b7cbbe 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,11 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C * [Use Case Which include Chronicle Map] (http://openhft.net/products/chronicle-engine/) #### Examples -*[Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) -*[Sharing the map on two ( or more ) processes on the same machine](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) -* [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-via-tcp) -* [Replicating data between process on different servers with UDP] (https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-using-udp) + + *[Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) + *[Sharing the map on two ( or more ) processes on the same machine](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) + * [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-via-tcp) + * [Replicating data between process on different servers with UDP] (https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-using-udp) #### Performance Topics From 19e77cf792259b74a37ffe4e5c87a2d13685feb3 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:42:25 +0100 Subject: [PATCH 07/13] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd2b7cbbe..b40b7d37b 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C #### Examples - *[Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) - *[Sharing the map on two ( or more ) processes on the same machine](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) + * [Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) + * [Sharing the map on two ( or more ) processes on the same machine](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) * [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-via-tcp) * [Replicating data between process on different servers with UDP] (https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-using-udp) From 2392de1a8a83522b02e59680f3af6a143c6f805c Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:44:40 +0100 Subject: [PATCH 08/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b40b7d37b..33aa6d0ad 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C #### Examples * [Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) - * [Sharing the map on two ( or more ) processes on the same machine](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) + * [Sharing the map between two ( or more ) processes on the same computer](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) * [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-via-tcp) * [Replicating data between process on different servers with UDP] (https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-using-udp) From 7ab9cd4547e7e0e911c67dc54a9a9a2816caa9ee Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:45:46 +0100 Subject: [PATCH 09/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33aa6d0ad..a05482378 100644 --- a/README.md +++ b/README.md @@ -661,7 +661,7 @@ Map map2; map1 = map1Builder.create(); } -// ---------- SERVER2 2 on the same server as ---------- +// ---------- SERVER2 on the same server as ---------- { TcpReplicationConfig tcpConfig = TcpReplicationConfig.of(8077) From a54c873589ccec2a9772f807b1ae7ec33e8c2311 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:48:18 +0100 Subject: [PATCH 10/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a05482378..84d984127 100644 --- a/README.md +++ b/README.md @@ -598,7 +598,7 @@ will run out of space between 1 and 2 million entries. You should set the .entries(..) and .entrySize(..) to those you require. -# Example :Simple Hello World +# Example : Simple Hello World This simple chronicle map, works just like ConcurrentHashMap but stores its data off-heap. If you want to use Chronicle Map to share data between java process you should look at the next exampl From fe62f1bbb111b1fc647ea0df8958c9957e8619a1 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:48:47 +0100 Subject: [PATCH 11/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84d984127..76ee1a7aa 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C #### Examples - * [Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example-simple-hello-world) + * [Hello World - A map which stores data off heap](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--simple-hello-world) * [Sharing the map between two ( or more ) processes on the same computer](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--sharing-the-map-on-two--or-more--processes-on-the-same-machine) * [Replicating data between process on different servers with TCP/IP Replication](https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-via-tcp) * [Replicating data between process on different servers with UDP] (https://github.com/OpenHFT/Chronicle-Map/blob/master/README.md#example--replicating-data-between-process-on-different-servers-using-udp) From 593f0fe7b809ba4287f0c1fda2fd6516d1c24c13 Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 7 Oct 2014 20:07:04 +0400 Subject: [PATCH 12/13] Deleted unused DirectBytesBuffer class --- .../map/serialization/DirectBytesBuffer.java | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/main/java/net/openhft/chronicle/map/serialization/DirectBytesBuffer.java diff --git a/src/main/java/net/openhft/chronicle/map/serialization/DirectBytesBuffer.java b/src/main/java/net/openhft/chronicle/map/serialization/DirectBytesBuffer.java deleted file mode 100644 index 1f454a62b..000000000 --- a/src/main/java/net/openhft/chronicle/map/serialization/DirectBytesBuffer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.openhft.chronicle.map.serialization; - -import net.openhft.lang.io.Bytes; -import net.openhft.lang.io.DirectBytes; -import net.openhft.lang.io.DirectStore; -import net.openhft.lang.io.serialization.JDKObjectSerializer; -import net.openhft.chronicle.map.threadlocal.StatefulCopyable; - -final class DirectBytesBuffer implements StatefulCopyable { - - private final Object identity; - private DirectBytes buffer; - - DirectBytesBuffer(Object identity) { - this.identity = identity; - } - - private Bytes buffer(long maxSize) { - DirectBytes buf; - if ((buf = buffer) != null) { - if (maxSize <= buf.capacity()) { - return buf.clear(); - } else { - DirectStore store = (DirectStore) buf.store(); - store.resize(maxSize, false); - return buffer = store.bytes(); - } - } else { - return buffer = new DirectStore(JDKObjectSerializer.INSTANCE, maxSize, false).bytes(); - } - } - - @Override - public Object stateIdentity() { - return identity; - } - - @Override - public DirectBytesBuffer copy() { - return new DirectBytesBuffer(identity); - } -} From 4913062481bbb8b4a14149259bd7d32be2ee36b3 Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 7 Oct 2014 20:10:27 +0400 Subject: [PATCH 13/13] HCOLL-161 eliminated inconsistency between VanillaChronicleMap and DirectBytesBuffer serializers --- .../java/net/openhft/chronicle/map/ChronicleMapBuilder.java | 3 ++- .../java/net/openhft/chronicle/map/VanillaChronicleMap.java | 2 +- .../java/net/openhft/chronicle/map/TestBooleanValues.java | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index b7aa0831b..cf20ec795 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -823,7 +823,8 @@ public class ChronicleMapBuilder implements Cloneable { public ChronicleMap create() throws IOException { VanillaChronicleMap map = newMap(); - BytesStore bytesStore = new DirectStore(objectSerializer(), map.sizeInBytes(), true); + BytesStore bytesStore = new DirectStore(JDKObjectSerializer.INSTANCE, + map.sizeInBytes(), true); map.createMappedStoreAndSegments(bytesStore); return establishReplication(map); } diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 13f445976..8718a0d38 100644 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -200,7 +200,7 @@ class VanillaChronicleMap, long createMappedStoreAndSegments(File file) throws IOException { return createMappedStoreAndSegments(new MappedStore(file, FileChannel.MapMode.READ_WRITE, - sizeInBytes(), objectSerializer)); + sizeInBytes(), JDKObjectSerializer.INSTANCE)); } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { diff --git a/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java b/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java index b6d33e2ed..7306e153f 100644 --- a/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java +++ b/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java @@ -11,13 +11,13 @@ import java.io.IOException; */ public class TestBooleanValues { - @Test - @Ignore /** * see issue http://stackoverflow.com/questions/26219313/strange-npe-from-chronicle-map-toy-code */ + @Test public void testTestBooleanValues() throws IOException, InterruptedException { - ChronicleMap map = ChronicleMapBuilder.of(Integer.class, Boolean.class).create(); + ChronicleMap map = + ChronicleMapBuilder.of(Integer.class, Boolean.class).create(); map.put(7, true); Boolean currentValue = map.get(7); // IllegalStateException here }