mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
CE-145 Review exception handling in Wire
This commit is contained in:
@@ -50,7 +50,7 @@ final class Replicators {
|
||||
protected Closeable applyTo(@NotNull final ChronicleMapBuilder builder,
|
||||
@NotNull final Replica replica,
|
||||
@NotNull final EntryExternalizable entryExternalizable,
|
||||
final ChronicleMap chronicleMap) throws IOException {
|
||||
final ChronicleMap chronicleMap) {
|
||||
|
||||
replication.engineReplicator().set(replica);
|
||||
|
||||
@@ -65,6 +65,47 @@ final class Replicators {
|
||||
};
|
||||
}
|
||||
|
||||
static Replicator tcp(final AbstractReplication replication) {
|
||||
return new Replicator() {
|
||||
|
||||
|
||||
@Override
|
||||
protected Closeable applyTo(@NotNull final ChronicleMapBuilder builder,
|
||||
@NotNull final Replica replica,
|
||||
@NotNull final EntryExternalizable entryExternalizable,
|
||||
final ChronicleMap chronicleMap) throws IOException {
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig = replication.tcpTransportAndNetwork();
|
||||
|
||||
StatelessClientParameters statelessClientParameters =
|
||||
new StatelessClientParameters(
|
||||
(VanillaChronicleMap) chronicleMap,
|
||||
builder.keyBuilder,
|
||||
builder.valueBuilder);
|
||||
|
||||
return new TcpReplicator(replica, entryExternalizable,
|
||||
tcpConfig,
|
||||
replication.remoteNodeValidator(),
|
||||
statelessClientParameters,
|
||||
replication.connectionListener());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static Replicator udp(
|
||||
final UdpTransportConfig replicationConfig) {
|
||||
return new Replicator() {
|
||||
@Override
|
||||
protected Closeable applyTo(@NotNull final ChronicleMapBuilder builder,
|
||||
@NotNull final Replica map,
|
||||
@NotNull final EntryExternalizable entryExternalizable,
|
||||
final ChronicleMap chronicleMap) throws IOException {
|
||||
return new UdpReplicator(map, entryExternalizable, replicationConfig
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static class OutBuffer implements BufferResizer {
|
||||
|
||||
@NotNull
|
||||
@@ -73,6 +114,11 @@ final class Replicators {
|
||||
@NotNull
|
||||
private ByteBuffer out;
|
||||
|
||||
OutBuffer(final int tcpBufferSize) {
|
||||
out = ByteBuffer.allocateDirect(tcpBufferSize);
|
||||
in = new ByteBufferBytes(out);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ByteBufferBytes in() {
|
||||
return in;
|
||||
@@ -83,12 +129,6 @@ final class Replicators {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
OutBuffer(final int tcpBufferSize) {
|
||||
out = ByteBuffer.allocateDirect(tcpBufferSize);
|
||||
in = new ByteBufferBytes(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bytes resizeBuffer(int newCapacity) {
|
||||
|
||||
@@ -128,46 +168,4 @@ final class Replicators {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static Replicator tcp(final AbstractReplication replication) {
|
||||
return new Replicator() {
|
||||
|
||||
|
||||
@Override
|
||||
protected Closeable applyTo(@NotNull final ChronicleMapBuilder builder,
|
||||
@NotNull final Replica replica,
|
||||
@NotNull final EntryExternalizable entryExternalizable,
|
||||
final ChronicleMap chronicleMap) throws IOException {
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig = replication.tcpTransportAndNetwork();
|
||||
|
||||
StatelessClientParameters statelessClientParameters =
|
||||
new StatelessClientParameters(
|
||||
(VanillaChronicleMap) chronicleMap,
|
||||
builder.keyBuilder,
|
||||
builder.valueBuilder);
|
||||
|
||||
return new TcpReplicator(replica, entryExternalizable,
|
||||
tcpConfig,
|
||||
replication.remoteNodeValidator(),
|
||||
statelessClientParameters,
|
||||
replication.connectionListener());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static Replicator udp(
|
||||
final UdpTransportConfig replicationConfig) {
|
||||
return new Replicator() {
|
||||
@Override
|
||||
protected Closeable applyTo(@NotNull final ChronicleMapBuilder builder,
|
||||
@NotNull final Replica map,
|
||||
@NotNull final EntryExternalizable entryExternalizable,
|
||||
final ChronicleMap chronicleMap)
|
||||
throws IOException {
|
||||
return new UdpReplicator(map, entryExternalizable, replicationConfig
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user