4
4
import com .alipay .oceanbase .rpc .bolt .transport .TransportCodes ;
5
5
import com .alipay .oceanbase .hbase .exception .FeatureNotSupportedException ;
6
6
import com .alipay .oceanbase .rpc .exception .ObTableTransportException ;
7
+ import com .alipay .oceanbase .rpc .meta .ObTableRpcMetaType ;
7
8
import org .apache .hadoop .conf .Configuration ;
8
9
import org .apache .hadoop .hbase .*;
9
10
import org .apache .hadoop .hbase .client .*;
@@ -243,7 +244,19 @@ public Future<Void> truncateTableAsync(TableName tableName, boolean b) throws IO
243
244
244
245
@ Override
245
246
public void enableTable (TableName tableName ) throws IOException {
246
- throw new FeatureNotSupportedException ("does not support yet" );
247
+ OHConnectionConfiguration connectionConf = new OHConnectionConfiguration (conf );
248
+ ObTableClient tableClient = ObTableClientManager .getOrCreateObTableClientByTableName (tableName , connectionConf );
249
+ OHTableAccessControlExecutor executor = new OHTableAccessControlExecutor (tableClient , ObTableRpcMetaType .HTABLE_ENABLE_TABLE );
250
+ try {
251
+ executor .enableTable (tableName .getNameAsString ());
252
+ } catch (IOException e ) {
253
+ if (e .getCause () instanceof ObTableTransportException
254
+ && ((ObTableTransportException ) e .getCause ()).getErrorCode () == TransportCodes .BOLT_TIMEOUT ) {
255
+ throw new TimeoutIOException (e .getCause ());
256
+ } else {
257
+ throw e ;
258
+ }
259
+ }
247
260
}
248
261
249
262
@ Override
@@ -268,7 +281,19 @@ public Future<Void> disableTableAsync(TableName tableName) throws IOException {
268
281
269
282
@ Override
270
283
public void disableTable (TableName tableName ) throws IOException {
271
- throw new FeatureNotSupportedException ("does not support yet" );
284
+ OHConnectionConfiguration connectionConf = new OHConnectionConfiguration (conf );
285
+ ObTableClient tableClient = ObTableClientManager .getOrCreateObTableClientByTableName (tableName , connectionConf );
286
+ OHTableAccessControlExecutor executor = new OHTableAccessControlExecutor (tableClient , ObTableRpcMetaType .HTABLE_DISABLE_TABLE );
287
+ try {
288
+ executor .disableTable (tableName .getNameAsString ());
289
+ } catch (IOException e ) {
290
+ if (e .getCause () instanceof ObTableTransportException
291
+ && ((ObTableTransportException ) e .getCause ()).getErrorCode () == TransportCodes .BOLT_TIMEOUT ) {
292
+ throw new TimeoutIOException (e .getCause ());
293
+ } else {
294
+ throw e ;
295
+ }
296
+ }
272
297
}
273
298
274
299
@ Override
@@ -283,12 +308,19 @@ public HTableDescriptor[] disableTables(Pattern pattern) throws IOException {
283
308
284
309
@ Override
285
310
public boolean isTableEnabled (TableName tableName ) throws IOException {
286
- throw new FeatureNotSupportedException ( "does not support yet" ) ;
311
+ return isDisabled ( tableName ) == false ;
287
312
}
288
313
289
314
@ Override
290
315
public boolean isTableDisabled (TableName tableName ) throws IOException {
291
- throw new FeatureNotSupportedException ("does not support yet" );
316
+ return isDisabled (tableName ) == true ;
317
+ }
318
+
319
+ private boolean isDisabled (TableName tableName ) throws IOException {
320
+ OHConnectionConfiguration connectionConf = new OHConnectionConfiguration (conf );
321
+ ObTableClient tableClient = ObTableClientManager .getOrCreateObTableClientByTableName (tableName , connectionConf );
322
+ OHTableDescriptorExecutor tableDescriptor = new OHTableDescriptorExecutor (tableName .getNameAsString (), tableClient );
323
+ return tableDescriptor .isDisable ();
292
324
}
293
325
294
326
@ Override
0 commit comments