/** * Invalidate any policy with action. It will send the cluster message to clean this policy in all * the nodes. * * @param policyId * @param action */ public void invalidateCache(String policyId, String action) { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (log.isDebugEnabled()) { log.debug( "Trigger invalidateCache to tenant : " + tenantId + " and policy " + policyId + " for action " + ": " + action); } IdentityCacheKey cacheKey = new IdentityCacheKey(tenantId, policyId); PolicyStatus policyStatus = (PolicyStatus) getValueFromCache(cacheKey); if (policyStatus == null) { policyStatus = new PolicyStatus(policyId, 0, action); } else { policyStatus.setStatusCount(policyStatus.getStatusCount() + 1); policyStatus.setPolicyAction(action); } updateToCache(cacheKey, policyStatus); synchronized (localPolicyCacheMap) { if (localPolicyCacheMap.get(cacheKey.getTenantId()) != null) { if (localPolicyCacheMap.get(cacheKey.getTenantId()).get(cacheKey.getKey()) != null) { PolicyStatus status = localPolicyCacheMap.get(cacheKey.getTenantId()).get(cacheKey.getKey()); status.setPolicyAction(getPriorityAction(status.getPolicyAction(), action)); } } else { Map<String, PolicyStatus> map = new HashMap<String, PolicyStatus>(); map.put(policyId, policyStatus); localPolicyCacheMap.put(cacheKey.getTenantId(), map); } } }