now using smaller default entry sizes for the tests

This commit is contained in:
Rob Austin
2015-04-30 09:55:30 +01:00
parent d6fa74f869
commit 26ff97a841
3 changed files with 28 additions and 9 deletions
@@ -1,6 +1,7 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.hash.ChronicleHashInstanceBuilder;
import net.openhft.chronicle.hash.function.SerializableFunction;
import net.openhft.chronicle.wire.TextWire;
import net.openhft.chronicle.wire.Wire;
@@ -16,6 +17,8 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static net.openhft.chronicle.map.ChronicleMapBuilder.of;
/**
* Created by Rob Austin
*/
@@ -34,10 +37,19 @@ public class EngineMap<K, V> implements ChronicleMap<K, V> {
Class<K> kClass,
Class<V> vClass,
MapWireConnectionHub mapWireConnectionHub,
Class<? extends Wire> wireType) throws IOException {
Class<? extends Wire> wireType,
long entries) throws IOException {
this.mapWireConnectionHub = mapWireConnectionHub;
this.wireType = wireType;
final BytesChronicleMap b = this.mapWireConnectionHub.acquireMap(name);
// todo - for the moment we will default to 100 entries per map, but this is for engine to
// todo decided later.
final ChronicleHashInstanceBuilder instance
= of(byte[].class, byte[].class).entries(entries).instance();
final BytesChronicleMap b = this.mapWireConnectionHub.acquireMap(name, instance);
this.map = (Map) b.delegate;
this.vClass = vClass;
this.kClass = kClass;
@@ -74,6 +74,7 @@ public class MapWireConnectionHub implements Closeable {
}
return (short) (max + 1);
}
/**
@@ -81,12 +82,12 @@ public class MapWireConnectionHub implements Closeable {
* channel
*
* @param fromName the name of the channel
* @param builder
* @return the id associated with this name
*/
BytesChronicleMap acquireMap(@NotNull final String fromName) throws IOException {
// todo this is a horrible hack, it slow and NOT processor safe, but was added to get
// todo something working for now.
BytesChronicleMap acquireMap(@NotNull final String fromName,
@NotNull final ChronicleHashInstanceBuilder builder)
throws IOException {
final Integer channelId = channelNameToId.get(fromName);
@@ -96,12 +97,14 @@ public class MapWireConnectionHub implements Closeable {
final int nextFreeChannel = getNextFreeChannel();
try {
mapFactory.get().replicatedViaChannel(hub.createChannel(nextFreeChannel)).create();
builder.replicatedViaChannel(hub.createChannel(nextFreeChannel)).create();
channelNameToId.put(fromName, nextFreeChannel);
return bytesMap(nextFreeChannel);
} catch (IOException e) {
// todo send this error back to the user
// todo send this error back to the user in wire
LOG.error("", e);
throw e;
}
@@ -48,6 +48,7 @@ import static net.openhft.chronicle.engine.client.ClientWiredStatelessTcpConnect
import static net.openhft.chronicle.engine.client.ClientWiredStatelessTcpConnectionHub.CoreFields.csp;
import static net.openhft.chronicle.engine.client.ClientWiredStatelessTcpConnectionHub.CoreFields.reply;
import static net.openhft.chronicle.engine.client.StringUtils.endsWith;
import static net.openhft.chronicle.map.ChronicleMapBuilder.*;
import static net.openhft.chronicle.map.MapWireHandler.EventId.*;
import static net.openhft.chronicle.map.MapWireHandler.Params.*;
import static net.openhft.chronicle.wire.Wires.acquireStringBuilder;
@@ -96,7 +97,10 @@ public class MapWireHandler<K, V> implements WireHandler, Consumer<WireHandlers>
hash != -1 && hash < (cspText.length() - 1)) {
final String channelStr = cspText.substring(slash + 1, hash);
try {
bytesChronicleMap = mapWireConnectionHub.acquireMap(channelStr);
// todo better get the number of entries
bytesChronicleMap = mapWireConnectionHub.acquireMap(channelStr,
of(byte[].class, byte[].class).entries(1000).instance());
} catch (IOException e) {
// todo send to user