mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Revert 'Make working with new bytes' and a couple of fixes
This commit is contained in:
@@ -40,7 +40,7 @@ public class BiMapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(MapQueryContext<K, V, DualLockSuccess> q, Data<V, ?> value,
|
||||
public void put(MapQueryContext<K, V, DualLockSuccess> q, Data<V> value,
|
||||
ReturnValue<V> returnValue) {
|
||||
while (true) {
|
||||
q.updateLock().lock();
|
||||
@@ -59,7 +59,7 @@ public class BiMapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putIfAbsent(MapQueryContext<K, V, DualLockSuccess> q, Data<V, ?> value,
|
||||
public void putIfAbsent(MapQueryContext<K, V, DualLockSuccess> q, Data<V> value,
|
||||
ReturnValue<V> returnValue) {
|
||||
while (true) {
|
||||
try {
|
||||
@@ -88,7 +88,7 @@ public class BiMapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(MapQueryContext<K, V, DualLockSuccess> q, Data<V, ?> value) {
|
||||
public boolean remove(MapQueryContext<K, V, DualLockSuccess> q, Data<V> value) {
|
||||
while (true) {
|
||||
q.updateLock().lock();
|
||||
MapEntry<K, V> entry = q.entry();
|
||||
@@ -116,14 +116,14 @@ public class BiMapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(MapQueryContext<K, V, DualLockSuccess> q, Data<V, ?> value,
|
||||
public void replace(MapQueryContext<K, V, DualLockSuccess> q, Data<V> value,
|
||||
ReturnValue<V> returnValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replace(MapQueryContext<K, V, DualLockSuccess> q, Data<V, ?> oldValue,
|
||||
Data<V, ?> newValue) {
|
||||
public boolean replace(MapQueryContext<K, V, DualLockSuccess> q, Data<V> oldValue,
|
||||
Data<V> newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class BiMapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(MapQueryContext<K, V, DualLockSuccess> q, Data<V, ?> value,
|
||||
public void merge(MapQueryContext<K, V, DualLockSuccess> q, Data<V> value,
|
||||
BiFunction<? super V, ? super V, ? extends V> remappingFunction,
|
||||
ReturnValue<V> returnValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -171,13 +171,13 @@ public class BiMapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualLockSuccess replaceValue(@NotNull MapEntry<K, V> entry, Data<V, ?> newValue) {
|
||||
public DualLockSuccess replaceValue(@NotNull MapEntry<K, V> entry, Data<V> newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualLockSuccess insert(@NotNull MapAbsentEntry<K, V> absentEntry,
|
||||
Data<V, ?> value) {
|
||||
Data<V> value) {
|
||||
try (ExternalMapQueryContext<V, K, ?> rq = reverse.queryContext(value)) {
|
||||
if (!rq.updateLock().tryLock())
|
||||
return FAIL;
|
||||
@@ -187,7 +187,7 @@ public class BiMapTest {
|
||||
reverseAbsentEntry.doInsert(absentEntry.absentKey());
|
||||
return SUCCESS;
|
||||
} else {
|
||||
Data<K, ?> reverseKey = rq.entry().value();
|
||||
Data<K> reverseKey = rq.entry().value();
|
||||
if (reverseKey.equals(absentEntry.absentKey())) {
|
||||
// recover
|
||||
absentEntry.doInsert(value);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class GuavaTest extends TestCase {
|
||||
|
||||
@Override
|
||||
public Void replaceValue(@NotNull MapEntry<CharSequence, CharSequence> entry,
|
||||
net.openhft.chronicle.hash.Data<CharSequence, ?> newValue) {
|
||||
net.openhft.chronicle.hash.Data<CharSequence> newValue) {
|
||||
Assert.assertEquals(m, entry.context().map());
|
||||
m.put(entry.key().get().toString(), newValue.get().toString());
|
||||
return MapEntryOperations.super.replaceValue(entry, newValue);
|
||||
@@ -149,7 +149,7 @@ public class GuavaTest extends TestCase {
|
||||
|
||||
@Override
|
||||
public Void insert(@NotNull MapAbsentEntry<CharSequence, CharSequence> absentEntry,
|
||||
Data<CharSequence, ?> value) {
|
||||
Data<CharSequence> value) {
|
||||
Assert.assertEquals(m, absentEntry.context().map());
|
||||
m.put(absentEntry.absentKey().get().toString(), value.get().toString());
|
||||
return MapEntryOperations.super.insert(absentEntry, value);
|
||||
|
||||
@@ -23,13 +23,13 @@ public class ListenersTest {
|
||||
return MapEntryOperations.super.remove(entry);
|
||||
}
|
||||
@Override
|
||||
public Void replaceValue(@NotNull MapEntry<K, V> entry, Data<V, ?> newValue) {
|
||||
public Void replaceValue(@NotNull MapEntry<K, V> entry, Data<V> newValue) {
|
||||
replaceValueCount.incrementAndGet();
|
||||
return MapEntryOperations.super.replaceValue(entry, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void insert(@NotNull MapAbsentEntry<K, V> absentEntry, Data<V, ?> value) {
|
||||
public Void insert(@NotNull MapAbsentEntry<K, V> absentEntry, Data<V> value) {
|
||||
insertCount.incrementAndGet();
|
||||
return MapEntryOperations.super.insert(absentEntry, value);
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class ListenersTest {
|
||||
.mapMethods(new MapMethods<Integer, Integer, Void>() {
|
||||
@Override
|
||||
public void put(MapQueryContext<Integer, Integer, Void> q,
|
||||
net.openhft.chronicle.hash.Data<Integer, ?> value,
|
||||
net.openhft.chronicle.hash.Data<Integer> value,
|
||||
ReturnValue<Integer> returnValue) {
|
||||
if (q.queriedKey().get() == 2) {
|
||||
MapMethods.super.put(q, value, NullReturnValue.get());
|
||||
|
||||
@@ -28,7 +28,7 @@ class LoggingMapEntryOperations<K, V> implements MapEntryOperations<K, V, Void>
|
||||
static final Logger LOG = LoggerFactory.getLogger(LoggingMapEntryOperations.class);
|
||||
|
||||
@Override
|
||||
public Void replaceValue(@NotNull MapEntry<K, V> entry, Data<V, ?> newValue) {
|
||||
public Void replaceValue(@NotNull MapEntry<K, V> entry, Data<V> newValue) {
|
||||
LOG.info("replace: old key: {}, old value: {}, new value: {}",
|
||||
entry.key(), entry.value(), newValue);
|
||||
entry.doReplaceValue(newValue);
|
||||
|
||||
@@ -34,32 +34,21 @@ public class MarkTest {
|
||||
|
||||
@Test(timeout = 25000)
|
||||
public void inMemoryTest() {
|
||||
test(new SerializableFunction<ChronicleMapBuilder<Integer, Integer>, ChronicleMap<Integer, Integer>>() {
|
||||
@Override
|
||||
public ChronicleMap<Integer, Integer> apply(
|
||||
ChronicleMapBuilder<Integer, Integer> builder) {
|
||||
return builder.create();
|
||||
}
|
||||
});
|
||||
test(builder -> builder.create());
|
||||
}
|
||||
|
||||
@Test(timeout = 25000)
|
||||
@Test
|
||||
public void persistedTest() {
|
||||
int rnd = new Random().nextInt();
|
||||
final File db = Paths.get(System.getProperty("java.io.tmpdir"), "mark" + rnd).toFile();
|
||||
if (db.exists())
|
||||
db.delete();
|
||||
try {
|
||||
test(new SerializableFunction<ChronicleMapBuilder<Integer, Integer>,
|
||||
ChronicleMap<Integer, Integer>>() {
|
||||
@Override
|
||||
public ChronicleMap<Integer, Integer> apply(
|
||||
ChronicleMapBuilder<Integer, Integer> builder) {
|
||||
try {
|
||||
return builder.createPersistedTo(db);
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
test(builder -> {
|
||||
try {
|
||||
return builder.createPersistedTo(db);
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
});
|
||||
System.out.println(MemoryUnit.BYTES.toMegabytes(db.length()) + " MB");
|
||||
|
||||
@@ -294,7 +294,7 @@ public class ReplicationCheckingMap<K, V> implements ChronicleMap<K, V> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExternalMapQueryContext<K, V, ?> queryContext(net.openhft.chronicle.hash.Data<K, ?> key) {
|
||||
public ExternalMapQueryContext<K, V, ?> queryContext(net.openhft.chronicle.hash.Data<K> key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,6 @@ import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.chronicle.map.replication.MapRemoteOperations;
|
||||
import net.openhft.chronicle.map.replication.MapRemoteQueryContext;
|
||||
import net.openhft.chronicle.map.replication.MapReplicableEntry;
|
||||
import net.openhft.lang.io.ByteBufferBytes;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.IntValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -18,13 +14,12 @@ import org.junit.Test;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.openhft.lang.MemoryUnit.MEGABYTES;
|
||||
import static net.openhft.chronicle.map.TcpReplicationSoakCrdtTest.GrowOnlySetValuedMapEntryOperations.growOnlySetValuedMapEntryOperations;
|
||||
import static net.openhft.chronicle.map.TcpReplicationSoakCrdtTest.GrowOnlySetValuedMapRemoteOperations.growOnlySetValuedMapRemoteOperations;
|
||||
import static net.openhft.lang.MemoryUnit.MEGABYTES;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TcpReplicationSoakCrdtTest {
|
||||
@@ -63,7 +58,7 @@ public class TcpReplicationSoakCrdtTest {
|
||||
private GrowOnlySetValuedMapRemoteOperations() {}
|
||||
|
||||
@Override
|
||||
public void put(MapRemoteQueryContext<K, Set<E>, Void> q, Data<Set<E>, ?> newValue) {
|
||||
public void put(MapRemoteQueryContext<K, Set<E>, Void> q, Data<Set<E>> newValue) {
|
||||
MapReplicableEntry<K, Set<E>> entry = q.entry();
|
||||
if (entry != null) {
|
||||
Set<E> merged = new HashSet<>(entry.value().get());
|
||||
|
||||
+4
-4
@@ -31,22 +31,22 @@ public class SimpleMapOperationsListeningTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void replaceValue(@NotNull MapEntry<K, V> entry, Data<V, ?> newValue) {
|
||||
public Void replaceValue(@NotNull MapEntry<K, V> entry, Data<V> newValue) {
|
||||
System.out.println("replace " + entry.key() + ": " + entry.value() + " -> " + newValue);
|
||||
entry.doReplaceValue(newValue);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void insert(@NotNull MapAbsentEntry<K, V> absentEntry, Data<V, ?> value) {
|
||||
public Void insert(@NotNull MapAbsentEntry<K, V> absentEntry, Data<V> value) {
|
||||
System.out.println("insert " + absentEntry.absentKey() + " -> " + value);
|
||||
absentEntry.doInsert(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data<V, ?> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
|
||||
Data<V, ?> defaultValue = absentEntry.defaultValue();
|
||||
public Data<V> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
|
||||
Data<V> defaultValue = absentEntry.defaultValue();
|
||||
System.out.println("default " + absentEntry.absentKey() + " -> " + defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExternalMapQueryContext<K, V, ?> queryContext(Data<K, ?> key) {
|
||||
public ExternalMapQueryContext<K, V, ?> queryContext(Data<K> key) {
|
||||
return d.queryContext(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user