com.continuent.tungsten.replicator.filter
Class DatabaseTransformFilter

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

public class DatabaseTransformFilter
extends java.lang.Object
implements Filter

Filter to transform a specific database name to a new value using Java regular expression rules. This filter matches the schema name using the fromRegex expression and then does a replacement on the name using the toRegex expression.
Can also be used to transform table names instead by turning on transformTables flag. However, statement data transformation is unsupported in this case.

Version:
1.0
Author:
Robert Hodges
See Also:
Pattern, Matcher

Constructor Summary
DatabaseTransformFilter()
           
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 ReplDBMSEvent filter(ReplDBMSEvent event)
          Filter the event.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setFromRegex1(java.lang.String fromRegex)
          Sets the regex used to match the database name.
 void setFromRegex2(java.lang.String fromRegex)
          Sets the regex used to match the database name.
 void setFromRegex3(java.lang.String fromRegex)
          Sets the regex used to match the database name.
 void setFromRegex4(java.lang.String fromRegex)
          Sets the regex used to match the database name.
 void setToRegex1(java.lang.String toRegex)
          Sets the corresponding regex to transform the name.
 void setToRegex2(java.lang.String toRegex)
          Sets the corresponding regex to transform the name.
 void setToRegex3(java.lang.String toRegex)
          Sets the corresponding regex to transform the name.
 void setToRegex4(java.lang.String toRegex)
          Sets the corresponding regex to transform the name.
 void setTransformTables(boolean transformTables)
          Transform table instead of database names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseTransformFilter

public DatabaseTransformFilter()
Method Detail

setFromRegex1

public void setFromRegex1(java.lang.String fromRegex)
Sets the regex used to match the database name.


setToRegex1

public void setToRegex1(java.lang.String toRegex)
Sets the corresponding regex to transform the name.


setFromRegex2

public void setFromRegex2(java.lang.String fromRegex)
Sets the regex used to match the database name.


setToRegex2

public void setToRegex2(java.lang.String toRegex)
Sets the corresponding regex to transform the name.


setFromRegex3

public void setFromRegex3(java.lang.String fromRegex)
Sets the regex used to match the database name.


setToRegex3

public void setToRegex3(java.lang.String toRegex)
Sets the corresponding regex to transform the name.


setFromRegex4

public void setFromRegex4(java.lang.String fromRegex)
Sets the regex used to match the database name.


setToRegex4

public void setToRegex4(java.lang.String toRegex)
Sets the corresponding regex to transform the name.


setTransformTables

public void setTransformTables(boolean transformTables)
Transform table instead of database names.


filter

public ReplDBMSEvent filter(ReplDBMSEvent event)
                     throws ReplicatorException
Filter the event. Filters may transform the event or return null if the event should be discarded. Filters must be prepared to be interrupted, which mechanism is used to cancel processing.

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
See Also:
Filter.filter(com.continuent.tungsten.replicator.event.ReplDBMSEvent)

configure

public void configure(PluginContext context)
               throws ReplicatorException
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
See Also:
ReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)

prepare

public void prepare(PluginContext context)
             throws ReplicatorException
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
See Also:
ReplicatorPlugin.prepare(com.continuent.tungsten.replicator.plugin.PluginContext)

release

public void release(PluginContext context)
             throws ReplicatorException
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
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)