use of org.jumpmind.symmetric.io.data.transform.TransformPoint in project symmetric-ds by JumpMind.
the class TransformService method readInCacheIfExpired.
private Map<NodeGroupLink, Map<TransformPoint, List<TransformTableNodeGroupLink>>> readInCacheIfExpired() {
// get the cache timeout
long cacheTimeoutInMs = parameterService.getLong(ParameterConstants.CACHE_TIMEOUT_TRANSFORM_IN_MS);
Map<NodeGroupLink, Map<TransformPoint, List<TransformTableNodeGroupLink>>> byByLinkByTransformPoint = transformsCacheByNodeGroupLinkByTransformPoint;
synchronized (this) {
if (System.currentTimeMillis() - lastCacheTimeInMs >= cacheTimeoutInMs || byByLinkByTransformPoint == null) {
byByLinkByTransformPoint = new HashMap<NodeGroupLink, Map<TransformPoint, List<TransformTableNodeGroupLink>>>();
List<TransformTableNodeGroupLink> transforms = getTransformTablesFromDB(true);
for (TransformTableNodeGroupLink transformTable : transforms) {
NodeGroupLink nodeGroupLink = transformTable.getNodeGroupLink();
Map<TransformPoint, List<TransformTableNodeGroupLink>> byTransformPoint = byByLinkByTransformPoint.get(nodeGroupLink);
if (byTransformPoint == null) {
byTransformPoint = new HashMap<TransformPoint, List<TransformTableNodeGroupLink>>();
byByLinkByTransformPoint.put(nodeGroupLink, byTransformPoint);
}
List<TransformTableNodeGroupLink> byTableName = byTransformPoint.get(transformTable.getTransformPoint());
if (byTableName == null) {
byTableName = new ArrayList<TransformTableNodeGroupLink>();
byTransformPoint.put(transformTable.getTransformPoint(), byTableName);
}
/* Allow for parameterized source and target names */
TypedProperties parameters = parameterService.getAllParameters();
transformTable.setSourceCatalogName(FormatUtils.replaceTokens(transformTable.getSourceCatalogName(), parameters, true));
transformTable.setSourceSchemaName(FormatUtils.replaceTokens(transformTable.getSourceSchemaName(), parameters, true));
transformTable.setSourceTableName(FormatUtils.replaceTokens(transformTable.getSourceTableName(), parameters, true));
transformTable.setTargetCatalogName(FormatUtils.replaceTokens(transformTable.getTargetCatalogName(), parameters, true));
transformTable.setTargetSchemaName(FormatUtils.replaceTokens(transformTable.getTargetSchemaName(), parameters, true));
transformTable.setTargetTableName(FormatUtils.replaceTokens(transformTable.getTargetTableName(), parameters, true));
byTableName.add(transformTable);
}
lastCacheTimeInMs = System.currentTimeMillis();
this.transformsCacheByNodeGroupLinkByTransformPoint = byByLinkByTransformPoint;
}
}
return byByLinkByTransformPoint;
}
Aggregations