mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Minor API cleanups
This commit is contained in:
+5
-4
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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<B extends 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,15 +64,15 @@ public final class TcpConfig {
|
||||
Collection<InetSocketAddress> 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.<InetSocketAddress>emptyList());
|
||||
return forUnknownTopology(serverPort, Collections.<InetSocketAddress>emptyList());
|
||||
}
|
||||
|
||||
public static TcpConfig unknownTopology(int serverPort,
|
||||
Collection<InetSocketAddress> endpoints) {
|
||||
public static TcpConfig forUnknownTopology(int serverPort,
|
||||
Collection<InetSocketAddress> endpoints) {
|
||||
for (final InetSocketAddress endpoint : endpoints) {
|
||||
if (endpoint.getPort() == serverPort && "localhost".equals(endpoint.getHostName()))
|
||||
throw new IllegalArgumentException("endpoint=" + endpoint
|
||||
|
||||
+2
-2
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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<K, V> implements ChronicleMap<K, V>, Closeable {
|
||||
|
||||
private void checkTimeout(long timeoutTime) {
|
||||
if (timeoutTime < System.currentTimeMillis())
|
||||
throw new TimeoutRuntimeException();
|
||||
throw new RemoteCallTimeoutException();
|
||||
}
|
||||
|
||||
private void writeSizeAndTransactionIdAt(long locationOfSize, final long transactionId) {
|
||||
|
||||
Reference in New Issue
Block a user