FileDocCategorySizeDatePackage
ReplicatedMapEntry.javaAPI DocApache Tomcat 6.0.143729Fri Jul 20 04:20:34 BST 2007org.apache.catalina.tribes.tipis

ReplicatedMapEntry

public interface ReplicatedMapEntry implements Serializable
For smarter replication, an object can implement this interface to replicate diffs
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);

author
Filip Hanik
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public voidapplyDiff(byte[] diff, int offset, int length)
Applies a diff to an existing object.

param
diff byte[]
param
offset int
param
length int
throws
IOException

public byte[]getDiff()
Returns a diff and sets the dirty map to false

return
byte[]
throws
IOException

public longgetVersion()
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

return
long - the version number or -1 if the data is not versioned

public booleanisDiffable()
If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.

return
boolean

public booleanisDirty()
Has the object changed since last replication and is not in a locked state

return
boolean

public voidlock()
Lock during serialization

public voidresetDiff()
Resets the current diff state and resets the dirty flag

public voidsetOwner(java.lang.Object owner)
This 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

param
owner Object

public voidsetVersion(long version)
Forces a certain version to a replicated map entry

param
version long

public voidunlock()
Unlock after serialization