diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java index e0cef2c72..c7e3764fd 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java @@ -211,68 +211,6 @@ public interface ChronicleMap extends ConcurrentMap, ChronicleHash { */ R updateForKey(K key, @NotNull Mutator mutator); - /** - * Returns a {@link java.util.concurrent.Future} containing the value to which the specified key - * is mapped, or {@code null} if this map contains no mapping for the key. This method behaves - * the same as {@link java.util.Map#get(java.lang.Object)} yet wraps result in a future a {@link - * java.util.concurrent.Future}. - * - * Calling this method may or may not block until the operating is complete depending on the - * implementation. - * - * @param key the key whose associated value is to be returned in the future - * @return a future containing the value to which the specified key is mapped after this method - * call, or {@code null} if no value is mapped - * @see java.util.Map#get(java.lang.Object) - * @see java.util.concurrent.Future - */ - Future getLater(@NotNull K key); - - /** - * Associates the specified value with the specified key in this map (optional operation). If - * the map previously contained a mapping for the key, the old value is replaced by the - * specified value. (A map m is said to contain a mapping for a key k if and - * only if {@link #containsKey(Object) m.containsKey(k)} would return true.) - * - * Calling this method may or may not block until the operating is complete depending on the - * implementation. - * - * @param key key with which the specified value is to be associated - * @param value value to be associated with the specified key * @return a future containing the - * previous value associated with key, or null if there was no - * mapping for key. (A null return can also indicate that the map - * previously associated null with key, if the implementation - * supports null values.) - * @return a future containing either, the previous value associated with key, or - * null if there was no mapping for key. - * @see java.util.Map#put(java.lang.Object, java.lang.Object) - * @see java.util.concurrent.Future - */ - Future putLater(@NotNull K key, @NotNull V value); - - /** - * Removes the mapping for a key from this map if it is present (optional operation). More - * formally, if this map contains a mapping from key k to value v such that - * (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can - * contain at most one such mapping.) - * - *

Returns a future containing, either the value to which this map previously associated the - * key, or null if the map contained no mapping for the key. - * - * This method behaves the same as {@link java.util.Map#remove(java.lang.Object)} yet wraps - * result in a future a {@link java.util.concurrent.Future}. - * - * Calling this method may or may not block until the operating is complete depending on the - * implementation. - * - * @param key key whose mapping is to be removed from the map - * @return a future containing either, the previous value associated with key, or - * null if there was no mapping for key. - * @see java.util.Map#remove(java.lang.Object) - * @see java.util.concurrent.Future - */ - Future removeLater(@NotNull K key); - /** * exports all the entries to a {@link java.io.File} storing them in JSON format, an attempt is * made where possible to use standard java serialisation and keep the data human readable, data diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index 59e2dbf3a..29fc940f8 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -157,40 +157,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } - @NotNull - @Override - public Future getLater(@NotNull final K key) { - return lazyExecutorService().submit(new Callable() { - @Nullable - @Override - public V call() throws Exception { - return StatelessChronicleMap.this.get(key); - } - }); - } - - @NotNull - @Override - public Future putLater(@NotNull final K key, @NotNull final V value) { - return lazyExecutorService().submit(new Callable() { - @Nullable - @Override - public V call() throws Exception { - return StatelessChronicleMap.this.put(key, value); - } - }); - } - - @Override - public Future removeLater(@NotNull final K key) { - return lazyExecutorService().submit(new Callable() { - @Override - public V call() throws Exception { - return StatelessChronicleMap.this.remove(key); - } - }); - } - @Override public void getAll(File toFile) { throw new UnsupportedOperationException(); diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 2670bec71..d83b83753 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -50,10 +50,7 @@ import java.lang.reflect.Array; import java.nio.ByteOrder; import java.nio.channels.FileChannel; import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import static java.lang.Class.forName; import static java.lang.Long.numberOfTrailingZeros; @@ -569,102 +566,6 @@ class VanillaChronicleMap, } } - @Override - public Future getLater(@NotNull K key) { - final V v = get(key); - return new Future() { - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return true; - } - - @Override - public V get() throws InterruptedException, ExecutionException { - return v; - } - - @Override - public V get(long timeout, @NotNull TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return v; - } - }; - } - - @Override - public Future putLater(@NotNull K key, @NotNull V value) { - final V v = put(key, value); - return new Future() { - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return true; - } - - @Override - public V get() throws InterruptedException, ExecutionException { - return v; - } - - @Override - public V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return v; - } - }; - } - - @Override - public Future removeLater(@NotNull K key) { - final V v = remove(key); - return new Future() { - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return true; - } - - @Override - public V get() throws InterruptedException, ExecutionException { - return v; - } - - @Override - public V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return v; - } - }; - } - @Override public synchronized void getAll(File toFile) throws IOException { diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index 6c98eb444..98eab7796 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -36,7 +36,7 @@ public class CHMUseCasesTest { */ try (ChronicleMap map = ChronicleMapBuilder .of(String.class, String.class) - .checkSerializedValues() // for testng purposes only + .checkSerializedValues() // for testing purposes only .create()) { map.put("Hello", "World"); assertEquals("World", map.get("Hello")); @@ -65,10 +65,6 @@ public class CHMUseCasesTest { // TODO replace with the specific exception. } - assertEquals(null, map.putLater("Bye", "For now").get()); - assertEquals("For now", map.getLater("Bye").get()); - assertEquals("For now", map.removeLater("Bye").get()); - assertEquals(null, map.removeLater("Bye").get()); } } @@ -81,7 +77,7 @@ public class CHMUseCasesTest { public void testCharSequenceCharSequenceMap() throws ExecutionException, InterruptedException { try (ChronicleMap map = ChronicleMapBuilder .of(CharSequence.class, CharSequence.class) - .checkSerializedValues() // for testng purposes only + .checkSerializedValues() // for testing purposes only .create()) { map.put("Hello", "World"); StringBuilder key = new StringBuilder(); @@ -129,10 +125,6 @@ public class CHMUseCasesTest { } })); - assertEquals(null, map.putLater("Bye", "For now").get()); - assertEquals("For now", map.getLater("Bye").get().toString()); - assertEquals("For now", map.removeLater("Bye").get().toString()); - assertEquals(null, map.removeLater("Bye").get()); } } @@ -144,7 +136,7 @@ public class CHMUseCasesTest { public void testStringValueStringValueMap() { try (ChronicleMap map = ChronicleMapBuilder .of(StringValue.class, StringValue.class) - .checkSerializedValues() // for testng purposes only + .checkSerializedValues() // for testing purposes only .create()) { StringValue key1 = DataValueClasses.newDirectInstance(StringValue.class); StringValue key2 = DataValueClasses.newInstance(StringValue.class); @@ -283,10 +275,7 @@ public class CHMUseCasesTest { } catch (Exception todoMoreSpecificException) { } - assertEquals(null, map.putLater(3, 4).get()); - assertEquals((Integer) 4, map.getLater(3).get()); - assertEquals((Integer) 4, map.removeLater(3).get()); - assertEquals(null, map.removeLater(3).get()); + } } @@ -331,10 +320,7 @@ public class CHMUseCasesTest { } catch (Exception todoMoreSpecificException) { } - assertEquals(null, map.putLater(3L, 4L).get()); - assertEquals((Long) 4L, map.getLater(3L).get()); - assertEquals((Long) 4L, map.removeLater(3L).get()); - assertEquals(null, map.removeLater(3L).get()); + } } @@ -379,10 +365,7 @@ public class CHMUseCasesTest { } catch (Exception todoMoreSpecificException) { } - assertEquals(null, map.putLater(3.0, 4.0).get()); - assertEquals((Double) 4.0, map.getLater(3.0).get()); - assertEquals((Double) 4.0, map.removeLater(3.0).get()); - assertEquals(null, map.removeLater(3.0).get()); + } } @@ -430,10 +413,6 @@ public class CHMUseCasesTest { byte[] key3 = {3, 3, 3, 3}; byte[] value3 = {4, 4, 4, 4}; - assertEquals(null, map.putLater(key3, value3).get()); - assertTrue(Arrays.equals(value3, map.getLater(key3).get())); - assertTrue(Arrays.equals(value3, map.removeLater(key3).get())); - assertEquals(null, map.removeLater(key3).get()); } } @@ -521,13 +500,7 @@ public class CHMUseCasesTest { assertBBEquals(bb1, valueA); } - ByteBuffer key3 = ByteBuffer.wrap(new byte[]{3, 3, 3, 3}); - ByteBuffer value3 = ByteBuffer.wrap(new byte[]{4, 4, 4, 4}); - assertEquals(null, map.putLater(key3, value3).get()); - assertBBEquals(value3, map.getLater(key3).get()); - assertBBEquals(value3, map.removeLater(key3).get()); - assertEquals(null, map.removeLater(key3).get()); } } @@ -579,15 +552,6 @@ public class CHMUseCasesTest { assertBBEquals(ByteBuffer.wrap(new byte[]{12, 10, 11, 11}), map.get(key1)); - ByteBuffer key3 = ByteBuffer.wrap(new byte[]{3, 3, 3, 3}); - ByteBuffer value3 = ByteBuffer.allocateDirect(4); - value3.put(new byte[]{4, 4, 4, 4}); - value3.flip(); - - assertEquals(null, map.putLater(key3, value3).get()); - assertBBEquals(value3, map.getLater(key3).get()); - assertBBEquals(value3, map.removeLater(key3).get()); - assertEquals(null, map.removeLater(key3).get()); } } diff --git a/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java b/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java index 10292c16f..e70843d33 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicationCheckingMap.java @@ -26,7 +26,6 @@ import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.Future; /** * @author Rob Austin. @@ -228,21 +227,6 @@ public class ReplicationCheckingMap implements ChronicleMap { return map1.updateForKey(key, mutator); } - @Override - public Future getLater(@NotNull K key) { - throw new UnsupportedOperationException(); - } - - @Override - public Future putLater(@NotNull K key, @NotNull V value) { - throw new UnsupportedOperationException(); - } - - @Override - public Future removeLater(@NotNull K key) { - throw new UnsupportedOperationException(); - } - @Override public void getAll(File toFile) { throw new UnsupportedOperationException(); diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java index 66b664e45..1d4288b61 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java @@ -453,60 +453,7 @@ public class StatelessClientTest { } } - @Test(timeout = 10000) - public void testGetLater() throws IOException, - InterruptedException, ExecutionException { - try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) - .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer - .class, CharSequence.class) - .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - statelessMap.put(1, "some value"); - - assertEquals("some value", statelessMap.getLater(1).get()); - assertEquals(1, statelessMap.size()); - - statelessMap.remove(1); - - assertEquals(null, statelessMap.getLater(1).get()); - assertEquals(0, statelessMap.size()); - } - } - } - - @Test - public void testPutLater() throws IOException, - InterruptedException, ExecutionException { - - try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) - .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer - .class, CharSequence.class) - .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - CharSequence oldValue = statelessMap.putLater(1, "some value").get(); - assertEquals("some value", statelessMap.get(1)); - assertEquals(1, statelessMap.size()); - } - } - } - - @Test(timeout = 10000) - public void testRemoveLater() throws IOException, - InterruptedException, ExecutionException { - - try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) - .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer - .class, CharSequence.class) - .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { - statelessMap.put(1, "some value"); - statelessMap.removeLater(1).get(); - assertEquals(null, statelessMap.get(1)); - assertEquals(0, statelessMap.size()); - } - } - } @Test(timeout = 10000) public void testGetAndEntryWeDontHave() throws IOException, diff --git a/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java index 3aa530b2c..1c487acf1 100755 --- a/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.*; -import java.util.concurrent.Future; import static org.junit.Assert.*; @@ -180,21 +179,6 @@ public class StatelessChronicleMapTest extends JSR166TestCase { return d.updateForKey(key, mutator); } - @Override - public Future getLater(@NotNull K key) { - return d.getLater(key); - } - - @Override - public Future putLater(@NotNull K key, @NotNull V value) { - return d.putLater(key, value); - } - - @Override - public Future removeLater(@NotNull K key) { - return d.removeLater(key); - } - @Override public void getAll(File toFile) throws IOException { d.getAll(toFile);