Skip to content

Commit

Permalink
0003099: target and source node caches don't get refreshed when sym_node
Browse files Browse the repository at this point in the history
is sync'd to other nodes for the first time
  • Loading branch information
chenson42 committed May 9, 2017
1 parent 911b17b commit e2401ad
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Expand Up @@ -38,6 +38,7 @@
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterFilterAdapter;
import org.jumpmind.symmetric.job.IJobManager;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeSecurity;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.IParameterService;
Expand Down Expand Up @@ -207,9 +208,14 @@ private void recordNodeSecurityFlushNeeded(DataContext context, Table table) {
}

private void recordNodeFlushNeeded(DataContext context, Table table, CsvData data) {
if (data.getDataEventType() == DataEventType.INSERT
&& matchesTable(table, TableConstants.SYM_NODE)) {
context.put(CTX_KEY_FLUSH_NODE_NEEDED, true);
if (matchesTable(table, TableConstants.SYM_NODE) &&
context.getBatch().getBatchId() != Constants.VIRTUAL_BATCH_FOR_REGISTRATION) {
Map<String, String> newData = data.toColumnNameValuePairs(table.getColumnNames(), CsvData.ROW_DATA);
String nodeId = newData.get("NODE_ID");
Node node = engine.getNodeService().findNodeInCacheOnly(nodeId);
if (node == null || data.getDataEventType() == DataEventType.INSERT || !node.isSyncEnabled()) {
context.put(CTX_KEY_FLUSH_NODE_NEEDED, true);
}
}
}

Expand Down Expand Up @@ -372,6 +378,7 @@ public void batchCommitted(DataContext context) {
if (context.get(CTX_KEY_FLUSH_NODE_NEEDED) != null) {
log.info("About to refresh the cache of nodes because new configuration came through the data loader");
nodeService.flushNodeCache();
nodeService.flushNodeGroupCache();
context.remove(CTX_KEY_FLUSH_NODE_NEEDED);
}

Expand Down
Expand Up @@ -46,6 +46,8 @@ public interface INodeService {

public Node findNode(String id, boolean useCache);

public Node findNodeInCacheOnly(String id);

public String getExternalId(String nodeId);

public List<NodeHost> findNodeHosts(String nodeId);
Expand Down
Expand Up @@ -150,6 +150,10 @@ public Node findNode(String id) {
new NodeRowMapper(), id);
return (Node) getFirstEntry(list);
}

public Node findNodeInCacheOnly(String id) {
return nodeCache.get(id);
}

public Node findNode(String id, boolean useCache) {
if (useCache) {
Expand Down
Expand Up @@ -140,6 +140,11 @@ public String findIdentityNodeId() {
public Node findNode(String nodeId) {
return null;
}

@Override
public Node findNodeInCacheOnly(String id) {
return null;
}

public Node findNodeByExternalId(String nodeGroupId, String externalId) {
return null;
Expand Down

0 comments on commit e2401ad

Please sign in to comment.