mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Standard code formatting
This commit is contained in:
@@ -6,11 +6,7 @@ import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -24,6 +20,10 @@ import static org.junit.Assert.assertThat;
|
||||
|
||||
public class BasicReplicationTest {
|
||||
|
||||
private static byte asByte(final int i) {
|
||||
return (byte) i;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReplicate() throws Exception {
|
||||
final ChronicleMapBuilder<String, String> builder = ChronicleMap.of(String.class, String.class)
|
||||
@@ -54,7 +54,7 @@ public class BasicReplicationTest {
|
||||
executorService.submit(processorTwo::processPendingChangesLoop);
|
||||
executorService.submit(processorThree::processPendingChangesLoop);
|
||||
|
||||
final Map[] maps = new Map[] {mapOne, mapTwo, mapThree};
|
||||
final Map[] maps = new Map[]{mapOne, mapTwo, mapThree};
|
||||
final Random random = new Random(0xBAD5EED);
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
final int mapIndex = random.nextInt(maps.length);
|
||||
@@ -77,7 +77,7 @@ public class BasicReplicationTest {
|
||||
assertThat(mapOne.size(), is(equalTo(mapTwo.size())));
|
||||
assertThat(mapOne.size(), is(equalTo(mapThree.size())));
|
||||
|
||||
for(String key : mapOne.keySet()) {
|
||||
for (String key : mapOne.keySet()) {
|
||||
final String mapOneValue = mapOne.get(key);
|
||||
final String mapTwoValue = mapTwo.get(key);
|
||||
final String mapThreeValue = mapThree.get(key);
|
||||
@@ -102,8 +102,10 @@ public class BasicReplicationTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static byte asByte(final int i) {
|
||||
return (byte) i;
|
||||
private ReplicatedChronicleMap<String, String, Object>
|
||||
createReplicatedMap(final ChronicleMapBuilder<String, String> builder, final byte replicaId) {
|
||||
final ChronicleMap<String, String> map = builder.replication(replicaId).create();
|
||||
return (ReplicatedChronicleMap<String, String, Object>) map;
|
||||
}
|
||||
|
||||
private static final class ReplicationEventProcessor<K, V> {
|
||||
@@ -131,7 +133,7 @@ public class BasicReplicationTest {
|
||||
|
||||
try {
|
||||
|
||||
while(!Thread.currentThread().isInterrupted()) {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
while (queueEmpty.get() && !Thread.currentThread().isInterrupted()) {
|
||||
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(7));
|
||||
}
|
||||
@@ -170,7 +172,7 @@ public class BasicReplicationTest {
|
||||
|
||||
@Override
|
||||
public void onEntry(final ReplicableEntry entry, final int chronicleId) {
|
||||
try {
|
||||
try {
|
||||
buffer.clear();
|
||||
sourceMap.writeExternalEntry(entry, null, buffer, chronicleId);
|
||||
|
||||
@@ -203,10 +205,4 @@ public class BasicReplicationTest {
|
||||
destinationMap.setRemoteNodeCouldBootstrapFrom((byte) chronicleId, bootstrapTime);
|
||||
}
|
||||
}
|
||||
|
||||
private ReplicatedChronicleMap<String, String, Object>
|
||||
createReplicatedMap(final ChronicleMapBuilder<String, String> builder, final byte replicaId) {
|
||||
final ChronicleMap<String, String> map = builder.replication(replicaId).create();
|
||||
return (ReplicatedChronicleMap<String, String, Object>) map;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,101 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BiMapTest {
|
||||
|
||||
|
||||
private static <K, V> void verifyBiMapConsistent(Map<K, V> m1, Map<V, K> m2) {
|
||||
assertEquals(m1.size(), m2.size());
|
||||
for (Entry<K, V> e : m1.entrySet()) {
|
||||
assertEquals(e.getKey(), m2.get(e.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void biMapTest() throws InterruptedException, ExecutionException {
|
||||
BiMapEntryOperations<Integer, CharSequence> biMapOps1 = new BiMapEntryOperations<>();
|
||||
ChronicleMap<Integer, CharSequence> map1 = ChronicleMapBuilder
|
||||
.of(Integer.class, CharSequence.class)
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.averageValueSize(10)
|
||||
.entryOperations(biMapOps1)
|
||||
.mapMethods(new BiMapMethods<>())
|
||||
.create();
|
||||
|
||||
BiMapEntryOperations<CharSequence, Integer> biMapOps2 = new BiMapEntryOperations<>();
|
||||
ChronicleMap<CharSequence, Integer> map2 = ChronicleMapBuilder
|
||||
.of(CharSequence.class, Integer.class)
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.averageKeySize(10)
|
||||
.entryOperations(biMapOps2)
|
||||
.mapMethods(new BiMapMethods<>())
|
||||
.create();
|
||||
|
||||
biMapOps1.setReverse(map2);
|
||||
biMapOps2.setReverse(map1);
|
||||
|
||||
map1.put(1, "1");
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
map2.remove("1");
|
||||
assertTrue(map2.isEmpty());
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
map1.put(3, "4");
|
||||
map2.put("5", 6);
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
try (ExternalMapQueryContext<CharSequence, Integer, ?> q = map2.queryContext("4")) {
|
||||
q.updateLock().lock();
|
||||
q.entry().doRemove();
|
||||
}
|
||||
|
||||
try {
|
||||
map1.remove(3);
|
||||
throw new AssertionError("expected IllegalStateException");
|
||||
} catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
map2.put("4", 6);
|
||||
throw new AssertionError("expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
map2.put("4", 3); // recover
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
map1.clear();
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
ForkJoinPool pool = new ForkJoinPool(8);
|
||||
try {
|
||||
pool.submit(() -> {
|
||||
ThreadLocalRandom.current().ints().limit(10_000).parallel().forEach(i -> {
|
||||
int v = Math.abs(i % 10);
|
||||
if ((i & 1) == 0) {
|
||||
if ((i & 2) == 0) {
|
||||
map1.putIfAbsent(v, "" + v);
|
||||
} else {
|
||||
map1.remove(v, "" + v);
|
||||
}
|
||||
} else {
|
||||
if ((i & 2) == 0) {
|
||||
map2.putIfAbsent("" + v, v);
|
||||
} else {
|
||||
map2.remove("" + v, v);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).get();
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
enum DualLockSuccess {SUCCESS, FAIL}
|
||||
|
||||
static class BiMapMethods<K, V> implements MapMethods<K, V, DualLockSuccess> {
|
||||
@@ -217,98 +311,4 @@ public class BiMapTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void biMapTest() throws InterruptedException, ExecutionException {
|
||||
BiMapEntryOperations<Integer, CharSequence> biMapOps1 = new BiMapEntryOperations<>();
|
||||
ChronicleMap<Integer, CharSequence> map1 = ChronicleMapBuilder
|
||||
.of(Integer.class, CharSequence.class)
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.averageValueSize(10)
|
||||
.entryOperations(biMapOps1)
|
||||
.mapMethods(new BiMapMethods<>())
|
||||
.create();
|
||||
|
||||
BiMapEntryOperations<CharSequence, Integer> biMapOps2 = new BiMapEntryOperations<>();
|
||||
ChronicleMap<CharSequence, Integer> map2 = ChronicleMapBuilder
|
||||
.of(CharSequence.class, Integer.class)
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.averageKeySize(10)
|
||||
.entryOperations(biMapOps2)
|
||||
.mapMethods(new BiMapMethods<>())
|
||||
.create();
|
||||
|
||||
biMapOps1.setReverse(map2);
|
||||
biMapOps2.setReverse(map1);
|
||||
|
||||
map1.put(1, "1");
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
map2.remove("1");
|
||||
assertTrue(map2.isEmpty());
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
map1.put(3, "4");
|
||||
map2.put("5", 6);
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
try (ExternalMapQueryContext<CharSequence, Integer, ?> q = map2.queryContext("4")) {
|
||||
q.updateLock().lock();
|
||||
q.entry().doRemove();
|
||||
}
|
||||
|
||||
try {
|
||||
map1.remove(3);
|
||||
throw new AssertionError("expected IllegalStateException");
|
||||
} catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
map2.put("4", 6);
|
||||
throw new AssertionError("expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
map2.put("4", 3); // recover
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
map1.clear();
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
|
||||
ForkJoinPool pool = new ForkJoinPool(8);
|
||||
try {
|
||||
pool.submit(() -> {
|
||||
ThreadLocalRandom.current().ints().limit(10_000).parallel().forEach(i -> {
|
||||
int v = Math.abs(i % 10);
|
||||
if ((i & 1) == 0) {
|
||||
if ((i & 2) == 0) {
|
||||
map1.putIfAbsent(v, "" + v);
|
||||
} else {
|
||||
map1.remove(v, "" + v);
|
||||
}
|
||||
} else {
|
||||
if ((i & 2) == 0) {
|
||||
map2.putIfAbsent("" + v, v);
|
||||
} else {
|
||||
map2.remove("" + v, v);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).get();
|
||||
verifyBiMapConsistent(map1, map2);
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
private static <K, V> void verifyBiMapConsistent(Map<K, V> m1, Map<V, K> m2) {
|
||||
assertEquals(m1.size(), m2.size());
|
||||
for (Entry<K, V> e : m1.entrySet()) {
|
||||
assertEquals(e.getKey(), m2.get(e.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,5 +44,5 @@ public class BytesMarshallableValueTest {
|
||||
this.x = x;
|
||||
this.foo = foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,26 +237,30 @@ public class CHMTest5 {
|
||||
|
||||
@Group(0)
|
||||
long getEntryLockState();
|
||||
|
||||
void setEntryLockState(long entryLockState);
|
||||
|
||||
@Group(1)
|
||||
int getMaxNumberOfProcessesAllowed();
|
||||
|
||||
void setMaxNumberOfProcessesAllowed(int max);
|
||||
|
||||
boolean compareAndSwapMaxNumberOfProcessesAllowed(int expected, int value);
|
||||
|
||||
@Group(1)
|
||||
@Array(length = 4)
|
||||
void setTimeAt(int index, long time);
|
||||
|
||||
long getTimeAt(int index);
|
||||
|
||||
@Deprecated()
|
||||
default boolean tryLockNanosEntry(long nanos) {
|
||||
return AcquisitionStrategies
|
||||
.<ReadWriteLockingStrategy>spinLoop(nanos, TimeUnit.NANOSECONDS).acquire(
|
||||
TryAcquireOperations.writeLock(),
|
||||
VanillaReadWriteWithWaitsLockingStrategy.instance(),
|
||||
checkedBytesStoreAccess(), ((Byteable) this).bytesStore(),
|
||||
((Byteable) this).offset());
|
||||
TryAcquireOperations.writeLock(),
|
||||
VanillaReadWriteWithWaitsLockingStrategy.instance(),
|
||||
checkedBytesStoreAccess(), ((Byteable) this).bytesStore(),
|
||||
((Byteable) this).offset());
|
||||
}
|
||||
|
||||
@Deprecated()
|
||||
|
||||
@@ -225,7 +225,7 @@ public class CHMUseCasesTest {
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (map1.equals(map2))
|
||||
break;
|
||||
Jvm.pause(1);
|
||||
Jvm.pause(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ public class CHMUseCasesTest {
|
||||
mpx1030.setAskPx(109.7);
|
||||
mpx1030.setBidPx(107.6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1022,7 +1022,7 @@ public class CHMUseCasesTest {
|
||||
|
||||
} catch (Exception todoMoreSpecificException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -157,8 +157,8 @@ public class ChronicleMapImportExportTest {
|
||||
System.out.println(file.getAbsolutePath());
|
||||
ChronicleMapBuilder<CharSequence, CharSequence> builder =
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.averageKeySize("hello".length()).averageValueSize("world".length())
|
||||
.entries(1000);
|
||||
.averageKeySize("hello".length()).averageValueSize("world".length())
|
||||
.entries(1000);
|
||||
try (ChronicleMap<CharSequence, CharSequence> expected = builder
|
||||
.create()) {
|
||||
expected.put("hello", "world");
|
||||
|
||||
@@ -36,8 +36,7 @@ import java.util.concurrent.locks.LockSupport;
|
||||
public class ChronicleMapSanityCheckTest {
|
||||
|
||||
@Test
|
||||
public void testSanity1() throws IOException, InterruptedException
|
||||
{
|
||||
public void testSanity1() throws IOException, InterruptedException {
|
||||
|
||||
String tmp = System.getProperty("java.io.tmpdir");
|
||||
|
||||
@@ -120,7 +119,7 @@ public class ChronicleMapSanityCheckTest {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum DummyValue {
|
||||
DUMMY_VALUE
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -42,7 +41,13 @@ import static org.junit.Assert.*;
|
||||
@SuppressWarnings({"unchecked", "ResultOfMethodCallIgnored"})
|
||||
public class ChronicleMapTest {
|
||||
|
||||
static final LongValue ONE = Values.newHeapInstance(LongValue.class);
|
||||
static long count = 0;
|
||||
|
||||
static {
|
||||
ONE.setValue(1);
|
||||
}
|
||||
|
||||
private StringBuilder sb = new StringBuilder();
|
||||
|
||||
static void assertKeySet(Set<Integer> keySet, int[] expectedKeys) {
|
||||
@@ -107,6 +112,20 @@ public class ChronicleMapTest {
|
||||
return file;
|
||||
}
|
||||
|
||||
private static void printStatus() {
|
||||
if (!new File("/proc/self/status").exists()) return;
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader("/proc/self/status"));
|
||||
for (String line; (line = br.readLine()) != null; )
|
||||
if (line.startsWith("Vm"))
|
||||
System.out.print(line.replaceAll(" +", " ") + ", ");
|
||||
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private ChronicleMap<Integer, CharSequence> getViewTestMap(int noOfElements) throws IOException {
|
||||
ChronicleMap<Integer, CharSequence> map =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
@@ -128,20 +147,6 @@ public class ChronicleMapTest {
|
||||
|
||||
}
|
||||
|
||||
private static void printStatus() {
|
||||
if (!new File("/proc/self/status").exists()) return;
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader("/proc/self/status"));
|
||||
for (String line; (line = br.readLine()) != null; )
|
||||
if (line.startsWith("Vm"))
|
||||
System.out.print(line.replaceAll(" +", " ") + ", ");
|
||||
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveWithKey() {
|
||||
|
||||
@@ -226,7 +231,7 @@ public class ChronicleMapTest {
|
||||
|
||||
assertEquals(map1, map2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -249,7 +254,7 @@ public class ChronicleMapTest {
|
||||
|
||||
assertEquals(map1, map2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -272,7 +277,7 @@ public class ChronicleMapTest {
|
||||
|
||||
assertEquals(map1, map2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -482,6 +487,37 @@ public class ChronicleMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
// i7-3970X CPU @ 3.50GHz, hex core: -verbose:gc -Xmx64m
|
||||
// to tmpfs file system
|
||||
// 10M users, updated 12 times. Throughput 19.3 M ops/sec, no GC!
|
||||
// 50M users, updated 12 times. Throughput 19.8 M ops/sec, no GC!
|
||||
// 100M users, updated 12 times. Throughput 19.0M ops/sec, no GC!
|
||||
// 200M users, updated 12 times. Throughput 18.4 M ops/sec, no GC!
|
||||
// 400M users, updated 12 times. Throughput 18.4 M ops/sec, no GC!
|
||||
|
||||
// to ext4 file system.
|
||||
// 10M users, updated 12 times. Throughput 17.7 M ops/sec, no GC!
|
||||
// 50M users, updated 12 times. Throughput 16.5 M ops/sec, no GC!
|
||||
// 100M users, updated 12 times. Throughput 15.9 M ops/sec, no GC!
|
||||
// 200M users, updated 12 times. Throughput 15.4 M ops/sec, no GC!
|
||||
// 400M users, updated 12 times. Throughput 7.8 M ops/sec, no GC!
|
||||
// 600M users, updated 12 times. Throughput 5.8 M ops/sec, no GC!
|
||||
|
||||
// dual E5-2650v2 @ 2.6 GHz, 128 GB: -verbose:gc -Xmx32m
|
||||
// to tmpfs
|
||||
// TODO small GC on startup should be tidied up, [GC 9216K->1886K(31744K), 0.0036750 secs]
|
||||
// 10M users, updated 16 times. Throughput 33.0M ops/sec, VmPeak: 5373848 kB, VmRSS: 544252 kB
|
||||
// 50M users, updated 16 times. Throughput 31.2 M ops/sec, VmPeak: 9091804 kB, VmRSS: 3324732 kB
|
||||
// 250M users, updated 16 times. Throughput 30.0 M ops/sec, VmPeak: 24807836 kB, VmRSS: 14329112 kB
|
||||
// 1000M users, updated 16 times, Throughput 24.1 M ops/sec, VmPeak: 85312732 kB, VmRSS: 57165952 kB
|
||||
// 2500M users, updated 16 times, Throughput 23.5 M ops/sec, VmPeak: 189545308 kB, VmRSS: 126055868 kB
|
||||
|
||||
// to ext4
|
||||
// 10M users, updated 16 times. Throughput 28.4 M ops/sec, VmPeak: 5438652 kB, VmRSS: 544624 kB
|
||||
// 50M users, updated 16 times. Throughput 28.2 M ops/sec, VmPeak: 9091804 kB, VmRSS: 9091804 kB
|
||||
// 250M users, updated 16 times. Throughput 26.1 M ops/sec, VmPeak: 24807836 kB, VmRSS: 24807836 kB
|
||||
// 1000M users, updated 16 times, Throughput 1.3 M ops/sec, TODO FIX this
|
||||
|
||||
@Test
|
||||
public void testRemoveWithKeyAndValue() {
|
||||
|
||||
@@ -534,36 +570,17 @@ public class ChronicleMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
// i7-3970X CPU @ 3.50GHz, hex core: -verbose:gc -Xmx64m
|
||||
// to tmpfs file system
|
||||
// 10M users, updated 12 times. Throughput 19.3 M ops/sec, no GC!
|
||||
// 50M users, updated 12 times. Throughput 19.8 M ops/sec, no GC!
|
||||
// 100M users, updated 12 times. Throughput 19.0M ops/sec, no GC!
|
||||
// 200M users, updated 12 times. Throughput 18.4 M ops/sec, no GC!
|
||||
// 400M users, updated 12 times. Throughput 18.4 M ops/sec, no GC!
|
||||
// i7-3970X CPU @ 3.50GHz, hex core: -Xmx30g -verbose:gc
|
||||
// 10M users, updated 12 times. Throughput 16.2 M ops/sec, longest [Full GC 853669K->852546K(3239936K), 0.8255960 secs]
|
||||
// 50M users, updated 12 times. Throughput 13.3 M ops/sec, longest [Full GC 5516214K->5511353K(13084544K), 3.5752970 secs]
|
||||
// 100M users, updated 12 times. Throughput 11.8 M ops/sec, longest [Full GC 11240703K->11233711K(19170432K), 5.8783010 secs]
|
||||
// 200M users, updated 12 times. Throughput 4.2 M ops/sec, longest [Full GC 25974721K->22897189K(27962048K), 21.7962600 secs]
|
||||
|
||||
// to ext4 file system.
|
||||
// 10M users, updated 12 times. Throughput 17.7 M ops/sec, no GC!
|
||||
// 50M users, updated 12 times. Throughput 16.5 M ops/sec, no GC!
|
||||
// 100M users, updated 12 times. Throughput 15.9 M ops/sec, no GC!
|
||||
// 200M users, updated 12 times. Throughput 15.4 M ops/sec, no GC!
|
||||
// 400M users, updated 12 times. Throughput 7.8 M ops/sec, no GC!
|
||||
// 600M users, updated 12 times. Throughput 5.8 M ops/sec, no GC!
|
||||
|
||||
// dual E5-2650v2 @ 2.6 GHz, 128 GB: -verbose:gc -Xmx32m
|
||||
// to tmpfs
|
||||
// TODO small GC on startup should be tidied up, [GC 9216K->1886K(31744K), 0.0036750 secs]
|
||||
// 10M users, updated 16 times. Throughput 33.0M ops/sec, VmPeak: 5373848 kB, VmRSS: 544252 kB
|
||||
// 50M users, updated 16 times. Throughput 31.2 M ops/sec, VmPeak: 9091804 kB, VmRSS: 3324732 kB
|
||||
// 250M users, updated 16 times. Throughput 30.0 M ops/sec, VmPeak: 24807836 kB, VmRSS: 14329112 kB
|
||||
// 1000M users, updated 16 times, Throughput 24.1 M ops/sec, VmPeak: 85312732 kB, VmRSS: 57165952 kB
|
||||
// 2500M users, updated 16 times, Throughput 23.5 M ops/sec, VmPeak: 189545308 kB, VmRSS: 126055868 kB
|
||||
|
||||
// to ext4
|
||||
// 10M users, updated 16 times. Throughput 28.4 M ops/sec, VmPeak: 5438652 kB, VmRSS: 544624 kB
|
||||
// 50M users, updated 16 times. Throughput 28.2 M ops/sec, VmPeak: 9091804 kB, VmRSS: 9091804 kB
|
||||
// 250M users, updated 16 times. Throughput 26.1 M ops/sec, VmPeak: 24807836 kB, VmRSS: 24807836 kB
|
||||
// 1000M users, updated 16 times, Throughput 1.3 M ops/sec, TODO FIX this
|
||||
// dual E5-2650v2 @ 2.6 GHz, 128 GB: -verbose:gc -Xmx100g
|
||||
// 10M users, updated 16 times. Throughput 155.3 M ops/sec, VmPeak: 113291428 kB, VmRSS: 9272176 kB, [Full GC 1624336K->1616457K(7299072K), 2.5381610 secs]
|
||||
// 50M users, updated 16 times. Throughput 120.4 M ops/sec, VmPeak: 113291428 kB, VmRSS: 28436248 kB [Full GC 6545332K->6529639K(18179584K), 6.9053810 secs]
|
||||
// 250M users, updated 16 times. Throughput 114.1 M ops/sec, VmPeak: 113291428 kB, VmRSS: 76441464 kB [Full GC 41349527K->41304543K(75585024K), 17.3217490 secs]
|
||||
// 1000M users, OutOfMemoryError.
|
||||
|
||||
@Test
|
||||
public void testGetWithNullContainer() {
|
||||
@@ -592,18 +609,6 @@ public class ChronicleMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
// i7-3970X CPU @ 3.50GHz, hex core: -Xmx30g -verbose:gc
|
||||
// 10M users, updated 12 times. Throughput 16.2 M ops/sec, longest [Full GC 853669K->852546K(3239936K), 0.8255960 secs]
|
||||
// 50M users, updated 12 times. Throughput 13.3 M ops/sec, longest [Full GC 5516214K->5511353K(13084544K), 3.5752970 secs]
|
||||
// 100M users, updated 12 times. Throughput 11.8 M ops/sec, longest [Full GC 11240703K->11233711K(19170432K), 5.8783010 secs]
|
||||
// 200M users, updated 12 times. Throughput 4.2 M ops/sec, longest [Full GC 25974721K->22897189K(27962048K), 21.7962600 secs]
|
||||
|
||||
// dual E5-2650v2 @ 2.6 GHz, 128 GB: -verbose:gc -Xmx100g
|
||||
// 10M users, updated 16 times. Throughput 155.3 M ops/sec, VmPeak: 113291428 kB, VmRSS: 9272176 kB, [Full GC 1624336K->1616457K(7299072K), 2.5381610 secs]
|
||||
// 50M users, updated 16 times. Throughput 120.4 M ops/sec, VmPeak: 113291428 kB, VmRSS: 28436248 kB [Full GC 6545332K->6529639K(18179584K), 6.9053810 secs]
|
||||
// 250M users, updated 16 times. Throughput 114.1 M ops/sec, VmPeak: 113291428 kB, VmRSS: 76441464 kB [Full GC 41349527K->41304543K(75585024K), 17.3217490 secs]
|
||||
// 1000M users, OutOfMemoryError.
|
||||
|
||||
@Test
|
||||
public void testAcquireAndGet() throws IOException, ClassNotFoundException,
|
||||
IllegalAccessException, InstantiationException {
|
||||
@@ -709,7 +714,7 @@ public class ChronicleMapTest {
|
||||
assertEquals(j, value3.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,7 +805,7 @@ public class ChronicleMapTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLargerEntries() {
|
||||
@@ -996,12 +1001,6 @@ public class ChronicleMapTest {
|
||||
es.awaitTermination(1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
static final LongValue ONE = Values.newHeapInstance(LongValue.class);
|
||||
|
||||
static {
|
||||
ONE.setValue(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Performance test")
|
||||
public void testAcquireLockedPerf()
|
||||
@@ -1263,7 +1262,7 @@ public class ChronicleMapTest {
|
||||
assertNull(map.getUsing(key, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1282,7 +1281,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, new CharSequence[]{"1", "3"});
|
||||
assertValues(map.values(), new CharSequence[]{"1", "3"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapPutReflectedInViews() throws IOException {
|
||||
@@ -1332,7 +1331,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, new CharSequence[]{"1", "3"});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesRemoveReflectedInMap() throws IOException {
|
||||
@@ -1348,7 +1347,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, new CharSequence[]{"1", "3"});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entrySetIteratorRemoveReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1391,7 +1390,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, expectedValues);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesIteratorRemoveReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1418,7 +1417,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, expectedValues);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entrySetRemoveAllReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1439,7 +1438,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, new CharSequence[]{"3"});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keySetRemoveAllReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1455,7 +1454,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, new CharSequence[]{"3"});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesRemoveAllReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1505,7 +1504,7 @@ public class ChronicleMapTest {
|
||||
assertValues(values, new CharSequence[]{"2", "1"});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesRetainAllReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1537,7 +1536,7 @@ public class ChronicleMapTest {
|
||||
org.junit.Assert.assertTrue(values.isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keySetClearReflectedInMapAndOtherViews() throws IOException {
|
||||
@@ -1569,7 +1568,7 @@ public class ChronicleMapTest {
|
||||
org.junit.Assert.assertTrue(values.isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearMapViaEntryIteratorRemoves() throws IOException {
|
||||
@@ -1587,7 +1586,7 @@ public class ChronicleMapTest {
|
||||
assertEquals(noOfElements, sum);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearMapViaKeyIteratorRemoves() throws IOException {
|
||||
@@ -1660,7 +1659,7 @@ public class ChronicleMapTest {
|
||||
assertValues(map.values(), new String[]{"B"});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() throws IOException {
|
||||
@@ -1679,40 +1678,7 @@ public class ChronicleMapTest {
|
||||
assertEquals(map1, map2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class IncrementRunnable implements Runnable {
|
||||
|
||||
private final ChronicleMap<CharSequence, LongValue> map;
|
||||
|
||||
private final CharSequence key;
|
||||
|
||||
private final int iterations;
|
||||
|
||||
private final CyclicBarrier barrier;
|
||||
|
||||
private IncrementRunnable(ChronicleMap<CharSequence, LongValue> map, CharSequence key,
|
||||
int iterations, CyclicBarrier barrier) {
|
||||
this.map = map;
|
||||
this.key = key;
|
||||
this.iterations = iterations;
|
||||
this.barrier = barrier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LongValue value = Values.newNativeReference(LongValue.class);
|
||||
barrier.await();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
map.acquireUsing(key, value);
|
||||
value.addAtomicValue(1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutLongValue() throws IOException {
|
||||
@@ -1733,7 +1699,7 @@ public class ChronicleMapTest {
|
||||
throw new AssertionError("Should throw either IllegalStateException or " +
|
||||
"NullPointerException, but succeed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOffheapAcquireUsingLocked() throws IOException {
|
||||
@@ -1789,7 +1755,7 @@ public class ChronicleMapTest {
|
||||
assert value == v;
|
||||
assertEquals(1, c.entry().value().get().getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -1897,5 +1863,38 @@ public class ChronicleMapTest {
|
||||
tmpFile.delete();
|
||||
}
|
||||
|
||||
private static final class IncrementRunnable implements Runnable {
|
||||
|
||||
private final ChronicleMap<CharSequence, LongValue> map;
|
||||
|
||||
private final CharSequence key;
|
||||
|
||||
private final int iterations;
|
||||
|
||||
private final CyclicBarrier barrier;
|
||||
|
||||
private IncrementRunnable(ChronicleMap<CharSequence, LongValue> map, CharSequence key,
|
||||
int iterations, CyclicBarrier barrier) {
|
||||
this.map = map;
|
||||
this.key = key;
|
||||
this.iterations = iterations;
|
||||
this.barrier = barrier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LongValue value = Values.newNativeReference(LongValue.class);
|
||||
barrier.await();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
map.acquireUsing(key, value);
|
||||
value.addAtomicValue(1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,38 @@ public class ConstantSizeBySampleTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnexpectedlyLongConstantExternalizableValues() throws IOException {
|
||||
try (ChronicleMap<Long, ExternalizableData> map =
|
||||
ChronicleMapBuilder.of(Long.class, ExternalizableData.class)
|
||||
.valueReaderAndDataAccess(new ExternalizableDataReader(),
|
||||
new ExternalizableDataDataAccess())
|
||||
.constantValueSizeBySample(new ExternalizableData())
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.create()) {
|
||||
ExternalizableData value = new ExternalizableData();
|
||||
value.data[42] = 1;
|
||||
map.put(1L, value);
|
||||
Assert.assertEquals(map.get(1L), value);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnexpectedlyLongConstantSerializableValues() throws IOException {
|
||||
try (ChronicleMap<Long, SerializableData> map =
|
||||
ChronicleMapBuilder.of(Long.class, SerializableData.class)
|
||||
.constantValueSizeBySample(new SerializableData())
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.create()) {
|
||||
SerializableData value = new SerializableData();
|
||||
value.data[42] = 1;
|
||||
map.put(1L, value);
|
||||
Assert.assertEquals(map.get(1L), value);
|
||||
}
|
||||
}
|
||||
|
||||
static class ExternalizableData implements Externalizable {
|
||||
byte[] data = new byte[512 * 1024];
|
||||
|
||||
@@ -86,23 +118,6 @@ public class ConstantSizeBySampleTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnexpectedlyLongConstantExternalizableValues() throws IOException {
|
||||
try ( ChronicleMap<Long, ExternalizableData> map =
|
||||
ChronicleMapBuilder.of(Long.class, ExternalizableData.class)
|
||||
.valueReaderAndDataAccess(new ExternalizableDataReader(),
|
||||
new ExternalizableDataDataAccess())
|
||||
.constantValueSizeBySample(new ExternalizableData())
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.create()) {
|
||||
ExternalizableData value = new ExternalizableData();
|
||||
value.data[42] = 1;
|
||||
map.put(1L, value);
|
||||
Assert.assertEquals(map.get(1L), value);
|
||||
}
|
||||
}
|
||||
|
||||
static class SerializableData implements Serializable {
|
||||
byte[] data = new byte[512 * 1024];
|
||||
|
||||
@@ -114,21 +129,6 @@ public class ConstantSizeBySampleTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnexpectedlyLongConstantSerializableValues() throws IOException {
|
||||
try ( ChronicleMap<Long, SerializableData> map =
|
||||
ChronicleMapBuilder.of(Long.class, SerializableData.class)
|
||||
.constantValueSizeBySample(new SerializableData())
|
||||
.entries(100)
|
||||
.actualSegments(1)
|
||||
.create()) {
|
||||
SerializableData value = new SerializableData();
|
||||
value.data[42] = 1;
|
||||
map.put(1L, value);
|
||||
Assert.assertEquals(map.get(1L), value);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExternalizableDataDataAccess
|
||||
extends ExternalizableDataAccess<ExternalizableData> implements Serializable {
|
||||
public ExternalizableDataDataAccess() {
|
||||
|
||||
@@ -56,7 +56,9 @@ public class DatasetTrackerIssue61Test {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/** According to Externalizable spec, there should be a public no-arg constructor */
|
||||
/**
|
||||
* According to Externalizable spec, there should be a public no-arg constructor
|
||||
*/
|
||||
public Value() {
|
||||
}
|
||||
|
||||
|
||||
@@ -36,13 +36,12 @@ import java.util.zip.InflaterInputStream;
|
||||
public final class DeflatorStringMarshaller implements BytesReader<CharSequence>,
|
||||
BytesWriter<CharSequence>, EnumMarshallable<DeflatorStringMarshaller> {
|
||||
public static final DeflatorStringMarshaller INSTANCE = new DeflatorStringMarshaller();
|
||||
|
||||
private DeflatorStringMarshaller() {}
|
||||
|
||||
private static final StringFactory STRING_FACTORY = getStringFactory();
|
||||
|
||||
private static final int NULL_LENGTH = -1;
|
||||
|
||||
private DeflatorStringMarshaller() {
|
||||
}
|
||||
|
||||
private static StringFactory getStringFactory() {
|
||||
try {
|
||||
return new StringFactory17();
|
||||
|
||||
@@ -27,13 +27,28 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.openhft.chronicle.values.Values.newNativeReference;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
interface DemoOrderVOInterface {
|
||||
public CharSequence getSymbol();
|
||||
// public StringBuilder getUsingSymbol(StringBuilder sb);
|
||||
|
||||
public void setSymbol(@MaxUtf8Length(20) CharSequence symbol);
|
||||
|
||||
public double addAtomicOrderQty(double toAdd);
|
||||
|
||||
public double getOrderQty();
|
||||
|
||||
public void setOrderQty(double orderQty);
|
||||
|
||||
}
|
||||
|
||||
public class DemoChronicleMapTest {
|
||||
|
||||
@Test
|
||||
public void testMap() throws IOException {
|
||||
File file = File.createTempFile("DummyOrders"+System.currentTimeMillis(), ".test");
|
||||
File file = File.createTempFile("DummyOrders" + System.currentTimeMillis(), ".test");
|
||||
file.deleteOnExit();
|
||||
int maxEntries = 1000;
|
||||
try (ChronicleMap<IntValue, DemoOrderVOInterface> map = ChronicleMapBuilder
|
||||
@@ -75,7 +90,7 @@ public class DemoChronicleMapTest {
|
||||
|
||||
@Test
|
||||
public void testMapLocked() throws IOException {
|
||||
File file = File.createTempFile("DummyOrders-"+System.currentTimeMillis(), ".test");
|
||||
File file = File.createTempFile("DummyOrders-" + System.currentTimeMillis(), ".test");
|
||||
file.deleteOnExit();
|
||||
int maxEntries = 1000;
|
||||
try (ChronicleMap<IntValue, DemoOrderVOInterface> map = ChronicleMapBuilder
|
||||
@@ -118,17 +133,3 @@ public class DemoChronicleMapTest {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
interface DemoOrderVOInterface {
|
||||
public CharSequence getSymbol();
|
||||
// public StringBuilder getUsingSymbol(StringBuilder sb);
|
||||
|
||||
public void setSymbol(@MaxUtf8Length(20) CharSequence symbol);
|
||||
|
||||
public double addAtomicOrderQty(double toAdd);
|
||||
|
||||
public double getOrderQty();
|
||||
|
||||
public void setOrderQty(double orderQty);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,9 +36,10 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class EntryCountMapTest {
|
||||
static final String TMP = System.getProperty("java.io.tmpdir");
|
||||
static final int ecmTests = Integer.getInteger("ecm.tests", 5);
|
||||
double score = 0;
|
||||
int scoreCount = 0;
|
||||
static final String TMP = System.getProperty("java.io.tmpdir");
|
||||
|
||||
static File getPersistenceFile() throws IOException {
|
||||
File file = File.createTempFile("ecm-chm-test", ".deleteme");
|
||||
@@ -57,7 +58,9 @@ public class EntryCountMapTest {
|
||||
return mapBuilder.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
static final int ecmTests = Integer.getInteger("ecm.tests", 5);
|
||||
private static int moreThanMaxSize(int maxSize) {
|
||||
return maxSize * 14 / 10 + 300;
|
||||
}
|
||||
|
||||
@Ignore("HCOLL-279 fix net.openhft.chronicle.map.EntryCountMapTest#testVerySmall")
|
||||
@Test
|
||||
@@ -256,10 +259,6 @@ public class EntryCountMapTest {
|
||||
", seg: " + segments + ", min: " + minSize +
|
||||
", size: " + map.size());
|
||||
}
|
||||
}
|
||||
|
||||
private static int moreThanMaxSize(int maxSize) {
|
||||
return maxSize * 14 / 10 + 300;
|
||||
}
|
||||
|
||||
private void dumpMapStats(int segments, int minSize,
|
||||
|
||||
@@ -32,6 +32,44 @@ public class ExitHookTest {
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
System.out.println("Other process started");
|
||||
File mapFile = new File(args[0]);
|
||||
ChronicleMap<Integer, Integer> map = createMap(mapFile);
|
||||
try (ExternalMapQueryContext<Integer, Integer, ?> c = map.queryContext(KEY)) {
|
||||
c.writeLock().lock();
|
||||
try {
|
||||
map.close();
|
||||
} finally {
|
||||
Thread.sleep(30_000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ChronicleMap<Integer, Integer> createMap(File mapFile) throws IOException {
|
||||
return ChronicleMap
|
||||
.of(Integer.class, Integer.class)
|
||||
.entries(1)
|
||||
.createPersistedTo(mapFile);
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/33171840/648955
|
||||
public static long getPidOfProcess(Process p) {
|
||||
long pid = -1;
|
||||
|
||||
try {
|
||||
if (p.getClass().getName().equals("java.lang.UNIXProcess")) {
|
||||
Field f = p.getClass().getDeclaredField("pid");
|
||||
f.setAccessible(true);
|
||||
pid = f.getLong(p);
|
||||
f.setAccessible(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
pid = -1;
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExitHook() throws IOException, InterruptedException {
|
||||
if (!OS.isLinux() && !OS.isMacOSX())
|
||||
@@ -55,27 +93,6 @@ public class ExitHookTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
System.out.println("Other process started");
|
||||
File mapFile = new File(args[0]);
|
||||
ChronicleMap<Integer, Integer> map = createMap(mapFile);
|
||||
try (ExternalMapQueryContext<Integer, Integer, ?> c = map.queryContext(KEY)) {
|
||||
c.writeLock().lock();
|
||||
try {
|
||||
map.close();
|
||||
} finally {
|
||||
Thread.sleep(30_000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ChronicleMap<Integer, Integer> createMap(File mapFile) throws IOException {
|
||||
return ChronicleMap
|
||||
.of(Integer.class, Integer.class)
|
||||
.entries(1)
|
||||
.createPersistedTo(mapFile);
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/7835467/648955
|
||||
private void interruptProcess(long pidOfProcess) throws IOException {
|
||||
Runtime.getRuntime().exec("kill -SIGINT " + pidOfProcess);
|
||||
@@ -96,21 +113,4 @@ public class ExitHookTest {
|
||||
builder.inheritIO();
|
||||
return builder.start();
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/33171840/648955
|
||||
public static long getPidOfProcess(Process p) {
|
||||
long pid = -1;
|
||||
|
||||
try {
|
||||
if (p.getClass().getName().equals("java.lang.UNIXProcess")) {
|
||||
Field f = p.getClass().getDeclaredField("pid");
|
||||
f.setAccessible(true);
|
||||
pid = f.getLong(p);
|
||||
f.setAccessible(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
pid = -1;
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GuavaTest extends TestCase {
|
||||
TestSuite backedTests = backed
|
||||
.named("Guava tests tests of Chronicle Map, backed with HashMap")
|
||||
.createTestSuite();
|
||||
|
||||
|
||||
TestSuite tests = new TestSuite();
|
||||
tests.addTest(chmTests);
|
||||
// TODO
|
||||
@@ -121,9 +121,9 @@ public class GuavaTest extends TestCase {
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class BackedUpMapGenerator extends CHMTestGenerator {
|
||||
|
||||
|
||||
@Override
|
||||
Map<String, String> newMap() {
|
||||
Map<String, String> m = new HashMap<>();
|
||||
|
||||
@@ -24,9 +24,9 @@ public class Histogram {
|
||||
static final String[] FRACTION_STR = "worst,99.99,99.9,99,90,50".split(",");
|
||||
static final int[] FRACTIONS = {Integer.MAX_VALUE, 10000, 1000, 100, 10, 2};
|
||||
static final int BITS_OF_ACCURACY = 5;
|
||||
final int[] counters = new int[40 << BITS_OF_ACCURACY];
|
||||
static final int MANTISSA = 52;
|
||||
static final int BITS_TO_TRUNCATE = MANTISSA - BITS_OF_ACCURACY;
|
||||
final int[] counters = new int[40 << BITS_OF_ACCURACY];
|
||||
long count = 0;
|
||||
|
||||
public void sample(long value) {
|
||||
|
||||
@@ -5,12 +5,6 @@ import net.openhft.chronicle.values.Values;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Issue110Test {
|
||||
interface IContainer {
|
||||
@Array(length=10)
|
||||
double getDoubleArrayAt(int i);
|
||||
void setDoubleArrayAt(int i, double d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChronicleDoubleArray() {
|
||||
ChronicleMap<String, IContainer> map =
|
||||
@@ -22,4 +16,11 @@ public class Issue110Test {
|
||||
map.put("0", Values.newHeapInstance(IContainer.class));
|
||||
assert map.get("0") != null;
|
||||
}
|
||||
|
||||
interface IContainer {
|
||||
@Array(length = 10)
|
||||
double getDoubleArrayAt(int i);
|
||||
|
||||
void setDoubleArrayAt(int i, double d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,14 @@ public class Issue43Test {
|
||||
EnumMarshallable<ArrayMarshaller> {
|
||||
public static final ArrayMarshaller INSTANCE = new ArrayMarshaller();
|
||||
|
||||
private ArrayMarshaller() {}
|
||||
private ArrayMarshaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Bytes bytes, @NotNull ValueWrapper vw) {
|
||||
bytes.writeInt(vw.values.length);
|
||||
|
||||
for (int i = 0; i < vw.values.length; i ++) {
|
||||
for (int i = 0; i < vw.values.length; i++) {
|
||||
bytes.writeDouble(vw.values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Issue58 {
|
||||
.collect(toMap(k -> data.get(k), k -> k));
|
||||
reverseMap.putAll(reverse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void test1(Map<String, UUID> data) throws IOException {
|
||||
try (
|
||||
@@ -125,13 +125,14 @@ public class Issue58 {
|
||||
map.entrySet().forEach(e -> System.out.println(e.getKey() + "->" + e.getValue()));
|
||||
reverseMap.forEach((k, v) -> System.out.println(k + " -> " + v));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final class UuidMarshaller
|
||||
implements BytesReader<UUID>, BytesWriter<UUID>, EnumMarshallable<UuidMarshaller> {
|
||||
public static final UuidMarshaller INSTANCE = new UuidMarshaller();
|
||||
|
||||
private UuidMarshaller() {}
|
||||
private UuidMarshaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Bytes bytes, @NotNull UUID uuid) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Issue62ChronicleClient {
|
||||
.replication((byte) 2);
|
||||
|
||||
try (ChronicleMap<String, Long> map =
|
||||
cityPostalCodesMapBuilder.createPersistedTo(MAP_FILE_B)) {
|
||||
cityPostalCodesMapBuilder.createPersistedTo(MAP_FILE_B)) {
|
||||
|
||||
LOGGER.info("Starting");
|
||||
Jvm.pause(3000);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Issue62ChronicleServer {
|
||||
ChronicleMap<String, Long> cityPostalCodes =
|
||||
cityPostalCodesMapBuilder.createPersistedTo(MAP_FILE_A);
|
||||
|
||||
for(int i = 0; i < 100; i++ ) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
cityPostalCodes.put(STR + i, (long) i);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,6 @@ import net.openhft.chronicle.values.Values;
|
||||
|
||||
public class LataTest {
|
||||
|
||||
public interface IData {
|
||||
int getData();
|
||||
void setData(int data);
|
||||
int addAtomicData(int addData);
|
||||
}
|
||||
|
||||
private static int max = 6000000;
|
||||
private static int run = 100;
|
||||
private static int currentRun = 0;
|
||||
@@ -69,8 +63,17 @@ public class LataTest {
|
||||
map.close();
|
||||
}
|
||||
|
||||
public interface IData {
|
||||
int getData();
|
||||
|
||||
void setData(int data);
|
||||
|
||||
int addAtomicData(int addData);
|
||||
}
|
||||
|
||||
interface StringValue {
|
||||
CharSequence getValue();
|
||||
|
||||
void setValue(@MaxUtf8Length(64) CharSequence value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,49 +29,27 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ListenersTest {
|
||||
|
||||
static class CountingEntryOperations<K, V> implements MapEntryOperations<K, V, Void> {
|
||||
AtomicInteger removeCount = new AtomicInteger();
|
||||
AtomicInteger insertCount = new AtomicInteger();
|
||||
AtomicInteger replaceValueCount = new AtomicInteger();
|
||||
@Override
|
||||
public Void remove(@NotNull MapEntry<K, V> entry) {
|
||||
removeCount.incrementAndGet();
|
||||
return MapEntryOperations.super.remove(entry);
|
||||
}
|
||||
@Override
|
||||
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) {
|
||||
insertCount.incrementAndGet();
|
||||
return MapEntryOperations.super.insert(absentEntry, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnyRemove() {
|
||||
CountingEntryOperations<Integer, Integer> removeCounting =
|
||||
new CountingEntryOperations<>();
|
||||
ChronicleMap<Integer, Integer> map =
|
||||
ChronicleMapBuilder.of(Integer.class, Integer.class)
|
||||
.entries(100)
|
||||
.entryOperations(removeCounting)
|
||||
.create();
|
||||
|
||||
.entries(100)
|
||||
.entryOperations(removeCounting)
|
||||
.create();
|
||||
|
||||
map.put(1, 1);
|
||||
map.remove(1); // removeCount 1
|
||||
|
||||
|
||||
map.put(1, 1);
|
||||
assertFalse(map.remove(1, 2));
|
||||
map.remove(1, 1); // removeCount 2
|
||||
|
||||
|
||||
map.put(1, 1);
|
||||
map.merge(1, 1, (v1, v2) -> null); // removeCount 3
|
||||
|
||||
|
||||
map.put(1, 1);
|
||||
Iterator<Map.Entry<Integer, Integer>> it = map.entrySet().iterator();
|
||||
it.next();
|
||||
@@ -94,15 +72,15 @@ public class ListenersTest {
|
||||
|
||||
map.put(1, 2); // replaceValue 1
|
||||
map.compute(1, (k, v) -> 2); // replaceValue 2
|
||||
|
||||
|
||||
map.entrySet().iterator().next().setValue(1); // replaceValue 3
|
||||
|
||||
|
||||
map.compute(2, (k, v) -> 1); // insert 2
|
||||
|
||||
assertEquals(3, putCounting.replaceValueCount.get());
|
||||
assertEquals(2, putCounting.insertCount.get());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContainsKey() {
|
||||
AtomicInteger c = new AtomicInteger();
|
||||
@@ -119,14 +97,14 @@ public class ListenersTest {
|
||||
}
|
||||
})
|
||||
.create();
|
||||
|
||||
|
||||
assertFalse(map.containsKey(1)); // 1
|
||||
map.put(1, 1);
|
||||
assertTrue(map.containsKey(1)); // 2
|
||||
|
||||
|
||||
map.put(2, 2);
|
||||
assertFalse(map.containsKey(2));
|
||||
|
||||
|
||||
assertEquals(2, c.get());
|
||||
}
|
||||
|
||||
@@ -188,13 +166,37 @@ public class ListenersTest {
|
||||
|
||||
assertNull(map.put(1, 1)); // 1
|
||||
assertEquals(1, map.put(1, 2).intValue()); // 2
|
||||
|
||||
|
||||
assertNull(map.put(2, 1));
|
||||
assertNull(map.put(2, 2));
|
||||
|
||||
|
||||
assertNull(map.put(3, 1));
|
||||
assertEquals(2, map.get(3).intValue());
|
||||
|
||||
assertEquals(2, c.get());
|
||||
}
|
||||
|
||||
static class CountingEntryOperations<K, V> implements MapEntryOperations<K, V, Void> {
|
||||
AtomicInteger removeCount = new AtomicInteger();
|
||||
AtomicInteger insertCount = new AtomicInteger();
|
||||
AtomicInteger replaceValueCount = new AtomicInteger();
|
||||
|
||||
@Override
|
||||
public Void remove(@NotNull MapEntry<K, V> entry) {
|
||||
removeCount.incrementAndGet();
|
||||
return MapEntryOperations.super.remove(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
insertCount.incrementAndGet();
|
||||
return MapEntryOperations.super.insert(absentEntry, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||
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) {
|
||||
LOG.info("replace: old key: {}, old value: {}, new value: {}",
|
||||
|
||||
@@ -55,7 +55,8 @@ public class MapCloseTest {
|
||||
Thread t = new Thread(() -> map.close());
|
||||
t.start();
|
||||
t.join();
|
||||
map.forEach((k, v) -> {});
|
||||
map.forEach((k, v) -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = ChronicleHashClosedException.class)
|
||||
|
||||
@@ -34,6 +34,26 @@ public class MarkTest {
|
||||
|
||||
static int ENTRIES = 25_000_000;
|
||||
|
||||
private static void test(
|
||||
Function<ChronicleMapBuilder<Integer, Integer>, ChronicleMap<Integer, Integer>>
|
||||
createMap) {
|
||||
long ms = System.currentTimeMillis();
|
||||
try (ChronicleMap<Integer, Integer> map = createMap.apply(ChronicleMapBuilder
|
||||
.of(Integer.class, Integer.class)
|
||||
.entries(ENTRIES)
|
||||
.entriesPerSegment((1 << 15) / 3)
|
||||
.checksumEntries(false)
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true))) {
|
||||
|
||||
Random r = ThreadLocalRandom.current();
|
||||
for (int i = 0; i < ENTRIES; i++) {
|
||||
map.put(r.nextInt(), r.nextInt());
|
||||
}
|
||||
}
|
||||
System.out.println(System.currentTimeMillis() - ms);
|
||||
}
|
||||
|
||||
@Ignore("often out of time, that is a parf issue, not a bug")
|
||||
@Test(timeout = 25000)
|
||||
public void inMemoryTest() {
|
||||
@@ -61,24 +81,4 @@ public class MarkTest {
|
||||
db.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(
|
||||
Function<ChronicleMapBuilder<Integer, Integer>, ChronicleMap<Integer, Integer>>
|
||||
createMap) {
|
||||
long ms = System.currentTimeMillis();
|
||||
try (ChronicleMap<Integer, Integer> map = createMap.apply(ChronicleMapBuilder
|
||||
.of(Integer.class, Integer.class)
|
||||
.entries(ENTRIES)
|
||||
.entriesPerSegment((1 << 15) / 3)
|
||||
.checksumEntries(false)
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true))) {
|
||||
|
||||
Random r = ThreadLocalRandom.current();
|
||||
for (int i = 0; i < ENTRIES; i++) {
|
||||
map.put(r.nextInt(), r.nextInt());
|
||||
}
|
||||
}
|
||||
System.out.println(System.currentTimeMillis() - ms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,7 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -50,6 +46,30 @@ import static org.junit.Assert.assertEquals;
|
||||
@RunWith(Parameterized.class)
|
||||
public class MemoryLeaksTest {
|
||||
|
||||
/**
|
||||
* Accounting {@link CountedStringReader} creation and finalization. All serializers,
|
||||
* created since the map creation, should become unreachable after map.close() or collection by
|
||||
* Cleaner, it means that map contexts (referencing serializers) are collected by the GC
|
||||
*/
|
||||
private final AtomicInteger serializerCount = new AtomicInteger();
|
||||
private final List<WeakReference<CountedStringReader>> serializers = new ArrayList<>();
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private boolean persisted;
|
||||
private ChronicleMapBuilder<IntValue, String> builder;
|
||||
private boolean closeWithinContext;
|
||||
public MemoryLeaksTest(String testType, boolean replicated, boolean persisted, boolean closeWithinContext) {
|
||||
this.persisted = persisted;
|
||||
this.closeWithinContext = closeWithinContext;
|
||||
builder = ChronicleMap
|
||||
.of(IntValue.class, String.class)
|
||||
.valueReaderAndDataAccess(new CountedStringReader(), new StringUtf8DataAccess());
|
||||
if (replicated)
|
||||
builder.replication((byte) 1);
|
||||
builder.entries(1).averageValueSize(1);
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Object[]> data() {
|
||||
List<Boolean> booleans = Arrays.asList(false, true);
|
||||
@@ -68,31 +88,6 @@ public class MemoryLeaksTest {
|
||||
(!flags.get(2) ? "not " : "") + "closed within context";
|
||||
}
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private boolean persisted;
|
||||
private ChronicleMapBuilder<IntValue, String> builder;
|
||||
private boolean closeWithinContext;
|
||||
/**
|
||||
* Accounting {@link CountedStringReader} creation and finalization. All serializers,
|
||||
* created since the map creation, should become unreachable after map.close() or collection by
|
||||
* Cleaner, it means that map contexts (referencing serializers) are collected by the GC
|
||||
*/
|
||||
private final AtomicInteger serializerCount = new AtomicInteger();
|
||||
private final List<WeakReference<CountedStringReader>> serializers = new ArrayList<>();
|
||||
|
||||
public MemoryLeaksTest(String testType, boolean replicated, boolean persisted, boolean closeWithinContext) {
|
||||
this.persisted = persisted;
|
||||
this.closeWithinContext = closeWithinContext;
|
||||
builder = ChronicleMap
|
||||
.of(IntValue.class, String.class)
|
||||
.valueReaderAndDataAccess(new CountedStringReader(), new StringUtf8DataAccess());
|
||||
if (replicated)
|
||||
builder.replication((byte) 1);
|
||||
builder.entries(1).averageValueSize(1);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initNoBytesStore() {
|
||||
Assert.assertNotEquals(0, NoBytesStore.NO_PAGE);
|
||||
|
||||
@@ -176,7 +176,8 @@ public class NestedContextsInIterationContextTest {
|
||||
.create()) {
|
||||
map.put(42, 42);
|
||||
try (MapSegmentContext<Integer, Integer, ?> cxt = map.segmentContext(0)) {
|
||||
cxt.forEachSegmentEntry(e -> map.segmentContext(1).forEachSegmentEntry(e2 -> {}));
|
||||
cxt.forEachSegmentEntry(e -> map.segmentContext(1).forEachSegmentEntry(e2 -> {
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,51 +32,6 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class NestedContextsTest {
|
||||
|
||||
@Test
|
||||
public void nestedContextsTest() throws ExecutionException, InterruptedException {
|
||||
HashSet<Integer> averageValue = new HashSet<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
averageValue.add(i);
|
||||
}
|
||||
ChronicleMap<Integer, Set<Integer>> graph = ChronicleMap
|
||||
.of(Integer.class, (Class<Set<Integer>>) (Class) Set.class)
|
||||
.entries(10)
|
||||
.averageValue(averageValue)
|
||||
.actualSegments(2)
|
||||
.create();
|
||||
|
||||
addEdge(graph, 1, 2);
|
||||
addEdge(graph, 2, 3);
|
||||
addEdge(graph, 1, 3);
|
||||
|
||||
assertEquals(ImmutableSet.of(2, 3), graph.get(1));
|
||||
assertEquals(ImmutableSet.of(1, 3), graph.get(2));
|
||||
assertEquals(ImmutableSet.of(1, 2), graph.get(3));
|
||||
|
||||
verifyGraphConsistent(graph);
|
||||
|
||||
ForkJoinPool pool = new ForkJoinPool(8);
|
||||
try {
|
||||
pool.submit(() -> {
|
||||
ThreadLocalRandom.current().ints().limit(10_000).parallel().forEach(i -> {
|
||||
int sourceNode = Math.abs(i % 10);
|
||||
int targetNode;
|
||||
do {
|
||||
targetNode = ThreadLocalRandom.current().nextInt(10);
|
||||
} while (targetNode == sourceNode);
|
||||
if (i % 2 == 0) {
|
||||
addEdge(graph, sourceNode, targetNode);
|
||||
} else {
|
||||
removeEdge(graph, sourceNode, targetNode);
|
||||
}
|
||||
});
|
||||
}).get();
|
||||
verifyGraphConsistent(graph);
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyGraphConsistent(ChronicleMap<Integer, Set<Integer>> graph) {
|
||||
graph.forEach((node, neighbours) ->
|
||||
neighbours.forEach(neighbour -> assertTrue(graph.get(neighbour).contains(node))));
|
||||
@@ -156,7 +111,7 @@ public class NestedContextsTest {
|
||||
}
|
||||
|
||||
private static void addEdgeBothAbsent(MapQueryContext<Integer, Set<Integer>, ?> sc, int source,
|
||||
MapQueryContext<Integer, Set<Integer>, ?> tc, int target) {
|
||||
MapQueryContext<Integer, Set<Integer>, ?> tc, int target) {
|
||||
addEdgeOneSide(sc, target);
|
||||
addEdgeOneSide(tc, source);
|
||||
}
|
||||
@@ -207,4 +162,49 @@ public class NestedContextsTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedContextsTest() throws ExecutionException, InterruptedException {
|
||||
HashSet<Integer> averageValue = new HashSet<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
averageValue.add(i);
|
||||
}
|
||||
ChronicleMap<Integer, Set<Integer>> graph = ChronicleMap
|
||||
.of(Integer.class, (Class<Set<Integer>>) (Class) Set.class)
|
||||
.entries(10)
|
||||
.averageValue(averageValue)
|
||||
.actualSegments(2)
|
||||
.create();
|
||||
|
||||
addEdge(graph, 1, 2);
|
||||
addEdge(graph, 2, 3);
|
||||
addEdge(graph, 1, 3);
|
||||
|
||||
assertEquals(ImmutableSet.of(2, 3), graph.get(1));
|
||||
assertEquals(ImmutableSet.of(1, 3), graph.get(2));
|
||||
assertEquals(ImmutableSet.of(1, 2), graph.get(3));
|
||||
|
||||
verifyGraphConsistent(graph);
|
||||
|
||||
ForkJoinPool pool = new ForkJoinPool(8);
|
||||
try {
|
||||
pool.submit(() -> {
|
||||
ThreadLocalRandom.current().ints().limit(10_000).parallel().forEach(i -> {
|
||||
int sourceNode = Math.abs(i % 10);
|
||||
int targetNode;
|
||||
do {
|
||||
targetNode = ThreadLocalRandom.current().nextInt(10);
|
||||
} while (targetNode == sourceNode);
|
||||
if (i % 2 == 0) {
|
||||
addEdge(graph, sourceNode, targetNode);
|
||||
} else {
|
||||
removeEdge(graph, sourceNode, targetNode);
|
||||
}
|
||||
});
|
||||
}).get();
|
||||
verifyGraphConsistent(graph);
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.ChronicleHashBuilderPrivateAPI;
|
||||
import net.openhft.chronicle.map.jsr166.JSR166TestCase;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ReplicationCheckingMap<K, V> implements ChronicleMap<K, V> {
|
||||
return r1;
|
||||
|
||||
if (i > 30) {
|
||||
Jvm.pause(i);
|
||||
Jvm.pause(i);
|
||||
} else {
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TrickyContextCasesTest {
|
||||
.of(Integer.class, IntValue.class)
|
||||
.entries(1).create();
|
||||
|
||||
IntValue v = Values.newHeapInstance(IntValue.class);
|
||||
IntValue v = Values.newHeapInstance(IntValue.class);
|
||||
v.setValue(2);
|
||||
map.put(1, v);
|
||||
try (ExternalMapQueryContext<Integer, IntValue, ?> q = map.queryContext(1)) {
|
||||
@@ -61,8 +61,8 @@ public class TrickyContextCasesTest {
|
||||
.of(Integer.class, byte[].class)
|
||||
.averageValue(new byte[1])
|
||||
.entries(100).actualSegments(1).create();
|
||||
map.put(1, new byte[] {1});
|
||||
map.put(2, new byte[] {2});
|
||||
map.put(1, new byte[]{1});
|
||||
map.put(2, new byte[]{2});
|
||||
try (ExternalMapQueryContext<Integer, byte[], ?> q = map.queryContext(1)) {
|
||||
MapEntry<Integer, byte[]> entry = q.entry(); // acquires read lock implicitly
|
||||
assertNotNull(entry);
|
||||
@@ -70,9 +70,9 @@ public class TrickyContextCasesTest {
|
||||
// this call should try to acquire write lock, that should lead to dead lock
|
||||
// but if not...
|
||||
// relocates the entry for the key 1 after the entry for 2, under update lock
|
||||
map.put(1, new byte[] {1, 2, 3, 4, 5});
|
||||
map.put(1, new byte[]{1, 2, 3, 4, 5});
|
||||
// puts the entry for 3 at the place of the entry for the key 1, under update lock
|
||||
map.put(3, new byte[] {3});
|
||||
map.put(3, new byte[]{3});
|
||||
}).get();
|
||||
// prints [3]
|
||||
System.out.println(Arrays.toString(entry.value().get()));
|
||||
|
||||
@@ -12,44 +12,48 @@ import java.util.stream.IntStream;
|
||||
*/
|
||||
public class ValueInterfaceWithEnumTest {
|
||||
|
||||
/**
|
||||
* This test will throw an {@link ArrayIndexOutOfBoundsException}. This seems to occur only with Enums having even number of
|
||||
* values
|
||||
*/
|
||||
@Test
|
||||
public void testValueInterface() {
|
||||
LongValue longValue = Values.newHeapInstance(LongValue.class);
|
||||
SimpleValueInterface simpleValueInterface = Values.newHeapInstance(SimpleValueInterface.class);
|
||||
/**
|
||||
* This test will throw an {@link ArrayIndexOutOfBoundsException}. This seems to occur only with Enums having even number of
|
||||
* values
|
||||
*/
|
||||
@Test
|
||||
public void testValueInterface() {
|
||||
LongValue longValue = Values.newHeapInstance(LongValue.class);
|
||||
SimpleValueInterface simpleValueInterface = Values.newHeapInstance(SimpleValueInterface.class);
|
||||
|
||||
ChronicleMap<LongValue, SimpleValueInterface> map = ChronicleMapBuilder.of(LongValue.class, SimpleValueInterface.class).entries(50).create();
|
||||
ChronicleMap<LongValue, SimpleValueInterface> map = ChronicleMapBuilder.of(LongValue.class, SimpleValueInterface.class).entries(50).create();
|
||||
|
||||
IntStream.range(1, 20).forEach(value -> {
|
||||
longValue.setValue(value);
|
||||
simpleValueInterface.setId(value);
|
||||
simpleValueInterface.setTruth(false);
|
||||
simpleValueInterface.setSVIEnum(SimpleValueInterface.SVIEnum.SIX);
|
||||
IntStream.range(1, 20).forEach(value -> {
|
||||
longValue.setValue(value);
|
||||
simpleValueInterface.setId(value);
|
||||
simpleValueInterface.setTruth(false);
|
||||
simpleValueInterface.setSVIEnum(SimpleValueInterface.SVIEnum.SIX);
|
||||
|
||||
map.put(longValue, simpleValueInterface);
|
||||
});
|
||||
map.put(longValue, simpleValueInterface);
|
||||
});
|
||||
|
||||
IntStream.range(1, 10).forEach(value -> {
|
||||
longValue.setValue(value);
|
||||
SimpleValueInterface simpleValueInterface1 = map.get(longValue);
|
||||
System.out.println(simpleValueInterface1.getId());
|
||||
});
|
||||
}
|
||||
IntStream.range(1, 10).forEach(value -> {
|
||||
longValue.setValue(value);
|
||||
SimpleValueInterface simpleValueInterface1 = map.get(longValue);
|
||||
System.out.println(simpleValueInterface1.getId());
|
||||
});
|
||||
}
|
||||
|
||||
public interface SimpleValueInterface {
|
||||
enum SVIEnum {
|
||||
ONE, TWO, THREE, FOUR, FIVE, SIX
|
||||
}
|
||||
public interface SimpleValueInterface {
|
||||
int getId();
|
||||
|
||||
int getId();
|
||||
void setId(int id);
|
||||
boolean getTruth();
|
||||
void setTruth(boolean truth);
|
||||
void setId(int id);
|
||||
|
||||
SVIEnum getSVIEnum();
|
||||
void setSVIEnum(SVIEnum val);
|
||||
}
|
||||
boolean getTruth();
|
||||
|
||||
void setTruth(boolean truth);
|
||||
|
||||
SVIEnum getSVIEnum();
|
||||
|
||||
void setSVIEnum(SVIEnum val);
|
||||
|
||||
enum SVIEnum {
|
||||
ONE, TWO, THREE, FOUR, FIVE, SIX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,12 +79,12 @@ public class WriteThroughputTest {
|
||||
int count = 2 << 10;
|
||||
int size = 50 << 10;
|
||||
|
||||
File file3 = new File("bandwidthTest"+System.nanoTime()+ ".Z.deleteme");
|
||||
File file3 = new File("bandwidthTest" + System.nanoTime() + ".Z.deleteme");
|
||||
file3.deleteOnExit();
|
||||
try (ChronicleMap<CharSequence, CharSequence> map = ChronicleMapBuilder
|
||||
.of(CharSequence.class, CharSequence.class)
|
||||
.entries(count*3/2)
|
||||
.averageValueSize(size/4)
|
||||
.entries(count * 3 / 2)
|
||||
.averageValueSize(size / 4)
|
||||
.valueMarshaller(DeflatorStringMarshaller.INSTANCE)
|
||||
.putReturnsNull(true)
|
||||
.createPersistedTo(file3)) {
|
||||
@@ -94,7 +94,7 @@ public class WriteThroughputTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void doTest(int count, int size,ChronicleMap<CharSequence, CharSequence> map) {
|
||||
private void doTest(int count, int size, ChronicleMap<CharSequence, CharSequence> map) {
|
||||
StringBuilder value = new StringBuilder("value");
|
||||
while (value.length() < size)
|
||||
value.append(value.length());
|
||||
@@ -118,5 +118,5 @@ public class WriteThroughputTest {
|
||||
long time = System.nanoTime() - start;
|
||||
System.out.printf("Concurrent %,d MB took %.3f seconds%n", size * count >> 20, time / 1e9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,16 +76,6 @@ public class HashQueryContextExamples {
|
||||
returnValue.returnValue(q.entry().value());
|
||||
}
|
||||
|
||||
interface Point {
|
||||
double getX();
|
||||
void setX(double x);
|
||||
double addX(double xAdd);
|
||||
|
||||
double getY();
|
||||
void setY(double y);
|
||||
double addY(double yAdd);
|
||||
}
|
||||
|
||||
<K> Point movePoint(ChronicleMap<K, Point> map, K key, double xMove, double yMove,
|
||||
Point using) {
|
||||
// Moves existing point by [xMove, yMove], if absent - assumes the default point is [0, 0].
|
||||
@@ -107,4 +97,18 @@ public class HashQueryContextExamples {
|
||||
return offHeapPoint;
|
||||
}
|
||||
}
|
||||
|
||||
interface Point {
|
||||
double getX();
|
||||
|
||||
void setX(double x);
|
||||
|
||||
double addX(double xAdd);
|
||||
|
||||
double getY();
|
||||
|
||||
void setY(double y);
|
||||
|
||||
double addY(double yAdd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
interface MyFloats {
|
||||
@Array(length = 6)
|
||||
public void setValueAt(int index, float f);
|
||||
|
||||
public float getValueAt(int index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by peter.lawrey on 19/12/14.
|
||||
*/
|
||||
@@ -82,7 +89,7 @@ public class LotsOfEntriesMain {
|
||||
else
|
||||
map.getUsing(sb, mf);
|
||||
} catch (Exception e) {
|
||||
System.out.println("map.size: "+map.size());
|
||||
System.out.println("map.size: " + map.size());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -99,10 +106,3 @@ public class LotsOfEntriesMain {
|
||||
map.close();
|
||||
}
|
||||
}
|
||||
|
||||
interface MyFloats {
|
||||
@Array(length = 6)
|
||||
public void setValueAt(int index, float f);
|
||||
|
||||
public float getValueAt(int index);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ public class PointListSerializationTest {
|
||||
EnumMarshallable<AMarshaller> {
|
||||
public static final AMarshaller INSTANCE = new AMarshaller();
|
||||
|
||||
private AMarshaller() {}
|
||||
private AMarshaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Bytes out, @NotNull A toWrite) {
|
||||
|
||||
+27
-25
@@ -29,17 +29,39 @@ import static net.openhft.chronicle.map.example.SimpleMapOperationsListeningTest
|
||||
|
||||
public class SimpleMapOperationsListeningTest {
|
||||
|
||||
@Test
|
||||
public void simpleLoggingTest() {
|
||||
ChronicleMap<Integer, IntValue> map = ChronicleMapBuilder
|
||||
.of(Integer.class, IntValue.class)
|
||||
.entries(100)
|
||||
.entryOperations(simpleLoggingMapEntryOperations())
|
||||
.defaultValueProvider(simpleLoggingDefaultValueProvider())
|
||||
.create();
|
||||
|
||||
IntValue value = Values.newHeapInstance(IntValue.class);
|
||||
value.setValue(2);
|
||||
map.put(1, value);
|
||||
map.remove(1);
|
||||
map.acquireUsing(3, Values.newNativeReference(IntValue.class)).addAtomicValue(1);
|
||||
IntValue value2 = Values.newHeapInstance(IntValue.class);
|
||||
value2.setValue(5);
|
||||
map.forEachEntry(e -> e.context().replaceValue(e, e.context().wrapValueAsData(value2)));
|
||||
map.forEachEntry(e -> e.context().remove(e));
|
||||
|
||||
}
|
||||
|
||||
static class SimpleLoggingMapEntryOperations<K, V> implements MapEntryOperations<K, V, Void> {
|
||||
|
||||
private static final SimpleLoggingMapEntryOperations INSTANCE =
|
||||
new SimpleLoggingMapEntryOperations();
|
||||
|
||||
private SimpleLoggingMapEntryOperations() {
|
||||
}
|
||||
|
||||
public static <K, V> MapEntryOperations<K, V, Void> simpleLoggingMapEntryOperations() {
|
||||
return SimpleLoggingMapEntryOperations.INSTANCE;
|
||||
}
|
||||
|
||||
private SimpleLoggingMapEntryOperations() {}
|
||||
|
||||
@Override
|
||||
public Void remove(@NotNull MapEntry<K, V> entry) {
|
||||
System.out.println("remove " + entry.key() + ": " + entry.value());
|
||||
@@ -67,12 +89,13 @@ public class SimpleMapOperationsListeningTest {
|
||||
private static final SimpleLoggingDefaultValueProvider INSTANCE =
|
||||
new SimpleLoggingDefaultValueProvider();
|
||||
|
||||
private SimpleLoggingDefaultValueProvider() {
|
||||
}
|
||||
|
||||
public static <K, V> DefaultValueProvider<K, V> simpleLoggingDefaultValueProvider() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private SimpleLoggingDefaultValueProvider() {}
|
||||
|
||||
@Override
|
||||
public Data<V> defaultValue(@NotNull MapAbsentEntry<K, V> absentEntry) {
|
||||
Data<V> defaultValue = absentEntry.defaultValue();
|
||||
@@ -80,25 +103,4 @@ public class SimpleMapOperationsListeningTest {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleLoggingTest() {
|
||||
ChronicleMap<Integer, IntValue> map = ChronicleMapBuilder
|
||||
.of(Integer.class, IntValue.class)
|
||||
.entries(100)
|
||||
.entryOperations(simpleLoggingMapEntryOperations())
|
||||
.defaultValueProvider(simpleLoggingDefaultValueProvider())
|
||||
.create();
|
||||
|
||||
IntValue value = Values.newHeapInstance(IntValue.class);
|
||||
value.setValue(2);
|
||||
map.put(1, value);
|
||||
map.remove(1);
|
||||
map.acquireUsing(3, Values.newNativeReference(IntValue.class)).addAtomicValue(1);
|
||||
IntValue value2 = Values.newHeapInstance(IntValue.class);
|
||||
value2.setValue(5);
|
||||
map.forEachEntry(e -> e.context().replaceValue(e, e.context().wrapValueAsData(value2)));
|
||||
map.forEachEntry(e -> e.context().remove(e));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,25 +25,33 @@ public interface BondVOInterface {
|
||||
|
||||
@Group(0)
|
||||
long getEntryLockState();
|
||||
|
||||
void setEntryLockState(long entryLockState);
|
||||
|
||||
@Group(1)
|
||||
long getIssueDate();
|
||||
|
||||
void setIssueDate(long issueDate); /* time in millis */
|
||||
|
||||
@Group(1)
|
||||
long getMaturityDate();
|
||||
|
||||
void setMaturityDate(long maturityDate); /* time in millis */
|
||||
|
||||
long addAtomicMaturityDate(long toAdd);
|
||||
|
||||
@Group(1)
|
||||
boolean compareAndSwapCoupon(double expected, double value);
|
||||
|
||||
double getCoupon();
|
||||
|
||||
void setCoupon(double coupon);
|
||||
|
||||
double addAtomicCoupon(double toAdd);
|
||||
|
||||
@Group(1)
|
||||
String getSymbol();
|
||||
|
||||
void setSymbol(@MaxUtf8Length(20) String symbol);
|
||||
|
||||
// OpenHFT Off-Heap array[ ] processing notice ‘At’ suffix
|
||||
|
||||
+2
-1
@@ -35,7 +35,8 @@ public final class CharSequenceArrayBytesMarshaller
|
||||
|
||||
static final CharSequenceArrayBytesMarshaller INSTANCE = new CharSequenceArrayBytesMarshaller();
|
||||
|
||||
private CharSequenceArrayBytesMarshaller() {}
|
||||
private CharSequenceArrayBytesMarshaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Bytes out, @NotNull CharSequence[] toWrite) {
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class CharSequenceArraySerializationTest {
|
||||
.entries(2)
|
||||
.create()) {
|
||||
map.put("fruits", new CharSequence[]{"banana", "pineapple"});
|
||||
map.put("vegetables", new CharSequence[] {"carrot", "potato"});
|
||||
map.put("vegetables", new CharSequence[]{"carrot", "potato"});
|
||||
Assert.assertEquals(2, map.get("fruits").length);
|
||||
Assert.assertEquals(2, map.get("vegetables").length);
|
||||
}
|
||||
|
||||
+9
-9
@@ -51,6 +51,15 @@ public final class CharSequenceCustomEncodingBytesWriter
|
||||
initTransients();
|
||||
}
|
||||
|
||||
/**
|
||||
* Need this method because {@link CharBuffer#append(CharSequence, int, int)} produces garbage
|
||||
*/
|
||||
private static void append(CharBuffer charBuffer, CharSequence cs, int start, int end) {
|
||||
for (int i = start; i < end; i++) {
|
||||
charBuffer.put(cs.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
charsetEncoder = charset.newEncoder();
|
||||
inputBuffer = CharBuffer.allocate(inputBufferSize);
|
||||
@@ -120,15 +129,6 @@ public final class CharSequenceCustomEncodingBytesWriter
|
||||
out.writeSkip(remaining);
|
||||
}
|
||||
|
||||
/**
|
||||
* Need this method because {@link CharBuffer#append(CharSequence, int, int)} produces garbage
|
||||
*/
|
||||
private static void append(CharBuffer charBuffer, CharSequence cs, int start, int end) {
|
||||
for (int i = start; i < end; i++) {
|
||||
charBuffer.put(cs.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readMarshallable(@NotNull WireIn wireIn) {
|
||||
charset = (Charset) wireIn.read(() -> "charset").object();
|
||||
|
||||
@@ -24,8 +24,6 @@ import org.junit.Test;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class CustomCharSequenceEncodingTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,12 +19,12 @@ package net.openhft.chronicle.map.fromdocs;
|
||||
|
||||
public final class Point {
|
||||
|
||||
double x, y;
|
||||
|
||||
public static Point of(double x, double y) {
|
||||
Point p = new Point();
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
return p;
|
||||
}
|
||||
|
||||
double x, y;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,14 @@ public final class PointListSizedMarshaller
|
||||
ReadResolvable<PointListSizedMarshaller> {
|
||||
|
||||
static final PointListSizedMarshaller INSTANCE = new PointListSizedMarshaller();
|
||||
|
||||
private PointListSizedMarshaller() {}
|
||||
|
||||
/** A point takes 16 bytes in serialized form: 8 bytes for both x and y value */
|
||||
/**
|
||||
* A point takes 16 bytes in serialized form: 8 bytes for both x and y value
|
||||
*/
|
||||
private static final long ELEMENT_SIZE = 16;
|
||||
|
||||
private PointListSizedMarshaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size(@NotNull List<Point> toWrite) {
|
||||
return toWrite.size() * ELEMENT_SIZE;
|
||||
|
||||
-1
@@ -17,7 +17,6 @@
|
||||
|
||||
package net.openhft.chronicle.map.fromdocs.pingpong_latency;
|
||||
|
||||
import net.openhft.chronicle.algo.bytes.Access;
|
||||
import net.openhft.chronicle.algo.locks.AcquisitionStrategies;
|
||||
import net.openhft.chronicle.algo.locks.ReadWriteLockingStrategy;
|
||||
import net.openhft.chronicle.algo.locks.TryAcquireOperations;
|
||||
|
||||
@@ -42,9 +42,9 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
* cause the associated test that generated them to itself Assert.fail (which
|
||||
* JUnit does not otherwise arrange). The rules for creating such
|
||||
* tests are:
|
||||
*
|
||||
* <p>
|
||||
* <ol>
|
||||
*
|
||||
* <p>
|
||||
* <li> All assertions in code running in generated threads must use
|
||||
* the forms {@link #threadFail}, {@link #threadAssertTrue}, {@link
|
||||
* #threadAssertEquals}, or {@link #threadAssertNull}, (not
|
||||
@@ -52,12 +52,12 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
* particularly recommended) for other code to use these forms too.
|
||||
* Only the most typically used JUnit assertion methods are defined
|
||||
* this way, but enough to live with.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li> If you override {@link #setUp} or {@link #tearDown}, make sure
|
||||
* to invoke {@code super.setUp} and {@code super.tearDown} within
|
||||
* them. These methods are used to clear and check for thread
|
||||
* assertion Assert.failures.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li>All delays and timeouts must use one of the constants {@code
|
||||
* SHORT_DELAY_MS}, {@code SMALL_DELAY_MS}, {@code MEDIUM_DELAY_MS},
|
||||
* {@code LONG_DELAY_MS}. The idea here is that a SHORT is always
|
||||
@@ -68,17 +68,17 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
* MEDIUM. And so on. These constants are set to conservative values,
|
||||
* but even so, if there is ever any doubt, they can all be increased
|
||||
* in one spot to rerun tests on slower platforms.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li> All threads generated must be joined inside each test case
|
||||
* method (or {@code Assert.fail} to do so) before returning from the
|
||||
* method. The {@code joinPool} method can be used to do this when
|
||||
* using Executors.</li>
|
||||
*
|
||||
* <p>
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* <p><b>Other notes</b>
|
||||
* <ul>
|
||||
*
|
||||
* <p>
|
||||
* <li> Usually, there is one testcase method per JSR166 method
|
||||
* covering "normal" operation, and then as many exception-testing
|
||||
* methods as there are exceptions the method can throw. Sometimes
|
||||
@@ -86,26 +86,26 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
* "normal" behaviors differ significantly. And sometimes testcases
|
||||
* cover multiple methods when they cannot be tested in
|
||||
* isolation.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li> The documentation style for testcases is to provide as javadoc
|
||||
* a simple sentence or two describing the property that the testcase
|
||||
* method purports to test. The javadocs do not say anything about how
|
||||
* the property is tested. To find out, read the code.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li> These tests are "conformance tests", and do not attempt to
|
||||
* test throughput, latency, scalability or other performance factors
|
||||
* (see the separate "jtreg" tests for a set intended to check these
|
||||
* for the most central aspects of functionality.) So, most tests use
|
||||
* the smallest sensible numbers of threads, collection sizes, etc
|
||||
* needed to check basic conformance.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li>The test classes currently do not declare inclusion in
|
||||
* any particular package to simplify things for people integrating
|
||||
* them in TCK test suites.</li>
|
||||
*
|
||||
* <p>
|
||||
* <li> As a convenience, the {@code main} of this class (JSR166TestCase)
|
||||
* runs all JSR166 unit tests.</li>
|
||||
*
|
||||
* <p>
|
||||
* </ul>
|
||||
*/
|
||||
public class JSR166TestCase {
|
||||
@@ -255,11 +255,11 @@ public class JSR166TestCase {
|
||||
|
||||
/**
|
||||
* Extra checks that get done for all test cases.
|
||||
*
|
||||
* <p>
|
||||
* <p>Triggers test case Assert.failure if any thread assertions have Assert.failed,
|
||||
* by rethrowing, in the test harness thread, any exception recorded
|
||||
* earlier by threadRecordFailure.
|
||||
*
|
||||
* <p>
|
||||
* <p>Triggers test case Assert.failure if interrupt status is set in the main thread.
|
||||
*/
|
||||
@After
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Builder {
|
||||
System.out.println("same");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Jvm.pause(1);
|
||||
if (System.currentTimeMillis() - startTime > timeOutMs)
|
||||
break;
|
||||
|
||||
@@ -33,7 +33,7 @@ import static com.samskivert.util.CollectionUtil.selectRandomSubset;
|
||||
|
||||
public class Issue24ChronicleSetTest {
|
||||
|
||||
public static <K, H extends ChronicleHash<K, ?, ?, ?>, B extends ChronicleHashBuilder<K, H, B>>
|
||||
public static <K, H extends ChronicleHash<K, ?, ?, ?>, B extends ChronicleHashBuilder<K, H, B>>
|
||||
H init(B builder, int entrySize, int averageKeySize) throws IOException {
|
||||
|
||||
File file = File.createTempFile("stringSet", ".dat");
|
||||
@@ -71,20 +71,21 @@ public class Issue24ChronicleSetTest {
|
||||
|
||||
public static class WorkerThread implements Runnable {
|
||||
private final ChronicleSet<String> set;
|
||||
public WorkerThread(ChronicleSet<String> set){
|
||||
|
||||
public WorkerThread(ChronicleSet<String> set) {
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(Thread.currentThread().getName()+" Start. Command = " + set.size());
|
||||
System.out.println(Thread.currentThread().getName() + " Start. Command = " + set.size());
|
||||
processCommand();
|
||||
System.out.println(Thread.currentThread().getName()+" End.");
|
||||
System.out.println(Thread.currentThread().getName() + " End.");
|
||||
}
|
||||
|
||||
private void processCommand() {
|
||||
Set<String> nomenclatures = new HashSet<>();
|
||||
for(int i = 0; i < 10; i++) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String nomenclature = "#############################" + i;
|
||||
nomenclatures.add(nomenclature);
|
||||
|
||||
@@ -119,5 +120,5 @@ public class Issue24ChronicleSetTest {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ public class MovingAverageCompact extends AbstractBytesMarshallable {
|
||||
out.writeDouble(stdDev);
|
||||
}
|
||||
|
||||
|
||||
public double getMovingAverage() {
|
||||
return movingAverage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user