@Override public void apply(DeleteEntries param)
throws Exception {
//FIXME : Doing nothing for now
+ dataSize = 0;
+ for(ReplicatedLogEntry entry : journal){
+ dataSize += entry.size();
+ }
}
});
}
appendAndPersist(null, null, replicatedLogEntry);
}
+ @Override
+ public int dataSize() {
+ return dataSize;
+ }
+
public void appendAndPersist(final ActorRef clientActor,
final String identifier,
final ReplicatedLogEntry replicatedLogEntry) {
new Procedure<ReplicatedLogEntry>() {
@Override
public void apply(ReplicatedLogEntry evt) throws Exception {
+ dataSize += replicatedLogEntry.size();
+
+ long dataThreshold = Runtime.getRuntime().totalMemory() *
+ getRaftActorContext().getConfigParams().getSnapshotDataThresholdPercentage() / 100;
+
// when a snaphsot is being taken, captureSnapshot != null
if (hasSnapshotCaptureInitiated == false &&
- journal.size() % context.getConfigParams().getSnapshotBatchCount() == 0) {
+ ( journal.size() % context.getConfigParams().getSnapshotBatchCount() == 0 ||
+ dataSize > dataThreshold)) {
LOG.info("Initiating Snapshot Capture..");
long lastAppliedIndex = -1;