Package org.apache.catalina.tribes.tipis
Interface ReplicatedMapEntry
- All Superinterfaces:
- Serializable
- All Known Implementing Classes:
- DeltaSession
For smarter replication, an object can implement this interface to replicate diffs
The replication logic will call the methods in the following order:
 
 
When the data is deserialized the logic is called in the following order
 
The replication logic will call the methods in the following order:
 1. if ( entry.isDirty() ) 
      try {
 2.     entry.lock();
 3.     byte[] diff = entry.getDiff();
 4.     entry.reset();
      } finally {
 5.     entry.unlock();
      }
    }
 
 When the data is deserialized the logic is called in the following order
 1. ReplicatedMapEntry entry = (ReplicatedMapEntry)objectIn.readObject();
 2. if ( isBackup(entry)||isPrimary(entry) ) entry.setOwner(owner); 
 - 
Method SummaryModifier and TypeMethodDescriptionvoidAccess to an existing object.voidapplyDiff(byte[] diff, int offset, int length) Applies a diff to an existing object.byte[]getDiff()Returns a diff and sets the dirty map to falselonglongFor accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data.booleanIf this returns true, to replicate that an object has been accessedbooleanIf this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.booleanisDirty()Has the object changed since last replication and is not in a locked statevoidlock()Lock during serializationvoidResets the current diff state and resets the dirty flagvoidsetLastTimeReplicated(long lastTimeReplicated) Set the last replicate time.voidThis method is called after the object has been created on a remote map.voidsetVersion(long version) Forces a certain version to a replicated map entryvoidunlock()Unlock after serialization
- 
Method Details- 
isDirtyboolean isDirty()Has the object changed since last replication and is not in a locked state- Returns:
- boolean
 
- 
isDiffableboolean isDiffable()If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.- Returns:
- boolean
 
- 
getDiffReturns a diff and sets the dirty map to false- Returns:
- Serialized diff data
- Throws:
- IOException- IO error serializing
 
- 
applyDiffApplies a diff to an existing object.- Parameters:
- diff- Serialized diff data
- offset- Array offset
- length- Array length
- Throws:
- IOException- IO error deserializing
- ClassNotFoundException- Serialization error
 
- 
resetDiffvoid resetDiff()Resets the current diff state and resets the dirty flag
- 
lockvoid lock()Lock during serialization
- 
unlockvoid unlock()Unlock after serialization
- 
setOwnerThis method is called after the object has been created on a remote map. On this method, the object can initialize itself for any data that wasn't- Parameters:
- owner- Object
 
- 
getVersionlong getVersion()For accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data. The replicated map can use this to ensure accuracy on a periodic basis- Returns:
- long - the version number or -1 if the data is not versioned
 
- 
setVersionvoid setVersion(long version) Forces a certain version to a replicated map entry- Parameters:
- version- long
 
- 
getLastTimeReplicatedlong getLastTimeReplicated()- Returns:
- the last replicate time.
 
- 
setLastTimeReplicatedvoid setLastTimeReplicated(long lastTimeReplicated) Set the last replicate time.- Parameters:
- lastTimeReplicated- New timestamp
 
- 
isAccessReplicateboolean isAccessReplicate()If this returns true, to replicate that an object has been accessed- Returns:
- boolean
 
- 
accessEntryvoid accessEntry()Access to an existing object.
 
-