HCOLL-246 Fixed - Tcp Replication fails with large values or entries sizes that don't included internal replication bytes"

This commit is contained in:
Rob Austin
2014-12-16 15:28:52 +00:00
parent c7b7af8e2b
commit 005f4d7a7e
10 changed files with 276 additions and 118 deletions
@@ -64,7 +64,7 @@ final class ChannelProvider implements Closeable {
final TcpReplicator tcpReplicator = new TcpReplicator(
channelProvider.asReplica,
channelProvider.asEntryExternalizable,
tcpConfig, hub.maxEntrySize(), null, hub.remoteNodeValidator());
tcpConfig, null, hub.remoteNodeValidator());
channelProvider.add(tcpReplicator);
}
@@ -85,6 +85,18 @@ final class ChannelProvider implements Closeable {
private static final byte BOOTSTRAP_MESSAGE = 'B';
final EntryExternalizable asEntryExternalizable = new EntryExternalizable() {
@Override
public int sizeOfEntry(@NotNull Bytes entry, int chronicleChannel) {
channelDataLock.readLock().lock();
try {
return channelEntryExternalizables[chronicleChannel]
.sizeOfEntry(entry, chronicleChannel);
} finally {
channelDataLock.readLock().unlock();
}
}
/**
* writes the entry to the chronicle channel provided
*
@@ -116,7 +128,7 @@ final class ChannelProvider implements Closeable {
final int chronicleId = (int) source.readStopBit();
if (chronicleId < chronicleChannels.length) {
// this channel is has not currently been created so it updates will be ignored
if (channelEntryExternalizables[chronicleId] != null)
if (channelEntryExternalizables[chronicleId] != null)
channelEntryExternalizables[chronicleId]
.readExternalEntry(copies, segmentState, source);
} else
@@ -398,8 +410,8 @@ final class ChannelProvider implements Closeable {
}
/**
* used to send system messages such as bootstrap from one remote node to another, it also can be used in
* a broadcast context
* used to send system messages such as bootstrap from one remote node to another, it also can
* be used in a broadcast context
*/
class SystemQueue {
@@ -467,6 +479,11 @@ final class ChannelProvider implements Closeable {
}
};
final EntryExternalizable asEntryExternalizable = new EntryExternalizable() {
@Override
public int sizeOfEntry(@NotNull Bytes entry, int chronicleId) {
return (int) entry.remaining();
}
@Override
public void writeExternalEntry(@NotNull Bytes entry, @NotNull Bytes destination,
int na) {