|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IReplicationFilter
A replication filter is a special hook point inside the replication object. Two types of replication filters can be defined - input replication and output replication. If the 2 classes specified (for input and output) are the same, only one filter object will be used for both input and output replication.
The filters are initiated when the replicator is initiated (i.e. during space creation).
In order to disable transmitted/received replicationFilterEntry (replication entries)
set IReplicationFilterEntry's operation-code to DUMMY, e.g.:
replicationFilterEntry.setOpCode(
IReplicationFilterEntry.DUMMY
)
// This snippet represents a default replication filter, for users using replication filters.
// The default filter simply prints the input and output packet codes.
public class DefaultReplicationFilter implements IReplicationFilter
{
private int m_counter = 0;
final private IJspace m_space = null;
//...
public void init(IJSpace space, String paramUrl, ReplicationPolicy replicationPolicy) {
m_space = space; //... initialize class variables
}
public void process(int direction, IReplicationFilterEntry replicationFilterEntry, String remoteSpaceMemberName)
{
String filterDirectionStr = null;
String operationCodeStr = null;
m_counter++;
switch( direction )
{
case IReplicationFilter.FILTER_DIRECTION_INPUT: filterDirectionStr = "INPUT"; break;
case IReplicationFilter.FILTER_DIRECTION_OUTPUT: filterDirectionStr = "OUTPUT"; break;
}
switch ( replicationFilterEntry.getOpCode()
)
{
case IReplicationFilterEntry.WRITE
: operationCodeStr = "WRITE"; break;
case IReplicationFilterEntry.TAKE
: ... break;
case IReplicationFilterEntry.EXTEND_LEASE
: ... break;
case IReplicationFilterEntry.UPDATE
: ... break;
case IReplicationFilterEntry.DUMMY
: ... break;
case IReplicationFilterEntry.LEASE_EXPIRATION
: ... break;
}
// we are simply print all replicated traffic.
System.out.println(
+ getClass().getName()
+ "| Space: " + m_space.getName()
+ " | Direction: "+ filterDirectionStr
+ " | Operation code: "+ operationCodeStr
+ " | Entry ("+ m_counter+"): "
+ replicationFilterEntry.getClassName()
+ replicationFilterEntry.getUID()
+ replicationFilterEntry.getFieldsValues()
);
}
...
}
ReplicationFilterException
Field Summary | |
---|---|
static int |
FILTER_DIRECTION_INPUT
Input filter direction. |
static int |
FILTER_DIRECTION_OUTPUT
Output filter direction. |
Method Summary | |
---|---|
void |
close()
Closes this filter, enabling the developer to clean open resources. |
void |
init(IJSpace space,
String paramUrl,
ReplicationPolicy replicationPolicy)
Initializes this filter. |
void |
process(int direction,
IReplicationFilterEntry replicationFilterEntry,
String remoteSpaceMemberName)
This method is called by sync/async replication when SyncPackets is about to get sent (for output filter) or received (for input one). |
Field Detail |
---|
static final int FILTER_DIRECTION_OUTPUT
process(int, IReplicationFilterEntry, String)
,
Constant Field Valuesstatic final int FILTER_DIRECTION_INPUT
process(int, IReplicationFilterEntry, String)
,
Constant Field ValuesMethod Detail |
---|
void init(IJSpace space, String paramUrl, ReplicationPolicy replicationPolicy)
space
- an embedded proxy to the space that contain this filter.paramUrl
- the url that was passed when this filter was created.replicationPolicy
- replication policy for this replication groupvoid process(int direction, IReplicationFilterEntry replicationFilterEntry, String remoteSpaceMemberName)
direction
- FILTER_DIRECTION_OUTPUT
or FILTER_DIRECTION_INPUT
replicationFilterEntry
- replicated dataremoteSpaceMemberName
- name of the remote peer space
(name format is container-name:space-name)void close()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |