com.continuent.tungsten.replicator.filter
Class ReplicateFilter

java.lang.Object
  extended by com.continuent.tungsten.replicator.filter.ReplicateFilter
All Implemented Interfaces:
Filter, ReplicatorPlugin

public class ReplicateFilter
extends java.lang.Object
implements Filter

Implements a filter to either apply or ignore operations on particular schemas and/or tables. Patterns are comma separated lists, where each entry may have the following form:

Schema and table names may contain * and ? characters, which substitute for a series of characters or a single character, respectively. For example, "test.*" matches all tables in database test, and "test?.foo" matches tables "test1.foo" and "test2.foo" but not "test.foo".

Version:
1.0
Author:
Stephane Giron

Constructor Summary
ReplicateFilter()
           
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 ReplDBMSEvent filter(ReplDBMSEvent event)
          Filters transactions using do and ignore rules.
 java.lang.String fullyQualifiedName(java.lang.String schema, java.lang.String table)
           
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setDo(java.lang.String doFilter)
           
 void setDoFilter(java.lang.String doFilter)
          Define a comma-separated list of schemas with optional table names (e.g., schema1,schema2.table1,etc.) to replicate.
 void setIgnore(java.lang.String ignore)
           
 void setIgnoreFilter(java.lang.String ignoreFilter)
          Define a comma-separated list of schemas with optional table names (e.g., schema1,schema2.table1,etc.) to ignore.
 void setTungstenSchema(java.lang.String tungstenSchema)
          Sets the Tungsten schema, which we ignore to prevent problems with the replicator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicateFilter

public ReplicateFilter()
Method Detail

setDoFilter

public void setDoFilter(java.lang.String doFilter)
Define a comma-separated list of schemas with optional table names (e.g., schema1,schema2.table1,etc.) to replicate. If set, only operations that match the list will be forwarded.


setDo

public void setDo(java.lang.String doFilter)

setIgnoreFilter

public void setIgnoreFilter(java.lang.String ignoreFilter)
Define a comma-separated list of schemas with optional table names (e.g., schema1,schema2.table1,etc.) to ignore. If set, all operations that match the list will be ignored.

Parameters:
ignoreFilter -

setIgnore

public void setIgnore(java.lang.String ignore)

setTungstenSchema

public void setTungstenSchema(java.lang.String tungstenSchema)
Sets the Tungsten schema, which we ignore to prevent problems with the replicator. This is mostly used for filter testing, which runs without a pipeline.


filter

public ReplDBMSEvent filter(ReplDBMSEvent event)
                     throws ReplicatorException,
                            java.lang.InterruptedException
Filters transactions using do and ignore rules. The logic is as follows.
  1. If the operation matches a schema or table to ignore, drop it.
  2. If the operation matches a schema or table to do, forward it.
  3. If the do list is enabled and the operation does not match, drop it.
Individual operations that match the filtering rules are removed. If the entire transaction becomes empty as a result, it will be removed.

Specified by:
filter in interface Filter
Parameters:
event - An event to be filtered
Returns:
Filtered ReplDBMSEvent or null
Throws:
ReplicatorException - Thrown if there is a processing error
java.lang.InterruptedException - Must be thrown if the filter is interrupted or the replicator may hang
See Also:
Filter.filter(com.continuent.tungsten.replicator.event.ReplDBMSEvent)

fullyQualifiedName

public java.lang.String fullyQualifiedName(java.lang.String schema,
                                           java.lang.String table)

configure

public void configure(PluginContext context)
               throws ReplicatorException,
                      java.lang.InterruptedException
Complete plug-in configuration. This is called after setters are invoked at the time that the replicator goes through configuration.

Specified by:
configure in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if configuration is incomplete or fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)

prepare

public void prepare(PluginContext context)
             throws ReplicatorException,
                    java.lang.InterruptedException
Prepare plug-in for use. This method is assumed to allocate all required resources. It is called before the plug-in performs any operations.

Specified by:
prepare in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if resource allocation fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.prepare(com.continuent.tungsten.replicator.plugin.PluginContext)

release

public void release(PluginContext context)
             throws ReplicatorException,
                    java.lang.InterruptedException
Release all resources used by plug-in. This is called before the plug-in is deallocated.

Specified by:
release in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if resource deallocation fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)