com.continuent.tungsten.replicator.channel
Class ShardChannelTable

java.lang.Object
  extended by com.continuent.tungsten.replicator.channel.ShardChannelTable

public class ShardChannelTable
extends java.lang.Object

Encapsulates management of shard to channel assignments. Such assignments are used to manage parallel apply with dynamic mapping of new shards to channels.

Author:
Robert Hodges

Field Summary
static java.lang.String CHANNEL_COL
           
static java.lang.String SHARD_ID_COL
           
static java.lang.String TABLE_NAME
           
 
Constructor Summary
ShardChannelTable(java.lang.String schema, java.lang.String tableType)
          Create and initialize a new shard channel table.
 
Method Summary
 void initializeShardTable(Database database, int channels)
          Set up the channel table.
 int insert(Database database, java.lang.String shardName, int channelNumber)
          Insert a shard/channel assignment into the database.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> list(Database conn)
          Return a list of currently known shard/channel assignments.
 int listMaxChannel(Database conn)
          Return the maximum assigned channel.
 int reduceAssignments(Database conn, int channels)
          Drop all channel definitions, but only if there are no channel assignments over the currently configured level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME

public static final java.lang.String TABLE_NAME
See Also:
Constant Field Values

SHARD_ID_COL

public static final java.lang.String SHARD_ID_COL
See Also:
Constant Field Values

CHANNEL_COL

public static final java.lang.String CHANNEL_COL
See Also:
Constant Field Values
Constructor Detail

ShardChannelTable

public ShardChannelTable(java.lang.String schema,
                         java.lang.String tableType)
Create and initialize a new shard channel table.

Parameters:
schema -
Method Detail

initializeShardTable

public void initializeShardTable(Database database,
                                 int channels)
                          throws java.sql.SQLException,
                                 ReplicatorException
Set up the channel table.

Throws:
ReplicatorException - Thrown if table appears to have invalid data
java.sql.SQLException

insert

public int insert(Database database,
                  java.lang.String shardName,
                  int channelNumber)
           throws java.sql.SQLException
Insert a shard/channel assignment into the database.

Throws:
java.sql.SQLException

reduceAssignments

public int reduceAssignments(Database conn,
                             int channels)
                      throws java.sql.SQLException
Drop all channel definitions, but only if there are no channel assignments over the currently configured level.

Throws:
java.sql.SQLException

list

public java.util.List<java.util.Map<java.lang.String,java.lang.String>> list(Database conn)
                                                                      throws java.sql.SQLException
Return a list of currently known shard/channel assignments.

Throws:
java.sql.SQLException

listMaxChannel

public int listMaxChannel(Database conn)
                   throws java.sql.SQLException
Return the maximum assigned channel.

Throws:
java.sql.SQLException