Search in sources :

Example 1 with TransformPoint

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;
}
Also used : TypedProperties(org.jumpmind.properties.TypedProperties) ArrayList(java.util.ArrayList) List(java.util.List) NodeGroupLink(org.jumpmind.symmetric.model.NodeGroupLink) HashMap(java.util.HashMap) Map(java.util.Map) TransformPoint(org.jumpmind.symmetric.io.data.transform.TransformPoint)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TypedProperties (org.jumpmind.properties.TypedProperties)1 TransformPoint (org.jumpmind.symmetric.io.data.transform.TransformPoint)1 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)1