This is an automated email from the ASF dual-hosted git repository.
dengzhhu653 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 055b052171b HIVE-29979: Operational metadata APIs reinforcement (#6829)
055b052171b is described below
commit 055b052171b781b3bbe7f80db948143a95b3cbae
Author: Daniel (Hongdan) Zhu <[email protected]>
AuthorDate: Tue Oct 27 18:42:26 2026 -0700
HIVE-29979: Operational metadata APIs reinforcement (#6829)
---
.../java/org/apache/hadoop/hive/metastore/HMSHandler.java | 13 +++++++++----
.../apache/hadoop/hive/metastore/handler/BaseHandler.java | 2 +-
.../hive/metastore/client/TestGetAllWriteEventInfo.java | 14 ++++++++++++++
.../hive/metastore/client/TestReplicationMetrics.java | 14 ++++++++++++++
.../hadoop/hive/metastore/client/TestRuntimeStats.java | 14 ++++++++++++++
5 files changed, 52 insertions(+), 5 deletions(-)
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
index 246a627fba3..3cc3eff494a 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
@@ -3890,6 +3890,7 @@ public void add_runtime_stats(RuntimeStat stat) throws
TException {
boolean success = false;
RawStore ms = getMS();
try {
+ authorizeProxyPrivilege();
ms.openTransaction();
ms.addRuntimeStat(stat);
success = ms.commitTransaction();
@@ -3910,9 +3911,10 @@ public List<RuntimeStat>
get_runtime_stats(GetRuntimeStatsRequest rqst) throws T
startFunction("get_runtime_stats");
Exception ex = null;
try {
+ authorizeProxyPrivilege();
List<RuntimeStat> res = getMS().getRuntimeStats(rqst.getMaxWeight(),
rqst.getMaxCreateTime());
return res;
- } catch (MetaException e) {
+ } catch (TException e) {
LOG.error("Caught exception", e);
ex = e;
throw e;
@@ -4029,10 +4031,11 @@ public ScheduledQuery
get_scheduled_query(ScheduledQueryKey scheduleKey) throws
}
@Override
- public void add_replication_metrics(ReplicationMetricList
replicationMetricList) throws MetaException{
+ public void add_replication_metrics(ReplicationMetricList
replicationMetricList) throws TException {
startFunction("add_replication_metrics");
Exception ex = null;
try {
+ authorizeProxyPrivilege();
getMS().addReplicationMetrics(replicationMetricList);
} catch (Exception e) {
LOG.error("Caught exception", e);
@@ -4045,10 +4048,11 @@ public void
add_replication_metrics(ReplicationMetricList replicationMetricList)
@Override
public ReplicationMetricList
get_replication_metrics(GetReplicationMetricsRequest
-
getReplicationMetricsRequest) throws MetaException{
+
getReplicationMetricsRequest) throws TException {
startFunction("get_replication_metrics");
Exception ex = null;
try {
+ authorizeProxyPrivilege();
return getMS().getReplicationMetrics(getReplicationMetricsRequest);
} catch (Exception e) {
LOG.error("Caught exception", e);
@@ -4192,10 +4196,11 @@ public void drop_package(DropPackageRequest request)
throws MetaException {
@Override
public List<WriteEventInfo>
get_all_write_event_info(GetAllWriteEventInfoRequest request)
- throws MetaException {
+ throws TException {
startFunction("get_all_write_event_info");
Exception ex = null;
try {
+ authorizeProxyPrivilege();
List<WriteEventInfo> writeEventInfoList =
getMS().getAllWriteEventInfo(request.getTxnId(),
request.getDbName(), request.getTableName());
return writeEventInfoList == null ? Collections.emptyList() :
writeEventInfoList;
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
index 9c9d7c078dd..33fe9351b19 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/handler/BaseHandler.java
@@ -853,7 +853,7 @@ public NotificationEventsCountResponse
get_notification_events_count(Notificatio
return ms.getNotificationEventsCount(rqst);
}
- private void authorizeProxyPrivilege() throws TException {
+ protected void authorizeProxyPrivilege() throws TException {
// Skip the auth in embedded mode or if the auth is disabled
if (!HiveMetaStore.isMetaStoreRemote() ||
!MetastoreConf.getBoolVar(conf,
MetastoreConf.ConfVars.EVENT_DB_NOTIFICATION_API_AUTH) ||
diff --git
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetAllWriteEventInfo.java
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetAllWriteEventInfo.java
index 7ffba73fd66..df1a863ab6b 100644
---
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetAllWriteEventInfo.java
+++
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetAllWriteEventInfo.java
@@ -28,11 +28,13 @@
import org.apache.hadoop.hive.metastore.api.WriteEventInfo;
import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder;
import org.apache.hadoop.hive.metastore.client.builder.TableBuilder;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
import org.apache.hadoop.hive.metastore.model.MTxnWriteNotificationLog;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
@@ -40,7 +42,9 @@
import javax.jdo.PersistenceManager;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Tests for API getAllWriteEventInfo.
@@ -62,6 +66,16 @@ public TestGetAllWriteEventInfo(String name,
AbstractMetaStoreService metaStore)
this.metaStore = metaStore;
}
+ @BeforeClass
+ public static void startMetaStores() {
+ // The remote mini-HMS marks the whole JVM as remote, so
authorizeProxyPrivilege() would also reject the
+ // (non-proxy) test user on this API. Disable it for this test.
+ Map<MetastoreConf.ConfVars, String> msConf = new HashMap<>();
+ Map<String, String> extraConf = new HashMap<>();
+
extraConf.put(MetastoreConf.ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.getVarname(),
"false");
+ startMetaStores(msConf, extraConf);
+ }
+
@Before
public void setUp() throws Exception {
client = metaStore.getClient();
diff --git
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestReplicationMetrics.java
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestReplicationMetrics.java
index e56c289aa76..abcbb9ed61c 100644
---
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestReplicationMetrics.java
+++
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestReplicationMetrics.java
@@ -25,16 +25,20 @@
import org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest;
import org.apache.hadoop.hive.metastore.api.ReplicationMetricList;
import org.apache.hadoop.hive.metastore.api.ReplicationMetrics;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import static org.junit.Assert.assertEquals;
@@ -52,6 +56,16 @@ public TestReplicationMetrics(String name,
AbstractMetaStoreService metaStore) t
this.metaStore = metaStore;
}
+ @BeforeClass
+ public static void startMetaStores() {
+ // The remote mini-HMS marks the whole JVM as remote, so
authorizeProxyPrivilege() would also reject the
+ // (non-proxy) test user on this API. Disable it for this test.
+ Map<MetastoreConf.ConfVars, String> msConf = new HashMap<>();
+ Map<String, String> extraConf = new HashMap<>();
+
extraConf.put(MetastoreConf.ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.getVarname(),
"false");
+ startMetaStores(msConf, extraConf);
+ }
+
@Before
public void setUp() throws Exception {
client = metaStore.getClient();
diff --git
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestRuntimeStats.java
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestRuntimeStats.java
index 4820e002926..0497e916476 100644
---
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestRuntimeStats.java
+++
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestRuntimeStats.java
@@ -23,14 +23,18 @@
import org.apache.hadoop.hive.metastore.ObjectStore;
import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest;
import org.apache.hadoop.hive.metastore.api.RuntimeStat;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertArrayEquals;
@@ -48,6 +52,16 @@ public TestRuntimeStats(String name,
AbstractMetaStoreService metaStore) throws
this.metaStore = metaStore;
}
+ @BeforeClass
+ public static void startMetaStores() {
+ // The remote mini-HMS marks the whole JVM as remote, so
authorizeProxyPrivilege() would also reject the
+ // (non-proxy) test user on this API. Disable it for this test.
+ Map<MetastoreConf.ConfVars, String> msConf = new HashMap<>();
+ Map<String, String> extraConf = new HashMap<>();
+
extraConf.put(MetastoreConf.ConfVars.EVENT_DB_NOTIFICATION_API_AUTH.getVarname(),
"false");
+ startMetaStores(msConf, extraConf);
+ }
+
@Before
public void setUp() throws Exception {
client = metaStore.getClient();