com.continuent.tungsten.replicator.channel
Class ChannelAssignmentService

java.lang.Object
  extended by com.continuent.tungsten.replicator.channel.ChannelAssignmentService
All Implemented Interfaces:
ReplicatorPlugin, PipelineService

public class ChannelAssignmentService
extends java.lang.Object
implements PipelineService

Provides a service interface to the shard-to-channel assignment table. This service only works for relational databases and deactivates automatically if the URL is not set. This is necessary to permit proper operation when applying against NoSQL DBMS like MongoDB.

Author:
Robert Hodges

Constructor Summary
ChannelAssignmentService()
           
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 java.lang.Integer getChannelAssignment(java.lang.String shardId)
          Looks up a channel assignment for a shard.
 java.lang.String getName()
          Gets the storage name.
 void insertChannelAssignment(java.lang.String shardId, int channel)
          Inserts a shard/channel assignment.
 boolean isActive()
          Returns true if the channel assignment service is active.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> listChannelAssignments()
          Return a list of current channel assignments.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void setChannels(int channels)
           
 void setName(java.lang.String name)
          Sets the storage name.
 void setPassword(java.lang.String password)
           
 void setUrl(java.lang.String url)
           
 void setUser(java.lang.String user)
           
 TungstenProperties status()
          Returns status information as a set of named properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelAssignmentService

public ChannelAssignmentService()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: PipelineService
Gets the storage name.

Specified by:
getName in interface PipelineService

setName

public void setName(java.lang.String name)
Description copied from interface: PipelineService
Sets the storage name.

Specified by:
setName in interface PipelineService

setUser

public void setUser(java.lang.String user)

setUrl

public void setUrl(java.lang.String url)

setPassword

public void setPassword(java.lang.String password)

setChannels

public void setChannels(int channels)

isActive

public boolean isActive()
Returns true if the channel assignment service is active.


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)

listChannelAssignments

public java.util.List<java.util.Map<java.lang.String,java.lang.String>> listChannelAssignments()
                                                                                        throws ReplicatorException
Return a list of current channel assignments.

Throws:
ReplicatorException

insertChannelAssignment

public void insertChannelAssignment(java.lang.String shardId,
                                    int channel)
                             throws ReplicatorException
Inserts a shard/channel assignment.

Parameters:
shardId - Shard name
channel - Channel number
Throws:
ReplicatorException - Thrown if there is an error accessing database

getChannelAssignment

public java.lang.Integer getChannelAssignment(java.lang.String shardId)
                                       throws ReplicatorException
Looks up a channel assignment for a shard. This creates a new assignment if required.

Parameters:
shardId - Shard name
Returns:
Integer channel number for shard
Throws:
ReplicatorException - Thrown if there is an error accessing database

status

public TungstenProperties status()
Returns status information as a set of named properties.

Specified by:
status in interface PipelineService
See Also:
PipelineService.status()