Merge remote-tracking branch 'origin/master'

This commit is contained in:
danielshaya
2015-04-24 16:54:01 +01:00
5 changed files with 21 additions and 32 deletions
@@ -40,6 +40,7 @@ import static java.util.Collections.emptyList;
import static net.openhft.chronicle.engine.client.ClientWiredStatelessTcpConnectionHub.CoreFields.reply;
import static net.openhft.chronicle.map.MapWireHandler.EventId;
import static net.openhft.chronicle.map.MapWireHandler.EventId.*;
import static net.openhft.chronicle.map.VanillaChronicleMap.newInstance;
/**
@@ -51,24 +52,19 @@ class ClientWiredStatelessChronicleMap<K, V> extends MapStatelessClient<K, V, Ev
private static final Logger LOG =
LoggerFactory.getLogger(ClientWiredStatelessChronicleMap.class);
public static final Consumer<ValueOut> VOID_PARAMETERS = out -> out.marshallable(AbstactStatelessClient.EMPTY);
private final Class vClass;
protected Class<K> kClass;
private boolean putReturnsNull;
private boolean removeReturnsNull;
// used with toString()
private static final int MAX_NUM_ENTRIES = 20;
public ClientWiredStatelessChronicleMap(
@NotNull final ClientWiredChronicleMapStatelessBuilder config,
@NotNull final Class kClass,
@NotNull final Class vClass,
@NotNull final String channelName,
ClientWiredStatelessTcpConnectionHub hub) {
@NotNull final ClientWiredStatelessTcpConnectionHub hub) {
super(channelName, hub, "MAP", 0, vClass);
this.putReturnsNull = config.putReturnsNull();
@@ -96,12 +92,12 @@ class ClientWiredStatelessChronicleMap<K, V> extends MapStatelessClient<K, V, Ev
@Override
public V newValueInstance() {
return (V) VanillaChronicleMap.newInstance(vClass, false);
return (V) newInstance(vClass, false);
}
@Override
public K newKeyInstance() {
return VanillaChronicleMap.newInstance(kClass, true);
return newInstance(kClass, true);
}
@Override
@@ -210,8 +206,7 @@ class ClientWiredStatelessChronicleMap<K, V> extends MapStatelessClient<K, V, Ev
@NotNull
public String toString() {
return "";
return "todo";
}
@NotNull
@@ -224,7 +219,7 @@ class ClientWiredStatelessChronicleMap<K, V> extends MapStatelessClient<K, V, Ev
}
public boolean containsKey(Object key) {
return proxyReturnBoolean(containsKey, out -> writeField(out, (K) key));
return proxyReturnBoolean(containsKey, out -> out.object(out));
}
@NotNull
@@ -233,7 +228,7 @@ class ClientWiredStatelessChronicleMap<K, V> extends MapStatelessClient<K, V, Ev
}
public boolean containsValue(Object value) {
return proxyReturnBoolean(containsValue, out -> writeField(out, (V) value));
return proxyReturnBoolean(containsValue, out -> out.object(out));
}
public void putAll(@NotNull Map<? extends K, ? extends V> map) {
@@ -3,6 +3,7 @@ package net.openhft.chronicle.map;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.hash.function.SerializableFunction;
import net.openhft.chronicle.wire.TextWire;
import net.openhft.chronicle.wire.ValueOut;
import net.openhft.chronicle.wire.Wire;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
@@ -80,7 +81,7 @@ public class EngineMap<K, V> implements ChronicleMap<K, V> {
if (b == null)
return null;
final Wire wire = toWire();
AbstactStatelessClient.writeField(b, wire.getValueOut());
((ValueOut) b).object(b);
wire.bytes().flip();
return toWire().getValueIn().bytes();
@@ -160,13 +161,12 @@ public class EngineMap<K, V> implements ChronicleMap<K, V> {
return null;
final Wire wire = toWire(bytes);
buffer.flip();
return AbstactStatelessClient.readObject(wire.getValueIn(), null, eClass);
return wire.getValueIn().object(eClass);
}
@Override
public V put(final K key, final V value) {
nullCheck(key);
// nullCheck(value);
return toObject(vClass, () -> map.put(bytes(key), bytes(value)));
}
@@ -286,12 +286,9 @@ public class FilePerKeyMap implements Map<String, String> {
}
}
private boolean isProgrammaticUpdate(File file){
if(lastModifiedByProgram.containsKey(file)){
return file.lastModified() == lastModifiedByProgram.get(file) ? true : false;
}else{
return false;
}
private boolean isProgrammaticUpdate(File file) {
return lastModifiedByProgram.containsKey(file)
&& (file.lastModified() == lastModifiedByProgram.get(file));
}
}
@@ -57,7 +57,7 @@ public abstract class MapStatelessClient<K, V, E extends ParameterizeWireKey>
@NotNull final E eventId, Object field) {
final long startTime = System.currentTimeMillis();
final long tid = sendEvent(startTime, eventId, out -> writeField(out, field));
final long tid = sendEvent(startTime, eventId, out -> out.object(out));
if (eventReturnsNull(eventId))
return null;
@@ -897,16 +897,13 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
serverSocket.bind(details.address());
// these can be run on this thread
addPendingRegistration(new Runnable() {
@Override
public void run() {
final Attached attached = new Attached();
attached.connector = ServerConnector.this;
try {
serverChannel.register(TcpReplicator.this.selector, OP_ACCEPT, attached);
} catch (ClosedChannelException e) {
LOG.debug("", e);
}
addPendingRegistration(() -> {
final Attached attached = new Attached();
attached.connector = ServerConnector.this;
try {
serverChannel.register(TcpReplicator.this.selector, OP_ACCEPT, attached);
} catch (ClosedChannelException e) {
LOG.debug("", e);
}
});