mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
now using smaller default entry sizes for the tests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user