Skip to content

Commit

Permalink
0005638: Flush cache of routers when a router is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Dec 16, 2022
1 parent 4521d85 commit 9e4872a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
Expand Up @@ -234,6 +234,15 @@ public void flushRouters() {
triggerRouterCache.flushRouters();
}

@Override
public void flushAllWithRouters() {
flushTriggerRoutersByNodeGroupId();
flushTriggerRoutersByChannel();
flushTriggerRouters();
flushTriggerRoutersByTriggerHist();
flushTriggerRoutersById();
}

@Override
public List<Node> getSourceNodesCache(NodeGroupLinkAction eventAction, Node node) {
initializeNodeCache();
Expand Down
Expand Up @@ -71,6 +71,8 @@ public interface ICacheManager {

public void flushRouters();

public void flushAllWithRouters();

public List<Node> getSourceNodesCache(NodeGroupLinkAction eventAction, Node node);

public List<Node> getTargetNodesCache(NodeGroupLinkAction eventAction, Node node);
Expand Down
Expand Up @@ -59,6 +59,7 @@ public class ConfigurationChangedHelper {
private static final String CTX_KEY_FLUSH_NODE_GROUP_LINKS_NEEDED = "FlushNodeGroups." + SUFFIX;
private static final String CTX_KEY_FLUSH_NODE_SECURITY_NEEDED = "FlushNodeSecurity." + SUFFIX;
private static final String CTX_KEY_FLUSH_NOTIFICATIONS_NEEDED = "FlushNotifications." + SUFFIX;
private static final String CTX_KEY_FLUSH_ROUTERS_NEEDED = "FlushRouters." + SUFFIX;
private static final String CTX_KEY_FLUSH_PARAMETERS_NEEDED = "FlushParameters." + SUFFIX;
private static final String CTX_KEY_FLUSH_TRANSFORMS_NEEDED = "FlushTransforms." + SUFFIX;
private static final String CTX_KEY_RESYNC_NEEDED = "Resync." + SUFFIX;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void handleChange(Context context, Table table, CsvData data) {
CTX_KEY_RESYNC_NEEDED);
updateContext(TableConstants.SYM_NOTIFICATION, table, context, CTX_KEY_FLUSH_NOTIFICATIONS_NEEDED);
updateContext(TableConstants.SYM_PARAMETER, table, context, CTX_KEY_FLUSH_PARAMETERS_NEEDED);
updateContext(TableConstants.SYM_ROUTER, table, context, CTX_KEY_RESYNC_NEEDED);
updateContext(TableConstants.SYM_ROUTER, table, context, CTX_KEY_RESYNC_NEEDED, CTX_KEY_FLUSH_ROUTERS_NEEDED);
updateContext(TableConstants.SYM_TRANSFORM_TABLE, table, context, CTX_KEY_FLUSH_TRANSFORMS_NEEDED);
updateContext(TableConstants.SYM_TRANSFORM_COLUMN, table, context, CTX_KEY_FLUSH_TRANSFORMS_NEEDED);
updateContext(TableConstants.SYM_TRIGGER_ROUTER_GROUPLET, table, context, CTX_KEY_FLUSH_GROUPLETS_NEEDED, CTX_KEY_RESYNC_NEEDED);
Expand Down Expand Up @@ -184,6 +185,11 @@ public void contextCommitted(Context context) {
log.info("Clearing cache for parameters");
engine.getParameterService().rereadParameters();
}
if (context.remove(CTX_KEY_FLUSH_ROUTERS_NEEDED) != null) {
log.info("Clearing cache for routers");
engine.getCacheManager().flushAllWithRouters();
engine.getRouterService().flushCache();
}
if (context.remove(CTX_KEY_CLUSTER_NEEDED) != null) {
engine.getClusterService().refreshLockEntries();
}
Expand Down
Expand Up @@ -53,4 +53,6 @@ public boolean shouldDataBeRouted(SimpleRouterContext context, DataMetaData data
public List<DataGap> getDataGaps();

public void stop();

public void flushCache();
}
Expand Up @@ -172,6 +172,10 @@ public synchronized void stop() {
}
}

public void flushCache() {
defaultRoutersCacheTime = 0;
}

/**
* This method will route data to specific nodes.
*/
Expand Down

0 comments on commit 9e4872a

Please sign in to comment.