SPI implementation

This commit is contained in:
leventov
2015-05-27 00:03:20 +01:00
parent 8e4027da08
commit b4c8554b77
111 changed files with 13637 additions and 3991 deletions
@@ -18,14 +18,21 @@
package net.openhft.chronicle.hash.replication;
import net.openhft.chronicle.hash.AcceptanceDecision;
import static net.openhft.chronicle.hash.AcceptanceDecision.ACCEPT;
import static net.openhft.chronicle.hash.AcceptanceDecision.DISCARD;
public final class DefaultEventualConsistencyStrategy {
public static boolean shouldApplyRemoteModification(
ReplicatedEntry entry, ReplicationContext context) {
public static AcceptanceDecision decideOnRemoteModification(
HashReplicableEntry<?> entry, RemoteOperationContext<?> context) {
long remoteTimestamp = context.remoteTimestamp();
long originTimestamp = entry.originTimestamp();
return remoteTimestamp > originTimestamp || (remoteTimestamp == originTimestamp &&
context.remoteIdentifier() <= entry.originIdentifier());
boolean shouldAccept = remoteTimestamp > originTimestamp ||
(remoteTimestamp == originTimestamp &&
context.remoteIdentifier() <= entry.originIdentifier());
return shouldAccept ? ACCEPT : DISCARD;
}
private DefaultEventualConsistencyStrategy() {}