HCOLL-329 fixing the bootstrapping timestamp issue

This commit is contained in:
Rob Austin
2015-05-29 19:09:54 +01:00
parent 7ceefca5d5
commit 80c80ff672
9 changed files with 170 additions and 47 deletions
@@ -113,21 +113,22 @@ final class ChannelProvider implements Closeable {
/**
* writes the entry to the chronicle channel provided
*
* @param entry the byte location of the entry to be stored
* @param destination a buffer the entry will be written to, the segment may reject
* this operation and add zeroBytes, if the identifier in the entry
* did not match the maps local
* @param chronicleChannel used in cluster into identify the canonical map or queue
* @param bootstrapTime
*/
@Override
public void writeExternalEntry(@NotNull Bytes entry, @NotNull Bytes destination,
int chronicleChannel) {
public void writeExternalEntry(@NotNull Bytes entry,
@NotNull Bytes destination,
int chronicleChannel, long bootstrapTime) {
channelDataLock.readLock().lock();
try {
destination.writeStopBit(chronicleChannel);
channelEntryExternalizables[chronicleChannel]
.writeExternalEntry(entry, destination, chronicleChannel);
.writeExternalEntry(entry, destination, chronicleChannel, bootstrapTime);
} finally {
channelDataLock.readLock().unlock();
}
@@ -136,7 +137,8 @@ final class ChannelProvider implements Closeable {
@Override
public void readExternalEntry(
@NotNull ThreadLocalCopies copies,
@NotNull VanillaChronicleMap.SegmentState segmentState, @NotNull Bytes source) {
@NotNull VanillaChronicleMap.SegmentState segmentState,
@NotNull Bytes source) {
channelDataLock.readLock().lock();
try {
final int chronicleId = (int) source.readStopBit();
@@ -274,6 +276,21 @@ final class ChannelProvider implements Closeable {
}
}
@Override
public void setLastModificationTime(byte identifier, long timestamp) {
channelDataLock.readLock().lock();
try {
// not including the SystemQueue at index 0
for (int i = 1, len = chronicleChannelList.size(); i < len; i++) {
Replica channel = chronicleChannelList.get(i);
channel.setLastModificationTime(identifier, timestamp);
}
} finally {
channelDataLock.readLock().unlock();
}
}
@Override
public void close() throws IOException {
ChannelProvider.this.close();
@@ -483,7 +500,7 @@ final class ChannelProvider implements Closeable {
final Bytes bytes = payloads.poll();
if (bytes == null)
return false;
callback.onEntry(bytes, 0);
callback.onEntry(bytes, 0, System.currentTimeMillis());
return true;
}
@@ -519,6 +536,11 @@ final class ChannelProvider implements Closeable {
return 0;
}
@Override
public void setLastModificationTime(byte identifier, long timestamp) {
// do nothing
}
@Override
public void close() throws IOException {
// do nothing
@@ -537,7 +559,7 @@ final class ChannelProvider implements Closeable {
@Override
public void writeExternalEntry(@NotNull Bytes entry, @NotNull Bytes destination,
int na) {
int na, long bootstrapTime) {
destination.write(entry, entry.position(), entry.remaining());
}