From 0c70fb48dc44c5c9b7243bc4c1386899b6b200ec Mon Sep 17 00:00:00 2001 From: Team City Date: Tue, 23 Dec 2014 22:58:51 +0000 Subject: [PATCH 01/10] [maven-release-plugin] prepare release chronicle-map-2.0.17b --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6c17abe1d..83dfeaec0 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.17b-SNAPSHOT + 2.0.17b OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.17b From fcd2c3275ad3f46f4bd4a57b87e12242a0c835b9 Mon Sep 17 00:00:00 2001 From: Team City Date: Tue, 23 Dec 2014 22:58:55 +0000 Subject: [PATCH 02/10] [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 83dfeaec0..596d48d4c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.17b + 2.0.18b-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.17b + master From ea6478bf6001c34b2f7651d00107360f48862f50 Mon Sep 17 00:00:00 2001 From: Team City Date: Tue, 23 Dec 2014 23:17:46 +0000 Subject: [PATCH 03/10] [maven-release-plugin] prepare release chronicle-map-2.0.18b --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 596d48d4c..671d63e6e 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.18b-SNAPSHOT + 2.0.18b OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.18b From 75fdf4337c09d93b0b9915e346f81eb43ea886c6 Mon Sep 17 00:00:00 2001 From: Team City Date: Tue, 23 Dec 2014 23:17:50 +0000 Subject: [PATCH 04/10] [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 671d63e6e..c8f55ba00 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.18b + 2.0.19b-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.18b + master From a135171370ac29e9d31d38ee2b522fc1fd49b8b3 Mon Sep 17 00:00:00 2001 From: Team City Date: Tue, 23 Dec 2014 23:26:01 +0000 Subject: [PATCH 05/10] [maven-release-plugin] prepare release chronicle-map-2.0.19b --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c8f55ba00..3f4e4dfba 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.19b-SNAPSHOT + 2.0.19b OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.19b From 1d2524340810d9bb2594cd95a144f1ee9dc09571 Mon Sep 17 00:00:00 2001 From: Team City Date: Tue, 23 Dec 2014 23:26:06 +0000 Subject: [PATCH 06/10] [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 3f4e4dfba..a39c38221 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.19b + 2.0.20b-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.19b + master From a77e0c0146e50e9e8ae06ae4183d5149b873882f Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 24 Dec 2014 00:00:29 +0000 Subject: [PATCH 07/10] totally externalized the Json serialization into external static methods so that they done get picked up if the XStream jar is not loaded --- .../map/ChroncileMapJsonSerializer.java | 68 +++++++++++++++++++ .../chronicle/map/VanillaChronicleMap.java | 40 ++--------- .../convertors/ByteBufferConverter.java | 19 +++++- .../convertors/ChronicleMapConverter.java | 17 +++++ .../convertors/DataValueConverter.java | 17 +++++ 5 files changed, 126 insertions(+), 35 deletions(-) create mode 100644 src/main/java/net/openhft/chronicle/map/ChroncileMapJsonSerializer.java diff --git a/src/main/java/net/openhft/chronicle/map/ChroncileMapJsonSerializer.java b/src/main/java/net/openhft/chronicle/map/ChroncileMapJsonSerializer.java new file mode 100644 index 000000000..04cd4e486 --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/ChroncileMapJsonSerializer.java @@ -0,0 +1,68 @@ +/* + * 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; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; +import net.openhft.xstreem.convertors.ByteBufferConverter; +import net.openhft.xstreem.convertors.ChronicleMapConverter; +import net.openhft.xstreem.convertors.DataValueConverter; + +import java.io.*; +import java.util.Map; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +/** + * @author Rob Austin. + */ +class JsonSerializer { + + static synchronized void getAll(File toFile, Map map) throws IOException { + final XStream xstream = new XStream(new JettisonMappedXmlDriver()); + xstream.setMode(XStream.NO_REFERENCES); + xstream.alias("cmap", VanillaChronicleMap.EntrySet.class); + + xstream.registerConverter(new ChronicleMapConverter(map)); + xstream.registerConverter(new ByteBufferConverter()); + xstream.registerConverter(new DataValueConverter()); + OutputStream outputStream = new FileOutputStream(toFile); + if (toFile.getName().toLowerCase().endsWith(".gz")) + outputStream = new GZIPOutputStream(outputStream); + try (OutputStream out = outputStream) { + xstream.toXML(map.entrySet(), out); + } + } + + + static synchronized void putAll(File fromFile, Map map) throws IOException { + final XStream xstream = new XStream(new JettisonMappedXmlDriver()); + xstream.setMode(XStream.NO_REFERENCES); + xstream.alias("cmap", VanillaChronicleMap.EntrySet.class); + xstream.registerConverter(new ChronicleMapConverter(map)); + xstream.registerConverter(new ByteBufferConverter()); + xstream.registerConverter(new DataValueConverter()); + + InputStream inputStream = new FileInputStream(fromFile); + if (fromFile.getName().toLowerCase().endsWith(".gz")) + inputStream = new GZIPInputStream(inputStream); + try (InputStream out = inputStream) { + xstream.fromXML(out); + } + } +} diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 8b7bd8f48..c63512eca 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -18,8 +18,6 @@ package net.openhft.chronicle.map; -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import net.openhft.chronicle.hash.ChronicleHashErrorListener; import net.openhft.chronicle.hash.hashing.Hasher; import net.openhft.chronicle.hash.serialization.BytesInterop; @@ -36,22 +34,20 @@ import net.openhft.lang.model.DataValueClasses; import net.openhft.lang.threadlocal.Provider; import net.openhft.lang.threadlocal.StatefulCopyable; import net.openhft.lang.threadlocal.ThreadLocalCopies; -import net.openhft.xstreem.convertors.ByteBufferConverter; -import net.openhft.xstreem.convertors.ChronicleMapConverter; -import net.openhft.xstreem.convertors.DataValueConverter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; import java.lang.reflect.Array; import java.nio.channels.FileChannel; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; import static java.lang.Long.numberOfTrailingZeros; import static java.lang.Math.max; @@ -667,36 +663,12 @@ class VanillaChronicleMap, @Override public synchronized void getAll(File toFile) throws IOException { - final XStream xstream = new XStream(new JettisonMappedXmlDriver()); - xstream.setMode(XStream.NO_REFERENCES); - xstream.alias("cmap", VanillaChronicleMap.EntrySet.class); - - xstream.registerConverter(new ChronicleMapConverter(this)); - xstream.registerConverter(new ByteBufferConverter()); - xstream.registerConverter(new DataValueConverter()); - OutputStream outputStream = new FileOutputStream(toFile); - if (toFile.getName().toLowerCase().endsWith(".gz")) - outputStream = new GZIPOutputStream(outputStream); - try (OutputStream out = outputStream) { - xstream.toXML(entrySet(), out); - } + JsonSerializer.getAll(toFile, this); } @Override public synchronized void putAll(File fromFile) throws IOException { - final XStream xstream = new XStream(new JettisonMappedXmlDriver()); - xstream.setMode(XStream.NO_REFERENCES); - xstream.alias("cmap", VanillaChronicleMap.EntrySet.class); - xstream.registerConverter(new ChronicleMapConverter(this)); - xstream.registerConverter(new ByteBufferConverter()); - xstream.registerConverter(new DataValueConverter()); - - InputStream inputStream = new FileInputStream(fromFile); - if (fromFile.getName().toLowerCase().endsWith(".gz")) - inputStream = new GZIPInputStream(inputStream); - try (InputStream out = inputStream) { - xstream.fromXML(out); - } + JsonSerializer.putAll(fromFile, this); } @Override diff --git a/src/main/java/net/openhft/xstreem/convertors/ByteBufferConverter.java b/src/main/java/net/openhft/xstreem/convertors/ByteBufferConverter.java index 8b76a66d0..c003cde8f 100644 --- a/src/main/java/net/openhft/xstreem/convertors/ByteBufferConverter.java +++ b/src/main/java/net/openhft/xstreem/convertors/ByteBufferConverter.java @@ -1,3 +1,20 @@ +/* + * 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.xstreem.convertors; import com.thoughtworks.xstream.converters.ConversionException; @@ -12,7 +29,7 @@ import java.nio.CharBuffer; import java.nio.charset.*; /** - * Created by Rob on 22/12/14. + * Created by Rob Austin */ public class ByteBufferConverter implements Converter { diff --git a/src/main/java/net/openhft/xstreem/convertors/ChronicleMapConverter.java b/src/main/java/net/openhft/xstreem/convertors/ChronicleMapConverter.java index 8b0d44b61..8c7bff28b 100644 --- a/src/main/java/net/openhft/xstreem/convertors/ChronicleMapConverter.java +++ b/src/main/java/net/openhft/xstreem/convertors/ChronicleMapConverter.java @@ -1,3 +1,20 @@ +/* + * 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.xstreem.convertors; import com.thoughtworks.xstream.converters.ConversionException; diff --git a/src/main/java/net/openhft/xstreem/convertors/DataValueConverter.java b/src/main/java/net/openhft/xstreem/convertors/DataValueConverter.java index 4f71ceecc..8525c462a 100644 --- a/src/main/java/net/openhft/xstreem/convertors/DataValueConverter.java +++ b/src/main/java/net/openhft/xstreem/convertors/DataValueConverter.java @@ -1,3 +1,20 @@ +/* + * 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.xstreem.convertors; import com.thoughtworks.xstream.converters.ConversionException; From c0584613b5ebf2c6fa2e6f6ac7719aed7139a382 Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 24 Dec 2014 00:06:42 +0000 Subject: [PATCH 08/10] [maven-release-plugin] prepare release chronicle-map-2.0.20b --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a39c38221..c089ed2c6 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.20b-SNAPSHOT + 2.0.20b OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.20b From 0fb631ccb431a695e95bf500be5bd404010d5d7f Mon Sep 17 00:00:00 2001 From: Team City Date: Wed, 24 Dec 2014 00:06:46 +0000 Subject: [PATCH 09/10] [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 c089ed2c6..906178988 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.20b + 2.0.21b-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map @@ -192,7 +192,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.20b + master From 8894206ab45751913d477de5c9a0c408976b10bb Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Wed, 24 Dec 2014 00:11:45 +0000 Subject: [PATCH 10/10] removed System.out --- src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index e11d95d03..bae848266 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -313,8 +313,6 @@ public class CHMUseCasesTest { try (ChronicleMap map = newInstance(builder)) { map.put("Key", expected); - char[] actual = map.get("Key"); - System.out.println(actual); assertEquals(Chars.asList(expected), Chars.asList(map.get("Key"))); mapChecks(); }