com.continuent.tungsten.replicator.database
Class TableMetadataCache

java.lang.Object
  extended by com.continuent.tungsten.replicator.database.TableMetadataCache
All Implemented Interfaces:
CacheResourceManager<Table>

public class TableMetadataCache
extends java.lang.Object
implements CacheResourceManager<Table>

Implements a cache for table metadata. The cache organizes Table metadata by schema and table name. It supports invalidation at multiple levels.

Author:
Robert Hodges

Constructor Summary
TableMetadataCache(int capacity)
          Creates a new table metadata cache.
 
Method Summary
 int invalidate(SqlOperation sqlOperation, java.lang.String defaultSchema)
          Invalidate appropriate range of metadata based on a particular SQL operation that we see.
 void invalidateAll()
          Release all metadata in the cache.
 int invalidateSchema(java.lang.String schema)
          Release all table metadata instances for a given schema.
 int invalidateTable(java.lang.String schema, java.lang.String tableName)
          Release all a single table metadata instance
 void release(Table metadata)
          Call back to release a table metadata instance that is dropped from the cache.
 Table retrieve(java.lang.String schema, java.lang.String tableName)
          Retrieves table metadata or returns null if it is not in the cache.
 int size()
          Returns the number of entries in the metadata cache.
 void store(Table metadata)
          Store metadata for a table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableMetadataCache

public TableMetadataCache(int capacity)
Creates a new table metadata cache.

Method Detail

release

public void release(Table metadata)
Call back to release a table metadata instance that is dropped from the cache.

Specified by:
release in interface CacheResourceManager<Table>
See Also:
CacheResourceManager.release(java.lang.Object)

size

public int size()
Returns the number of entries in the metadata cache.


store

public void store(Table metadata)
Store metadata for a table.


retrieve

public Table retrieve(java.lang.String schema,
                      java.lang.String tableName)
Retrieves table metadata or returns null if it is not in the cache.


invalidateAll

public void invalidateAll()
Release all metadata in the cache.


invalidateSchema

public int invalidateSchema(java.lang.String schema)
Release all table metadata instances for a given schema.


invalidateTable

public int invalidateTable(java.lang.String schema,
                           java.lang.String tableName)
Release all a single table metadata instance


invalidate

public int invalidate(SqlOperation sqlOperation,
                      java.lang.String defaultSchema)
Invalidate appropriate range of metadata based on a particular SQL operation that we see.

Parameters:
sqlOperation - A SQLOperation from parsing
defaultSchema - Default schema in case it is not supplied by sqlOperation