mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-246 Fixed - Tcp Replication fails with large values or entries sizes that don't included internal replication bytes"
This commit is contained in:
@@ -30,10 +30,10 @@ 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
|
||||
* it becomes available on TCP/IP. In order to not miss data, UdpReplicator should be used in conjunction with
|
||||
* the TCP Replicator.
|
||||
* 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 it becomes available on TCP/IP. In order to not miss data, UdpReplicator
|
||||
* should be used in conjunction with the TCP Replicator.
|
||||
*/
|
||||
final class UdpReplicator extends UdpChannelReplicator implements Replica.ModificationNotifier, Closeable {
|
||||
|
||||
@@ -106,7 +106,7 @@ final class UdpReplicator extends UdpChannelReplicator implements Replica.Modifi
|
||||
|
||||
// check the the first 4 bytes are the inverted len followed by the len
|
||||
// we do this to check that this is a valid start of entry, otherwise we throw it away
|
||||
if ( ~size != invertedSize)
|
||||
if (~size != invertedSize)
|
||||
return;
|
||||
|
||||
if (out.remaining() != size)
|
||||
@@ -118,8 +118,7 @@ final class UdpReplicator extends UdpChannelReplicator implements Replica.Modifi
|
||||
|
||||
private static class UdpSocketChannelEntryWriter implements EntryWriter {
|
||||
|
||||
private final ByteBuffer out;
|
||||
private final ByteBufferBytes in;
|
||||
|
||||
private final EntryCallback entryCallback;
|
||||
private final UdpChannelReplicator udpReplicator;
|
||||
private Replica.ModificationIterator modificationIterator;
|
||||
@@ -131,9 +130,8 @@ final class UdpReplicator extends UdpChannelReplicator implements Replica.Modifi
|
||||
this.udpReplicator = udpReplicator;
|
||||
|
||||
// we make the buffer twice as large just to give ourselves headroom
|
||||
out = ByteBuffer.allocateDirect(serializedEntrySize * 2);
|
||||
in = new ByteBufferBytes(out);
|
||||
entryCallback = new EntryCallback(externalizable, in);
|
||||
|
||||
entryCallback = new EntryCallback(externalizable, serializedEntrySize);
|
||||
this.modificationIterator = modificationIterator;
|
||||
}
|
||||
|
||||
@@ -156,6 +154,9 @@ final class UdpReplicator extends UdpChannelReplicator implements Replica.Modifi
|
||||
public int writeAll(@NotNull final DatagramChannel socketChannel)
|
||||
throws InterruptedException, IOException {
|
||||
|
||||
final ByteBufferBytes in = entryCallback.in();
|
||||
final ByteBuffer out = entryCallback.out();
|
||||
|
||||
out.clear();
|
||||
in.clear();
|
||||
in.skip(SIZE_OF_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user