Skip to content

Commit

Permalink
SYMMETRICDS-513 - time out table metadata cache
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Sep 20, 2011
1 parent e358959 commit 65e3988
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Expand Up @@ -146,6 +146,7 @@ private ParameterConstants() {
public final static String CACHE_TIMEOUT_TRIGGER_ROUTER_IN_MS = "cache.trigger.router.time.ms";
public final static String CACHE_TIMEOUT_CHANNEL_IN_MS = "cache.channel.time.ms";
public final static String CACHE_TIMEOUT_TRANSFORM_IN_MS = "cache.transform.time.ms";
public final static String CACHE_TIMEOUT_TABLES_IN_MS = "cache.table.time.ms";

public final static String TRIGGER_UPDATE_CAPTURE_CHANGED_DATA_ONLY = "trigger.update.capture.changed.data.only.enabled";

Expand Down
Expand Up @@ -123,7 +123,9 @@ abstract public class AbstractDbDialect implements IDbDialect {

protected Platform platform;

protected DatabaseModel cachedModel = new DatabaseModel();
protected DatabaseModel cachedModel = new DatabaseModel();

protected long lastTimeCachedModelClearedInMs = System.currentTimeMillis();

protected SqlTemplate sqlTemplate;

Expand Down Expand Up @@ -351,8 +353,15 @@ public Table getTable(Trigger trigger, boolean useCache) {
* Dialect may optionally override this method to more efficiently lookup up
* table metadata directly against information schemas.
*/
public Table getTable(String catalogName, String schemaName, String tableName, boolean useCache) {
Table retTable = cachedModel.findTable(catalogName, schemaName, tableName);
public Table getTable(String catalogName, String schemaName, String tableName, boolean useCache) {
if (System.currentTimeMillis()-lastTimeCachedModelClearedInMs > parameterService.getLong(ParameterConstants.CACHE_TIMEOUT_TABLES_IN_MS)) {
synchronized (this.getClass()) {
cachedModel = new DatabaseModel();
lastTimeCachedModelClearedInMs = System.currentTimeMillis();
}
}
DatabaseModel model = cachedModel;
Table retTable = model != null ? model.findTable(catalogName, schemaName, tableName) : null;
if (retTable == null || !useCache) {
synchronized (this.getClass()) {
try {
Expand Down
Expand Up @@ -682,26 +682,32 @@ dataloader.max.rows.before.commit=10000
# Tags: other
parameter.reload.timeout.ms=600000

# This is the amount of time node security entries will be cached before rereading
# This is the amount of time node security entries will be cached before re-reading
# them from the database.
#
# DatabaseOverridable: true
# Tags: other
cache.node.security.time.ms=0

# This is the amount of time trigger entries will be cached before rereading them from the database.
# This is the amount of time trigger entries will be cached before re-reading them from the database.
#
# DatabaseOverridable: true
# Tags: other
cache.trigger.router.time.ms=600000

# This is the amount of time transform entries will be cached before rereading them from the database.
# This is the amount of time transform entries will be cached before re-reading them from the database.
#
# DatabaseOverridable: true
# Tags: other
cache.transform.time.ms=600000

# This is the amount of time channel entries will be cached before rereading them from the database.
# This is the amount of time table meta data will be cached before re-reading it from the database
#
# DatabaseOverridable: true
# Tags: other
cache.table.time.ms=3600000

# This is the amount of time channel entries will be cached before re-reading them from the database.
#
# DatabaseOverridable: true
# Tags: other
Expand Down

0 comments on commit 65e3988

Please sign in to comment.