diff --git a/src/main/java/net/openhft/chronicle/hash/exceptions/TimeoutRuntimeException.java b/src/main/java/net/openhft/chronicle/hash/RemoteCallTimeoutException.java similarity index 76% rename from src/main/java/net/openhft/chronicle/hash/exceptions/TimeoutRuntimeException.java rename to src/main/java/net/openhft/chronicle/hash/RemoteCallTimeoutException.java index 477e5b56e..eedb9a276 100644 --- a/src/main/java/net/openhft/chronicle/hash/exceptions/TimeoutRuntimeException.java +++ b/src/main/java/net/openhft/chronicle/hash/RemoteCallTimeoutException.java @@ -16,19 +16,20 @@ * limitations under the License. */ -package net.openhft.chronicle.hash.exceptions; +package net.openhft.chronicle.hash; /** + * TODO mention in docs * @author Rob Austin. */ -public class TimeoutRuntimeException extends RuntimeException { +public class RemoteCallTimeoutException extends RuntimeException { - public TimeoutRuntimeException(String s) { + public RemoteCallTimeoutException(String s) { super(s); } - public TimeoutRuntimeException() { + public RemoteCallTimeoutException() { super(); } } diff --git a/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java b/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java index ac269165b..53bc4f538 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java @@ -19,14 +19,14 @@ package net.openhft.chronicle.hash.replication; import org.jetbrains.annotations.Nullable; class AbstractReplication { - protected final byte localIdentifier; - protected final UdpConfig udpConfig; - protected final TcpConfig tcpConfig; + private final byte localIdentifier; + private final TcpConfig tcpConfig; + private final UdpConfig udpConfig; AbstractReplication(byte localIdentifier, Builder builder) { - udpConfig = builder.udpConfig; this.localIdentifier = localIdentifier; tcpConfig = builder.tcpConfig; + udpConfig = builder.udpConfig; } public byte identifier() { @@ -44,8 +44,8 @@ class AbstractReplication { } static abstract class Builder { - protected UdpConfig udpConfig = null; - protected TcpConfig tcpConfig = null; + private TcpConfig tcpConfig = null; + private UdpConfig udpConfig = null; public B tcpTransportAndNetwork(TcpConfig tcpConfig) { this.tcpConfig = tcpConfig; diff --git a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java index 6c833c8f1..6b75785a6 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/ReplicationHub.java @@ -62,6 +62,16 @@ public final class ReplicationHub extends AbstractReplication { private Builder() {} + @Override + public Builder tcpTransportAndNetwork(TcpConfig tcpConfig) { + return super.tcpTransportAndNetwork(tcpConfig); + } + + @Override + public Builder udpTransport(UdpConfig udpConfig) { + return super.udpTransport(udpConfig); + } + public Builder maxEntrySize(int maxEntrySize) { this.maxEntrySize = maxEntrySize; return this; diff --git a/src/main/java/net/openhft/chronicle/hash/replication/SimpleReplication.java b/src/main/java/net/openhft/chronicle/hash/replication/SimpleReplication.java index 0f716083f..b32dbda8a 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/SimpleReplication.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/SimpleReplication.java @@ -34,5 +34,15 @@ public final class SimpleReplication extends AbstractReplication { check(); return new SimpleReplication(identifier, this); } + + @Override + public Builder tcpTransportAndNetwork(TcpConfig tcpConfig) { + return super.tcpTransportAndNetwork(tcpConfig); + } + + @Override + public Builder udpTransport(UdpConfig udpConfig) { + return super.udpTransport(udpConfig); + } } } diff --git a/src/main/java/net/openhft/chronicle/hash/replication/TcpConfig.java b/src/main/java/net/openhft/chronicle/hash/replication/TcpConfig.java index 66332f21e..97f97de26 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/TcpConfig.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/TcpConfig.java @@ -64,15 +64,15 @@ public final class TcpConfig { Collection endpoints) { if (endpoints.isEmpty()) throw new IllegalArgumentException("There should be some endpoints"); - return unknownTopology(serverPort, endpoints); + return forUnknownTopology(serverPort, endpoints); } public static TcpConfig forReceivingOnlyNode(int serverPort) { - return unknownTopology(serverPort, Collections.emptyList()); + return forUnknownTopology(serverPort, Collections.emptyList()); } - public static TcpConfig unknownTopology(int serverPort, - Collection endpoints) { + public static TcpConfig forUnknownTopology(int serverPort, + Collection endpoints) { for (final InetSocketAddress endpoint : endpoints) { if (endpoint.getPort() == serverPort && "localhost".equals(endpoint.getHostName())) throw new IllegalArgumentException("endpoint=" + endpoint diff --git a/src/main/java/net/openhft/chronicle/hash/exceptions/IORuntimeException.java b/src/main/java/net/openhft/chronicle/map/IORuntimeException.java similarity index 88% rename from src/main/java/net/openhft/chronicle/hash/exceptions/IORuntimeException.java rename to src/main/java/net/openhft/chronicle/map/IORuntimeException.java index 48fafd020..e58603bd8 100644 --- a/src/main/java/net/openhft/chronicle/hash/exceptions/IORuntimeException.java +++ b/src/main/java/net/openhft/chronicle/map/IORuntimeException.java @@ -16,14 +16,14 @@ * limitations under the License. */ -package net.openhft.chronicle.hash.exceptions; +package net.openhft.chronicle.map; import java.io.IOException; /** * @author Rob Austin. */ -public class IORuntimeException extends RuntimeException{ +class IORuntimeException extends RuntimeException{ public IORuntimeException(IOException e) { super(e); diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java index 97eca2983..10b2954c2 100644 --- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java +++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java @@ -222,7 +222,7 @@ public class NodeDiscovery { knownNodes.add(ourAddressAndPort, identifier); final TcpConfig tcpConfig = TcpConfig - .unknownTopology(ourAddressAndPort.getPort(), + .forUnknownTopology(ourAddressAndPort.getPort(), toInetSocketCollection(knownHostPorts)) .heartBeatInterval(1, SECONDS) .nonUniqueIdentifierListener(identifierListener); diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index 77784449a..38eee0456 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -19,8 +19,7 @@ package net.openhft.chronicle.map; import com.sun.jdi.connect.spi.ClosedConnectionException; -import net.openhft.chronicle.hash.exceptions.IORuntimeException; -import net.openhft.chronicle.hash.exceptions.TimeoutRuntimeException; +import net.openhft.chronicle.hash.RemoteCallTimeoutException; import net.openhft.lang.io.ByteBufferBytes; import net.openhft.lang.io.Bytes; import net.openhft.lang.threadlocal.ThreadLocalCopies; @@ -942,7 +941,7 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { private void checkTimeout(long timeoutTime) { if (timeoutTime < System.currentTimeMillis()) - throw new TimeoutRuntimeException(); + throw new RemoteCallTimeoutException(); } private void writeSizeAndTransactionIdAt(long locationOfSize, final long transactionId) { diff --git a/src/test/java/net/openhft/chronicle/map/Builder.java b/src/test/java/net/openhft/chronicle/map/Builder.java index 41db8cced..8b5fd4afd 100644 --- a/src/test/java/net/openhft/chronicle/map/Builder.java +++ b/src/test/java/net/openhft/chronicle/map/Builder.java @@ -72,7 +72,7 @@ public class Builder { final byte identifier, final int serverPort, final InetSocketAddress... endpoints) throws IOException { - TcpConfig tcpConfig = TcpConfig.unknownTopology(serverPort, Arrays.asList(endpoints)) + TcpConfig tcpConfig = TcpConfig.forUnknownTopology(serverPort, Arrays.asList(endpoints)) .heartBeatInterval(1L, TimeUnit.SECONDS); return ChronicleMapBuilder.of(kClass, vClass) .replication(identifier, tcpConfig); diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest3wayPutReturnsNull.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest3wayPutReturnsNull.java index 98636a26b..cbe2fb665 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest3wayPutReturnsNull.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest3wayPutReturnsNull.java @@ -48,7 +48,7 @@ public class TCPSocketReplicationTest3wayPutReturnsNull { final byte identifier, final int serverPort, final InetSocketAddress... endpoints) throws IOException { - TcpConfig tcpConfig = TcpConfig.unknownTopology(serverPort, Arrays.asList(endpoints)); + TcpConfig tcpConfig = TcpConfig.forUnknownTopology(serverPort, Arrays.asList(endpoints)); return (T) ChronicleMapBuilder.of(Integer.class, CharSequence.class) .putReturnsNull(true) diff --git a/src/test/java/net/openhft/chronicle/set/SetForTCPSocketReplicationTest3way.java b/src/test/java/net/openhft/chronicle/set/SetForTCPSocketReplicationTest3way.java index 89325d86e..c7d7864ee 100644 --- a/src/test/java/net/openhft/chronicle/set/SetForTCPSocketReplicationTest3way.java +++ b/src/test/java/net/openhft/chronicle/set/SetForTCPSocketReplicationTest3way.java @@ -26,7 +26,6 @@ import org.junit.Test; import java.io.Closeable; import java.io.IOException; import java.net.InetSocketAddress; -import java.util.Arrays; import static java.util.Arrays.asList; import static java.util.concurrent.TimeUnit.SECONDS; @@ -53,7 +52,7 @@ public class SetForTCPSocketReplicationTest3way { final int serverPort, final InetSocketAddress... endpoints) throws IOException { return (T) ChronicleSetBuilder.of(Integer.class) - .replication(identifier, TcpConfig.unknownTopology(serverPort, asList(endpoints)) + .replication(identifier, TcpConfig.forUnknownTopology(serverPort, asList(endpoints)) .heartBeatInterval(1L, SECONDS)) .createPersistedTo(getPersistenceFile()); }