mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Add ReplicableEntry.raiseChangedFor(), raiseChangedForAllExcept(), improve MapRemoteOperations
This commit is contained in:
+14
@@ -119,6 +119,20 @@ public abstract class ReplicatedMapEntryStages<K, V> extends MapEntryStages<K, V
|
||||
ru.raiseChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void raiseChangedFor(byte remoteIdentifier) {
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
s.innerUpdateLock.lock();
|
||||
ru.raiseChangeFor(remoteIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void raiseChangedForAllExcept(byte remoteIdentifier) {
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
s.innerUpdateLock.lock();
|
||||
ru.raiseChangeForAllExcept(remoteIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChanged() {
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
|
||||
@@ -48,10 +48,10 @@ public abstract class ReplicatedInput<K, V, R> implements RemoteOperationContext
|
||||
return dummyValue;
|
||||
}
|
||||
|
||||
public void processReplicatedEvent(Bytes replicatedInputBytes) {
|
||||
public void processReplicatedEvent(byte remoteNodeIdentifier, Bytes replicatedInputBytes) {
|
||||
long timestamp = replicatedInputBytes.readStopBit();
|
||||
byte identifier = replicatedInputBytes.readByte();
|
||||
ru.initReplicationUpdate(identifier, timestamp);
|
||||
ru.initReplicationUpdate(identifier, timestamp, remoteNodeIdentifier);
|
||||
|
||||
boolean isDeleted = replicatedInputBytes.readBoolean();
|
||||
long keySize = mh.m().keySizeMarshaller.readSize(replicatedInputBytes);
|
||||
@@ -73,15 +73,18 @@ public abstract class ReplicatedInput<K, V, R> implements RemoteOperationContext
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remotePut(Data<V> newValue, byte remoteIdentifier, long timestamp) {
|
||||
ru.initReplicationUpdate(remoteIdentifier, timestamp);
|
||||
public void remotePut(
|
||||
Data<V> newValue,
|
||||
byte remoteEntryIdentifier, long remoteEntryTimestamp, byte remoteNodeIdentifier) {
|
||||
ru.initReplicationUpdate(remoteEntryIdentifier, remoteEntryTimestamp, remoteNodeIdentifier);
|
||||
s.innerUpdateLock.lock();
|
||||
mh.m().remoteOperations.put(this, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteRemove(byte remoteIdentifier, long timestamp) {
|
||||
ru.initReplicationUpdate(remoteIdentifier, timestamp);
|
||||
public void remoteRemove(
|
||||
byte remoteEntryIdentifier, long remoteEntryTimestamp, byte remoteNodeIdentifier) {
|
||||
ru.initReplicationUpdate(remoteEntryIdentifier, remoteEntryTimestamp, remoteNodeIdentifier);
|
||||
s.innerWriteLock.lock();
|
||||
mh.m().remoteOperations.remove(this);
|
||||
}
|
||||
|
||||
+19
-1
@@ -34,14 +34,18 @@ public abstract class ReplicationUpdate<K> implements RemoteOperationContext<K>
|
||||
|
||||
@Stage("ReplicationUpdate") public byte innerRemoteIdentifier = (byte) 0;
|
||||
@Stage("ReplicationUpdate") public long innerRemoteTimestamp;
|
||||
@Stage("ReplicationUpdate") public byte innerRemoteNodeIdentifier;
|
||||
|
||||
public abstract boolean replicationUpdateInit();
|
||||
|
||||
public void initReplicationUpdate(byte identifier, long timestamp) {
|
||||
public void initReplicationUpdate(byte identifier, long timestamp, byte remoteNodeIdentifier) {
|
||||
innerRemoteTimestamp = timestamp;
|
||||
if (identifier == 0)
|
||||
throw new IllegalStateException("identifier can't be 0");
|
||||
innerRemoteIdentifier = identifier;
|
||||
if (remoteNodeIdentifier == 0)
|
||||
throw new IllegalStateException("remote node identifier can't be 0");
|
||||
innerRemoteNodeIdentifier = remoteNodeIdentifier;
|
||||
}
|
||||
|
||||
public void dropChange() {
|
||||
@@ -62,6 +66,14 @@ public abstract class ReplicationUpdate<K> implements RemoteOperationContext<K>
|
||||
mh.m().raiseChange(s.tierIndex, e.pos);
|
||||
}
|
||||
|
||||
public void raiseChangeFor(byte remoteIdentifier) {
|
||||
mh.m().raiseChangeFor(s.tierIndex, e.pos, remoteIdentifier);
|
||||
}
|
||||
|
||||
public void raiseChangeForAllExcept(byte remoteIdentifier) {
|
||||
mh.m().raiseChangeForAllExcept(s.tierIndex, e.pos, remoteIdentifier);
|
||||
}
|
||||
|
||||
public boolean changed() {
|
||||
return mh.m().isChanged(s.tierIndex, e.pos);
|
||||
}
|
||||
@@ -78,6 +90,12 @@ public abstract class ReplicationUpdate<K> implements RemoteOperationContext<K>
|
||||
return innerRemoteIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte remoteNodeIdentifier() {
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
return innerRemoteNodeIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte currentNodeIdentifier() {
|
||||
return mh.m().identifier();
|
||||
|
||||
Reference in New Issue
Block a user