Apache Tomcat 7.0.28

org.apache.catalina.tribes.tipis
Interface ReplicatedMapEntry

All Superinterfaces:
Serializable
All Known Implementing Classes:
DeltaSession

public interface ReplicatedMapEntry
extends 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);

Version:
1.0
Author:
Filip Hanik

Method Summary
 void accessEntry()
          Access to an existing object.
 void applyDiff(byte[] diff, int offset, int length)
          Applies a diff to an existing object.
 byte[] getDiff()
          Returns a diff and sets the dirty map to false
 long getLastTimeReplicated()
          Return the last replicate time.
 long getVersion()
          For accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data.
 boolean isAccessReplicate()
          If this returns true, to replicate that an object has been accessed
 boolean isDiffable()
          If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.
 boolean isDirty()
          Has the object changed since last replication and is not in a locked state
 void lock()
          Lock during serialization
 void resetDiff()
          Resets the current diff state and resets the dirty flag
 void setLastTimeReplicated(long lastTimeReplicated)
          Set the last replicate time.
 void setOwner(Object owner)
          This method is called after the object has been created on a remote map.
 void setVersion(long version)
          Forces a certain version to a replicated map entry
 void unlock()
          Unlock after serialization
 

Method Detail

isDirty

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

Returns:
boolean

isDiffable

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

Returns:
boolean

getDiff

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

Returns:
byte[]
Throws:
IOException

applyDiff

void applyDiff(byte[] diff,
               int offset,
               int length)
               throws IOException,
                      ClassNotFoundException
Applies a diff to an existing object.

Parameters:
diff - byte[]
offset - int
length - int
Throws:
IOException
ClassNotFoundException

resetDiff

void resetDiff()
Resets the current diff state and resets the dirty flag


lock

void lock()
Lock during serialization


unlock

void unlock()
Unlock after serialization


setOwner

void setOwner(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

Parameters:
owner - Object

getVersion

long 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

setVersion

void setVersion(long version)
Forces a certain version to a replicated map entry

Parameters:
version - long

getLastTimeReplicated

long getLastTimeReplicated()
Return the last replicate time.


setLastTimeReplicated

void setLastTimeReplicated(long lastTimeReplicated)
Set the last replicate time.

Parameters:
lastTimeReplicated -

isAccessReplicate

boolean isAccessReplicate()
If this returns true, to replicate that an object has been accessed

Returns:
boolean

accessEntry

void accessEntry()
Access to an existing object.


Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.