Remove double and triple blank lines

This commit is contained in:
Peter Lawrey
2014-11-30 22:43:32 +02:00
parent 6dc1792f19
commit 6d4b143903
83 changed files with 9 additions and 621 deletions
@@ -450,6 +450,5 @@ public interface ChronicleHashBuilder<K, C extends ChronicleHash,
*/
C createPersistedTo(File file) throws IOException;
String name();
}
@@ -18,7 +18,6 @@
package net.openhft.chronicle.hash;
import org.slf4j.LoggerFactory;
public final class ChronicleHashErrorListeners {
@@ -24,7 +24,6 @@ package net.openhft.chronicle.hash;
*/
public class RemoteCallTimeoutException extends RuntimeException {
public RemoteCallTimeoutException(String s) {
super(s);
}
@@ -44,7 +44,6 @@ public abstract class AbstractReplication implements Serializable {
remoteNodeValidator = builder.remoteNodeValidator;
}
@Override
public String toString() {
return ", localIdentifier=" + localIdentifier +
@@ -137,7 +136,6 @@ public abstract class AbstractReplication implements Serializable {
" given");
}
@Override
public String toString() {
return ", udpConfig=" + udpConfig +
@@ -16,7 +16,6 @@
package net.openhft.chronicle.hash.replication;
import net.openhft.chronicle.hash.ChronicleHash;
import net.openhft.chronicle.hash.ChronicleHashInstanceConfig;
import org.jetbrains.annotations.NotNull;
@@ -78,7 +78,6 @@ public final class ReplicationHub extends AbstractReplication {
", channels=" + Arrays.toString(channels) + '}';
}
/**
* Returns the maximum {@linkplain ChronicleHashBuilder#entrySize(int) entry size} of {@link
* ChronicleHash}es, replicated by this {@code ReplicationHub}, could have. {@code RuntimeException} is
@@ -185,7 +184,6 @@ public final class ReplicationHub extends AbstractReplication {
return new ReplicationHub(identifier, this);
}
}
}
@@ -29,7 +29,6 @@ import java.util.concurrent.TimeUnit;
import static java.util.Collections.unmodifiableSet;
import static java.util.concurrent.TimeUnit.SECONDS;
public final class TcpTransportAndNetworkConfig implements Serializable {
private static final int DEFAULT_PACKET_SIZE = 1024 * 8;
@@ -158,7 +157,6 @@ public final class TcpTransportAndNetworkConfig implements Serializable {
heartBeatIntervalUnit);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -18,7 +18,6 @@
package net.openhft.chronicle.hash.replication;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
@@ -37,7 +36,6 @@ public final class ThrottlingConfig implements Serializable {
private final long bucketInterval;
private final TimeUnit bucketIntervalUnit;
ThrottlingConfig(
long throttle,
TimeUnit throttlePerUnit,
@@ -94,7 +92,6 @@ public final class ThrottlingConfig implements Serializable {
throttleBucketInterval, throttleBucketIntervalUnit);
}
/**
* Returns maximum bits per the given time unit, i. e. the throttling. {@code 0} (zero) designates there
* is no throttling.
@@ -106,7 +103,6 @@ public final class ThrottlingConfig implements Serializable {
return throttlePerUnit.convert(throttle, perUnit);
}
/**
* Returns the throttle bucketing interval in the given time units. <p>Default throttle bucketing
* interval is 100 millis.
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.Nullable;
import java.net.InetAddress;
import java.net.NetworkInterface;
public final class UdpTransportConfig {
private final InetAddress address;
private final int port;
@@ -49,7 +48,6 @@ public final class UdpTransportConfig {
this.throttlingConfig = throttlingConfig;
}
public static UdpTransportConfig multiCast(@NotNull InetAddress address, int port,
@NotNull NetworkInterface networkInterface) {
if (!address.isMulticastAddress() || networkInterface == null)
@@ -44,7 +44,6 @@ public final class CharSequenceReader<S extends CharSequence>
private static final CharSequenceReader<String> DEFAULT_READER =
new CharSequenceReader<String>(NoInterning.INSTANCE, NoInterning.INSTANCE);
public static CharSequenceReader<String> of() {
return DEFAULT_READER;
}
@@ -88,7 +88,6 @@ public abstract class CopyingMetaBytesInterop<E, W> implements MetaBytesInterop<
return buffer;
}
public static <E, M extends BytesMarshaller<E>>
MetaBytesInterop<E, M> forBytesMarshaller(Serializable bufferIdentity) {
return new DirectBytesBuffer(bufferIdentity).forBytesMarshaller;
@@ -170,7 +169,6 @@ public abstract class CopyingMetaBytesInterop<E, W> implements MetaBytesInterop<
}
}
private static class DirectBytesBuffer
implements StatefulCopyable<DirectBytesBuffer>, Serializable {
private static final long serialVersionUID = 0L;
@@ -71,7 +71,6 @@ abstract class AbstractChannelReplicator implements Closeable {
@Nullable
private final Throttler throttler;
volatile boolean isClosed = false;
ThreadLocalCopies copies;
VanillaChronicleMap.SegmentState segmentState;
@@ -118,7 +117,6 @@ abstract class AbstractChannelReplicator implements Closeable {
}
}
}
);
return openSelector(result, selectedKeys);
@@ -146,7 +144,6 @@ abstract class AbstractChannelReplicator implements Closeable {
return result;
}
/**
* this is similar to the code in Netty
*
@@ -156,10 +153,8 @@ abstract class AbstractChannelReplicator implements Closeable {
private Selector openSelector(@NotNull final Selector selector,
@NotNull final SelectedSelectionKeySet selectedKeySet) {
try {
Class<?> selectorImplClass =
Class.forName("sun.nio.ch.SelectorImpl", false, getSystemClassLoader());
@@ -171,7 +166,6 @@ abstract class AbstractChannelReplicator implements Closeable {
Field selectedKeysField = selectorImplClass.getDeclaredField("selectedKeys");
Field publicSelectedKeysField = selectorImplClass.getDeclaredField("publicSelectedKeys");
selectedKeysField.setAccessible(true);
publicSelectedKeysField.setAccessible(true);
@@ -234,7 +228,6 @@ abstract class AbstractChannelReplicator implements Closeable {
);
}
@Override
public void close() {
if (Thread.interrupted())
@@ -297,7 +290,6 @@ abstract class AbstractChannelReplicator implements Closeable {
closeables.closeQuietly(channel);
}
void checkThrottleInterval() throws ClosedChannelException {
if (throttler != null)
throttler.checkThrottleInterval();
@@ -372,7 +364,6 @@ abstract class AbstractChannelReplicator implements Closeable {
}
}
/**
* checks the number of bytes written in this interval, if this number of bytes exceeds a
* threshold, the selected will de-register the socket that is being written to, until the
@@ -465,7 +456,6 @@ abstract class AbstractChannelReplicator implements Closeable {
throw new IllegalStateException("entry too large, the entry size=" + entrySize + ", " +
"entries are limited to a size of " + Integer.MAX_VALUE);
int entrySize1 = (int) entrySize;
if (LOG.isDebugEnabled())
LOG.debug("sending entry of entrySize=" + entrySize1);
@@ -511,7 +501,6 @@ abstract class AbstractChannelReplicator implements Closeable {
doConnect(0);
}
/**
* @param reconnectionInterval the period to wait before connecting
*/
@@ -539,7 +528,6 @@ abstract class AbstractChannelReplicator implements Closeable {
AbstractConnector.this.socketChannel = socketChannel;
} catch (Exception e) {
closeQuietly(socketChannel);
LOG.debug("", e);
@@ -561,7 +549,6 @@ abstract class AbstractChannelReplicator implements Closeable {
thread.setDaemon(true);
thread.start();
}
public void setSuccessfullyConnected() {
@@ -569,5 +556,4 @@ abstract class AbstractChannelReplicator implements Closeable {
}
}
}
@@ -107,7 +107,6 @@ abstract class AbstractChronicleMapBuilder<K, V,
private static final Logger LOG =
LoggerFactory.getLogger(AbstractChronicleMapBuilder.class.getName());
SerializationBuilder<K> keyBuilder;
SerializationBuilder<V> valueBuilder;
@@ -157,7 +156,6 @@ abstract class AbstractChronicleMapBuilder<K, V,
return Byteable.class.isAssignableFrom(valueClass);
}
private static long roundUpMapHeaderSize(long headerSize) {
long roundUp = (headerSize + 127L) & ~127L;
if (roundUp - headerSize < 64)
@@ -449,7 +447,6 @@ abstract class AbstractChronicleMapBuilder<K, V,
return segments <= maxSegments ? segments : -segments;
}
int segmentHeaderSize() {
int segments = actualSegments();
// reduce false sharing unless we have a lot of segments.
@@ -617,7 +614,6 @@ abstract class AbstractChronicleMapBuilder<K, V,
return self();
}
/**
* {@inheritDoc}
*
@@ -749,7 +745,6 @@ abstract class AbstractChronicleMapBuilder<K, V,
return new PrepareValueBytesAsWriter<>(prepareValueBytes, valueSize());
}
/**
* Non-public because should be called only after {@link #preMapConstruction(boolean)}
*/
@@ -775,13 +770,11 @@ abstract class AbstractChronicleMapBuilder<K, V,
return self();
}
@Override
public B replication(byte identifier) {
return replication(SingleChronicleHashReplication.builder().createWithId(identifier));
}
@Override
public B replication(byte identifier, TcpTransportAndNetworkConfig tcpTransportAndNetwork) {
return replication(SingleChronicleHashReplication.builder()
@@ -1005,7 +998,6 @@ abstract class AbstractChronicleMapBuilder<K, V,
return this;
}
@Override
public ChronicleMapBuilderI<K, V> bootstrapOnlyLocalEntries(boolean bootstapOnlyLocalEntries) {
this.bootstrapOnlyLocalEntries = bootstapOnlyLocalEntries;
@@ -18,7 +18,6 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.ReplicationHub;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.hash.replication.UdpTransportConfig;
@@ -323,7 +322,6 @@ final class ChannelProvider implements Closeable {
private static ByteBufferBytes toBootstrapMessage(int chronicleChannel, final long lastModificationTime, final byte localIdentifier) {
final ByteBufferBytes writeBuffer = new ByteBufferBytes(ByteBuffer.allocate(1 + 1 + 2 + 8));
writeBuffer.writeByte(BOOTSTRAP_MESSAGE);
writeBuffer.writeByte(localIdentifier);
@@ -411,7 +409,6 @@ final class ChannelProvider implements Closeable {
*/
class SystemQueue {
final Replica asReplica = new Replica() {
@Override
@@ -423,7 +420,6 @@ final class ChannelProvider implements Closeable {
public ModificationIterator acquireModificationIterator(
final byte remoteIdentifier, final ModificationNotifier modificationNotifier) {
final ModificationIterator result = systemModificationIterator.get(remoteIdentifier);
if (result != null)
@@ -187,7 +187,6 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
*/
V acquireUsing(@NotNull K key, V usingValue);
@NotNull
WriteContext<K, V> acquireUsingLocked(@NotNull K key, @NotNull V usingValue);
@@ -228,7 +227,6 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
*/
Future<V> getLater(@NotNull K key);
/**
* Associates the specified value with the specified key in this map (optional operation). If
* the map previously contained a mapping for the key, the old value is replaced by the
@@ -247,7 +245,6 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
*/
Future<V> putLater(@NotNull K key, @NotNull V value);
/**
* Removes the mapping for a key from this map if it is present (optional operation). More
* formally, if this map contains a mapping from key <tt>k</tt> to value <tt>v</tt> such that
@@ -309,6 +306,5 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
*/
void putAll(File fromFile) throws IOException;
}
@@ -76,12 +76,10 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
this.delegate = delegate;
}
private static boolean offHeapReference(Class valueClass) {
return Byteable.class.isAssignableFrom(valueClass);
}
/**
* {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}.
*
@@ -158,14 +156,12 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
@Override
public ChronicleMapBuilder<K, V> keySize(int keySize) {
delegate.keySize(keySize);
return this;
}
@Override
public ChronicleMapBuilder<K, V> constantKeySizeBySample(K sampleKey) {
delegate.constantKeySizeBySample(sampleKey);
@@ -235,7 +231,6 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
/**
* {@inheritDoc}
*
@@ -306,7 +301,6 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
/**
* Configures the marshaller used to serialize actual value sizes to off-heap memory in maps, created by
* this builder.
@@ -335,7 +329,6 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
/**
* each map can be identified by a name
*
@@ -348,7 +341,6 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
@Override
public String name() {
return delegate.name();
@@ -450,7 +442,6 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
@Override
public StatelessClientConfig<ChronicleMap<K, V>> statelessClient(InetSocketAddress remoteAddress) {
return delegate.statelessClient(remoteAddress);
@@ -503,7 +494,6 @@ public final class ChronicleMapBuilder<K, V> implements ChronicleMapBuilderI<K,
return this;
}
@Override
public ChronicleMap<K, V> createPersistedTo(File file) throws IOException {
return delegate.createPersistedTo(file);
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
*/
public interface ChronicleMapBuilderI<K, V> extends Serializable {
/**
* {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}.
*
@@ -58,7 +57,6 @@ public interface ChronicleMapBuilderI<K, V> extends Serializable {
*/
ChronicleMapBuilderI<K, V> entryAndValueAlignment(Alignment alignment);
/**
* {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} configuration to this
* {@code ChronicleMapBuilder}.
@@ -71,7 +69,6 @@ public interface ChronicleMapBuilderI<K, V> extends Serializable {
*/
ChronicleMapBuilderI<K, V> defaultValue(V defaultValue);
/**
* Configures the procedure which is called on the bytes, which later the returned value is pointing to,
* if the key is absent, on {@link ChronicleMap#acquireUsing(Object, Object) acquireUsing()} call on maps,
@@ -90,7 +87,6 @@ public interface ChronicleMapBuilderI<K, V> extends Serializable {
ChronicleMapBuilderI<K, V> prepareValueBytesOnAcquire(
@NotNull PrepareValueBytes<K, V> prepareValueBytes);
/**
* {@inheritDoc}
*
@@ -147,7 +143,6 @@ public interface ChronicleMapBuilderI<K, V> extends Serializable {
* @see #constantKeySizeBySample(Object)
*/
ChronicleMapBuilderI<K, V> constantValueSizeBySample(
@NotNull V sampleValue);
@@ -203,7 +198,6 @@ public interface ChronicleMapBuilderI<K, V> extends Serializable {
ChronicleMapBuilderI<K, V> valueMarshaller(
@NotNull BytesMarshaller<V> valueMarshaller);
/**
* Configures the marshallers, used to serialize/deserialize values to/from off-heap memory in maps,
* created by this builder. See <a href="https://github.com/OpenHFT/Chronicle-Map#serialization">the
@@ -313,5 +307,4 @@ public interface ChronicleMapBuilderI<K, V> extends Serializable {
String name();
}
@@ -31,7 +31,6 @@ final class CloseablesManager implements Closeable {
private final List<Closeable> closeables = new ArrayList<>();
public synchronized void add(Closeable closeable) {
if (closeable == null)
@@ -79,7 +78,6 @@ final class CloseablesManager implements Closeable {
}
}
public synchronized boolean isEmpty() {
return closeables.isEmpty();
}
@@ -22,5 +22,4 @@ public interface Function<T, R> extends Serializable {
*/
R apply(T t);
}
@@ -250,7 +250,6 @@ class Int24Int24MultiMap implements MultiMap {
bytes.writeInt48(prevPos, entry(searchHash, newValue));
}
@Override
public void putAfterFailedSearch(long value) {
checkValueForPut(value);
@@ -18,7 +18,6 @@
package net.openhft.chronicle.map;
import net.openhft.lang.Maths;
import net.openhft.lang.collection.ATSDirectBitSet;
import net.openhft.lang.collection.DirectBitSet;
import net.openhft.lang.io.Bytes;
@@ -251,7 +250,6 @@ class IntIntMultiMap implements MultiMap {
bytes.writeLong(prevPos, entry(searchHash, newValue));
}
@Override
public void putAfterFailedSearch(long value) {
checkValueForPut(value);
@@ -75,12 +75,10 @@ public class NodeDiscovery {
}
private final DiscoveryNodeBytesMarshallable discoveryNodeBytesMarshallable;
private final AtomicReference<NodeDiscoveryEventListener> nodeDiscoveryEventListenerAtomicReference =
new AtomicReference<NodeDiscoveryEventListener>();
private KnownNodes knownNodes;
public NodeDiscovery() throws IOException {
@@ -105,7 +103,6 @@ public class NodeDiscovery {
discoveryNodeBytesMarshallable.setModificationNotifier(nodeDiscoveryBroadcaster);
}
public synchronized ReplicationHubFindByName mapByName() throws
IOException, InterruptedException {
@@ -150,7 +147,6 @@ public class NodeDiscovery {
countDownLatch.get().countDown();
}
};
nodeDiscoveryEventListenerAtomicReference.set(nodeDiscoveryEventListener);
@@ -220,7 +216,6 @@ public class NodeDiscovery {
break;
}
// we should make a local copy as this may change
final RemoteNodeValidator remoteNodeValidator = new RemoteNodeValidator() {
@@ -253,7 +248,6 @@ public class NodeDiscovery {
LOG.info("Using Remote identifier=" + identifier);
nodeDiscoveryEventListenerAtomicReference.set(null);
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8123, new
InetSocketAddress("192.168.1.253", 8123));
@@ -286,7 +280,6 @@ public class NodeDiscovery {
return addresses;
}
/**
* bitwise OR's the two bit sets or put another way, merges the source bitset into the destination bitset
* and returns the destination
@@ -311,12 +304,10 @@ public class NodeDiscovery {
return destination;
}
static byte proposeRandomUnusedIdentifier(final DirectBitSet knownIdentifiers,
boolean isFirstTime) throws UnknownHostException {
byte possible;
// the first time, rather than choosing a random number, we will choose the last value of the IP
// address as our random number, ( or at least something that is based upon it)
if (isFirstTime) {
@@ -463,7 +454,6 @@ class NodeDiscoveryBroadcaster extends UdpChannelReplicator {
externalizable.readMarshallable(out);
}
}
static class UdpSocketChannelEntryWriter implements EntryWriter {
@@ -487,7 +477,6 @@ class NodeDiscoveryBroadcaster extends UdpChannelReplicator {
in = new ByteBufferBytes(out);
}
/**
* @param socketChannel the socketChannel that we will write to
* @throws InterruptedException
@@ -526,7 +515,6 @@ class NodeDiscoveryBroadcaster extends UdpChannelReplicator {
}
class KnownNodes implements BytesMarshallable {
private Bytes activeIdentifiersBitSetBytes;
@@ -540,7 +528,6 @@ class KnownNodes implements BytesMarshallable {
this.atsDirectBitSet = new ATSDirectBitSet(this.activeIdentifiersBitSetBytes);
}
public Set<AddressAndPort> addressAndPorts() {
return addressAndPorts;
}
@@ -559,7 +546,6 @@ class KnownNodes implements BytesMarshallable {
return atsDirectBitSet;
}
@Override
public void readMarshallable(@net.openhft.lang.model.constraints.NotNull Bytes in) throws IllegalStateException {
short size = in.readShort();
@@ -606,7 +592,6 @@ class KnownNodes implements BytesMarshallable {
}
}
class AddressAndPort implements Comparable<AddressAndPort>, BytesMarshallable {
private byte[] address;
private short port;
@@ -656,7 +641,6 @@ class AddressAndPort implements Comparable<AddressAndPort>, BytesMarshallable {
return result;
}
@Override
public int compareTo(AddressAndPort o) {
int i = 0;
@@ -668,7 +652,6 @@ class AddressAndPort implements Comparable<AddressAndPort>, BytesMarshallable {
return Short.compare(port, o.port);
}
@Override
public String toString() {
return "{" +
@@ -696,10 +679,8 @@ class AddressAndPort implements Comparable<AddressAndPort>, BytesMarshallable {
return sb.toString();
}
@Override
public void readMarshallable(@net.openhft.lang.model.constraints.NotNull Bytes in) throws IllegalStateException {
short len = in.readShort();
@@ -722,7 +703,6 @@ class AddressAndPort implements Comparable<AddressAndPort>, BytesMarshallable {
}
}
class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
private AddressAndPort sourceAddressAndPort = new AddressAndPort();
@@ -788,7 +768,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
proposedIdentifiersWithHost.writeMarshallable(out);
}
private boolean writeBootstrap(Bytes out) {
@@ -838,7 +817,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
}
}
@Override
public void readMarshallable(@net.openhft.lang.model.constraints.NotNull Bytes in) throws IllegalStateException {
@@ -863,7 +841,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
return;
}
// the host and port the message came from
this.sourceAddressAndPort.readMarshallable(in);
if (sourceAddressAndPort.equals(ourAddressAndPort))
@@ -879,7 +856,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
listener.onRemoteNodeEvent(remoteNode, proposedIdentifiersWithHost);
}
public void onChange() {
if (modificationNotifier != null)
modificationNotifier.onChange();
@@ -906,7 +882,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
this.timestamp = System.currentTimeMillis();
}
AddressAndPort addressAndPort() {
return addressAndPort;
}
@@ -957,7 +932,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
}
}
/**
* sends a bootstrap message to the other nodes in the grid, the bootstrap message contains the host:port
* and perhaps even proposed identifier of the node that sent it.
@@ -970,7 +944,6 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
onChange();
}
}
interface NodeDiscoveryEventListener {
@@ -1061,7 +1034,6 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
});
}
// this is used for expiry
private final Queue<Map.Entry<K, W<V>>> queue = new ConcurrentLinkedQueue<Map.Entry<K, W<V>>>();
@@ -1069,7 +1041,6 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
return map.values();
}
void expireEntries(long timeOlderThan) {
for (; ; ) {
@@ -1087,7 +1058,6 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
}
}
public static void main(String... args) {
String ip;
try {
@@ -1110,7 +1080,6 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
}
}
/**
* private NetworkInterface defaultNetworkInterface() throws SocketException { NetworkInterface
* networkInterface = null
@@ -1154,7 +1123,6 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
inetAddress = inetAddresses.nextElement();
}
if (inetAddress == null)
throw new IllegalStateException();
@@ -153,22 +153,17 @@ final class OffHeapUpdatableChronicleMapBuilder<K, V>
throw new UnsupportedOperationException("not supported for this combination of key/value type");
}
public ChronicleMapBuilderI<K, V> valueMarshallers(@NotNull BytesWriter<V> valueWriter, @NotNull BytesReader<V> valueReader) {
throw new UnsupportedOperationException("not supported for this combination of key/value type");
}
public ChronicleMapBuilderI<K, V> valueSizeMarshaller(@NotNull SizeMarshaller valueSizeMarshaller) {
throw new UnsupportedOperationException("not supported for this combination of key/value type");
}
@Override
public OffHeapUpdatableChronicleMapBuilder<K, V> constantValueSizeBySample(V sampleValue) {
throw new UnsupportedOperationException("not supported for this combination of key/value type");
}
}
@@ -31,7 +31,6 @@ import org.jetbrains.annotations.NotNull;
import java.io.Externalizable;
import java.io.Serializable;
/**
* {@code ChronicleMapOnHeapUpdatableBuilder} is intended to be used to configure {@link ChronicleMap}s with
* non-{@link Byteable} values, which don't point to off-heap memory directly, including primitives ({@link
@@ -276,10 +275,8 @@ final class OnHeapUpdatableChronicleMapBuilder<K, V>
throw new UnsupportedOperationException("not supported for this combination of key/value type");
}
public OnHeapUpdatableChronicleMapBuilder<K, V> entryAndValueAlignment(Alignment a) {
throw new UnsupportedOperationException("not supported for this combination of key/value type");
}
}
@@ -23,7 +23,6 @@ import net.openhft.lang.threadlocal.Provider;
import net.openhft.lang.threadlocal.ThreadLocalCopies;
import org.jetbrains.annotations.Nullable;
final class ReaderWithSize<T> {
private final SizeMarshaller sizeMarshaller;
private final BytesReader<T> originalReader;
@@ -68,7 +68,6 @@ interface Replica extends Closeable {
*/
long lastModificationTime(byte remoteIdentifier);
/**
* notifies when there is a changed to the modification iterator
*/
@@ -85,7 +84,6 @@ interface Replica extends Closeable {
void onChange();
}
/**
* Holds a record of which entries have modification. Each remote map supported will require a
* corresponding ModificationIterator instance
@@ -119,7 +117,6 @@ interface Replica extends Closeable {
void dirtyEntries(long fromTimeStamp);
}
/**
* supports reading and writing serialize entries
*/
@@ -151,7 +148,6 @@ interface Replica extends Closeable {
}
/**
* provides a key and value from NativeBytes, this can be used in conjunction with the modification
* iterator to get the key and value out of the NativeBytes
@@ -167,7 +163,6 @@ interface Replica extends Closeable {
*/
K key(@NotNull Bytes entry, K usingKey);
/**
* gets the value from the entry
*
@@ -18,7 +18,6 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.TimeProvider;
import net.openhft.chronicle.hash.serialization.BytesInterop;
import net.openhft.chronicle.hash.serialization.BytesReader;
@@ -37,7 +36,8 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -166,7 +166,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
identifierUpdatedBytes.writeLong(offset, timestamp);
}
@Override
public long lastModificationTime(byte remoteIdentifier) {
assert remoteIdentifier != this.identifier();
@@ -393,13 +392,11 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
final long keySize = keySizeMarshaller.readSize(entry);
final long keyPosition = entry.position();
entry.skip(keySize);
final long keyLimit = entry.position();
final long timeStamp = entry.readLong();
final byte identifier = entry.readByte();
if (identifier != localIdentifier) {
// although unlikely, this may occur if the entry has been updated
@@ -420,7 +417,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
valueSizeMarshaller.writeSize(destination, valueSize);
destination.writeStopBit(timeStamp);
destination.writeByte(identifier);
destination.writeBoolean(isDeleted);
@@ -472,7 +468,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
final long valueSize = valueSizeMarshaller.readSize(source);
final long timeStamp = source.readStopBit();
final byte id = source.readByte();
final boolean isDeleted = source.readBoolean();
@@ -534,7 +529,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
LOG.debug(message + "value=" + source.toString().trim() + ")");
}
}
@Override
@@ -696,7 +690,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
incrementSize();
hashLookup.putPosition(pos);
entry.position(valueSizePos);
long valueSize = readValueSize(entry);
long valuePos = entry.position();
@@ -22,7 +22,6 @@ import net.openhft.chronicle.hash.ChronicleHashInstanceConfig;
import net.openhft.chronicle.hash.FindByName;
import net.openhft.chronicle.hash.replication.ReplicationChannel;
import net.openhft.chronicle.hash.replication.ReplicationHub;
import net.openhft.lang.io.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,7 +46,6 @@ class ReplicationHubFindByName<K> implements FindByName {
private final Map<String, ChronicleMapBuilderWithChannelId> map;
private final ReplicationHub replicationHub;
public static class ChronicleMapBuilderWithChannelId<K, V> implements Serializable {
ChronicleHashBuilder<K, ChronicleMap<K, V>, ?> chronicleMapBuilder;
int channelId;
@@ -58,7 +56,6 @@ class ReplicationHubFindByName<K> implements FindByName {
*/
public ReplicationHubFindByName(ReplicationHub replicationHub) throws IOException {
LOG.info("connecting to replicationHub=" + replicationHub);
this.replicationHub = replicationHub;
@@ -92,7 +89,6 @@ class ReplicationHubFindByName<K> implements FindByName {
}
};
this.map = (Map) of(CharSequence.class, ChronicleMapBuilderWithChannelId.class)
@@ -106,7 +102,6 @@ class ReplicationHubFindByName<K> implements FindByName {
LOG.debug("map=" + map);
}
public <T extends ChronicleHash> T create(ChronicleMapBuilder<CharSequence, CharSequence> builder) throws IllegalArgumentException,
IOException, TimeoutException, InterruptedException {
@@ -122,13 +117,11 @@ class ReplicationHubFindByName<K> implements FindByName {
}
public <T extends ChronicleHash> T from(String name) throws IllegalArgumentException,
IOException, TimeoutException, InterruptedException {
return (T) replicatedViaChannel(name).create();
}
ChronicleMapBuilderWithChannelId get(String name) throws IllegalArgumentException,
TimeoutException,
InterruptedException {
@@ -140,7 +133,6 @@ class ReplicationHubFindByName<K> implements FindByName {
return chronicleMapBuilder;
}
/**
* * waits until map1 and map2 show the same value
*
@@ -160,7 +152,6 @@ class ReplicationHubFindByName<K> implements FindByName {
}
private ChronicleHashInstanceConfig replicatedViaChannel(String name) throws TimeoutException, InterruptedException {
ChronicleMapBuilderWithChannelId builder = get(name);
return toReplicatedViaChannel(builder.chronicleMapBuilder, builder.channelId);
@@ -196,5 +187,4 @@ class ReplicationHubFindByName<K> implements FindByName {
return builder.instance().replicatedViaChannel(replicationHub.createChannel((short) withChannelId));
}
}
@@ -18,7 +18,6 @@
package net.openhft.chronicle.map;
import net.openhft.lang.io.NativeBytes;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -47,5 +46,4 @@ interface SharedSegment<K, V> {
long offsetFromPos(long pos);
}
@@ -18,7 +18,6 @@
package net.openhft.chronicle.map;
import net.openhft.lang.collection.ATSDirectBitSet;
import net.openhft.lang.collection.DirectBitSet;
import net.openhft.lang.io.Bytes;
@@ -91,7 +90,6 @@ class ShortShortMultiMap implements MultiMap {
assert positions.isSet(value) : "Shouldn't remove absent value";
}
private static long maskUnsetKey(long key) {
return (key &= MASK) != UNSET_KEY ? key : HASH_INSTEAD_OF_UNSET_KEY;
}
@@ -51,7 +51,6 @@ import static net.openhft.chronicle.map.StatelessChronicleMap.EventId.*;
*/
class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Cloneable {
public static final String START_OF = "Attempt to write ";
private static final Logger LOG = LoggerFactory.getLogger(StatelessChronicleMap.class);
public static final byte STATELESS_CLIENT_IDENTIFIER = (byte) -127;
@@ -80,7 +79,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
private ExecutorService executorService;
static enum EventId {
HEARTBEAT,
STATEFUL_UPDATE,
@@ -136,7 +134,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
bytes = new ByteBufferBytes(buffer.slice());
}
@Override
public Future<V> getLater(@NotNull final K key) {
return lazyExecutorService().submit(new Callable<V>() {
@@ -181,7 +178,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
throw new UnsupportedOperationException();
}
private ExecutorService lazyExecutorService() {
if (executorService == null) {
@@ -196,7 +192,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return executorService;
}
private SocketChannel lazyConnect(final long timeoutMs,
final InetSocketAddress remoteAddress) throws IOException {
@@ -219,7 +214,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
result.connect(config.remoteAddress());
result.socket().setTcpNoDelay(true);
doHandShaking(result);
break;
} catch (IOException e) {
@@ -234,7 +228,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return result;
}
/**
* attempts a single connect without a timeout and eat any IOException used typically in the
* constructor, its possible the server is not running with this instance is created, {@link
@@ -265,7 +258,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
/**
* closes the existing connections and establishes a new closeables
*/
@@ -278,7 +270,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
closeables = new CloseablesManager();
}
/**
* initiates a very simple level of handshaking with the remote server, we send a special ID of
* -127 ( when the server receives this it knows its dealing with a stateless client, receive
@@ -348,7 +339,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return transactionID;
}
public synchronized V putIfAbsent(K key, V value) {
if (key == null || value == null)
throw new NullPointerException();
@@ -358,7 +348,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return readValue(sizeLocation, copies);
}
public synchronized boolean remove(Object key, Object value) {
if (key == null)
throw new NullPointerException();
@@ -373,7 +362,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return blockingFetch(sizeLocation).readBoolean();
}
public synchronized boolean replace(K key, V oldValue, V newValue) {
if (key == null || oldValue == null || newValue == null)
throw new NullPointerException();
@@ -387,7 +375,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return blockingFetch(sizeLocation).readBoolean();
}
public synchronized V replace(K key, V value) {
if (key == null || value == null)
throw new NullPointerException();
@@ -400,12 +387,10 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return readValue(sizeLocation, copies);
}
public synchronized int size() {
return (int) longSize();
}
/**
* calling this method should be avoided at all cost, as the entire {@code object} is
* serialized. This equals can be used to compare map that extends ChronicleMap. So two
@@ -435,7 +420,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
@Override
public synchronized int hashCode() {
return blockingFetch(writeEventAnSkip(HASH_CODE)).readInt();
@@ -446,12 +430,10 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
.class);
}
public synchronized boolean isEmpty() {
return blockingFetch(writeEventAnSkip(IS_EMPTY)).readBoolean();
}
public synchronized boolean containsKey(Object key) {
if (key == null)
throw keyNotNullNPE();
@@ -467,7 +449,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return new NullPointerException("key can not be null");
}
public synchronized boolean containsValue(Object value) {
if (value == null)
throw new NullPointerException();
@@ -478,12 +459,10 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return blockingFetch(sizeLocation).readBoolean();
}
public synchronized long longSize() {
return blockingFetch(writeEventAnSkip(LONG_SIZE)).readLong();
}
public synchronized V get(Object key) {
final long sizeLocation = writeEventAnSkip(GET);
ThreadLocalCopies copies = writeKey((K) key);
@@ -498,7 +477,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
"clients");
}
public synchronized V acquireUsing(@NotNull K key, V usingValue) {
throw new UnsupportedOperationException("acquireUsing() is not supported for stateless " +
"clients");
@@ -517,7 +495,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
throw new UnsupportedOperationException();
}
public synchronized V remove(Object key) {
if (key == null)
@@ -525,7 +502,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
final long sizeLocation = removeReturnsNull ? writeEvent(REMOVE_WITHOUT_ACC) : writeEventAnSkip(REMOVE);
ThreadLocalCopies copies = writeKey((K) key);
if (removeReturnsNull) {
@@ -536,7 +512,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return readValue(sizeLocation, copies);
}
public synchronized V put(K key, V value) {
if (key == null || value == null)
throw new NullPointerException();
@@ -555,7 +530,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
public synchronized <R> R mapForKey(K key, @NotNull Function<? super V, R> function) {
final long sizeLocation = writeEventAnSkip(MAP_FOR_KEY);
writeKey(key);
@@ -575,7 +549,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return (R) reader.readObject();
}
private synchronized <R> void writeObject(@NotNull Object function) {
long start = bytes.position();
for (; ; ) {
@@ -597,7 +570,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
}
public synchronized void putAll(Map<? extends K, ? extends V> map) {
final long sizeLocation = putReturnsNull ? writeEvent(PUT_ALL_WITHOUT_ACC) :
@@ -612,7 +584,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
private synchronized void sendWithoutAcc(final Bytes bytes, long sizeLocation) {
writeSizeAt(sizeLocation);
long timeoutTime = config.timeoutMs() + System.currentTimeMillis();
@@ -637,7 +608,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
}
private synchronized void writeEntriesForPutAll(Map<? extends K, ? extends V> map) {
final int numberOfEntries = map.size();
@@ -665,7 +635,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
// as the volume of data could cause us to have to resize our buffers
resizeIfRequired(numberOfEntries, numberOfEntriesReadSoFar, start);
final Class<?> keyClass = key.getClass();
if (!kClass.isAssignableFrom(keyClass)) {
throw new ClassCastException("key=" + key + " is of type=" + keyClass + " " +
@@ -675,14 +644,12 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
writeKeyInLoop(key, keyWriter, copies);
final Class<?> valueClass = value.getClass();
if (!vClass.isAssignableFrom(valueClass))
throw new ClassCastException("value=" + value + " is of type=" + valueClass +
" and " +
"should be of type=" + vClass);
writeValueInLoop(value, valueWriter, copies);
final int len = (int) (bytes.position() - start);
@@ -714,7 +681,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return (long) ((double) bytes.position() / percentageComplete);
}
private void resizeBuffer(int size, long start) {
if (LOG.isDebugEnabled())
@@ -755,14 +721,12 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
bytes.position(start);
}
public synchronized void clear() {
// get the data back from the server
blockingFetch(writeEventAnSkip(CLEAR));
}
@NotNull
public Collection<V> values() {
final long sizeLocation = writeEventAnSkip(VALUES);
@@ -797,7 +761,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return result;
}
@NotNull
public synchronized Set<Map.Entry<K, V>> entrySet() {
final long sizeLocation = writeEventAnSkip(ENTRY_SET);
@@ -835,7 +798,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
in = blockingFetchReadOnly(timeoutTime, transactionId);
}
return result.entrySet();
}
@@ -848,7 +810,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
}
@NotNull
public synchronized Set<K> keySet() {
final long sizeLocation = writeEventAnSkip(KEY_SET);
@@ -888,15 +849,12 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
buffer.clear();
bytes.clear();
bytes.write((byte) event.ordinal());
long sizeLocation = markSizeLocation();
return sizeLocation;
}
/**
* skips for the transactionid
*
@@ -912,7 +870,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return sizeLocation;
}
class Entry implements Map.Entry<K, V> {
final K key;
@@ -982,7 +939,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
private Bytes blockingFetch0(long sizeLocation, final long transactionId, long startTime) {
try {
@@ -997,7 +953,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
private Bytes blockingFetchThrowable(long sizeLocation, long timeOutMs, final long transactionId, final long startTime) throws IOException {
final long timeoutTime = startTime + timeOutMs;
@@ -1043,7 +998,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
private Bytes blockingFetch(long timeoutTime, long transactionId) throws IOException {
// the number of bytes in the response
@@ -1095,7 +1049,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
return bytes;
}
private Bytes receive(int requiredNumberOfBytes, long timeoutTime) throws IOException {
while (bytes.buffer().position() < requiredNumberOfBytes) {
@@ -1128,7 +1081,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
buffer.clear();
}
private void checkTimeout(long timeoutTime) {
if (timeoutTime < System.currentTimeMillis())
throw new RemoteCallTimeoutException();
@@ -1143,20 +1095,17 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
bytes.position(pos);
}
private void writeSizeAt(long locationOfSize) {
final long size = bytes.position() - locationOfSize;
bytes.writeInt(locationOfSize, (int) size - SIZE_OF_SIZE);
}
private long markSizeLocation() {
final long position = bytes.position();
bytes.skip(SIZE_OF_SIZE);
return position;
}
private ThreadLocalCopies writeKey(K key) {
return writeKey(key, null);
}
@@ -1221,7 +1170,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
}
private ThreadLocalCopies writeValueInLoop(V value, Object writer, ThreadLocalCopies copies) {
long start = bytes.position();
for (; ; ) {
@@ -173,7 +173,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
final SelectionKey[] keys = selectedKeys.flip();
try {
for (int i = 0; i < keys.length && keys[i] != null; i++) {
final SelectionKey key = keys[i];
@@ -289,7 +288,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
return selector.select(selectorTimeout);
}
/**
* checks that we receive heartbeats and send out heart beats.
*
@@ -411,7 +409,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
closeEarlyAndQuietly(key.channel());
}
/**
* called when the selector receives a OP_CONNECT message
*/
@@ -491,7 +488,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
closeables.add(channel);
}
channel.configureBlocking(false);
channel.socket().setReuseAddress(true);
channel.socket().setTcpNoDelay(true);
@@ -542,7 +538,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
if (attached.remoteIdentifier == Byte.MIN_VALUE) {
final byte remoteIdentifier = reader.identifierFromBuffer();
if (remoteIdentifier == STATELESS_CLIENT) {
@@ -584,7 +579,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
LOG.debug("handshaking for localIdentifier=" + localIdentifier + "," +
"remoteIdentifier=" + remoteIdentifier);
attached.remoteModificationIterator = replica.acquireModificationIterator(remoteIdentifier,
attached);
@@ -791,7 +785,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
SelectableChannel doConnect() throws
IOException, InterruptedException {
final ServerSocketChannel serverChannel = openServerSocketChannel();
serverChannel.socket().setReceiveBufferSize(BUFFER_SIZE);
@@ -805,7 +798,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
closeables.add(serverSocket);
}
serverSocket.setReuseAddress(true);
serverSocket.bind(details.address());
@@ -840,7 +832,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
this.details = details;
}
@Override
public String toString() {
return "ClientConnector{" + details + '}';
@@ -909,7 +900,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
}
}
}
/**
@@ -954,7 +944,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
TcpReplicator.this.opWriteUpdater.set(remoteIdentifier);
}
}
/**
@@ -984,7 +973,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
uncompletedWork = null;
}
/**
* writes the timestamp into the buffer
*
@@ -1062,7 +1050,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
int size = (int) in.position();
out.limit(size);
final int len = socketChannel.write(out);
if (LOG.isDebugEnabled())
@@ -1099,7 +1086,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
in.writeLong(localHeartbeatInterval);
}
/**
* removes back in the OP_WRITE from the selector, otherwise it'll spin loop. The OP_WRITE
* will get added back in as soon as we have data to write
@@ -1126,7 +1112,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
}
}
public boolean doWork() {
return uncompletedWork.doWork(in);
}
@@ -1147,7 +1132,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
private long sizeInBytes;
private byte state;
private TcpSocketChannelEntryReader() {
in = ByteBuffer.allocateDirect(replicationConfig.packetSize() + maxEntrySizeBytes);
out = new ByteBufferBytes(in.slice());
@@ -1155,7 +1139,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
in.clear();
}
void resizeBuffer(long size) {
assert size < Integer.MAX_VALUE;
@@ -1165,7 +1148,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
final ByteBuffer buffer = ByteBuffer.allocateDirect((int) size).order(ByteOrder.nativeOrder());
final int inPosition = in.position();
long outPosition = out.position();
@@ -1293,7 +1275,6 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
}
/**
* compacts the buffer and updates the {@code in} and {@code out} accordingly
*/
@@ -1351,7 +1332,6 @@ class StatelessServerConnector<K, V> {
public static final int SIZE_OF_IS_EXCEPTION = 1;
public static final int HEADER_SIZE = SIZE_OF_SIZE + SIZE_OF_IS_EXCEPTION + SIZE_OF_TRANSACTION_ID;
private final ReaderWithSize<K> keyReaderWithSize;
private final WriterWithSize<K> keyWriterWithSize;
private final ReaderWithSize<V> valueReaderWithSize;
@@ -1359,7 +1339,6 @@ class StatelessServerConnector<K, V> {
private final VanillaChronicleMap<K, ?, ?, V, ?, ?> map;
private double maxEntrySizeBytes;
StatelessServerConnector(
SerializationBuilder<K> keySerializationBuilder,
SerializationBuilder<V> valueSerializationBuilder,
@@ -1377,7 +1356,6 @@ class StatelessServerConnector<K, V> {
@NotNull final Bytes writer,
@NotNull final ByteBufferBytes reader) {
final StatelessChronicleMap.EventId event = VALUES[eventId];
// these methods don't return a result
@@ -1405,7 +1383,6 @@ class StatelessServerConnector<K, V> {
final long sizeLocation = reflectTransactionId(reader, writer);
// these methods return a result
switch (event) {
@@ -1468,7 +1445,6 @@ class StatelessServerConnector<K, V> {
}
public Work mapForKey(ByteBufferBytes reader, Bytes writer, long sizeLocation) {
final K key = keyReaderWithSize.read(reader, null);
final Function<V, ?> function = (Function<V, ?>) reader.readObject();
@@ -1538,7 +1514,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work longSize(Bytes reader, Bytes writer, final long sizeLocation) {
try {
@@ -1550,7 +1525,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work hashCode(Bytes reader, Bytes writer, final long sizeLocation) {
try {
@@ -1563,7 +1537,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work toString(Bytes reader, Bytes writer, final long sizeLocation) {
final String str;
@@ -1587,7 +1560,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work sendException(Bytes writer, long sizeLocation, Throwable e) {
// move the position to ignore any bytes written so far
@@ -1599,7 +1571,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work isEmpty(Bytes reader, Bytes writer, final long sizeLocation) {
try {
@@ -1657,7 +1628,6 @@ class StatelessServerConnector<K, V> {
}
private Work put(Bytes reader) {
if (MAP_SUPPORTS_BYTES) {
map.put(reader);
@@ -1701,7 +1671,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work remove(Bytes reader, Bytes writer, final long sizeLocation) {
try {
if (MAP_SUPPORTS_BYTES) {
@@ -1746,7 +1715,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work clear(Bytes reader, Bytes writer, final long sizeLocation) {
try {
@@ -1759,7 +1727,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work values(Bytes reader, Bytes writer) {
final long transactionId = reader.readLong();
@@ -1895,7 +1862,6 @@ class StatelessServerConnector<K, V> {
valueWriterWithSize.writeInLoop(out, next.getValue(), valueWriter, copies);
}
writeHeader(out, sizeLocation, count, false);
return true;
}
@@ -1903,7 +1869,6 @@ class StatelessServerConnector<K, V> {
};
}
private Work putIfAbsent(Bytes reader, Bytes writer, final long sizeLocation) {
try {
if (MAP_SUPPORTS_BYTES) {
@@ -1922,7 +1887,6 @@ class StatelessServerConnector<K, V> {
return null;
}
private Work replace(Bytes reader, Bytes writer, final long sizeLocation) {
try {
if (MAP_SUPPORTS_BYTES) {
@@ -1976,13 +1940,11 @@ class StatelessServerConnector<K, V> {
return result;
}
private Work sendException(Bytes reader, Bytes writer, Throwable e) {
final long sizeLocation = reflectTransactionId(reader, writer);
return sendException(writer, sizeLocation, e);
}
private long header(Bytes writer, final long transactionId) {
final long sizeLocation = writer.position();
@@ -2023,4 +1985,3 @@ class StatelessServerConnector<K, V> {
}
@@ -39,7 +39,6 @@ import static java.net.StandardSocketOptions.SO_REUSEADDR;
import static java.nio.channels.SelectionKey.OP_READ;
import static java.nio.channels.SelectionKey.OP_WRITE;
/**
* The UdpReplicator attempts to read the data ( but it does not enforce or grantee delivery ),
* typically, you should use the UdpReplicator if you have a large number of nodes, and you wish to
@@ -85,7 +84,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica.
serverConnector = new ServerConnector();
}
void setWriter(EntryWriter writer) {
this.writer = writer;
}
@@ -169,7 +167,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica.
}
}
private DatagramChannel connectClient() throws IOException {
final DatagramChannel client = address.isMulticastAddress() ?
DatagramChannel.open(address.getAddress().length == 4 ? INET : INET6) :
@@ -240,7 +237,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica.
}
}
private class ServerConnector extends AbstractConnector {
private final InetSocketAddress socketAddress;
@@ -293,12 +289,10 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica.
return server;
}
}
}
interface EntryReader {
void readAll(@NotNull final DatagramChannel socketChannel) throws IOException, InterruptedException;
}
@@ -307,5 +301,3 @@ interface EntryWriter {
int writeAll(@NotNull final DatagramChannel socketChannel) throws InterruptedException, IOException;
}
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
/**
* The UdpReplicator attempts to read the data ( but it does not enforce or grantee delivery ), typically, you
* should use the UdpReplicator if you have a large number of nodes, and you wish to receive the data before
@@ -178,10 +177,5 @@ final class UdpReplicator extends UdpChannelReplicator implements Replica.Modifi
}
}
}
@@ -493,7 +493,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
segmentHash, replaceIfPresent, readValue, resultUnused);
}
enum LockType {READ_LOCK, WRITE_LOCK}
@Override
@@ -698,7 +697,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
private XStreamConverter xStreamConverter;
/**
@@ -709,7 +707,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
(xStreamConverter = new XStreamConverter());
}
private class XStreamConverter {
private Bytes buffer;
@@ -849,7 +846,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
}
@NotNull
@Override
public final WriteContext<K, V> acquireUsingLocked(@NotNull K key, @NotNull V usingValue) {
@@ -975,7 +971,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
key, keySizeMarshaller.readSize(key));
}
private <KB, KBI, MKBI extends MetaBytesInterop<KB, ? super KBI>>
boolean containsKey(ThreadLocalCopies copies,
MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize) {
@@ -1170,7 +1165,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
readValueToLazyBytes, false);
}
private <KB, KBI, MKBI extends MetaBytesInterop<KB, ? super KBI>,
RV, VB extends RV, VBI, MVBI extends MetaBytesInterop<? super VB, ? super VBI>>
Object remove(ThreadLocalCopies copies, SegmentState segmentState,
@@ -1496,7 +1490,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
assert booleanResult || expectedValue == null;
}
// these methods should be package local, not public or private.
class Segment implements SharedSegment {
/*
@@ -1564,7 +1557,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
return index;
}
/* Methods with private access modifier considered private to Segment
* class, although Java allows to access them from outer class anyway.
*/
@@ -2437,7 +2429,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
return new WriteThroughEntry(key, value);
}
boolean isDeleted(long pos) {
return false;
}
@@ -29,7 +29,6 @@ public interface WriteContext<K, V> extends Context<K, V> {
*/
void dontPutOnClose();
/**
* this is simular by more efficient than calling map.remove("key") as the entry is already available to
* the WriteContext
@@ -22,7 +22,6 @@ import net.openhft.chronicle.hash.serialization.internal.MetaBytesWriter;
import net.openhft.chronicle.hash.serialization.internal.MetaProvider;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.threadlocal.Provider;
import net.openhft.lang.threadlocal.StatefulCopyable;
import net.openhft.lang.threadlocal.ThreadLocalCopies;
import org.jetbrains.annotations.Nullable;
@@ -41,8 +40,6 @@ final class WriterWithSize<T> {
metaWriterProvider = serializationBuilder.metaInteropProvider();
}
ThreadLocalCopies getCopies(ThreadLocalCopies copies) {
copies = writerProvider.getCopies(copies);
return metaWriterProvider.getCopies(copies);
@@ -319,6 +319,5 @@ public class ChronicleSetBuilder<E>
return this;
}
}