From b418bc94d356746554c3d40d44142c5fd50477cd Mon Sep 17 00:00:00 2001 From: zjw Date: Fri, 30 May 2025 11:03:38 +0800 Subject: [PATCH 1/4] fix syntax errors --- .../hbase/util/OHTableAccessControlExecutor.java | 12 ++++++------ .../oceanbase/hbase/OHTableAdminInterfaceTest.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java index e2aadd0f..f3c02553 100644 --- a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java +++ b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java @@ -1,7 +1,6 @@ package com.alipay.oceanbase.hbase.util; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.alipay.oceanbase.hbase.execute.AbstractObTableMetaExecutor; import com.alipay.oceanbase.rpc.ObTableClient; import com.alipay.oceanbase.rpc.meta.ObTableMetaRequest; @@ -30,26 +29,27 @@ public ObTableRpcMetaType getMetaType() throws IOException { } @Override - public Boolean parse(ObTableMetaResponse response) throws IOException { + public Void parse(ObTableMetaResponse response) throws IOException { + return null; } - public void enableTable(String tableName) throws IOException, TableNotFoundException, TableNotEnabledException { + public Void enableTable(String tableName) throws IOException, TableNotFoundException, TableNotEnabledException { ObTableMetaRequest request = new ObTableMetaRequest(); request.setMetaType(getMetaType()); Map requestData = new HashMap<>(); requestData.put("name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - execute(tableClient, request); + return execute(tableClient, request); } - public void disableTable(String tableName) throws IOException, TableNotFoundException, TableNotDisabledException { + public Void disableTable(String tableName) throws IOException, TableNotFoundException, TableNotDisabledException { ObTableMetaRequest request = new ObTableMetaRequest(); request.setMetaType(getMetaType()); Map requestData = new HashMap<>(); requestData.put("name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - execute(tableClient, request); + return execute(tableClient, request); } } diff --git a/src/test/java/com/alipay/oceanbase/hbase/OHTableAdminInterfaceTest.java b/src/test/java/com/alipay/oceanbase/hbase/OHTableAdminInterfaceTest.java index f724d98f..ed656fbd 100644 --- a/src/test/java/com/alipay/oceanbase/hbase/OHTableAdminInterfaceTest.java +++ b/src/test/java/com/alipay/oceanbase/hbase/OHTableAdminInterfaceTest.java @@ -356,7 +356,7 @@ public void testAdminEnDisableTable() throws Exception { // enable an enabled table thrown = assertThrows(IOException.class, () -> { - admin.disableTable(TableName.valueOf("n1", "test"); + admin.disableTable(TableName.valueOf("n1", "test")); }); assertTrue(thrown.getCause() instanceof ObTableException); Assert.assertEquals(ResultCodes.OB_KV_TABLE_NOT_ENABLED.errorCode, ((ObTableException) thrown.getCause()).getErrorCode()); From 701c1e9cf49bcb830bc659f1661a6d6806f3bfe0 Mon Sep 17 00:00:00 2001 From: zjw Date: Fri, 30 May 2025 11:03:38 +0800 Subject: [PATCH 2/4] fix syntax errors --- .../hbase/util/OHTableAccessControlExecutor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java index 090da7e4..06bd9fe0 100644 --- a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java +++ b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java @@ -33,23 +33,23 @@ public Void parse(ObTableMetaResponse response) throws IOException { return null; } - public void enableTable(String tableName) throws IOException, TableNotFoundException, TableNotEnabledException { + public Void enableTable(String tableName) throws IOException, TableNotFoundException, TableNotEnabledException { ObTableMetaRequest request = new ObTableMetaRequest(); request.setMetaType(getMetaType()); Map requestData = new HashMap<>(); requestData.put("table_name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - execute(tableClient, request); + return execute(tableClient, request); } - public void disableTable(String tableName) throws IOException, TableNotFoundException, TableNotDisabledException { + public Void disableTable(String tableName) throws IOException, TableNotFoundException, TableNotDisabledException { ObTableMetaRequest request = new ObTableMetaRequest(); request.setMetaType(getMetaType()); Map requestData = new HashMap<>(); requestData.put("table_name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - execute(tableClient, request); + return execute(tableClient, request); } } From 1bfe3029224476bc0613b408a4faa492e4e83459 Mon Sep 17 00:00:00 2001 From: zjw Date: Thu, 5 Jun 2025 15:10:46 +0800 Subject: [PATCH 3/4] Align obkv-hbase enable/disable exception handling with HBase --- .../util/OHTableAccessControlExecutor.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java index 06bd9fe0..88e16317 100644 --- a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java +++ b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java @@ -2,7 +2,9 @@ import com.alibaba.fastjson.JSON; import com.alipay.oceanbase.hbase.execute.AbstractObTableMetaExecutor; +import com.alipay.oceanbase.rpc.protocol.payload.ResultCodes; import com.alipay.oceanbase.rpc.ObTableClient; +import com.alipay.oceanbase.rpc.exception.ObTableException; import com.alipay.oceanbase.rpc.meta.ObTableMetaRequest; import com.alipay.oceanbase.rpc.meta.ObTableMetaResponse; import com.alipay.oceanbase.rpc.meta.ObTableRpcMetaType; @@ -40,7 +42,21 @@ public Void enableTable(String tableName) throws IOException, TableNotFoundExcep requestData.put("table_name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - return execute(tableClient, request); + try{ + return execute(tableClient, request); + } catch (IOException e) { + Throwable cause = e.getCause(); + if (cause instanceof ObTableException) { + ObTableException obEx = (ObTableException) cause; + int errCode = obEx.getErrorCode(); + if(ResultCodes.OB_KV_TABLE_NOT_DISABLED.errorCode == errCode) { + throw new TableNotEnabledException("Table is not enabled: " + tableName + obEx); + } else if (ResultCodes.OB_TABLEGROUP_NOT_EXIST.errorCode == errCode) { + throw new TableNotFoundException("Table not found: " + tableName + obEx); + } + } + throw e; + } } public Void disableTable(String tableName) throws IOException, TableNotFoundException, TableNotDisabledException { @@ -50,6 +66,20 @@ public Void disableTable(String tableName) throws IOException, TableNotFoundExce requestData.put("table_name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - return execute(tableClient, request); + try{ + return execute(tableClient, request); + } catch (IOException e) { + Throwable cause = e.getCause(); + if (cause instanceof ObTableException) { + ObTableException obEx = (ObTableException) cause; + int errCode = obEx.getErrorCode(); + if(ResultCodes.OB_KV_TABLE_NOT_DISABLED.errorCode == errCode) { + throw new TableNotEnabledException("Table is not enabled: " + tableName + obEx); + } else if (ResultCodes.OB_TABLEGROUP_NOT_EXIST.errorCode == errCode) { + throw new TableNotFoundException("Table not found: " + tableName + obEx); + } + } + throw e; + } } } From da5089cd7d4313e0b7d6eec7d6a6b155e9d21230 Mon Sep 17 00:00:00 2001 From: zjw Date: Thu, 5 Jun 2025 17:41:20 +0800 Subject: [PATCH 4/4] Align obkv-hbase enable/disable exception handling with HBase --- .../hbase/util/OHTableAccessControlExecutor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java index 88e16317..e9dcfb2d 100644 --- a/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java +++ b/src/main/java/com/alipay/oceanbase/hbase/util/OHTableAccessControlExecutor.java @@ -42,14 +42,14 @@ public Void enableTable(String tableName) throws IOException, TableNotFoundExcep requestData.put("table_name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - try{ + try { return execute(tableClient, request); } catch (IOException e) { Throwable cause = e.getCause(); if (cause instanceof ObTableException) { ObTableException obEx = (ObTableException) cause; int errCode = obEx.getErrorCode(); - if(ResultCodes.OB_KV_TABLE_NOT_DISABLED.errorCode == errCode) { + if(ResultCodes.OB_KV_TABLE_NOT_ENABLED.errorCode == errCode) { throw new TableNotEnabledException("Table is not enabled: " + tableName + obEx); } else if (ResultCodes.OB_TABLEGROUP_NOT_EXIST.errorCode == errCode) { throw new TableNotFoundException("Table not found: " + tableName + obEx); @@ -66,7 +66,7 @@ public Void disableTable(String tableName) throws IOException, TableNotFoundExce requestData.put("table_name", tableName); String jsonData = JSON.toJSONString(requestData); request.setData(jsonData); - try{ + try { return execute(tableClient, request); } catch (IOException e) { Throwable cause = e.getCause(); @@ -74,7 +74,7 @@ public Void disableTable(String tableName) throws IOException, TableNotFoundExce ObTableException obEx = (ObTableException) cause; int errCode = obEx.getErrorCode(); if(ResultCodes.OB_KV_TABLE_NOT_DISABLED.errorCode == errCode) { - throw new TableNotEnabledException("Table is not enabled: " + tableName + obEx); + throw new TableNotDisabledException("Table is not disabled: " + tableName + obEx); } else if (ResultCodes.OB_TABLEGROUP_NOT_EXIST.errorCode == errCode) { throw new TableNotFoundException("Table not found: " + tableName + obEx); }