mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Merge branch '2.1' of github.com:OpenHFT/Chronicle-Map into 2.1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@ package net.openhft.chronicle.map;
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.model.constraints.MaxSize;
|
||||
import net.openhft.lang.values.IntValue;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -51,6 +50,8 @@ public class DemoChronicleMapTest {
|
||||
assertNotNull(v);
|
||||
}
|
||||
}
|
||||
|
||||
file.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,6 +94,7 @@ public class DemoChronicleMapTest {
|
||||
assertNotNull(v);
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,17 +190,26 @@ public class EntryCountMapTest {
|
||||
Random random = new Random(seed);
|
||||
int counter = minSize + random.nextInt(9999 + maxSize);
|
||||
final int stride = 1 + random.nextInt(100);
|
||||
int maxKeySize = "key:".length() +
|
||||
final int maxKeySize = "key:".length() +
|
||||
(int) round(log10(moreThanMaxSize(maxSize) * stride + counter)) + 1;
|
||||
final ChronicleMap<CharSequence, LongValue> map =
|
||||
getSharedMap(minSize, segments, maxKeySize);
|
||||
|
||||
|
||||
return es.submit(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
testEntriesMaxSize0(segments, minSize, maxSize, seed, stride, map);
|
||||
return null;
|
||||
File f = null;
|
||||
try (final ChronicleMap<CharSequence, LongValue> map =
|
||||
getSharedMap(minSize, segments, maxKeySize)) {
|
||||
f = map.file();
|
||||
testEntriesMaxSize0(segments, minSize, maxSize, seed, stride, map);
|
||||
} finally {
|
||||
if (f != null && f.exists())
|
||||
f.delete();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void testEntriesMaxSize(int segments, int minSize, int maxSize, int seed) throws IOException {
|
||||
@@ -210,8 +219,12 @@ public class EntryCountMapTest {
|
||||
int stride = 1 + random.nextInt(100);
|
||||
int maxKeySize = "key:".length() +
|
||||
(int) round(log10(moreThanMaxSize(maxSize) * stride + counter)) + 1;
|
||||
ChronicleMap<CharSequence, LongValue> map = getSharedMap(minSize, segments, maxKeySize);
|
||||
testEntriesMaxSize0(segments, minSize, maxSize, counter, stride, map);
|
||||
File file;
|
||||
try (ChronicleMap<CharSequence, LongValue> map = getSharedMap(minSize, segments, maxKeySize)) {
|
||||
file = map.file();
|
||||
testEntriesMaxSize0(segments, minSize, maxSize, counter, stride, map);
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
|
||||
void testEntriesMaxSize0(int segments, int minSize, int maxSize, int counter, int stride,
|
||||
|
||||
@@ -41,7 +41,6 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class LargeEntriesTest {
|
||||
|
||||
@Ignore("Issues with TC")
|
||||
@Test
|
||||
public void testLargeStrings() throws ExecutionException, InterruptedException, IOException {
|
||||
final int ENTRIES = 250;
|
||||
@@ -49,7 +48,7 @@ public class LargeEntriesTest {
|
||||
|
||||
File file = File.createTempFile("largeEntries" + System.currentTimeMillis(), ".deleteme");
|
||||
file.deleteOnExit();
|
||||
final ChronicleMap<String, String> map = ChronicleMapBuilder
|
||||
try (final ChronicleMap<String, String> map = ChronicleMapBuilder
|
||||
.of(String.class, String.class)
|
||||
.valueMarshaller(SnappyStringMarshaller.INSTANCE)
|
||||
.actualSegments(1) // to force an error.
|
||||
@@ -57,37 +56,38 @@ public class LargeEntriesTest {
|
||||
.averageKeySize(10)
|
||||
.averageValueSize(ENTRY_SIZE)
|
||||
.putReturnsNull(true)
|
||||
.createPersistedTo(file);
|
||||
{
|
||||
warmUpCompression(ENTRY_SIZE);
|
||||
int threads = 4; //Runtime.getRuntime().availableProcessors();
|
||||
ExecutorService es = Executors.newFixedThreadPool(threads);
|
||||
final int block = ENTRIES / threads;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
long start = System.currentTimeMillis();
|
||||
List<Future<?>> futureList = new ArrayList<>();
|
||||
for (int t = 0; t < threads; t++) {
|
||||
final int finalT = t;
|
||||
futureList.add(es.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
exerciseLargeStrings(map, finalT * block, finalT * block + block,
|
||||
ENTRY_SIZE);
|
||||
}
|
||||
}));
|
||||
.createPersistedTo(file)) {
|
||||
{
|
||||
warmUpCompression(ENTRY_SIZE);
|
||||
int threads = 4; //Runtime.getRuntime().availableProcessors();
|
||||
ExecutorService es = Executors.newFixedThreadPool(threads);
|
||||
final int block = ENTRIES / threads;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
long start = System.currentTimeMillis();
|
||||
List<Future<?>> futureList = new ArrayList<>();
|
||||
for (int t = 0; t < threads; t++) {
|
||||
final int finalT = t;
|
||||
futureList.add(es.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
exerciseLargeStrings(map, finalT * block, finalT * block + block,
|
||||
ENTRY_SIZE);
|
||||
}
|
||||
}));
|
||||
}
|
||||
for (Future<?> future : futureList) {
|
||||
future.get();
|
||||
}
|
||||
long time = System.currentTimeMillis() - start;
|
||||
long operations = 3;
|
||||
System.out.printf("Put/Get rate was %.1f MB/s%n",
|
||||
operations * ENTRIES * ENTRY_SIZE / 1e6 / (time / 1e3));
|
||||
}
|
||||
for (Future<?> future : futureList) {
|
||||
future.get();
|
||||
}
|
||||
long time = System.currentTimeMillis() - start;
|
||||
long operations = 3;
|
||||
System.out.printf("Put/Get rate was %.1f MB/s%n",
|
||||
operations * ENTRIES * ENTRY_SIZE / 1e6 / (time / 1e3));
|
||||
es.shutdown();
|
||||
|
||||
}
|
||||
es.shutdown();
|
||||
if (es.isTerminated())
|
||||
map.close();
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
|
||||
private void warmUpCompression(int entrySize) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.openhft.lang.io.ByteBufferBytes;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -151,8 +150,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO ignore why?
|
||||
@Ignore
|
||||
|
||||
@Test(timeout = 10000)
|
||||
public void testBufferOverFlowPutAllAndEntrySet() throws IOException, InterruptedException {
|
||||
int port = s_port++;
|
||||
|
||||
@@ -55,8 +55,9 @@ public class TCPSocketReplicationBootStrapTest {
|
||||
ChronicleMapBuilder<Integer, CharSequence> map2aBuilder =
|
||||
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
|
||||
(byte) 2, 8092, new InetSocketAddress("localhost", 8091));
|
||||
File persistenceFile = getPersistenceFile();
|
||||
final ChronicleMap<Integer, CharSequence> map2a =
|
||||
map2aBuilder.createPersistedTo(getPersistenceFile());
|
||||
map2aBuilder.createPersistedTo(persistenceFile);
|
||||
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2
|
||||
|
||||
long lastModificationTime;
|
||||
@@ -85,6 +86,9 @@ public class TCPSocketReplicationBootStrapTest {
|
||||
// add data into it
|
||||
waitTillEqual(5000);
|
||||
assertEquals("ADDED WHEN DISCONNECTED TO MAP1", map1.get(11));
|
||||
|
||||
map2.file().delete();
|
||||
persistenceFile.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.IntValue;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.Closeable;
|
||||
@@ -34,7 +33,6 @@ import java.nio.ByteBuffer;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static net.openhft.chronicle.map.Builder.newTcpSocketShmBuilder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -59,7 +57,7 @@ public class TCPSocketReplicationIntValueTest {
|
||||
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
|
||||
map1Builder = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
(byte) 1, s_port, new InetSocketAddress("localhost", s_port + 1));
|
||||
map1 = map1Builder.createPersistedTo(getPersistenceFile());
|
||||
map1 = map1Builder.create();
|
||||
map2 = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
(byte) 2, s_port + 1)
|
||||
.entries(Builder.SIZE)
|
||||
@@ -72,7 +70,9 @@ public class TCPSocketReplicationIntValueTest {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{map1, map2}) {
|
||||
try {
|
||||
|
||||
closeable.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -39,12 +38,6 @@ public class TimeBasedReplicationTest extends JSR166TestCase {
|
||||
|
||||
public static final byte IDENTIFIER = 1;
|
||||
|
||||
private static File getPersistenceFile() {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
File file = new File(TMP + "/chm-test" + System.nanoTime());
|
||||
file.deleteOnExit();
|
||||
return file;
|
||||
}
|
||||
|
||||
Set<Thread> threads;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class UDPSocketReplicationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Ignore("just used for manual testing")
|
||||
public void testBufferOverflow() throws IOException, InterruptedException {
|
||||
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
|
||||
@@ -111,12 +111,6 @@ public class MapCheck {
|
||||
serTest(size);
|
||||
}
|
||||
|
||||
private static File getPersistenceFile() {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
File file = new File(TMP + "/chm-test" + System.nanoTime());
|
||||
file.deleteOnExit();
|
||||
return file;
|
||||
}
|
||||
|
||||
static Map newMap() {
|
||||
try {
|
||||
|
||||
@@ -308,7 +308,7 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
static int s_port = 11050;
|
||||
|
||||
@Test(timeout = 30000)
|
||||
@Ignore
|
||||
@Ignore("performance test")
|
||||
public void testByteArrayPerf() throws IOException {
|
||||
ByteBuffer key = ByteBuffer.allocate(8);
|
||||
ByteBuffer value = ByteBuffer.allocate(50);
|
||||
|
||||
Reference in New Issue
Block a user