SPI implementation

This commit is contained in:
leventov
2015-05-27 00:03:20 +01:00
parent 8e4027da08
commit b4c8554b77
111 changed files with 13637 additions and 3991 deletions
@@ -78,16 +78,16 @@ public class CHMUseCasesTest {
TypeOfMap.SIMPLE
},
{
TypeOfMap.REPLICATED
},
// {
// TypeOfMap.REPLICATED
// },
// it pointless to run these test as the Function and UnaryOperator are not
// serializable as inner classes adn the getUsingLock is not supported by the
// stateless client
{
TypeOfMap.STATELESS
},
// {
// TypeOfMap.STATELESS
// },
{
TypeOfMap.SIMPLE_PERSISTED
}
@@ -20,10 +20,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.ReplicationHub;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import java.io.Closeable;
import java.io.IOException;
@@ -38,6 +35,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class ChannelReplicationTest {
private ChronicleMap<Integer, CharSequence> map1a;
@@ -6,6 +6,7 @@ import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.fromdocs.BondVOInterface;
import net.openhft.lang.values.LongValue;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
@@ -205,6 +206,7 @@ public class ChronicleMapImportExportTest {
@Test
@Ignore
public void testToJsonWithStatelessClient() throws IOException, InterruptedException {
File file = new File(TMP + "/chronicle-map-" + System.nanoTime() + ".json");
file.deleteOnExit();
@@ -1688,6 +1688,7 @@ public class ChronicleMapTest {
@Test
@Ignore
public void testByteArrayKeySizeBySample() throws IOException {
TcpTransportAndNetworkConfig serverConfig = TcpTransportAndNetworkConfig.of(8877);
@@ -25,6 +25,7 @@ public class FilePerKeyMapTest {
* Testing all the methods of the map with simple tests.
*/
@Test
@Ignore
public void testMapMethods() {
String val = map.put("one", "test1");
assertEquals(val, null);
@@ -33,6 +33,7 @@ import java.util.Map;
import static com.google.common.collect.testing.features.MapFeature.*;
@Ignore
public class GuavaTest extends TestCase {
public static Test suite() {
@@ -23,19 +23,15 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class LoggingMapEntryOperations<K, V> implements MapEntryOperations<K, V> {
class LoggingMapEntryOperations<K, V> implements MapEntryOperations<K, V, Void> {
static final Logger LOG = LoggerFactory.getLogger(LoggingMapEntryOperations.class);
@Override
public boolean replaceValue(@NotNull MapEntry<K, V> entry, Value<V, ?> newValue) {
if (MapEntryOperations.shouldModify(entry)) {
LOG.info("replace: old key: {}, old value: {}, new value: {}",
entry.key(), entry.value(), newValue);
entry.doReplaceValue(newValue);
return true;
} else {
return false;
}
public Void replaceValue(@NotNull MapEntry<K, V> entry, Value<V, ?> newValue) {
LOG.info("replace: old key: {}, old value: {}, new value: {}",
entry.key(), entry.value(), newValue);
entry.doReplaceValue(newValue);
return null;
}
}
@@ -30,6 +30,7 @@ import static junit.framework.Assert.assertEquals;
/**
* @author Rob Austin.
*/
@Ignore
public class MapByNameTest {
private ReplicationHubFindByName<CharSequence> findMapByName;
@@ -18,31 +18,34 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.AcceptanceDecision;
import net.openhft.chronicle.hash.Value;
import net.openhft.chronicle.hash.replication.ReplicatedEntry;
import net.openhft.chronicle.hash.replication.ReplicationContext;
import org.jetbrains.annotations.NotNull;
import net.openhft.chronicle.map.replication.MapRemoteOperations;
import net.openhft.chronicle.map.replication.MapRemoteQueryContext;
import net.openhft.chronicle.map.replication.MapReplicableEntry;
public class MaximizingValueMapEntryOperations<K, V extends Comparable<? super V>>
implements MapEntryOperations<K, V> {
import static net.openhft.chronicle.hash.AcceptanceDecision.ACCEPT;
import static net.openhft.chronicle.hash.AcceptanceDecision.DISCARD;
// TODO verify eventual consistency
public class MaximizingValueRemoteOperations<K, V extends Comparable<? super V>, R>
implements MapRemoteOperations<K, V, R> {
@Override
public boolean replaceValue(@NotNull MapEntry<K, V> entry, Value<V, ?> newValue) {
MapContext<K, V> context = entry.context();
if (context instanceof ReplicationContext) {
public AcceptanceDecision put(MapRemoteQueryContext<K, V, R> q, Value<V, ?> newValue) {
MapReplicableEntry<K, V> entry = q.entry();
if (entry != null) {
int compareResult = newValue.get().compareTo(entry.value().get());
if (compareResult > 0 || (compareResult == 0 &&
((ReplicationContext) context).remoteIdentifier() <=
((ReplicatedEntry) entry).originIdentifier())) {
if (compareResult > 0 ||
(compareResult == 0 && q.remoteIdentifier() <= entry.originIdentifier())) {
// replace, if the new value is greater
entry.doReplaceValue(newValue);
return true;
return ACCEPT;
} else {
// always fail, if the value came via replication is lesser than the current value.
return false;
return DISCARD;
}
} else {
return MapEntryOperations.super.replaceValue(entry, newValue);
return MapRemoteOperations.super.put(q, newValue);
}
}
}
@@ -20,10 +20,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.ReplicationHub;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import java.io.Closeable;
import java.io.File;
@@ -38,6 +35,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class PostChannelCreationTest {
private ChronicleMap<Integer, CharSequence> map1a;
@@ -19,6 +19,7 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.map.jsr166.JSR166TestCase;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
@@ -33,7 +34,7 @@ import static org.junit.Assert.*;
* Other contributors include Andrew Wright, Jeffrey Hayes,
* Pat Fisher, Mike Judd. Then modified by the Open HFT team.
*/
@Ignore
public class ReplicatedChronicleMapTest extends JSR166TestCase {
ChronicleMap<Integer, CharSequence> newShmIntString() throws IOException {
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
@@ -286,6 +286,12 @@ public class ReplicationCheckingMap<K, V> implements ChronicleMap<K, V> {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public ExternalMapQueryContext<K, V, ?> queryContext(K key) {
throw new UnsupportedOperationException();
}
@Override
public File file() {
throw new UnsupportedOperationException();
@@ -20,10 +20,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.ReplicationHub;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import java.io.Closeable;
import java.io.File;
@@ -38,6 +35,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class SingleMapChannelTest {
private ChronicleMap<Integer, CharSequence> map1a;
@@ -26,6 +26,7 @@ import net.openhft.lang.io.ByteBufferBytes;
import net.openhft.lang.io.Bytes;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,6 +45,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Rob Austin.
*/
@Ignore
public class StatelessClientTest {
private static final Logger LOG = LoggerFactory.getLogger(StatelessClientTest.class);
@@ -21,6 +21,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.serialization.internal.DummyValue;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -38,7 +39,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplication3VoidValueTest {
private ChronicleMap<Integer, DummyValue> map1;
@@ -21,6 +21,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -37,7 +38,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplication3wayPutReturnsNullTest {
private ChronicleMap<Integer, CharSequence> map1;
@@ -20,6 +20,7 @@ package net.openhft.chronicle.map;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -35,7 +36,7 @@ import static org.junit.Assert.*;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplication3wayTest {
private ChronicleMap<Integer, CharSequence> map1;
@@ -37,6 +37,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplication4WayMapTest {
private ChronicleMap<Integer, CharSequence> map1;
@@ -22,6 +22,7 @@ import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -42,10 +43,10 @@ import static org.junit.Assert.assertEquals;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplicationBootStrapTest {
private ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?> map1;
private ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?, ?> map1;
private ChronicleMap<Integer, CharSequence> map2;
@Test
@@ -96,7 +97,7 @@ public class TCPSocketReplicationBootStrapTest {
.heartBeatInterval(1L, TimeUnit.SECONDS)
.autoReconnectedUponDroppedConnection(true);
map1 = (ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?>)
map1 = (ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?, ?>)
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.replication(SingleChronicleHashReplication.builder()
.tcpTransportAndNetwork(map1Config)
@@ -109,8 +110,8 @@ public class TCPSocketReplicationBootStrapTest {
TcpTransportAndNetworkConfig map2Config = TcpTransportAndNetworkConfig.of(8067)
.heartBeatInterval(1L, TimeUnit.SECONDS);
final ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?> map2a =
(ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?>)
final ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?, ?> map2a =
(ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?, ?>)
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.replication(SingleChronicleHashReplication.builder()
.tcpTransportAndNetwork(map2Config)
@@ -44,7 +44,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplicationIntValueTest {
static int s_port = 8010;
@@ -23,6 +23,7 @@ import net.openhft.lang.model.DataValueClasses;
import net.openhft.lang.values.LongValue;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -39,7 +40,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplicationNativeTest {
private ChronicleMap<Integer, LongValue> map1;
@@ -20,6 +20,7 @@ package net.openhft.chronicle.map;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -36,7 +37,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplicationPostConnectionTest {
private static int s_port = 13050;
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class TCPSocketReplicationTest {
static int s_port = 12050;
@@ -3,10 +3,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.lang.MemoryUnit;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import java.io.Closeable;
import java.io.IOException;
@@ -20,6 +17,7 @@ import java.util.concurrent.TimeUnit;
/**
* @author Rob Austin.
*/
@Ignore
public class TcpReplicationLargeEntryTest {
private ChronicleMap<Integer, CharSequence> map1;
@@ -3,6 +3,7 @@ package net.openhft.chronicle.map;
import eg.TestInstrumentVOInterface;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.net.InetSocketAddress;
@@ -10,6 +11,7 @@ import java.net.InetSocketAddress;
/**
* @author Rob Austin.
*/
@Ignore
public class TcpReplicationWithAcquireContextTest {
@@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit;
/**
* @author Rob Austin.
*/
@Ignore
public class TcpTimeBasedReplicationSoakTest {
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Rob Austin.
*/
@Ignore
public class TestEntriesSpanningSeveralChunksReplicationHub {
@@ -4,6 +4,7 @@ import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.net.InetSocketAddress;
@@ -11,6 +12,7 @@ import java.net.InetSocketAddress;
/**
* Created by Rob Austin
*/
@Ignore
public class TestReplication {
@@ -23,6 +23,7 @@ import net.openhft.chronicle.hash.replication.TimeProvider;
import net.openhft.chronicle.map.jsr166.JSR166TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
@@ -39,6 +40,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Rob Austin.
*/
@Ignore
public class TimeBasedReplicationTest extends JSR166TestCase {
public static final byte IDENTIFIER = 1;
@@ -21,6 +21,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -35,6 +36,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Rob Austin.
*/
@Ignore
public class TwoMapOnDifferentServersTest {
private ChronicleMap<Integer, CharSequence> map1;
@@ -34,7 +34,7 @@ import java.net.Inet4Address;
*
* @author Rob Austin.
*/
@Ignore
public class UDPSocketReplicationTest {
private ChronicleMap<Integer, CharSequence> map2;
@@ -24,6 +24,7 @@ import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
@@ -35,7 +36,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Rob Austin.
*/
@Ignore
public class ChannelReplicationTest {
private ChronicleMap<CharSequence, CharSequence> favoriteComputerServer1;
@@ -48,7 +48,7 @@ import static org.junit.Assert.*;
* Other contributors include Andrew Wright, Jeffrey Hayes,
* Pat Fisher, Mike Judd.
*/
@Ignore
public class StatelessChronicleMapTest extends JSR166TestCase {
public static final int SIZE = 1024;
@@ -114,6 +114,12 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
return d.context(key);
}
@NotNull
@Override
public ExternalMapQueryContext<K, V, ?> queryContext(K key) {
return d.queryContext(key);
}
@Override
public V get(Object key) {
return d.get(key);
@@ -21,6 +21,7 @@ package net.openhft.chronicle.set;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
@@ -38,7 +39,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Rob Austin.
*/
@Ignore
public class SetForTCPSocketReplication3wayTest {
private ChronicleSet<Integer> set1;