Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

To Brian Oliver or Other Coherence Incubator Developers: Filter Examples

AntonZJul 24 2012 — edited Nov 14 2012
Hi.

Trying to get a custom clas filter working within push replication and without an example have hard time getting it right. Could not find any samples on the project page or on the forum.

Please provide an example or correct my sample below. Below I try to write a custom filter where meeting criteria on one property, delete event always gets distributed, while update/insert gets distributed when one more condition is met.

(When I try to run cluster with this, I get error: The filter specified in <event:filtering-transformer-scheme> does not implement the com.tangosol.util.Filter interface

<event:filtering-transformer-scheme>
<class-scheme>
<class-name>com.eventdistribution.MyFilter</class-name>
</class-scheme>
</event:filtering-transformer-scheme>


JAVA:

package com.eventdistribution;

import java.io.IOException;
import java.io.Serializable;

import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import com.tangosol.io.pof.PortableObject;
import com.tangosol.util.Filter;
import com.tangosol.util.MapEvent;

public class MyFilter implements Filter, Serializable, PortableObject
{

private static final long serialVersionUID = 107L;

public void readExternal(PofReader arg0) throws IOException {
// TODO Auto-generated method stub

}

public void writeExternal(PofWriter arg0) throws IOException {
// TODO Auto-generated method stub

}

public boolean evaluate(Object o)
{

if (o instanceof DistributableEntryEvent)
{
DistributableEntryEvent event = (DistributableEntryEvent) o;
DistributableEntry entry = event.getEntry();

Trade trade = new Trade();
if (entry.getValue()!=null)
trade = (Trade) entry.getValue();
else
trade = (Trade) entry.getOriginalValue();
if (trade.getIsDistributable()==true)
if (o instanceof EntryRemovedEvent)
return true;
else
if (trade.getIsNew()==true) return true;
return false;
}
else
{
return false;
}

}
}

Edited by: AntonZ on 24-Jul-2012 14:43
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2012
Added on Jul 24 2012
1 comment
196 views