Description
During the servie deletion ,we need to clear the RangerServicePoliciesCache for the given serviceName
@Override public void deleteService(Long id) throws Exception { if(LOG.isDebugEnabled()) { LOG.debug("==> ServiceDBStore.deleteService(" + id + ")"); } RangerService service = getService(id); if(service == null) { throw new Exception("no service exists with ID=" + id); } // Manage zone disassociateZonesForService(service); //RANGER-3016 List<Long> policyIds = daoMgr.getXXPolicy().findPolicyIdsByServiceId(service.getId()); if (CollectionUtils.isNotEmpty(policyIds)) { long totalDeletedPolicies = 0; for (Long policyID : policyIds) { RangerPolicy rangerPolicy = getPolicy(policyID); deletePolicy(rangerPolicy, service); totalDeletedPolicies = totalDeletedPolicies + 1; // its a bulk policy delete call flush and clear if (totalDeletedPolicies % RangerBizUtil.policyBatchSize == 0) { bizUtil.bulkModeOnlyFlushAndClear(); } } bizUtil.bulkModeOnlyFlushAndClear(); } XXServiceConfigMapDao configDao = daoMgr.getXXServiceConfigMap(); List<XXServiceConfigMap> configs = configDao.findByServiceId(service.getId()); for (XXServiceConfigMap configMap : configs) { configDao.remove(configMap); } // Purge x_rms data daoMgr.getXXRMSServiceResource().purge(service.getId()); Long version = service.getVersion(); if(version == null) { version = Long.valueOf(1); LOG.info("Found Version Value: `null`, so setting value of version to 1, While updating object, version should not be null."); } else { version = Long.valueOf(version.longValue() + 1); } service.setVersion(version); svcService.delete(service); dataHistService.createObjectDataHistory(service, RangerDataHistService.ACTION_DELETE); List<XXTrxLog> trxLogList = svcService.getTransactionLog(service, RangerServiceService.OPERATION_DELETE_CONTEXT); bizUtil.createTrxLog(trxLogList); //During the servie deletion ,we need to clear the RangerServicePoliciesCache for the given serviceName. resetPolicyCache(service.getName()); }