001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.thrift2.client;
019
020import java.io.IOException;
021import java.nio.ByteBuffer;
022import java.util.EnumSet;
023import java.util.List;
024import java.util.Map;
025import java.util.Set;
026import java.util.concurrent.Future;
027import java.util.regex.Pattern;
028import org.apache.commons.lang3.NotImplementedException;
029import org.apache.hadoop.conf.Configuration;
030import org.apache.hadoop.hbase.CacheEvictionStats;
031import org.apache.hadoop.hbase.ClusterMetrics;
032import org.apache.hadoop.hbase.HConstants;
033import org.apache.hadoop.hbase.NamespaceDescriptor;
034import org.apache.hadoop.hbase.NamespaceNotFoundException;
035import org.apache.hadoop.hbase.RegionMetrics;
036import org.apache.hadoop.hbase.ServerName;
037import org.apache.hadoop.hbase.TableExistsException;
038import org.apache.hadoop.hbase.TableName;
039import org.apache.hadoop.hbase.TableNotFoundException;
040import org.apache.hadoop.hbase.client.Admin;
041import org.apache.hadoop.hbase.client.BalanceRequest;
042import org.apache.hadoop.hbase.client.BalanceResponse;
043import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
044import org.apache.hadoop.hbase.client.CompactType;
045import org.apache.hadoop.hbase.client.CompactionState;
046import org.apache.hadoop.hbase.client.Connection;
047import org.apache.hadoop.hbase.client.LogEntry;
048import org.apache.hadoop.hbase.client.LogQueryFilter;
049import org.apache.hadoop.hbase.client.NormalizeTableFilterParams;
050import org.apache.hadoop.hbase.client.OnlineLogRecord;
051import org.apache.hadoop.hbase.client.RegionInfo;
052import org.apache.hadoop.hbase.client.ServerType;
053import org.apache.hadoop.hbase.client.SnapshotDescription;
054import org.apache.hadoop.hbase.client.SnapshotType;
055import org.apache.hadoop.hbase.client.TableDescriptor;
056import org.apache.hadoop.hbase.client.replication.TableCFs;
057import org.apache.hadoop.hbase.client.security.SecurityCapability;
058import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
059import org.apache.hadoop.hbase.net.Address;
060import org.apache.hadoop.hbase.quotas.QuotaFilter;
061import org.apache.hadoop.hbase.quotas.QuotaSettings;
062import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot;
063import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
064import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
065import org.apache.hadoop.hbase.replication.SyncReplicationState;
066import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
067import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest;
068import org.apache.hadoop.hbase.security.access.Permission;
069import org.apache.hadoop.hbase.security.access.UserPermission;
070import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
071import org.apache.hadoop.hbase.thrift2.ThriftUtilities;
072import org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor;
073import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
074import org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter;
075import org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor;
076import org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord;
077import org.apache.hadoop.hbase.thrift2.generated.TServerName;
078import org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor;
079import org.apache.hadoop.hbase.thrift2.generated.TTableName;
080import org.apache.hadoop.hbase.util.Bytes;
081import org.apache.hadoop.hbase.util.Pair;
082import org.apache.thrift.TException;
083import org.apache.thrift.transport.TTransport;
084import org.apache.yetus.audience.InterfaceAudience;
085
086@InterfaceAudience.Private
087public class ThriftAdmin implements Admin {
088
089  private THBaseService.Client client;
090  private TTransport transport;
091  private int operationTimeout;
092  private int syncWaitTimeout;
093  private Configuration conf;
094
095  public ThriftAdmin(THBaseService.Client client, TTransport tTransport, Configuration conf) {
096    this.client = client;
097    this.transport = tTransport;
098    this.operationTimeout = conf.getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT,
099      HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT);
100    this.syncWaitTimeout = conf.getInt("hbase.client.sync.wait.timeout.msec", 10 * 60000); // 10min
101    this.conf = conf;
102  }
103
104  @Override
105  public int getOperationTimeout() {
106    return operationTimeout;
107  }
108
109  @Override
110  public int getSyncWaitTimeout() {
111    return syncWaitTimeout;
112  }
113
114  @Override
115  public void abort(String why, Throwable e) {
116  }
117
118  @Override
119  public boolean isAborted() {
120    return false;
121  }
122
123  @Override
124  public void close() {
125    transport.close();
126  }
127
128  @Override
129  public Configuration getConfiguration() {
130    return conf;
131  }
132
133  @Override
134  public boolean tableExists(TableName tableName) throws IOException {
135    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
136    try {
137      return client.tableExists(tTableName);
138    } catch (TException e) {
139      throw new IOException(e);
140    }
141  }
142
143  @Override
144  public Connection getConnection() {
145    throw new NotImplementedException("getConnection not supported in ThriftAdmin");
146  }
147
148  @Override
149  public List<TableDescriptor> listTableDescriptors() throws IOException {
150    return listTableDescriptors((Pattern) null);
151  }
152
153  @Override
154  public List<TableDescriptor> listTableDescriptors(boolean includeSysTables) throws IOException {
155    return listTableDescriptors(null, includeSysTables);
156  }
157
158  @Override
159  public List<TableDescriptor> listTableDescriptors(Pattern pattern) throws IOException {
160    return listTableDescriptors(pattern, false);
161  }
162
163  @Override
164  public List<TableDescriptor> listTableDescriptors(Pattern pattern, boolean includeSysTables)
165    throws IOException {
166    try {
167      String regex = (pattern == null ? null : pattern.toString());
168      List<TTableDescriptor> tTableDescriptors =
169        client.getTableDescriptorsByPattern(regex, includeSysTables);
170      return ThriftUtilities.tableDescriptorsFromThrift(tTableDescriptors);
171
172    } catch (TException e) {
173      throw new IOException(e);
174    }
175  }
176
177  @Override
178  public TableName[] listTableNames() throws IOException {
179    return listTableNames(null);
180  }
181
182  @Override
183  public TableName[] listTableNames(Pattern pattern) throws IOException {
184    return listTableNames(pattern, false);
185  }
186
187  @Override
188  public TableName[] listTableNames(Pattern pattern, boolean includeSysTables) throws IOException {
189    String regex = (pattern == null ? null : pattern.toString());
190    try {
191      List<TTableName> tTableNames = client.getTableNamesByPattern(regex, includeSysTables);
192      return ThriftUtilities.tableNamesArrayFromThrift(tTableNames);
193    } catch (TException e) {
194      throw new IOException(e);
195    }
196  }
197
198  @Override
199  public TableDescriptor getDescriptor(TableName tableName)
200    throws TableNotFoundException, IOException {
201    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
202    try {
203      TTableDescriptor tTableDescriptor = client.getTableDescriptor(tTableName);
204      return ThriftUtilities.tableDescriptorFromThrift(tTableDescriptor);
205    } catch (TException e) {
206      throw new IOException(e);
207    }
208  }
209
210  @Override
211  public List<TableDescriptor> listTableDescriptorsByNamespace(byte[] name) throws IOException {
212    try {
213      List<TTableDescriptor> tTableDescriptors =
214        client.getTableDescriptorsByNamespace(Bytes.toString(name));
215      return ThriftUtilities.tableDescriptorsFromThrift(tTableDescriptors);
216    } catch (TException e) {
217      throw new IOException(e);
218    }
219  }
220
221  @Override
222  public TableName[] listTableNamesByNamespace(String name) throws IOException {
223    try {
224      List<TTableName> tTableNames = client.getTableNamesByNamespace(name);
225      return ThriftUtilities.tableNamesArrayFromThrift(tTableNames);
226    } catch (TException e) {
227      throw new IOException(e);
228    }
229  }
230
231  @Override
232  public void createTable(TableDescriptor desc) throws IOException {
233    createTable(desc, null);
234  }
235
236  @Override
237  public void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
238    throws IOException {
239    if (numRegions < 3) {
240      throw new IllegalArgumentException("Must create at least three regions");
241    } else if (Bytes.compareTo(startKey, endKey) >= 0) {
242      throw new IllegalArgumentException("Start key must be smaller than end key");
243    }
244    if (numRegions == 3) {
245      createTable(desc, new byte[][] { startKey, endKey });
246      return;
247    }
248    byte[][] splitKeys = Bytes.split(startKey, endKey, numRegions - 3);
249    if (splitKeys == null || splitKeys.length != numRegions - 1) {
250      throw new IllegalArgumentException("Unable to split key range into enough regions");
251    }
252    createTable(desc, splitKeys);
253  }
254
255  @Override
256  public void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOException {
257    TTableDescriptor tTableDescriptor = ThriftUtilities.tableDescriptorFromHBase(desc);
258    List<ByteBuffer> splitKeyInBuffer = ThriftUtilities.splitKeyFromHBase(splitKeys);
259    try {
260      client.createTable(tTableDescriptor, splitKeyInBuffer);
261    } catch (TException e) {
262      throw new IOException(e);
263    }
264  }
265
266  @Override
267  public void deleteTable(TableName tableName) throws IOException {
268    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
269    try {
270      client.deleteTable(tTableName);
271    } catch (TException e) {
272      throw new IOException(e);
273    }
274  }
275
276  @Override
277  public void truncateTable(TableName tableName, boolean preserveSplits) throws IOException {
278    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
279    try {
280      client.truncateTable(tTableName, preserveSplits);
281    } catch (TException e) {
282      throw new IOException(e);
283    }
284  }
285
286  @Override
287  public void enableTable(TableName tableName) throws IOException {
288    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
289    try {
290      client.enableTable(tTableName);
291    } catch (TException e) {
292      throw new IOException(e);
293    }
294  }
295
296  @Override
297  public void disableTable(TableName tableName) throws IOException {
298    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
299    try {
300      client.disableTable(tTableName);
301    } catch (TException e) {
302      throw new IOException(e);
303    }
304  }
305
306  @Override
307  public boolean isTableEnabled(TableName tableName) throws IOException {
308    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
309    try {
310      return client.isTableEnabled(tTableName);
311    } catch (TException e) {
312      throw new IOException(e);
313    }
314  }
315
316  @Override
317  public boolean isTableDisabled(TableName tableName) throws IOException {
318    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
319    try {
320      return client.isTableDisabled(tTableName);
321    } catch (TException e) {
322      throw new IOException(e);
323    }
324  }
325
326  @Override
327  public boolean isTableAvailable(TableName tableName) throws IOException {
328    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
329    try {
330      return client.isTableAvailable(tTableName);
331    } catch (TException e) {
332      throw new IOException(e);
333    }
334  }
335
336  @Override
337  public void addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily)
338    throws IOException {
339    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
340    TColumnFamilyDescriptor tColumnFamilyDescriptor =
341      ThriftUtilities.columnFamilyDescriptorFromHBase(columnFamily);
342    try {
343      client.addColumnFamily(tTableName, tColumnFamilyDescriptor);
344    } catch (TException e) {
345      throw new IOException(e);
346    }
347  }
348
349  @Override
350  public void deleteColumnFamily(TableName tableName, byte[] columnFamily) throws IOException {
351    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
352    try {
353      client.deleteColumnFamily(tTableName, ByteBuffer.wrap(columnFamily));
354    } catch (TException e) {
355      throw new IOException(e);
356    }
357  }
358
359  @Override
360  public void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily)
361    throws IOException {
362    TTableName tTableName = ThriftUtilities.tableNameFromHBase(tableName);
363    TColumnFamilyDescriptor tColumnFamilyDescriptor =
364      ThriftUtilities.columnFamilyDescriptorFromHBase(columnFamily);
365    try {
366      client.modifyColumnFamily(tTableName, tColumnFamilyDescriptor);
367    } catch (TException e) {
368      throw new IOException(e);
369    }
370  }
371
372  @Override
373  public void modifyTable(TableDescriptor td) throws IOException {
374    TTableDescriptor tTableDescriptor = ThriftUtilities.tableDescriptorFromHBase(td);
375    try {
376      client.modifyTable(tTableDescriptor);
377    } catch (TException e) {
378      throw new IOException(e);
379    }
380  }
381
382  @Override
383  public void modifyNamespace(NamespaceDescriptor descriptor) throws IOException {
384    TNamespaceDescriptor tNamespaceDescriptor =
385      ThriftUtilities.namespaceDescriptorFromHBase(descriptor);
386    try {
387      client.modifyNamespace(tNamespaceDescriptor);
388    } catch (TException e) {
389      throw new IOException(e);
390    }
391  }
392
393  @Override
394  public void deleteNamespace(String name) throws IOException {
395    try {
396      client.deleteNamespace(name);
397    } catch (TException e) {
398      throw new IOException(e);
399    }
400  }
401
402  @Override
403  public NamespaceDescriptor getNamespaceDescriptor(String name)
404    throws NamespaceNotFoundException, IOException {
405    try {
406      TNamespaceDescriptor tNamespaceDescriptor = client.getNamespaceDescriptor(name);
407      return ThriftUtilities.namespaceDescriptorFromThrift(tNamespaceDescriptor);
408    } catch (TException e) {
409      throw new IOException(e);
410    }
411  }
412
413  @Override
414  public String[] listNamespaces() throws IOException {
415    try {
416      List<String> tNamespaces = client.listNamespaces();
417      return tNamespaces.toArray(new String[tNamespaces.size()]);
418    } catch (TException e) {
419      throw new IOException(e);
420    }
421  }
422
423  @Override
424  public NamespaceDescriptor[] listNamespaceDescriptors() throws IOException {
425    try {
426      List<TNamespaceDescriptor> tNamespaceDescriptors = client.listNamespaceDescriptors();
427      return ThriftUtilities.namespaceDescriptorsFromThrift(tNamespaceDescriptors);
428    } catch (TException e) {
429      throw new IOException(e);
430    }
431  }
432
433  @Override
434  public void createNamespace(NamespaceDescriptor descriptor) throws IOException {
435    TNamespaceDescriptor tNamespaceDescriptor =
436      ThriftUtilities.namespaceDescriptorFromHBase(descriptor);
437    try {
438      client.createNamespace(tNamespaceDescriptor);
439    } catch (TException e) {
440      throw new IOException(e);
441    }
442  }
443
444  @Override
445  public boolean switchRpcThrottle(boolean enable) throws IOException {
446    throw new NotImplementedException("switchRpcThrottle by pattern not supported in ThriftAdmin");
447  }
448
449  @Override
450  public boolean isRpcThrottleEnabled() throws IOException {
451    throw new NotImplementedException(
452      "isRpcThrottleEnabled by pattern not supported in ThriftAdmin");
453  }
454
455  @Override
456  public boolean exceedThrottleQuotaSwitch(boolean enable) throws IOException {
457    throw new NotImplementedException(
458      "exceedThrottleQuotaSwitch by pattern not supported in ThriftAdmin");
459  }
460
461  @Override
462  public List<TableDescriptor> listTableDescriptors(List<TableName> tableNames) throws IOException {
463    throw new NotImplementedException("listTableDescriptors not supported in ThriftAdmin"
464      + ", use getDescriptor to get descriptors one by one");
465  }
466
467  @Override
468  public List<RegionInfo> getRegions(ServerName serverName) {
469    throw new NotImplementedException("getRegions not supported in ThriftAdmin");
470  }
471
472  @Override
473  public void flush(TableName tableName) {
474    throw new NotImplementedException("flush not supported in ThriftAdmin");
475
476  }
477
478  @Override
479  public void flush(TableName tableName, byte[] columnFamily) {
480    throw new NotImplementedException("flush not supported in ThriftAdmin");
481  }
482
483  @Override
484  public void flushRegion(byte[] regionName) {
485    throw new NotImplementedException("flushRegion not supported in ThriftAdmin");
486
487  }
488
489  @Override
490  public void flushRegion(byte[] regionName, byte[] columnFamily) {
491    throw new NotImplementedException("flushRegion not supported in ThriftAdmin");
492  }
493
494  @Override
495  public void flushRegionServer(ServerName serverName) {
496    throw new NotImplementedException("flushRegionServer not supported in ThriftAdmin");
497
498  }
499
500  @Override
501  public void compact(TableName tableName) {
502    throw new NotImplementedException("compact not supported in ThriftAdmin");
503
504  }
505
506  @Override
507  public void compactRegion(byte[] regionName) {
508    throw new NotImplementedException("compactRegion not supported in ThriftAdmin");
509
510  }
511
512  @Override
513  public void compact(TableName tableName, byte[] columnFamily) {
514    throw new NotImplementedException("compact not supported in ThriftAdmin");
515
516  }
517
518  @Override
519  public void compactRegion(byte[] regionName, byte[] columnFamily) {
520    throw new NotImplementedException("compactRegion not supported in ThriftAdmin");
521
522  }
523
524  @Override
525  public void compact(TableName tableName, CompactType compactType) {
526    throw new NotImplementedException("compact not supported in ThriftAdmin");
527
528  }
529
530  @Override
531  public void compact(TableName tableName, byte[] columnFamily, CompactType compactType) {
532    throw new NotImplementedException("compact not supported in ThriftAdmin");
533
534  }
535
536  @Override
537  public void majorCompact(TableName tableName) {
538    throw new NotImplementedException("majorCompact not supported in ThriftAdmin");
539
540  }
541
542  @Override
543  public void majorCompactRegion(byte[] regionName) {
544    throw new NotImplementedException("majorCompactRegion not supported in ThriftAdmin");
545
546  }
547
548  @Override
549  public void majorCompact(TableName tableName, byte[] columnFamily) {
550    throw new NotImplementedException("majorCompact not supported in ThriftAdmin");
551
552  }
553
554  @Override
555  public void majorCompactRegion(byte[] regionName, byte[] columnFamily) {
556    throw new NotImplementedException("majorCompactRegion not supported in ThriftAdmin");
557
558  }
559
560  @Override
561  public void majorCompact(TableName tableName, CompactType compactType) {
562    throw new NotImplementedException("majorCompact not supported in ThriftAdmin");
563
564  }
565
566  @Override
567  public void majorCompact(TableName tableName, byte[] columnFamily, CompactType compactType) {
568    throw new NotImplementedException("majorCompact not supported in ThriftAdmin");
569
570  }
571
572  @Override
573  public Map<ServerName, Boolean> compactionSwitch(boolean switchState,
574    List<String> serverNamesList) {
575    throw new NotImplementedException("compactionSwitch not supported in ThriftAdmin");
576  }
577
578  @Override
579  public void compactRegionServer(ServerName serverName) {
580    throw new NotImplementedException("compactRegionServer not supported in ThriftAdmin");
581
582  }
583
584  @Override
585  public void majorCompactRegionServer(ServerName serverName) {
586    throw new NotImplementedException("majorCompactRegionServer not supported in ThriftAdmin");
587
588  }
589
590  @Override
591  public void move(byte[] encodedRegionName) {
592    throw new NotImplementedException("move not supported in ThriftAdmin");
593  }
594
595  @Override
596  public void move(byte[] encodedRegionName, ServerName destServerName) {
597    throw new NotImplementedException("move not supported in ThriftAdmin");
598  }
599
600  @Override
601  public void assign(byte[] regionName) {
602    throw new NotImplementedException("assign not supported in ThriftAdmin");
603
604  }
605
606  @Override
607  public void unassign(byte[] regionName) {
608    throw new NotImplementedException("unassign not supported in ThriftAdmin");
609  }
610
611  @Override
612  public void offline(byte[] regionName) {
613    throw new NotImplementedException("offline not supported in ThriftAdmin");
614
615  }
616
617  @Override
618  public boolean balancerSwitch(boolean onOrOff, boolean synchronous) {
619    throw new NotImplementedException("balancerSwitch not supported in ThriftAdmin");
620  }
621
622  @Override
623  public boolean balance() {
624    throw new NotImplementedException("balance not supported in ThriftAdmin");
625  }
626
627  @Override
628  public boolean balance(boolean force) {
629    throw new NotImplementedException("balance not supported in ThriftAdmin");
630  }
631
632  @Override
633  public BalanceResponse balance(BalanceRequest request) throws IOException {
634    throw new NotImplementedException("balance not supported in ThriftAdmin");
635  }
636
637  @Override
638  public boolean isBalancerEnabled() {
639    throw new NotImplementedException("isBalancerEnabled not supported in ThriftAdmin");
640  }
641
642  @Override
643  public CacheEvictionStats clearBlockCache(TableName tableName) {
644    throw new NotImplementedException("clearBlockCache not supported in ThriftAdmin");
645  }
646
647  @Override
648  public boolean normalize(NormalizeTableFilterParams ntfp) {
649    throw new NotImplementedException("normalize not supported in ThriftAdmin");
650  }
651
652  @Override
653  public boolean isNormalizerEnabled() {
654    throw new NotImplementedException("isNormalizerEnabled not supported in ThriftAdmin");
655  }
656
657  @Override
658  public boolean normalizerSwitch(boolean on) {
659    throw new NotImplementedException("normalizerSwitch not supported in ThriftAdmin");
660  }
661
662  @Override
663  public boolean catalogJanitorSwitch(boolean onOrOff) {
664    throw new NotImplementedException("catalogJanitorSwitch not supported in ThriftAdmin");
665  }
666
667  @Override
668  public int runCatalogJanitor() {
669    throw new NotImplementedException("runCatalogJanitor not supported in ThriftAdmin");
670  }
671
672  @Override
673  public boolean isCatalogJanitorEnabled() {
674    throw new NotImplementedException("isCatalogJanitorEnabled not supported in ThriftAdmin");
675  }
676
677  @Override
678  public boolean cleanerChoreSwitch(boolean onOrOff) {
679    throw new NotImplementedException("cleanerChoreSwitch not supported in ThriftAdmin");
680  }
681
682  @Override
683  public boolean runCleanerChore() {
684    throw new NotImplementedException("runCleanerChore not supported in ThriftAdmin");
685  }
686
687  @Override
688  public boolean isCleanerChoreEnabled() {
689    throw new NotImplementedException("isCleanerChoreEnabled not supported in ThriftAdmin");
690  }
691
692  @Override
693  public Future<Void> mergeRegionsAsync(byte[] nameOfRegionA, byte[] nameOfRegionB,
694    boolean forcible) {
695    throw new NotImplementedException("mergeRegionsAsync not supported in ThriftAdmin");
696  }
697
698  @Override
699  public Future<Void> mergeRegionsAsync(byte[][] nameofRegionsToMerge, boolean forcible) {
700    throw new NotImplementedException("mergeRegionsAsync not supported in ThriftAdmin");
701  }
702
703  @Override
704  public void split(TableName tableName) {
705    throw new NotImplementedException("split not supported in ThriftAdmin");
706  }
707
708  @Override
709  public void split(TableName tableName, byte[] splitPoint) {
710    throw new NotImplementedException("split not supported in ThriftAdmin");
711  }
712
713  @Override
714  public Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint) {
715    throw new NotImplementedException("splitRegionAsync not supported in ThriftAdmin");
716  }
717
718  @Override
719  public Future<Void> modifyTableAsync(TableDescriptor td) {
720    throw new NotImplementedException("modifyTableAsync not supported in ThriftAdmin");
721  }
722
723  @Override
724  public void shutdown() {
725    throw new NotImplementedException("shutdown not supported in ThriftAdmin");
726
727  }
728
729  @Override
730  public void stopMaster() {
731    throw new NotImplementedException("stopMaster not supported in ThriftAdmin");
732
733  }
734
735  @Override
736  public boolean isMasterInMaintenanceMode() {
737    throw new NotImplementedException("isMasterInMaintenanceMode not supported in ThriftAdmin");
738  }
739
740  @Override
741  public void stopRegionServer(String hostnamePort) {
742    throw new NotImplementedException("stopRegionServer not supported in ThriftAdmin");
743
744  }
745
746  @Override
747  public ClusterMetrics getClusterMetrics(EnumSet<ClusterMetrics.Option> options) {
748    throw new NotImplementedException("getClusterMetrics not supported in ThriftAdmin");
749  }
750
751  @Override
752  public List<RegionMetrics> getRegionMetrics(ServerName serverName) {
753    throw new NotImplementedException("getRegionMetrics not supported in ThriftAdmin");
754  }
755
756  @Override
757  public List<RegionMetrics> getRegionMetrics(ServerName serverName, TableName tableName) {
758    throw new NotImplementedException("getRegionMetrics not supported in ThriftAdmin");
759  }
760
761  @Override
762  public Future<Void> createNamespaceAsync(NamespaceDescriptor descriptor) {
763    throw new NotImplementedException("createNamespaceAsync not supported in ThriftAdmin");
764  }
765
766  @Override
767  public Future<Void> modifyNamespaceAsync(NamespaceDescriptor descriptor) {
768    throw new NotImplementedException("modifyNamespaceAsync not supported in ThriftAdmin");
769  }
770
771  @Override
772  public List<RegionInfo> getRegions(TableName tableName) {
773    throw new NotImplementedException("getRegions not supported in ThriftAdmin");
774  }
775
776  @Override
777  public boolean abortProcedure(long procId, boolean mayInterruptIfRunning) {
778    throw new NotImplementedException("abortProcedure not supported in ThriftAdmin");
779  }
780
781  @Override
782  public Future<Boolean> abortProcedureAsync(long procId, boolean mayInterruptIfRunning) {
783    throw new NotImplementedException("abortProcedureAsync not supported in ThriftAdmin");
784  }
785
786  @Override
787  public String getProcedures() {
788    throw new NotImplementedException("getProcedures not supported in ThriftAdmin");
789  }
790
791  @Override
792  public String getLocks() {
793    throw new NotImplementedException("getLocks not supported in ThriftAdmin");
794  }
795
796  @Override
797  public void rollWALWriter(ServerName serverName) {
798    throw new NotImplementedException("rollWALWriter not supported in ThriftAdmin");
799
800  }
801
802  @Override
803  public CompactionState getCompactionState(TableName tableName) {
804    throw new NotImplementedException("getCompactionState not supported in ThriftAdmin");
805  }
806
807  @Override
808  public CompactionState getCompactionState(TableName tableName, CompactType compactType) {
809    throw new NotImplementedException("getCompactionState not supported in ThriftAdmin");
810  }
811
812  @Override
813  public CompactionState getCompactionStateForRegion(byte[] regionName) {
814    throw new NotImplementedException("getCompactionStateForRegion not supported in ThriftAdmin");
815  }
816
817  @Override
818  public long getLastMajorCompactionTimestamp(TableName tableName) {
819    throw new NotImplementedException(
820      "getLastMajorCompactionTimestamp not supported in ThriftAdmin");
821  }
822
823  @Override
824  public long getLastMajorCompactionTimestampForRegion(byte[] regionName) {
825    throw new NotImplementedException(
826      "getLastMajorCompactionTimestampForRegion not supported in ThriftAdmin");
827  }
828
829  @Override
830  public void snapshot(String snapshotName, TableName tableName) {
831    throw new NotImplementedException("snapshot not supported in ThriftAdmin");
832
833  }
834
835  @Override
836  public void snapshot(String snapshotName, TableName tableName, SnapshotType type) {
837    throw new NotImplementedException("snapshot not supported in ThriftAdmin");
838
839  }
840
841  @Override
842  public void snapshot(SnapshotDescription snapshot) {
843    throw new NotImplementedException("snapshot not supported in ThriftAdmin");
844
845  }
846
847  @Override
848  public Future<Void> snapshotAsync(SnapshotDescription snapshot) {
849    throw new NotImplementedException("snapshotAsync not supported in ThriftAdmin");
850
851  }
852
853  @Override
854  public boolean isSnapshotFinished(SnapshotDescription snapshot) {
855    throw new NotImplementedException("isSnapshotFinished not supported in ThriftAdmin");
856  }
857
858  @Override
859  public void restoreSnapshot(String snapshotName) {
860    throw new NotImplementedException("restoreSnapshot not supported in ThriftAdmin");
861
862  }
863
864  @Override
865  public void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot,
866    boolean restoreAcl) {
867    throw new NotImplementedException("restoreSnapshot not supported in ThriftAdmin");
868  }
869
870  @Override
871  public Future<Void> cloneSnapshotAsync(String snapshotName, TableName tableName, boolean cloneAcl,
872    String customSFT) throws IOException, TableExistsException, RestoreSnapshotException {
873    throw new NotImplementedException("cloneSnapshotAsync not supported in ThriftAdmin");
874  }
875
876  @Override
877  public void execProcedure(String signature, String instance, Map<String, String> props) {
878    throw new NotImplementedException("execProcedure not supported in ThriftAdmin");
879
880  }
881
882  @Override
883  public byte[] execProcedureWithReturn(String signature, String instance,
884    Map<String, String> props) {
885    throw new NotImplementedException("execProcedureWithReturn not supported in ThriftAdmin");
886  }
887
888  @Override
889  public boolean isProcedureFinished(String signature, String instance, Map<String, String> props) {
890    throw new NotImplementedException("isProcedureFinished not supported in ThriftAdmin");
891  }
892
893  @Override
894  public List<SnapshotDescription> listSnapshots() {
895    throw new NotImplementedException("listSnapshots not supported in ThriftAdmin");
896  }
897
898  @Override
899  public List<SnapshotDescription> listSnapshots(Pattern pattern) {
900    throw new NotImplementedException("listSnapshots not supported in ThriftAdmin");
901  }
902
903  @Override
904  public List<SnapshotDescription> listTableSnapshots(Pattern tableNamePattern,
905    Pattern snapshotNamePattern) {
906    throw new NotImplementedException("listTableSnapshots not supported in ThriftAdmin");
907  }
908
909  @Override
910  public void deleteSnapshot(String snapshotName) {
911    throw new NotImplementedException("deleteSnapshot not supported in ThriftAdmin");
912  }
913
914  @Override
915  public void deleteSnapshots(Pattern pattern) {
916    throw new NotImplementedException("deleteSnapshots not supported in ThriftAdmin");
917  }
918
919  @Override
920  public void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern) {
921    throw new NotImplementedException("deleteTableSnapshots not supported in ThriftAdmin");
922  }
923
924  @Override
925  public void setQuota(QuotaSettings quota) {
926    throw new NotImplementedException("setQuota not supported in ThriftAdmin");
927  }
928
929  @Override
930  public List<QuotaSettings> getQuota(QuotaFilter filter) {
931    throw new NotImplementedException("getQuota not supported in ThriftAdmin");
932  }
933
934  @Override
935  public CoprocessorRpcChannel coprocessorService() {
936    throw new NotImplementedException("coprocessorService not supported in ThriftAdmin");
937  }
938
939  @Override
940  public CoprocessorRpcChannel coprocessorService(ServerName serverName) {
941    throw new NotImplementedException("coprocessorService not supported in ThriftAdmin");
942  }
943
944  @Override
945  public void updateConfiguration(ServerName server) {
946    throw new NotImplementedException("updateConfiguration not supported in ThriftAdmin");
947  }
948
949  @Override
950  public void updateConfiguration() {
951    throw new NotImplementedException("updateConfiguration not supported in ThriftAdmin");
952  }
953
954  @Override
955  public void updateConfiguration(String groupName) {
956    throw new NotImplementedException("updateConfiguration not supported in ThriftAdmin");
957  }
958
959  @Override
960  public List<SecurityCapability> getSecurityCapabilities() {
961    throw new NotImplementedException("getSecurityCapabilities not supported in ThriftAdmin");
962  }
963
964  @Override
965  public boolean splitSwitch(boolean enabled, boolean synchronous) {
966    throw new NotImplementedException("splitSwitch not supported in ThriftAdmin");
967  }
968
969  @Override
970  public boolean mergeSwitch(boolean enabled, boolean synchronous) {
971    throw new NotImplementedException("mergeSwitch not supported in ThriftAdmin");
972  }
973
974  @Override
975  public boolean isSplitEnabled() {
976    throw new NotImplementedException("isSplitEnabled not supported in ThriftAdmin");
977  }
978
979  @Override
980  public boolean isMergeEnabled() {
981    throw new NotImplementedException("isMergeEnabled not supported in ThriftAdmin");
982  }
983
984  @Override
985  public Future<Void> addReplicationPeerAsync(String peerId, ReplicationPeerConfig peerConfig,
986    boolean enabled) {
987    throw new NotImplementedException("addReplicationPeerAsync not supported in ThriftAdmin");
988  }
989
990  @Override
991  public Future<Void> removeReplicationPeerAsync(String peerId) {
992    throw new NotImplementedException("removeReplicationPeerAsync not supported in ThriftAdmin");
993  }
994
995  @Override
996  public Future<Void> enableReplicationPeerAsync(String peerId) {
997    throw new NotImplementedException("enableReplicationPeerAsync not supported in ThriftAdmin");
998  }
999
1000  @Override
1001  public Future<Void> disableReplicationPeerAsync(String peerId) {
1002    throw new NotImplementedException("disableReplicationPeerAsync not supported in ThriftAdmin");
1003  }
1004
1005  @Override
1006  public ReplicationPeerConfig getReplicationPeerConfig(String peerId) {
1007    throw new NotImplementedException("getReplicationPeerConfig not supported in ThriftAdmin");
1008  }
1009
1010  @Override
1011  public Future<Void> updateReplicationPeerConfigAsync(String peerId,
1012    ReplicationPeerConfig peerConfig) {
1013    throw new NotImplementedException(
1014      "updateReplicationPeerConfigAsync not supported in ThriftAdmin");
1015  }
1016
1017  @Override
1018  public List<ReplicationPeerDescription> listReplicationPeers() {
1019    throw new NotImplementedException("listReplicationPeers not supported in ThriftAdmin");
1020  }
1021
1022  @Override
1023  public List<ReplicationPeerDescription> listReplicationPeers(Pattern pattern) {
1024    throw new NotImplementedException("listReplicationPeers not supported in ThriftAdmin");
1025  }
1026
1027  @Override
1028  public Future<Void> transitReplicationPeerSyncReplicationStateAsync(String peerId,
1029    SyncReplicationState state) {
1030    throw new NotImplementedException(
1031      "transitReplicationPeerSyncReplicationStateAsync not supported in ThriftAdmin");
1032  }
1033
1034  @Override
1035  public void decommissionRegionServers(List<ServerName> servers, boolean offload) {
1036    throw new NotImplementedException("decommissionRegionServers not supported in ThriftAdmin");
1037
1038  }
1039
1040  @Override
1041  public List<ServerName> listDecommissionedRegionServers() {
1042    throw new NotImplementedException(
1043      "listDecommissionedRegionServers not supported in ThriftAdmin");
1044  }
1045
1046  @Override
1047  public void recommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames) {
1048    throw new NotImplementedException("recommissionRegionServer not supported in ThriftAdmin");
1049
1050  }
1051
1052  @Override
1053  public List<TableCFs> listReplicatedTableCFs() {
1054    throw new NotImplementedException("listReplicatedTableCFs not supported in ThriftAdmin");
1055  }
1056
1057  @Override
1058  public void enableTableReplication(TableName tableName) {
1059    throw new NotImplementedException("enableTableReplication not supported in ThriftAdmin");
1060
1061  }
1062
1063  @Override
1064  public void disableTableReplication(TableName tableName) {
1065    throw new NotImplementedException("disableTableReplication not supported in ThriftAdmin");
1066
1067  }
1068
1069  @Override
1070  public void clearCompactionQueues(ServerName serverName, Set<String> queues) {
1071    throw new NotImplementedException("clearCompactionQueues not supported in ThriftAdmin");
1072
1073  }
1074
1075  @Override
1076  public List<ServerName> clearDeadServers(List<ServerName> servers) {
1077    throw new NotImplementedException("clearDeadServers not supported in ThriftAdmin");
1078  }
1079
1080  @Override
1081  public void cloneTableSchema(TableName tableName, TableName newTableName,
1082    boolean preserveSplits) {
1083    throw new NotImplementedException("cloneTableSchema not supported in ThriftAdmin");
1084
1085  }
1086
1087  @Override
1088  public Future<Void> createTableAsync(TableDescriptor desc) {
1089    throw new NotImplementedException("createTableAsync not supported in ThriftAdmin");
1090  }
1091
1092  @Override
1093  public Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys) {
1094    throw new NotImplementedException("createTableAsync not supported in ThriftAdmin");
1095  }
1096
1097  @Override
1098  public Future<Void> deleteTableAsync(TableName tableName) {
1099    throw new NotImplementedException("deleteTableAsync not supported in ThriftAdmin");
1100  }
1101
1102  @Override
1103  public Future<Void> truncateTableAsync(TableName tableName, boolean preserveSplits) {
1104    throw new NotImplementedException("truncateTableAsync not supported in ThriftAdmin");
1105  }
1106
1107  @Override
1108  public Future<Void> enableTableAsync(TableName tableName) {
1109    throw new NotImplementedException("enableTableAsync not supported in ThriftAdmin");
1110  }
1111
1112  @Override
1113  public Future<Void> disableTableAsync(TableName tableName) {
1114    throw new NotImplementedException("disableTableAsync not supported in ThriftAdmin");
1115  }
1116
1117  @Override
1118  public Future<Void> deleteColumnFamilyAsync(TableName tableName, byte[] columnFamily) {
1119    throw new NotImplementedException("deleteColumnFamilyAsync not supported in ThriftAdmin");
1120  }
1121
1122  @Override
1123  public Future<Void> addColumnFamilyAsync(TableName tableName,
1124    ColumnFamilyDescriptor columnFamily) {
1125    throw new NotImplementedException("addColumnFamilyAsync not supported in ThriftAdmin");
1126  }
1127
1128  @Override
1129  public Future<Void> modifyColumnFamilyAsync(TableName tableName,
1130    ColumnFamilyDescriptor columnFamily) {
1131    throw new NotImplementedException("modifyColumnFamilyAsync not supported in ThriftAdmin");
1132  }
1133
1134  @Override
1135  public Future<Void> deleteNamespaceAsync(String name) {
1136    throw new NotImplementedException("deleteNamespaceAsync not supported in ThriftAdmin");
1137  }
1138
1139  @Override
1140  public Map<TableName, Long> getSpaceQuotaTableSizes() throws IOException {
1141    throw new NotImplementedException("getSpaceQuotaTableSizes not supported in ThriftAdmin");
1142  }
1143
1144  @Override
1145  public Map<TableName, SpaceQuotaSnapshot>
1146    getRegionServerSpaceQuotaSnapshots(ServerName serverName) throws IOException {
1147    throw new NotImplementedException(
1148      "getRegionServerSpaceQuotaSnapshots not supported in ThriftAdmin");
1149  }
1150
1151  @Override
1152  public SpaceQuotaSnapshot getCurrentSpaceQuotaSnapshot(String namespace) throws IOException {
1153    throw new NotImplementedException("getCurrentSpaceQuotaSnapshot not supported in ThriftAdmin");
1154  }
1155
1156  @Override
1157  public SpaceQuotaSnapshot getCurrentSpaceQuotaSnapshot(TableName tableName) throws IOException {
1158    throw new NotImplementedException("getCurrentSpaceQuotaSnapshot not supported in ThriftAdmin");
1159  }
1160
1161  @Override
1162  public void grant(UserPermission userPermission, boolean mergeExistingPermissions) {
1163    throw new NotImplementedException("grant not supported in ThriftAdmin");
1164  }
1165
1166  @Override
1167  public void revoke(UserPermission userPermission) {
1168    throw new NotImplementedException("revoke not supported in ThriftAdmin");
1169  }
1170
1171  @Override
1172  public List<UserPermission>
1173    getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest) {
1174    throw new NotImplementedException("getUserPermissions not supported in ThriftAdmin");
1175  }
1176
1177  @Override
1178  public List<Boolean> hasUserPermissions(String userName, List<Permission> permissions) {
1179    throw new NotImplementedException("hasUserPermissions not supported in ThriftAdmin");
1180  }
1181
1182  @Override
1183  public boolean snapshotCleanupSwitch(boolean on, boolean synchronous) {
1184    throw new NotImplementedException("snapshotCleanupSwitch not supported in ThriftAdmin");
1185  }
1186
1187  @Override
1188  public boolean isSnapshotCleanupEnabled() {
1189    throw new NotImplementedException("isSnapshotCleanupEnabled not supported in ThriftAdmin");
1190  }
1191
1192  @Override
1193  public List<OnlineLogRecord> getSlowLogResponses(final Set<ServerName> serverNames,
1194    final LogQueryFilter logQueryFilter) throws IOException {
1195    Set<TServerName> tServerNames = ThriftUtilities.getServerNamesFromHBase(serverNames);
1196    TLogQueryFilter tLogQueryFilter = ThriftUtilities.getSlowLogQueryFromHBase(logQueryFilter);
1197    try {
1198      List<TOnlineLogRecord> tOnlineLogRecords =
1199        client.getSlowLogResponses(tServerNames, tLogQueryFilter);
1200      return ThriftUtilities.getSlowLogRecordsFromThrift(tOnlineLogRecords);
1201    } catch (TException e) {
1202      throw new IOException(e);
1203    }
1204  }
1205
1206  @Override
1207  public List<Boolean> clearSlowLogResponses(final Set<ServerName> serverNames) throws IOException {
1208    Set<TServerName> tServerNames = ThriftUtilities.getServerNamesFromHBase(serverNames);
1209    try {
1210      return client.clearSlowLogResponses(tServerNames);
1211    } catch (TException e) {
1212      throw new IOException(e);
1213    }
1214  }
1215
1216  @Override
1217  public RSGroupInfo getRSGroup(String groupName) {
1218    throw new NotImplementedException("getRSGroup not supported in ThriftAdmin");
1219  }
1220
1221  @Override
1222  public void moveServersToRSGroup(Set<Address> servers, String targetGroup) {
1223    throw new NotImplementedException("moveToRSGroup not supported in ThriftAdmin");
1224  }
1225
1226  @Override
1227  public void addRSGroup(String groupName) {
1228    throw new NotImplementedException("addRSGroup not supported in ThriftAdmin");
1229  }
1230
1231  @Override
1232  public void removeRSGroup(String groupName) {
1233    throw new NotImplementedException("removeRSGroup not supported in ThriftAdmin");
1234  }
1235
1236  @Override
1237  public BalanceResponse balanceRSGroup(String groupName, BalanceRequest request) {
1238    throw new NotImplementedException("balanceRSGroup not supported in ThriftAdmin");
1239  }
1240
1241  @Override
1242  public List<RSGroupInfo> listRSGroups() {
1243    throw new NotImplementedException("listRSGroups not supported in ThriftAdmin");
1244  }
1245
1246  @Override
1247  public RSGroupInfo getRSGroup(Address hostPort) {
1248    throw new NotImplementedException("getRSGroup not supported in ThriftAdmin");
1249  }
1250
1251  @Override
1252  public void removeServersFromRSGroup(Set<Address> servers) {
1253    throw new NotImplementedException("removeRSGroup not supported in ThriftAdmin");
1254  }
1255
1256  @Override
1257  public RSGroupInfo getRSGroup(TableName tableName) {
1258    throw new NotImplementedException("getRSGroup not supported in ThriftAdmin");
1259  }
1260
1261  @Override
1262  public void setRSGroup(Set<TableName> tables, String groupName) {
1263    throw new NotImplementedException("setRSGroup not supported in ThriftAdmin");
1264  }
1265
1266  @Override
1267  public Future<Void> splitRegionAsync(byte[] regionName) throws IOException {
1268    return splitRegionAsync(regionName, null);
1269  }
1270
1271  @Override
1272  public List<TableName> listTablesInRSGroup(String groupName) throws IOException {
1273    throw new NotImplementedException("setRSGroup not supported in ThriftAdmin");
1274  }
1275
1276  @Override
1277  public Pair<List<String>, List<TableName>>
1278    getConfiguredNamespacesAndTablesInRSGroup(String groupName) throws IOException {
1279    throw new NotImplementedException("setRSGroup not supported in ThriftAdmin");
1280  }
1281
1282  @Override
1283  public void renameRSGroup(String oldName, String newName) throws IOException {
1284    throw new NotImplementedException("renameRSGroup not supported in ThriftAdmin");
1285  }
1286
1287  @Override
1288  public void updateRSGroupConfig(String groupName, Map<String, String> configuration)
1289    throws IOException {
1290    throw new NotImplementedException("updateRSGroupConfig not supported in ThriftAdmin");
1291  }
1292
1293  @Override
1294  public List<LogEntry> getLogEntries(Set<ServerName> serverNames, String logType,
1295    ServerType serverType, int limit, Map<String, Object> filterParams) throws IOException {
1296    throw new NotImplementedException("getLogEntries not supported in ThriftAdmin");
1297  }
1298
1299  @Override
1300  public Future<Void> modifyColumnFamilyStoreFileTrackerAsync(TableName tableName, byte[] family,
1301    String dstSFT) throws IOException {
1302    throw new NotImplementedException(
1303      "modifyColumnFamilyStoreFileTrackerAsync not supported in ThriftAdmin");
1304  }
1305
1306  @Override
1307  public Future<Void> modifyTableStoreFileTrackerAsync(TableName tableName, String dstSFT)
1308    throws IOException {
1309    throw new NotImplementedException(
1310      "modifyTableStoreFileTrackerAsync not supported in ThriftAdmin");
1311  }
1312}