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