You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2025/09/18 10:32:26 UTC
(ranger) branch RANGER-5288_master created (now 3883fd130)
This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a change to branch RANGER-5288_master
in repository https://gitbox.apache.org/repos/asf/ranger.git
at 3883fd130 RANGER-5260: Improve performance of MetricUtil for policies count
This branch includes the following new commits:
new 7809e2130 RANGER-5288: Rename column of table x_gds_shared_resource from resource to resource_name
new 3883fd130 RANGER-5260: Improve performance of MetricUtil for policies count
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(ranger) 01/02: RANGER-5288: Rename column of table x_gds_shared_resource from resource to resource_name
Posted by pr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch RANGER-5288_master
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 7809e21303c9a30c792a1cdc01373b505b51b323
Author: Pradeep AgrawaL <pr...@apache.org>
AuthorDate: Thu Sep 18 11:59:01 2025 +0530
RANGER-5288: Rename column of table x_gds_shared_resource from resource to resource_name
---
security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql | 2 +-
security-admin/db/mysql/patches/067-create-gds-tables.sql | 2 +-
security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql | 2 +-
security-admin/db/oracle/patches/067-create-gds-tables.sql | 2 +-
.../db/postgres/optimized/current/ranger_core_db_postgres.sql | 2 +-
security-admin/db/postgres/patches/067-create-gds-tables.sql | 2 +-
.../src/main/java/org/apache/ranger/entity/XXGdsSharedResource.java | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
index 26e8b6590..f0448738e 100644
--- a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
+++ b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
@@ -1787,7 +1787,7 @@ CREATE TABLE `x_gds_shared_resource`(
, `name` VARCHAR(512) NOT NULL
, `description` TEXT NULL DEFAULT NULL
, `data_share_id` BIGINT(20) NOT NULL
- , `resource` TEXT NOT NULL
+ , `resource_name` TEXT NOT NULL
, `resource_signature` VARCHAR(128) NOT NULL
, `sub_resource` TEXT NULL DEFAULT NULL
, `sub_resource_type` TEXT NULL DEFAULT NULL
diff --git a/security-admin/db/mysql/patches/067-create-gds-tables.sql b/security-admin/db/mysql/patches/067-create-gds-tables.sql
index ed74da8ae..f8663d5a5 100644
--- a/security-admin/db/mysql/patches/067-create-gds-tables.sql
+++ b/security-admin/db/mysql/patches/067-create-gds-tables.sql
@@ -111,7 +111,7 @@ CREATE TABLE `x_gds_shared_resource`(
, `name` VARCHAR(512) NOT NULL
, `description` TEXT NULL DEFAULT NULL
, `data_share_id` BIGINT(20) NOT NULL
- , `resource` TEXT NOT NULL
+ , `resource_name` TEXT NOT NULL
, `resource_signature` VARCHAR(128) NOT NULL
, `sub_resource` TEXT NULL DEFAULT NULL
, `sub_resource_type` TEXT NULL DEFAULT NULL
diff --git a/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql b/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql
index 4bd984ced..64e998e24 100644
--- a/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql
+++ b/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql
@@ -2026,7 +2026,7 @@ CREATE TABLE x_gds_shared_resource (
name VARCHAR2(512) NOT NULL,
description CLOB DEFAULT NULL NULL,
data_share_id NUMBER(20) NOT NULL,
- "resource" CLOB NOT NULL,
+ resource_name CLOB NOT NULL,
resource_signature VARCHAR2(128) NOT NULL,
sub_resource CLOB DEFAULT NULL NULL,
sub_resource_type CLOB DEFAULT NULL NULL,
diff --git a/security-admin/db/oracle/patches/067-create-gds-tables.sql b/security-admin/db/oracle/patches/067-create-gds-tables.sql
index ebaa34465..c3f2772b9 100644
--- a/security-admin/db/oracle/patches/067-create-gds-tables.sql
+++ b/security-admin/db/oracle/patches/067-create-gds-tables.sql
@@ -159,7 +159,7 @@ CREATE TABLE x_gds_shared_resource (
name VARCHAR2(512) NOT NULL,
description CLOB DEFAULT NULL NULL,
data_share_id NUMBER(20) NOT NULL,
- "resource" CLOB NOT NULL,
+ resource_name CLOB NOT NULL,
resource_signature VARCHAR2(128) NOT NULL,
sub_resource CLOB DEFAULT NULL NULL,
sub_resource_type CLOB DEFAULT NULL NULL,
diff --git a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
index 8bfca56a1..8b0d8ae6e 100644
--- a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
+++ b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
@@ -1782,7 +1782,7 @@ CREATE TABLE x_gds_shared_resource(
, name VARCHAR(512) NOT NULL
, description TEXT NULL DEFAULT NULL
, data_share_id BIGINT NOT NULL
- , resource TEXT NOT NULL
+ , resource_name TEXT NOT NULL
, resource_signature VARCHAR(128) NOT NULL
, sub_resource TEXT NULL DEFAULT NULL
, sub_resource_type TEXT NULL DEFAULT NULL
diff --git a/security-admin/db/postgres/patches/067-create-gds-tables.sql b/security-admin/db/postgres/patches/067-create-gds-tables.sql
index 688173527..de02f34b4 100644
--- a/security-admin/db/postgres/patches/067-create-gds-tables.sql
+++ b/security-admin/db/postgres/patches/067-create-gds-tables.sql
@@ -127,7 +127,7 @@ CREATE TABLE x_gds_shared_resource(
, name VARCHAR(512) NOT NULL
, description TEXT NULL DEFAULT NULL
, data_share_id BIGINT NOT NULL
- , resource TEXT NOT NULL
+ , resource_name TEXT NOT NULL
, resource_signature VARCHAR(128) NOT NULL
, sub_resource TEXT NULL DEFAULT NULL
, sub_resource_type TEXT NULL DEFAULT NULL
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXGdsSharedResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXGdsSharedResource.java
index 90968f8a6..efd7ed4ea 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXGdsSharedResource.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXGdsSharedResource.java
@@ -67,7 +67,7 @@ public class XXGdsSharedResource extends XXDBBase implements Serializable {
@Column(name = "data_share_id")
protected Long dataShareId;
- @Column(name = "resource")
+ @Column(name = "resource_name")
protected String resource;
@Column(name = "sub_resource")
(ranger) 02/02: RANGER-5260: Improve performance of MetricUtil for policies count
Posted by pr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch RANGER-5288_master
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 3883fd130bdb81c7b285dda0511ace7ba8aa2e66
Author: Pradeep AgrawaL <pr...@apache.org>
AuthorDate: Thu Sep 18 12:09:25 2025 +0530
RANGER-5260: Improve performance of MetricUtil for policies count
---
.../apache/ranger/patch/cliutil/MetricUtil.java | 75 +---------------------
.../ranger/patch/cliutil/TestMetricUtil.java | 4 +-
2 files changed, 4 insertions(+), 75 deletions(-)
diff --git a/security-admin/src/main/java/org/apache/ranger/patch/cliutil/MetricUtil.java b/security-admin/src/main/java/org/apache/ranger/patch/cliutil/MetricUtil.java
index 92dacca14..5a83f2f06 100644
--- a/security-admin/src/main/java/org/apache/ranger/patch/cliutil/MetricUtil.java
+++ b/security-admin/src/main/java/org/apache/ranger/patch/cliutil/MetricUtil.java
@@ -16,7 +16,6 @@
*/
package org.apache.ranger.patch.cliutil;
-import org.apache.commons.lang.StringUtils;
import org.apache.ranger.audit.provider.MiscUtil;
import org.apache.ranger.authorization.utils.JsonUtils;
import org.apache.ranger.biz.AssetMgr;
@@ -30,7 +29,6 @@
import org.apache.ranger.common.SearchCriteria;
import org.apache.ranger.patch.BaseLoader;
import org.apache.ranger.plugin.model.RangerPolicy;
-import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem;
import org.apache.ranger.plugin.model.RangerService;
import org.apache.ranger.plugin.model.RangerServiceDef;
import org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef;
@@ -390,76 +388,9 @@ private void metricCalculation(String caseValue) {
break;
case "denyconditions":
try {
- SearchFilter policyFilter1 = new SearchFilter();
-
- policyFilter1.setMaxRows(200);
- policyFilter1.setStartIndex(0);
- policyFilter1.setGetCount(true);
- policyFilter1.setSortBy("serviceId");
- policyFilter1.setSortType("asc");
-
- int denyCount = 0;
- Map<String, Integer> denyconditionsonMap = new HashMap<>();
- PList<RangerServiceDef> paginatedSvcDefs = svcStore.getPaginatedServiceDefs(policyFilter1);
-
- if (paginatedSvcDefs != null) {
- List<RangerServiceDef> rangerServiceDefs = paginatedSvcDefs.getList();
-
- if (rangerServiceDefs != null && !rangerServiceDefs.isEmpty()) {
- for (RangerServiceDef rangerServiceDef : rangerServiceDefs) {
- if (rangerServiceDef != null) {
- String serviceDef = rangerServiceDef.getName();
-
- if (!StringUtils.isEmpty(serviceDef)) {
- policyFilter1.setParam("serviceType", serviceDef);
- policyFilter1.setParam("denyCondition", "true");
-
- PList<RangerPolicy> policiesList = svcStore.getPaginatedPolicies(policyFilter1);
-
- if (policiesList != null && policiesList.getListSize() > 0) {
- int policyListCount = policiesList.getListSize();
-
- if (policyListCount > 0 && policiesList.getList() != null) {
- List<RangerPolicy> policies = policiesList.getList();
-
- for (RangerPolicy policy : policies) {
- if (policy != null) {
- List<RangerPolicyItem> policyItem = policy.getDenyPolicyItems();
-
- if (policyItem != null && !policyItem.isEmpty()) {
- if (denyconditionsonMap.get(serviceDef) != null) {
- denyCount = denyconditionsonMap.get(serviceDef) + denyCount + policyItem.size();
- } else {
- denyCount = denyCount + policyItem.size();
- }
- }
-
- List<RangerPolicyItem> policyItemExclude = policy.getDenyExceptions();
- if (policyItemExclude != null && !policyItemExclude.isEmpty()) {
- if (denyconditionsonMap.get(serviceDef) != null) {
- denyCount = denyconditionsonMap.get(serviceDef) + denyCount + policyItemExclude.size();
- } else {
- denyCount = denyCount + policyItemExclude.size();
- }
- }
- }
- }
- }
- }
-
- policyFilter1.removeParam("serviceType");
- }
-
- denyconditionsonMap.put(serviceDef, denyCount);
-
- denyCount = 0;
- }
- }
- }
- }
-
- String jsonContextDenyCondtionOn = JsonUtils.objectToJson(denyconditionsonMap);
- System.out.println(jsonContextDenyCondtionOn);
+ Map<String, Long> denyconditionsonMap = svcStore.getPolicyCountByDenyConditionsAndServiceDef();
+ String jsonContextDenyCondition = JsonUtils.objectToJson(denyconditionsonMap);
+ System.out.println(jsonContextDenyCondition);
} catch (Exception e) {
logger.error("Error calculating Metric for denyconditions : {}", e.getMessage());
}
diff --git a/security-admin/src/test/java/org/apache/ranger/patch/cliutil/TestMetricUtil.java b/security-admin/src/test/java/org/apache/ranger/patch/cliutil/TestMetricUtil.java
index fa0ce8688..70f8eba98 100644
--- a/security-admin/src/test/java/org/apache/ranger/patch/cliutil/TestMetricUtil.java
+++ b/security-admin/src/test/java/org/apache/ranger/patch/cliutil/TestMetricUtil.java
@@ -216,7 +216,6 @@ public void testExecLoad_denyconditions() throws Exception {
PList<RangerServiceDef> defs = new PList<>();
defs.setList(Collections.singletonList(def));
defs.setTotalCount(1L);
- Mockito.when(svcStore.getPaginatedServiceDefs(Mockito.any(SearchFilter.class))).thenReturn(defs);
RangerPolicy policy = new RangerPolicy();
policy.setDenyPolicyItems(Collections.singletonList(new RangerPolicy.RangerPolicyItem()));
@@ -224,10 +223,9 @@ public void testExecLoad_denyconditions() throws Exception {
PList<RangerPolicy> policyList = new PList<>();
policyList.setList(Collections.singletonList(policy));
policyList.setTotalCount(1L);
- Mockito.when(svcStore.getPaginatedPolicies(Mockito.any(SearchFilter.class))).thenReturn(policyList);
metricUtil.execLoad();
- Mockito.verify(svcStore, Mockito.atLeast(1)).getPaginatedServiceDefs(Mockito.any(SearchFilter.class));
+ Mockito.verify(svcStore, Mockito.atLeast(1)).getPolicyCountByDenyConditionsAndServiceDef();
}
}