Skip to content

Commit

Permalink
refresh cache of parameters when new parameters come through
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 1, 2012
1 parent 1f30534 commit 9b1250a
Showing 1 changed file with 21 additions and 0 deletions.
Expand Up @@ -55,6 +55,9 @@ public class ConfigurationChangedFilter extends DatabaseWriterFilterAdapter impl
final String CTX_KEY_FLUSH_TRANSFORMS_NEEDED = "FlushTransforms."
+ ConfigurationChangedFilter.class.getSimpleName() + hashCode();

final String CTX_KEY_FLUSH_PARAMETERS_NEEDED = "FlushParameters."
+ ConfigurationChangedFilter.class.getSimpleName() + hashCode();

private IParameterService parameterService;

private IConfigurationService configurationService;
Expand All @@ -78,6 +81,7 @@ public void afterWrite(
recordSyncNeeded(context, table, data);
recordChannelFlushNeeded(context, table);
recordTransformFlushNeeded(context, table);
recordParametersFlushNeeded(context, table);
}

private void recordSyncNeeded(
Expand All @@ -87,6 +91,13 @@ private void recordSyncNeeded(
}
}

private void recordParametersFlushNeeded(
DataContext context, Table table) {
if (isParameterFlushNeeded(table)) {
context.put(CTX_KEY_FLUSH_PARAMETERS_NEEDED, true);
}
}

private void recordChannelFlushNeeded(
DataContext context, Table table) {
if (isChannelFlushNeeded(table)) {
Expand All @@ -111,6 +122,10 @@ private boolean isSyncTriggersNeeded(Table table) {
private boolean isChannelFlushNeeded(Table table) {
return matchesTable(table, TableConstants.SYM_CHANNEL);
}

private boolean isParameterFlushNeeded(Table table) {
return matchesTable(table, TableConstants.SYM_PARAMETER);
}

private boolean isTransformFlushNeeded(Table table) {
return matchesTable(table, TableConstants.SYM_TRANSFORM_COLUMN)
Expand Down Expand Up @@ -144,6 +159,12 @@ public void batchCommitted(
log.info("About to refresh the cache of transformation because new configuration came through the data loader");
transformService.resetCache();
}

if (context.get(CTX_KEY_FLUSH_PARAMETERS_NEEDED) != null
&& parameterService.is(ParameterConstants.AUTO_SYNC_CONFIGURATION)) {
log.info("About to refresh the cache of parameters because new configuration came through the data loader");
parameterService.rereadParameters();
}
}

}

0 comments on commit 9b1250a

Please sign in to comment.