diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 4755690efe..53f30f3330 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -34,7 +34,7 @@ net.openhft third-party-bom - 3.26.0 + 3.27ea0-SNAPSHOT pom import @@ -42,7 +42,7 @@ net.openhft chronicle-bom - 2.26ea-SNAPSHOT + 2.27ea-SNAPSHOT pom import diff --git a/pom.xml b/pom.xml index c6a52f0078..8e43fbabba 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ net.openhft java-parent-pom - 1.26.0 + 1.27ea0-SNAPSHOT chronicle-map - 3.26ea5-SNAPSHOT + 3.27ea0-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map bundle @@ -28,7 +28,7 @@ net.openhft third-party-bom - 3.26.0 + 3.27ea0-SNAPSHOT pom import @@ -36,7 +36,7 @@ net.openhft chronicle-bom - 2.26ea-SNAPSHOT + 2.27ea-SNAPSHOT pom import diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 3478860874..4d6c40fe51 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -54,6 +54,7 @@ import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.util.HashMap; @@ -401,7 +402,9 @@ private static ByteBuffer writeHeader(@NotNull final FileChannel fileChan headerBuffer.putInt(SIZE_WORD_OFFSET, NOT_COMPLETE | DATA | headerSize); // Write the size-prefixed blob to the file - headerBuffer.position(0); + @SuppressWarnings("UnnecessaryLocalVariable") + Buffer bufferForBackwardCompatibility = headerBuffer; + bufferForBackwardCompatibility.position(0); headerBuffer.limit(headerLimit); writeFully(fileChannel, 0, headerBuffer); diff --git a/src/test/java/net/openhft/chronicle/map/channel/MapHandlerTest.java b/src/test/java/net/openhft/chronicle/map/channel/MapHandlerTest.java deleted file mode 100644 index 3b6ff71953..0000000000 --- a/src/test/java/net/openhft/chronicle/map/channel/MapHandlerTest.java +++ /dev/null @@ -1,226 +0,0 @@ -package net.openhft.chronicle.map.channel; - -import net.openhft.chronicle.bytes.Bytes; -import net.openhft.chronicle.bytes.MethodReader; -import net.openhft.chronicle.core.io.Closeable; -import net.openhft.chronicle.core.io.IORuntimeException; -import net.openhft.chronicle.hash.serialization.impl.BytesSizedMarshaller; -import net.openhft.chronicle.hash.serialization.impl.MarshallableReaderWriter; -import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.wire.DocumentContext; -import net.openhft.chronicle.wire.SelfDescribingMarshallable; -import net.openhft.chronicle.wire.Wire; -import net.openhft.chronicle.wire.Wires; -import net.openhft.chronicle.wire.channel.*; -import net.openhft.chronicle.wire.utils.*; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; - -import static org.junit.Assert.*; - -@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) -public class MapHandlerTest { - @Test - public void passThroughMapFF() throws IOException { - doPassThroughMap(false, false); - } - - @Test - public void passThroughMapFT() throws IOException { - doPassThroughMap(false, true); - } - - @Test - @Ignore(/*TODO FIX*/) - public void passThroughMapTF() throws IOException { - doPassThroughMap(true, false); - } - - @Test - @Ignore(/*TODO FIX*/) - public void passThroughMapTT() throws IOException { - doPassThroughMap(true, true); - } - - public void doPassThroughMap(boolean serverBuffered, boolean clientBuffered) throws IOException { - String ns = "passThroughMap"; - - PassMapService mapService = new PassMapService(); - MapHandler mapHandler = MapHandler.createMapHandler(ns, mapService); - - try (ChronicleContext cc = ChronicleContext.newContext("tcp://:65301").buffered(serverBuffered); - ChronicleMap, DTO> map = createMap(cc, ns); - ChronicleChannel channel = cc.newChannelSupplier(mapHandler).buffered(clientBuffered).get()) { - assertNotNull(map); - cc.toFile(ns + ".cm3").deleteOnExit(); - final PassMapServiceIn serviceIn = channel.methodWriter(PassMapServiceIn.class); - - final Bytes one = Bytes.from("one"); - final Bytes two = Bytes.from("two"); - final Bytes three = Bytes.from("three"); - final Bytes four = Bytes.from("four"); - serviceIn.put(one, new DTO("1")); - serviceIn.put(two, new DTO("22")); - serviceIn.put(three, new DTO("333")); - serviceIn.get(one); - serviceIn.get(two); - serviceIn.get(three); - serviceIn.get(four); - serviceIn.remove(three); - serviceIn.remove(four); - serviceIn.get(two); - serviceIn.get(three); - serviceIn.goodbye(); - - Wire wire = Wire.newYamlWireOnHeap(); - Reply reply2 = wire.methodWriter(Reply.class); - MethodReader reader = channel.methodReader(reply2); - for (int i = 0; i < 12; i++) { - if (!reader.readOne()) - i--; - } - try { - try (DocumentContext dc = channel.readingDocument()) { - if (dc.isPresent()) { - fail(Wires.fromSizePrefixedBlobs(dc)); - } - } - } catch (IORuntimeException expected) { - } - //noinspection YAMLDuplicatedKeys - assertEquals("" + - "status: true\n" + - "...\n" + - "status: true\n" + - "...\n" + - "status: true\n" + - "...\n" + - "reply: {\n" + - " text: \"1\"\n" + - "}\n" + - "...\n" + - "reply: {\n" + - " text: \"22\"\n" + - "}\n" + - "...\n" + - "reply: {\n" + - " text: \"333\"\n" + - "}\n" + - "...\n" + - "reply: !!null \"\"\n" + - "...\n" + - "status: true\n" + - "...\n" + - "status: false\n" + - "...\n" + - "reply: {\n" + - " text: \"22\"\n" + - "}\n" + - "...\n" + - "reply: !!null \"\"\n" + - "...\n" + - "goodbye: \"\"\n" + - "...\n", - wire.toString()); - } - } - - @Test - public void passThroughServiceYaml() throws IOException { - String ns = "passThroughServiceYaml"; - new File(ns + ".cm3").deleteOnExit(); - try (PassMapService mapService = new PassMapService(); - ChronicleMap, DTO> map = createMap(null, ns)) { - mapService.map(map); - final YamlTester yamlTester = YamlTester.runTest(out -> { - mapService.reply(out); - return mapService; - }, Reply.class, "pass-through"); - assertEquals(yamlTester.expected(), yamlTester.actual()); - } - } - - private ChronicleMap, DTO> createMap(ChronicleContext context, String namespace) throws IOException { - final MarshallableReaderWriter valueMarshaller = new MarshallableReaderWriter<>(DTO.class); - final File file = context == null ? new File(namespace + ".cm3") : context.toFile(namespace + ".cm3"); - final Class> keyClass = (Class) Bytes.class; - return ChronicleMap.of(keyClass, DTO.class) - .averageKeySize(128) - .averageValueSize(1 << 10) - .entries(128 << 10) - .sparseFile(true) - .keyMarshaller(new BytesSizedMarshaller()) - .valueMarshaller(valueMarshaller) - .createPersistedTo(file); - } - - interface PassMapServiceIn extends Closeable { - void put(Bytes key, DTO value); - - void get(Bytes key); - - void remove(Bytes key); - - void goodbye(); - } - - interface Reply { - void status(boolean ok); - - void reply(DTO t); - - void goodbye(); - } - - static class DTO extends SelfDescribingMarshallable { - String text; - - public DTO(String text) { - this.text = text; - } - } - - static class PassMapService extends AbstractMapService implements PassMapServiceIn { - - private transient DTO dataValue; - - @Override - public void put(Bytes key, DTO value) { - map.put(key, value); - reply.status(true); - } - - @Override - public void get(Bytes key) { - reply.reply(map.getUsing(key, dataValue())); - } - - private DTO dataValue() { - return dataValue == null ? dataValue = new DTO(null) : dataValue; - } - - @Override - public void remove(Bytes key) { - reply.status(map.remove(key, dataValue())); - } - - @Override - public Class valueClass() { - return DTO.class; - } - - @Override - public Class replyClass() { - return Reply.class; - } - - @Override - public void goodbye() { - reply.goodbye(); - close(); - } - } -} diff --git a/src/test/resources/pass-through/in.yaml b/src/test/resources/pass-through/in.yaml deleted file mode 100644 index 2d5bf93cf3..0000000000 --- a/src/test/resources/pass-through/in.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# put 1 ---- -put: [ one, { text: "1" } ] -... -# put 2 ---- -put: [ two, { text: "22" } ] -... -# put 3 ---- -put: [ three, { text: "333" } ] -... -# get one ok ---- -get: one -... -# get two ok ---- -get: two -... -# get three ok ---- -get: three -... -# get four missing ---- -get: four -... -# remove 3 ok ---- -remove: three -... -# remove 4 missing ---- -remove: four -... -# get 2 ok ---- -get: two -... -# get 3 removed ---- -get: three -... -# graceful disconnect ---- -goodbye: "" -... diff --git a/src/test/resources/pass-through/out.yaml b/src/test/resources/pass-through/out.yaml deleted file mode 100644 index 0ae2cb3da3..0000000000 --- a/src/test/resources/pass-through/out.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# put 1 ---- -status: true -... -# put 2 ---- -status: true -... -# put 3 ---- -status: true -... -# get one ok ---- -reply: { - text: "1" -} -... -# get two ok ---- -reply: { - text: "22" -} -... -# get three ok ---- -reply: { - text: "333" -} -... -# get four missing ---- -reply: !!null "" -... -# remove 3 ok ---- -status: true -... -# remove 4 missing ---- -status: false -... -# get 2 ok ---- -reply: { - text: "22" -} -... -# get 3 removed ---- -reply: !!null "" -... -# graceful disconnect ---- -goodbye: "" -...