22
33import com .alibaba .fastjson .JSON ;
44import com .alipay .oceanbase .hbase .execute .AbstractObTableMetaExecutor ;
5+ import com .alipay .oceanbase .rpc .protocol .payload .ResultCodes ;
56import com .alipay .oceanbase .rpc .ObTableClient ;
7+ import com .alipay .oceanbase .rpc .exception .ObTableException ;
68import com .alipay .oceanbase .rpc .meta .ObTableMetaRequest ;
79import com .alipay .oceanbase .rpc .meta .ObTableMetaResponse ;
810import com .alipay .oceanbase .rpc .meta .ObTableRpcMetaType ;
@@ -40,7 +42,21 @@ public Void enableTable(String tableName) throws IOException, TableNotFoundExcep
4042 requestData .put ("table_name" , tableName );
4143 String jsonData = JSON .toJSONString (requestData );
4244 request .setData (jsonData );
43- return execute (tableClient , request );
45+ try {
46+ return execute (tableClient , request );
47+ } catch (IOException e ) {
48+ Throwable cause = e .getCause ();
49+ if (cause instanceof ObTableException ) {
50+ ObTableException obEx = (ObTableException ) cause ;
51+ int errCode = obEx .getErrorCode ();
52+ if (ResultCodes .OB_KV_TABLE_NOT_ENABLED .errorCode == errCode ) {
53+ throw new TableNotEnabledException ("Table is not enabled: " + tableName + obEx );
54+ } else if (ResultCodes .OB_TABLEGROUP_NOT_EXIST .errorCode == errCode ) {
55+ throw new TableNotFoundException ("Table not found: " + tableName + obEx );
56+ }
57+ }
58+ throw e ;
59+ }
4460 }
4561
4662 public Void disableTable (String tableName ) throws IOException , TableNotFoundException , TableNotDisabledException {
@@ -50,6 +66,20 @@ public Void disableTable(String tableName) throws IOException, TableNotFoundExce
5066 requestData .put ("table_name" , tableName );
5167 String jsonData = JSON .toJSONString (requestData );
5268 request .setData (jsonData );
53- return execute (tableClient , request );
69+ try {
70+ return execute (tableClient , request );
71+ } catch (IOException e ) {
72+ Throwable cause = e .getCause ();
73+ if (cause instanceof ObTableException ) {
74+ ObTableException obEx = (ObTableException ) cause ;
75+ int errCode = obEx .getErrorCode ();
76+ if (ResultCodes .OB_KV_TABLE_NOT_DISABLED .errorCode == errCode ) {
77+ throw new TableNotDisabledException ("Table is not disabled: " + tableName + obEx );
78+ } else if (ResultCodes .OB_TABLEGROUP_NOT_EXIST .errorCode == errCode ) {
79+ throw new TableNotFoundException ("Table not found: " + tableName + obEx );
80+ }
81+ }
82+ throw e ;
83+ }
5484 }
5585}
0 commit comments