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.client; 019 020import java.io.Closeable; 021import java.io.IOException; 022import java.util.Collection; 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.hadoop.conf.Configuration; 030import org.apache.hadoop.hbase.Abortable; 031import org.apache.hadoop.hbase.CacheEvictionStats; 032import org.apache.hadoop.hbase.ClusterMetrics; 033import org.apache.hadoop.hbase.ClusterMetrics.Option; 034import org.apache.hadoop.hbase.ClusterStatus; 035import org.apache.hadoop.hbase.HRegionInfo; 036import org.apache.hadoop.hbase.HTableDescriptor; 037import org.apache.hadoop.hbase.NamespaceDescriptor; 038import org.apache.hadoop.hbase.NamespaceNotFoundException; 039import org.apache.hadoop.hbase.RegionMetrics; 040import org.apache.hadoop.hbase.ServerName; 041import org.apache.hadoop.hbase.TableExistsException; 042import org.apache.hadoop.hbase.TableName; 043import org.apache.hadoop.hbase.TableNotFoundException; 044import org.apache.hadoop.hbase.client.replication.TableCFs; 045import org.apache.hadoop.hbase.client.security.SecurityCapability; 046import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel; 047import org.apache.hadoop.hbase.quotas.QuotaFilter; 048import org.apache.hadoop.hbase.quotas.QuotaRetriever; 049import org.apache.hadoop.hbase.quotas.QuotaSettings; 050import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException; 051import org.apache.hadoop.hbase.replication.ReplicationException; 052import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; 053import org.apache.hadoop.hbase.replication.ReplicationPeerDescription; 054import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException; 055import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException; 056import org.apache.hadoop.hbase.snapshot.SnapshotCreationException; 057import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException; 058import org.apache.hadoop.hbase.util.Pair; 059import org.apache.yetus.audience.InterfaceAudience; 060 061/** 062 * The administrative API for HBase. Obtain an instance from {@link Connection#getAdmin()} and 063 * call {@link #close()} when done. 064 * <p>Admin can be used to create, drop, list, enable and disable and otherwise modify tables, 065 * as well as perform other administrative operations. 066 * 067 * @see ConnectionFactory 068 * @see Connection 069 * @see Table 070 * @since 0.99.0 071 */ 072@InterfaceAudience.Public 073public interface Admin extends Abortable, Closeable { 074 int getOperationTimeout(); 075 076 @Override 077 void abort(String why, Throwable e); 078 079 @Override 080 boolean isAborted(); 081 082 /** 083 * @return Connection used by this object. 084 */ 085 Connection getConnection(); 086 087 /** 088 * @param tableName Table to check. 089 * @return <code>true</code> if table exists already. 090 * @throws IOException 091 */ 092 boolean tableExists(TableName tableName) throws IOException; 093 094 /** 095 * List all the userspace tables. 096 * 097 * @return an array of read-only HTableDescriptors 098 * @throws IOException if a remote or network exception occurs 099 * @deprecated since 2.0 version and will be removed in 3.0 version. 100 * Use {@link #listTableDescriptors()}. 101 * @see #listTableDescriptors() 102 */ 103 @Deprecated 104 HTableDescriptor[] listTables() throws IOException; 105 106 /** 107 * List all the userspace tables. 108 * 109 * @return a list of TableDescriptors 110 * @throws IOException if a remote or network exception occurs 111 */ 112 List<TableDescriptor> listTableDescriptors() throws IOException; 113 114 /** 115 * List all the userspace tables that match the given pattern. 116 * 117 * @param pattern The compiled regular expression to match against 118 * @return an array of read-only HTableDescriptors 119 * @throws IOException if a remote or network exception occurs 120 * @see #listTables() 121 * @deprecated since 2.0 version and will be removed in 3.0 version. 122 * Use {@link #listTableDescriptors(java.util.regex.Pattern)}. 123 * @see #listTableDescriptors(Pattern) 124 */ 125 @Deprecated 126 HTableDescriptor[] listTables(Pattern pattern) throws IOException; 127 128 /** 129 * List all the userspace tables that match the given pattern. 130 * 131 * @param pattern The compiled regular expression to match against 132 * @return a list of TableDescriptors 133 * @throws IOException if a remote or network exception occurs 134 * @see #listTables() 135 */ 136 List<TableDescriptor> listTableDescriptors(Pattern pattern) throws IOException; 137 138 /** 139 * List all the userspace tables matching the given regular expression. 140 * 141 * @param regex The regular expression to match against 142 * @return a list of read-only HTableDescriptors 143 * @throws IOException if a remote or network exception occurs 144 * @see #listTableDescriptors(Pattern) 145 * @deprecated since 2.0 version and will be removed in 3.0 version. Use 146 * {@link #listTableDescriptors(Pattern)} instead. 147 */ 148 @Deprecated 149 HTableDescriptor[] listTables(String regex) throws IOException; 150 151 /** 152 * List all the tables matching the given pattern. 153 * 154 * @param pattern The compiled regular expression to match against 155 * @param includeSysTables <code>false</code> to match only against userspace tables 156 * @return an array of read-only HTableDescriptors 157 * @throws IOException if a remote or network exception occurs 158 * @see #listTables() 159 * @deprecated since 2.0 version and will be removed in 3.0 version. 160 * Use {@link #listTableDescriptors(java.util.regex.Pattern, boolean)}. 161 * @see #listTableDescriptors(java.util.regex.Pattern, boolean) 162 */ 163 @Deprecated 164 HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables) 165 throws IOException; 166 167 /** 168 * List all the tables matching the given pattern. 169 * 170 * @param pattern The compiled regular expression to match against 171 * @param includeSysTables <code>false</code> to match only against userspace tables 172 * @return a list of TableDescriptors 173 * @throws IOException if a remote or network exception occurs 174 * @see #listTables() 175 */ 176 List<TableDescriptor> listTableDescriptors(Pattern pattern, boolean includeSysTables) 177 throws IOException; 178 179 /** 180 * List all the tables matching the given pattern. 181 * 182 * @param regex The regular expression to match against 183 * @param includeSysTables <code>false</code> to match only against userspace tables 184 * @return an array of read-only HTableDescriptors 185 * @throws IOException if a remote or network exception occurs 186 * @see #listTables(java.util.regex.Pattern, boolean) 187 * @deprecated since 2.0 version and will be removed in 3.0 version. 188 * Use {@link #listTableDescriptors(Pattern, boolean)}. 189 */ 190 @Deprecated 191 HTableDescriptor[] listTables(String regex, boolean includeSysTables) 192 throws IOException; 193 194 /** 195 * List all of the names of userspace tables. 196 * 197 * @return TableName[] table names 198 * @throws IOException if a remote or network exception occurs 199 */ 200 TableName[] listTableNames() throws IOException; 201 202 /** 203 * List all of the names of userspace tables. 204 * @param pattern The regular expression to match against 205 * @return array of table names 206 * @throws IOException if a remote or network exception occurs 207 */ 208 TableName[] listTableNames(Pattern pattern) throws IOException; 209 210 /** 211 * List all of the names of userspace tables. 212 * @param regex The regular expression to match against 213 * @return TableName[] table names 214 * @throws IOException if a remote or network exception occurs 215 * @deprecated since 2.0 version and will be removed in 3.0 version. Use 216 * {@link #listTableNames(Pattern)} instead. 217 */ 218 @Deprecated 219 TableName[] listTableNames(String regex) throws IOException; 220 221 /** 222 * List all of the names of userspace tables. 223 * @param pattern The regular expression to match against 224 * @param includeSysTables <code>false</code> to match only against userspace tables 225 * @return TableName[] table names 226 * @throws IOException if a remote or network exception occurs 227 */ 228 TableName[] listTableNames(Pattern pattern, boolean includeSysTables) 229 throws IOException; 230 231 /** 232 * List all of the names of userspace tables. 233 * @param regex The regular expression to match against 234 * @param includeSysTables <code>false</code> to match only against userspace tables 235 * @return TableName[] table names 236 * @throws IOException if a remote or network exception occurs 237 * @deprecated since 2.0 version and will be removed in 3.0 version. Use 238 * {@link #listTableNames(Pattern, boolean)} instead. 239 */ 240 @Deprecated 241 TableName[] listTableNames(String regex, boolean includeSysTables) 242 throws IOException; 243 244 /** 245 * Get a table descriptor. 246 * 247 * @param tableName as a {@link TableName} 248 * @return the read-only tableDescriptor 249 * @throws org.apache.hadoop.hbase.TableNotFoundException 250 * @throws IOException if a remote or network exception occurs 251 * @deprecated since 2.0 version and will be removed in 3.0 version. 252 * Use {@link #getDescriptor(TableName)}. 253 */ 254 @Deprecated 255 HTableDescriptor getTableDescriptor(TableName tableName) 256 throws TableNotFoundException, IOException; 257 258 /** 259 * Get a table descriptor. 260 * 261 * @param tableName as a {@link TableName} 262 * @return the tableDescriptor 263 * @throws org.apache.hadoop.hbase.TableNotFoundException 264 * @throws IOException if a remote or network exception occurs 265 */ 266 TableDescriptor getDescriptor(TableName tableName) 267 throws TableNotFoundException, IOException; 268 269 /** 270 * Creates a new table. Synchronous operation. 271 * 272 * @param desc table descriptor for table 273 * @throws IllegalArgumentException if the table name is reserved 274 * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running 275 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent 276 * threads, the table may have been created between test-for-existence and attempt-at-creation). 277 * @throws IOException if a remote or network exception occurs 278 */ 279 void createTable(TableDescriptor desc) throws IOException; 280 281 /** 282 * Creates a new table with the specified number of regions. The start key specified will become 283 * the end key of the first region of the table, and the end key specified will become the start 284 * key of the last region of the table (the first region has a null start key and the last region 285 * has a null end key). BigInteger math will be used to divide the key range specified into enough 286 * segments to make the required number of total regions. Synchronous operation. 287 * 288 * @param desc table descriptor for table 289 * @param startKey beginning of key range 290 * @param endKey end of key range 291 * @param numRegions the total number of regions to create 292 * @throws IllegalArgumentException if the table name is reserved 293 * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running 294 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent 295 * threads, the table may have been created between test-for-existence and attempt-at-creation). 296 * @throws IOException 297 */ 298 void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) 299 throws IOException; 300 301 /** 302 * Creates a new table with an initial set of empty regions defined by the specified split keys. 303 * The total number of regions created will be the number of split keys plus one. Synchronous 304 * operation. Note : Avoid passing empty split key. 305 * 306 * @param desc table descriptor for table 307 * @param splitKeys array of split keys for the initial regions of the table 308 * @throws IllegalArgumentException if the table name is reserved, if the split keys are repeated 309 * and if the split key has empty byte array. 310 * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running 311 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent 312 * threads, the table may have been created between test-for-existence and attempt-at-creation). 313 * @throws IOException 314 */ 315 void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOException; 316 317 /** 318 * Creates a new table but does not block and wait for it to come online. 319 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 320 * It may throw ExecutionException if there was an error while executing the operation 321 * or TimeoutException in case the wait timeout was not long enough to allow the 322 * operation to complete. 323 * Throws IllegalArgumentException Bad table name, if the split keys 324 * are repeated and if the split key has empty byte array. 325 * 326 * @param desc table descriptor for table 327 * @param splitKeys keys to check if the table has been created with all split keys 328 * @throws IOException if a remote or network exception occurs 329 * @return the result of the async creation. You can use Future.get(long, TimeUnit) 330 * to wait on the operation to complete. 331 */ 332 Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys) 333 throws IOException; 334 335 /** 336 * Deletes a table. Synchronous operation. 337 * 338 * @param tableName name of table to delete 339 * @throws IOException if a remote or network exception occurs 340 */ 341 void deleteTable(TableName tableName) throws IOException; 342 343 /** 344 * Deletes the table but does not block and wait for it to be completely removed. 345 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 346 * It may throw ExecutionException if there was an error while executing the operation 347 * or TimeoutException in case the wait timeout was not long enough to allow the 348 * operation to complete. 349 * 350 * @param tableName name of table to delete 351 * @throws IOException if a remote or network exception occurs 352 * @return the result of the async delete. You can use Future.get(long, TimeUnit) 353 * to wait on the operation to complete. 354 */ 355 Future<Void> deleteTableAsync(TableName tableName) throws IOException; 356 357 /** 358 * Deletes tables matching the passed in pattern and wait on completion. Warning: Use this method 359 * carefully, there is no prompting and the effect is immediate. Consider using {@link 360 * #listTableDescriptors(Pattern)} 361 * and {@link #deleteTable(org.apache.hadoop.hbase.TableName)} 362 * 363 * @param regex The regular expression to match table names against 364 * @return Table descriptors for tables that couldn't be deleted. 365 * The return htds are read-only 366 * @throws IOException 367 * @see #deleteTables(java.util.regex.Pattern) 368 * @see #deleteTable(org.apache.hadoop.hbase.TableName) 369 * @deprecated since 2.0 version and will be removed in 3.0 version 370 * This is just a trivial helper method without any magic. 371 * Consider using {@link #listTableDescriptors(Pattern)} 372 * and {@link #deleteTable(TableName)} 373 */ 374 @Deprecated 375 HTableDescriptor[] deleteTables(String regex) throws IOException; 376 377 /** 378 * Delete tables matching the passed in pattern and wait on completion. Warning: Use this method 379 * carefully, there is no prompting and the effect is immediate. Consider using {@link 380 * #listTableDescriptors(java.util.regex.Pattern)} and 381 * {@link #deleteTable(org.apache.hadoop.hbase.TableName)} 382 * 383 * @param pattern The pattern to match table names against 384 * @return Table descriptors for tables that couldn't be deleted 385 * The return htds are read-only 386 * @throws IOException 387 * @deprecated since 2.0 version and will be removed in 3.0 version 388 * This is just a trivial helper method without any magic. 389 * Consider using {@link #listTableDescriptors(java.util.regex.Pattern)} 390 * and {@link #deleteTable(TableName)} 391 */ 392 @Deprecated 393 HTableDescriptor[] deleteTables(Pattern pattern) throws IOException; 394 395 /** 396 * Truncate a table. 397 * Synchronous operation. 398 * 399 * @param tableName name of table to truncate 400 * @param preserveSplits <code>true</code> if the splits should be preserved 401 * @throws IOException if a remote or network exception occurs 402 */ 403 void truncateTable(TableName tableName, boolean preserveSplits) 404 throws IOException; 405 406 /** 407 * Truncate the table but does not block and wait for it to be completely enabled. You can use 408 * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw 409 * ExecutionException if there was an error while executing the operation or TimeoutException in 410 * case the wait timeout was not long enough to allow the operation to complete. 411 * @param tableName name of table to delete 412 * @param preserveSplits <code>true</code> if the splits should be preserved 413 * @throws IOException if a remote or network exception occurs 414 * @return the result of the async truncate. You can use Future.get(long, TimeUnit) to wait on the 415 * operation to complete. 416 */ 417 Future<Void> truncateTableAsync(TableName tableName, boolean preserveSplits) 418 throws IOException; 419 420 /** 421 * Enable a table. May timeout. Use {@link #enableTableAsync(org.apache.hadoop.hbase.TableName)} 422 * and {@link #isTableEnabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in 423 * disabled state for it to be enabled. 424 * 425 * @param tableName name of the table 426 * @throws IOException if a remote or network exception occurs There could be couple types of 427 * IOException TableNotFoundException means the table doesn't exist. TableNotDisabledException 428 * means the table isn't in disabled state. 429 * @see #isTableEnabled(org.apache.hadoop.hbase.TableName) 430 * @see #disableTable(org.apache.hadoop.hbase.TableName) 431 * @see #enableTableAsync(org.apache.hadoop.hbase.TableName) 432 */ 433 void enableTable(TableName tableName) throws IOException; 434 435 /** 436 * Enable the table but does not block and wait for it to be completely enabled. 437 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 438 * It may throw ExecutionException if there was an error while executing the operation 439 * or TimeoutException in case the wait timeout was not long enough to allow the 440 * operation to complete. 441 * 442 * @param tableName name of table to delete 443 * @throws IOException if a remote or network exception occurs 444 * @return the result of the async enable. You can use Future.get(long, TimeUnit) 445 * to wait on the operation to complete. 446 */ 447 Future<Void> enableTableAsync(TableName tableName) throws IOException; 448 449 /** 450 * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method 451 * carefully, there is no prompting and the effect is immediate. Consider using {@link 452 * #listTableDescriptors(Pattern)} and {@link #enableTable(org.apache.hadoop.hbase.TableName)} 453 * 454 * @param regex The regular expression to match table names against 455 * @throws IOException 456 * @return Table descriptors for tables that couldn't be enabled. 457 * The return HTDs are read-only. 458 * @see #enableTables(java.util.regex.Pattern) 459 * @see #enableTable(org.apache.hadoop.hbase.TableName) 460 * @deprecated since 2.0 version and will be removed in 3.0 version 461 * This is just a trivial helper method without any magic. 462 * Consider using {@link #listTableDescriptors(Pattern)} 463 * and {@link #enableTable(org.apache.hadoop.hbase.TableName)} 464 */ 465 @Deprecated 466 HTableDescriptor[] enableTables(String regex) throws IOException; 467 468 /** 469 * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method 470 * carefully, there is no prompting and the effect is immediate. Consider using {@link 471 * #listTableDescriptors(java.util.regex.Pattern)} and 472 * {@link #enableTable(org.apache.hadoop.hbase.TableName)} 473 * 474 * @param pattern The pattern to match table names against 475 * @throws IOException 476 * @return Table descriptors for tables that couldn't be enabled. 477 * The return HTDs are read-only. 478 * @deprecated since 2.0 version and will be removed in 3.0 version 479 * This is just a trivial helper method without any magic. 480 * Consider using {@link #listTableDescriptors(java.util.regex.Pattern)} 481 * and {@link #enableTable(org.apache.hadoop.hbase.TableName)} 482 */ 483 @Deprecated 484 HTableDescriptor[] enableTables(Pattern pattern) throws IOException; 485 486 /** 487 * Disable the table but does not block and wait for it to be completely disabled. 488 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 489 * It may throw ExecutionException if there was an error while executing the operation 490 * or TimeoutException in case the wait timeout was not long enough to allow the 491 * operation to complete. 492 * 493 * @param tableName name of table to delete 494 * @throws IOException if a remote or network exception occurs 495 * @return the result of the async disable. You can use Future.get(long, TimeUnit) 496 * to wait on the operation to complete. 497 */ 498 Future<Void> disableTableAsync(TableName tableName) throws IOException; 499 500 /** 501 * Disable table and wait on completion. May timeout eventually. Use {@link 502 * #disableTableAsync(org.apache.hadoop.hbase.TableName)} and 503 * {@link #isTableDisabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in 504 * enabled state for it to be disabled. 505 * 506 * @param tableName 507 * @throws IOException There could be couple types of IOException TableNotFoundException means the 508 * table doesn't exist. TableNotEnabledException means the table isn't in enabled state. 509 */ 510 void disableTable(TableName tableName) throws IOException; 511 512 /** 513 * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method 514 * carefully, there is no prompting and the effect is immediate. Consider using {@link 515 * #listTableDescriptors(Pattern)} and {@link #disableTable(org.apache.hadoop.hbase.TableName)} 516 * 517 * @param regex The regular expression to match table names against 518 * @return Table descriptors for tables that couldn't be disabled 519 * The return htds are read-only 520 * @throws IOException 521 * @see #disableTables(java.util.regex.Pattern) 522 * @see #disableTable(org.apache.hadoop.hbase.TableName) 523 * @deprecated since 2.0 version and will be removed in 3.0 version 524 * This is just a trivial helper method without any magic. 525 * Consider using {@link #listTableDescriptors(Pattern)} 526 * and {@link #disableTable(org.apache.hadoop.hbase.TableName)} 527 */ 528 @Deprecated 529 HTableDescriptor[] disableTables(String regex) throws IOException; 530 531 /** 532 * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method 533 * carefully, there is no prompting and the effect is immediate. Consider using {@link 534 * #listTableDescriptors(java.util.regex.Pattern)} and 535 * {@link #disableTable(org.apache.hadoop.hbase.TableName)} 536 * 537 * @param pattern The pattern to match table names against 538 * @return Table descriptors for tables that couldn't be disabled 539 * The return htds are read-only 540 * @throws IOException 541 * @deprecated since 2.0 version and will be removed in 3.0 version 542 * This is just a trivial helper method without any magic. 543 * Consider using {@link #listTableDescriptors(java.util.regex.Pattern)} 544 * and {@link #disableTable(org.apache.hadoop.hbase.TableName)} 545 */ 546 @Deprecated 547 HTableDescriptor[] disableTables(Pattern pattern) throws IOException; 548 549 /** 550 * @param tableName name of table to check 551 * @return <code>true</code> if table is on-line 552 * @throws IOException if a remote or network exception occurs 553 */ 554 boolean isTableEnabled(TableName tableName) throws IOException; 555 556 /** 557 * @param tableName name of table to check 558 * @return <code>true</code> if table is off-line 559 * @throws IOException if a remote or network exception occurs 560 */ 561 boolean isTableDisabled(TableName tableName) throws IOException; 562 563 /** 564 * @param tableName name of table to check 565 * @return <code>true</code> if all regions of the table are available 566 * @throws IOException if a remote or network exception occurs 567 */ 568 boolean isTableAvailable(TableName tableName) throws IOException; 569 570 /** 571 * Use this api to check if the table has been created with the specified number of splitkeys 572 * which was used while creating the given table. Note : If this api is used after a table's 573 * region gets splitted, the api may return <code>false</code>. 574 * 575 * @param tableName name of table to check 576 * @param splitKeys keys to check if the table has been created with all split keys 577 * @throws IOException if a remote or network excpetion occurs 578 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #isTableAvailable(TableName)} 579 */ 580 @Deprecated 581 boolean isTableAvailable(TableName tableName, byte[][] splitKeys) throws IOException; 582 583 /** 584 * Get the status of an <code>alter</code> (a.k.a <code>modify</code>) command - indicates how 585 * many regions have received the updated schema Asynchronous operation. 586 * 587 * @param tableName TableName instance 588 * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are 589 * yet to be updated Pair.getSecond() is the total number of regions of the table 590 * @throws IOException if a remote or network exception occurs 591 * @deprecated Since 2.0.0. Will be removed in 3.0.0. No longer needed now you get a Future 592 * on an operation. 593 */ 594 @Deprecated 595 Pair<Integer, Integer> getAlterStatus(TableName tableName) throws IOException; 596 597 /** 598 * Get the status of <code>alter</code> (a.k.a <code>modify</code>) command - indicates how many 599 * regions have received the updated schema Asynchronous operation. 600 * 601 * @param tableName name of the table to get the status of 602 * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are 603 * yet to be updated Pair.getSecond() is the total number of regions of the table 604 * @throws IOException if a remote or network exception occurs 605 * @deprecated Since 2.0.0. Will be removed in 3.0.0. No longer needed now you get a Future 606 * on an operation. 607 */ 608 @Deprecated 609 Pair<Integer, Integer> getAlterStatus(byte[] tableName) throws IOException; 610 611 /** 612 * Add a column family to an existing table. Synchronous operation. 613 * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it 614 * returns a {@link Future} from which you can learn whether success or failure. 615 * 616 * @param tableName name of the table to add column family to 617 * @param columnFamily column family descriptor of column family to be added 618 * @throws IOException if a remote or network exception occurs 619 * @deprecated As of release 2.0.0. 620 * This will be removed in HBase 3.0.0. 621 * Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}. 622 */ 623 @Deprecated 624 default void addColumn(TableName tableName, ColumnFamilyDescriptor columnFamily) 625 throws IOException { 626 addColumnFamily(tableName, columnFamily); 627 } 628 629 /** 630 * Add a column family to an existing table. Synchronous operation. 631 * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it 632 * returns a {@link Future} from which you can learn whether success or failure. 633 * 634 * @param tableName name of the table to add column family to 635 * @param columnFamily column family descriptor of column family to be added 636 * @throws IOException if a remote or network exception occurs 637 */ 638 void addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) 639 throws IOException; 640 641 /** 642 * Add a column family to an existing table. Asynchronous operation. 643 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 644 * It may throw ExecutionException if there was an error while executing the operation 645 * or TimeoutException in case the wait timeout was not long enough to allow the 646 * operation to complete. 647 * 648 * @param tableName name of the table to add column family to 649 * @param columnFamily column family descriptor of column family to be added 650 * @throws IOException if a remote or network exception occurs 651 * @return the result of the async add column family. You can use Future.get(long, TimeUnit) to 652 * wait on the operation to complete. 653 */ 654 Future<Void> addColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily) 655 throws IOException; 656 657 /** 658 * Delete a column family from a table. Synchronous operation. 659 * Use {@link #deleteColumnFamily(TableName, byte[])} instead because it 660 * returns a {@link Future} from which you can learn whether success or failure. 661 * 662 * @param tableName name of table 663 * @param columnFamily name of column family to be deleted 664 * @throws IOException if a remote or network exception occurs 665 * @deprecated As of release 2.0.0. 666 * This will be removed in HBase 3.0.0. 667 * Use {@link #deleteColumnFamily(TableName, byte[])}}. 668 */ 669 @Deprecated 670 void deleteColumn(TableName tableName, byte[] columnFamily) throws IOException; 671 672 /** 673 * Delete a column family from a table. Synchronous operation. 674 * Use {@link #deleteColumnFamily(TableName, byte[])} instead because it 675 * returns a {@link Future} from which you can learn whether success or failure. 676 * @param tableName name of table 677 * @param columnFamily name of column family to be deleted 678 * @throws IOException if a remote or network exception occurs 679 */ 680 void deleteColumnFamily(TableName tableName, byte[] columnFamily) throws IOException; 681 682 /** 683 * Delete a column family from a table. Asynchronous operation. 684 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 685 * It may throw ExecutionException if there was an error while executing the operation 686 * or TimeoutException in case the wait timeout was not long enough to allow the 687 * operation to complete. 688 * 689 * @param tableName name of table 690 * @param columnFamily name of column family to be deleted 691 * @throws IOException if a remote or network exception occurs 692 * @return the result of the async delete column family. You can use Future.get(long, TimeUnit) to 693 * wait on the operation to complete. 694 */ 695 Future<Void> deleteColumnFamilyAsync(TableName tableName, byte[] columnFamily) 696 throws IOException; 697 698 /** 699 * Modify an existing column family on a table. Synchronous operation. 700 * Use {@link #modifyColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it 701 * returns a {@link Future} from which you can learn whether success or failure. 702 * @param tableName name of table 703 * @param columnFamily new column family descriptor to use 704 * @throws IOException if a remote or network exception occurs 705 * @deprecated As of release 2.0.0. 706 * This will be removed in HBase 3.0.0. 707 * Use {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)}. 708 */ 709 @Deprecated 710 default void modifyColumn(TableName tableName, ColumnFamilyDescriptor columnFamily) 711 throws IOException { 712 modifyColumnFamily(tableName, columnFamily); 713 } 714 715 /** 716 * Modify an existing column family on a table. Synchronous operation. 717 * Use {@link #modifyColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it 718 * returns a {@link Future} from which you can learn whether success or failure. 719 * @param tableName name of table 720 * @param columnFamily new column family descriptor to use 721 * @throws IOException if a remote or network exception occurs 722 */ 723 void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily) 724 throws IOException; 725 726 /** 727 * Modify an existing column family on a table. Asynchronous operation. 728 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 729 * It may throw ExecutionException if there was an error while executing the operation 730 * or TimeoutException in case the wait timeout was not long enough to allow the 731 * operation to complete. 732 * 733 * @param tableName name of table 734 * @param columnFamily new column family descriptor to use 735 * @throws IOException if a remote or network exception occurs 736 * @return the result of the async modify column family. You can use Future.get(long, TimeUnit) to 737 * wait on the operation to complete. 738 */ 739 Future<Void> modifyColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily) 740 throws IOException; 741 742 /** 743 * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. 744 * 745 * @param regionname region name to close 746 * @param serverName Deprecated. Not used. 747 * @throws IOException if a remote or network exception occurs 748 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. 749 * Use {@link #unassign(byte[], boolean)}. 750 */ 751 @Deprecated 752 void closeRegion(String regionname, String serverName) throws IOException; 753 754 /** 755 * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. 756 * 757 * @param regionname region name to close 758 * @param serverName Deprecated. Not used. 759 * @throws IOException if a remote or network exception occurs 760 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. 761 * Use {@link #unassign(byte[], boolean)}. 762 */ 763 @Deprecated 764 void closeRegion(byte[] regionname, String serverName) throws IOException; 765 766 /** 767 * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. 768 * 769 * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name 770 * suffix: e.g. if regionname is 771 * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>, 772 * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>. 773 * @param serverName Deprecated. Not used. 774 * @return Deprecated. Returns <code>true</code> always. 775 * @throws IOException if a remote or network exception occurs 776 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. 777 * Use {@link #unassign(byte[], boolean)}. 778 */ 779 @Deprecated 780 boolean closeRegionWithEncodedRegionName(String encodedRegionName, String serverName) 781 throws IOException; 782 783 /** 784 * Used {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins. 785 * 786 * @param sn Deprecated. Not used. 787 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 788 * (<a href="https://issues.apache.org/jira/browse/HBASE-18231">HBASE-18231</a>). 789 * Use {@link #unassign(byte[], boolean)}. 790 */ 791 @Deprecated 792 void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException; 793 794 /** 795 * Get all the online regions on a region server. 796 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 797 * (<a href="https://issues.apache.org/jira/browse/HBASE-17980">HBASE-17980</a>). 798 * Use {@link #getRegions(ServerName sn)}. 799 */ 800 @Deprecated 801 List<HRegionInfo> getOnlineRegions(ServerName sn) throws IOException; 802 803 /** 804 * Get all the online regions on a region server. 805 * 806 * @return List of {@link RegionInfo} 807 * @throws java.io.IOException 808 */ 809 List<RegionInfo> getRegions(ServerName serverName) throws IOException; 810 811 /** 812 * Flush a table. Synchronous operation. 813 * 814 * @param tableName table to flush 815 * @throws IOException if a remote or network exception occurs 816 */ 817 void flush(TableName tableName) throws IOException; 818 819 /** 820 * Flush an individual region. Synchronous operation. 821 * 822 * @param regionName region to flush 823 * @throws IOException if a remote or network exception occurs 824 */ 825 void flushRegion(byte[] regionName) throws IOException; 826 827 /** 828 * Flush all regions on the region server. Synchronous operation. 829 * @param serverName the region server name to flush 830 * @throws IOException if a remote or network exception occurs 831 */ 832 void flushRegionServer(ServerName serverName) throws IOException; 833 834 /** 835 * Compact a table. Asynchronous operation in that this method requests that a 836 * Compaction run and then it returns. It does not wait on the completion of Compaction 837 * (it can take a while). 838 * 839 * @param tableName table to compact 840 * @throws IOException if a remote or network exception occurs 841 */ 842 void compact(TableName tableName) throws IOException; 843 844 /** 845 * Compact an individual region. Asynchronous operation in that this method requests that a 846 * Compaction run and then it returns. It does not wait on the completion of Compaction 847 * (it can take a while). 848 * 849 * @param regionName region to compact 850 * @throws IOException if a remote or network exception occurs 851 */ 852 void compactRegion(byte[] regionName) throws IOException; 853 854 /** 855 * Compact a column family within a table. Asynchronous operation in that this method requests 856 * that a Compaction run and then it returns. It does not wait on the completion of Compaction 857 * (it can take a while). 858 * 859 * @param tableName table to compact 860 * @param columnFamily column family within a table 861 * @throws IOException if a remote or network exception occurs 862 */ 863 void compact(TableName tableName, byte[] columnFamily) 864 throws IOException; 865 866 /** 867 * Compact a column family within a region. Asynchronous operation in that this method requests 868 * that a Compaction run and then it returns. It does not wait on the completion of Compaction 869 * (it can take a while). 870 * 871 * @param regionName region to compact 872 * @param columnFamily column family within a region 873 * @throws IOException if a remote or network exception occurs 874 */ 875 void compactRegion(byte[] regionName, byte[] columnFamily) 876 throws IOException; 877 878 /** 879 * Compact a table. Asynchronous operation in that this method requests that a 880 * Compaction run and then it returns. It does not wait on the completion of Compaction 881 * (it can take a while). 882 * 883 * @param tableName table to compact 884 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 885 * @throws IOException if a remote or network exception occurs 886 * @throws InterruptedException 887 */ 888 void compact(TableName tableName, CompactType compactType) 889 throws IOException, InterruptedException; 890 891 /** 892 * Compact a column family within a table. Asynchronous operation in that this method 893 * requests that a Compaction run and then it returns. It does not wait on the 894 * completion of Compaction (it can take a while). 895 * 896 * @param tableName table to compact 897 * @param columnFamily column family within a table 898 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 899 * @throws IOException if not a mob column family or if a remote or network exception occurs 900 * @throws InterruptedException 901 */ 902 void compact(TableName tableName, byte[] columnFamily, CompactType compactType) 903 throws IOException, InterruptedException; 904 905 /** 906 * Major compact a table. Asynchronous operation in that this method requests 907 * that a Compaction run and then it returns. It does not wait on the completion of Compaction 908 * (it can take a while). 909 * 910 * @param tableName table to major compact 911 * @throws IOException if a remote or network exception occurs 912 */ 913 void majorCompact(TableName tableName) throws IOException; 914 915 /** 916 * Major compact a table or an individual region. Asynchronous operation in that this method requests 917 * that a Compaction run and then it returns. It does not wait on the completion of Compaction 918 * (it can take a while). 919 * 920 * @param regionName region to major compact 921 * @throws IOException if a remote or network exception occurs 922 */ 923 void majorCompactRegion(byte[] regionName) throws IOException; 924 925 /** 926 * Major compact a column family within a table. Asynchronous operation in that this method requests 927 * that a Compaction run and then it returns. It does not wait on the completion of Compaction 928 * (it can take a while). 929 * 930 * @param tableName table to major compact 931 * @param columnFamily column family within a table 932 * @throws IOException if a remote or network exception occurs 933 */ 934 void majorCompact(TableName tableName, byte[] columnFamily) 935 throws IOException; 936 937 /** 938 * Major compact a column family within region. Asynchronous operation in that this method requests 939 * that a Compaction run and then it returns. It does not wait on the completion of Compaction 940 * (it can take a while). 941 * 942 * @param regionName egion to major compact 943 * @param columnFamily column family within a region 944 * @throws IOException if a remote or network exception occurs 945 */ 946 void majorCompactRegion(byte[] regionName, byte[] columnFamily) 947 throws IOException; 948 949 /** 950 * Major compact a table. Asynchronous operation in that this method requests that a 951 * Compaction run and then it returns. It does not wait on the completion of Compaction 952 * (it can take a while). 953 * 954 * @param tableName table to compact 955 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 956 * @throws IOException if a remote or network exception occurs 957 * @throws InterruptedException 958 */ 959 void majorCompact(TableName tableName, CompactType compactType) 960 throws IOException, InterruptedException; 961 962 /** 963 * Major compact a column family within a table. Asynchronous operation in that this method requests that a 964 * Compaction run and then it returns. It does not wait on the completion of Compaction 965 * (it can take a while). 966 * 967 * @param tableName table to compact 968 * @param columnFamily column family within a table 969 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 970 * @throws IOException if not a mob column family or if a remote or network exception occurs 971 * @throws InterruptedException 972 */ 973 void majorCompact(TableName tableName, byte[] columnFamily, CompactType compactType) 974 throws IOException, InterruptedException; 975 976 /** 977 * Compact all regions on the region server. Asynchronous operation in that this method requests 978 * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it 979 * can take a while). 980 * @param sn the region server name 981 * @param major if it's major compaction 982 * @throws IOException if a remote or network exception occurs 983 * @throws InterruptedException 984 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use 985 * {@link #compactRegionServer(ServerName)} or 986 * {@link #majorCompactRegionServer(ServerName)}. 987 */ 988 @Deprecated 989 default void compactRegionServer(ServerName sn, boolean major) throws IOException, 990 InterruptedException { 991 if (major) { 992 majorCompactRegionServer(sn); 993 } else { 994 compactRegionServer(sn); 995 } 996 } 997 998 /** 999 * Compact all regions on the region server. Asynchronous operation in that this method requests 1000 * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it 1001 * can take a while). 1002 * @param serverName the region server name 1003 * @throws IOException if a remote or network exception occurs 1004 */ 1005 void compactRegionServer(ServerName serverName) throws IOException; 1006 1007 /** 1008 * Major compact all regions on the region server. Asynchronous operation in that this method 1009 * requests that a Compaction run and then it returns. It does not wait on the completion of 1010 * Compaction (it can take a while). 1011 * @param serverName the region server name 1012 * @throws IOException if a remote or network exception occurs 1013 */ 1014 void majorCompactRegionServer(ServerName serverName) throws IOException; 1015 1016 /** 1017 * Move the region <code>r</code> to <code>dest</code>. 1018 * 1019 * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name 1020 * suffix: e.g. if regionname is 1021 * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>, 1022 * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>. 1023 * @param destServerName The servername of the destination regionserver. If passed the empty byte 1024 * array we'll assign to a random server. A server name is made of host, port and startcode. 1025 * Here is an example: <code> host187.example.com,60020,1289493121758</code> 1026 * @throws IOException if we can't find a region named 1027 * <code>encodedRegionName</code> 1028 */ 1029 void move(byte[] encodedRegionName, byte[] destServerName) throws IOException; 1030 1031 /** 1032 * Assign a Region. 1033 * @param regionName Region name to assign. 1034 */ 1035 void assign(byte[] regionName) throws IOException; 1036 1037 /** 1038 * Unassign a region from current hosting regionserver. Region will then be assigned to a 1039 * regionserver chosen at random. Region could be reassigned back to the same server. Use {@link 1040 * #move(byte[], byte[])} if you want to control the region movement. 1041 * 1042 * @param regionName Region to unassign. Will clear any existing RegionPlan if one found. 1043 * @param force If <code>true</code>, force unassign (Will remove region from regions-in-transition too if 1044 * present. If results in double assignment use hbck -fix to resolve. To be used by experts). 1045 */ 1046 void unassign(byte[] regionName, boolean force) 1047 throws IOException; 1048 1049 /** 1050 * Offline specified region from master's in-memory state. It will not attempt to reassign the 1051 * region as in unassign. This API can be used when a region not served by any region server and 1052 * still online as per Master's in memory state. If this API is incorrectly used on active region 1053 * then master will loose track of that region. This is a special method that should be used by 1054 * experts or hbck. 1055 * 1056 * @param regionName Region to offline. 1057 * @throws IOException 1058 */ 1059 void offline(byte[] regionName) throws IOException; 1060 1061 /** 1062 * Turn the load balancer on or off. 1063 * 1064 * @param synchronous If <code>true</code>, it waits until current balance() call, if 1065 * outstanding, to return. 1066 * @return Previous balancer value 1067 * @deprecated Since 2.0.0. Will be removed in 3.0.0. 1068 * Use {@link #balancerSwitch(boolean, boolean)} instead. 1069 */ 1070 @Deprecated 1071 default boolean setBalancerRunning(boolean on, boolean synchronous) throws IOException { 1072 return balancerSwitch(on, synchronous); 1073 } 1074 1075 /** 1076 * Turn the load balancer on or off. 1077 * @param onOrOff Set to <code>true</code> to enable, <code>false</code> to disable. 1078 * @param synchronous If <code>true</code>, it waits until current balance() call, if 1079 * outstanding, to return. 1080 * @return Previous balancer value 1081 */ 1082 boolean balancerSwitch(boolean onOrOff, boolean synchronous) 1083 throws IOException; 1084 1085 /** 1086 * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the 1087 * reassignments. Can NOT run for various reasons. Check logs. 1088 * 1089 * @return <code>true</code> if balancer ran, <code>false</code> otherwise. 1090 * @deprecated Since 2.0.0. Will be removed in 3.0.0. 1091 * Use {@link #balance()} instead. 1092 */ 1093 @Deprecated 1094 default boolean balancer() throws IOException { 1095 return balance(); 1096 } 1097 1098 /** 1099 * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the 1100 * reassignments. Can NOT run for various reasons. Check logs. 1101 * 1102 * @return <code>true</code> if balancer ran, <code>false</code> otherwise. 1103 */ 1104 boolean balance() throws IOException; 1105 1106 /** 1107 * Invoke the balancer. Will run the balancer and if regions to move, it will 1108 * go ahead and do the reassignments. If there is region in transition, force parameter of true 1109 * would still run balancer. Can *not* run for other reasons. Check 1110 * logs. 1111 * @param force whether we should force balance even if there is region in transition 1112 * @return <code>true</code> if balancer ran, <code>false</code> otherwise. 1113 * @deprecated Since 2.0.0. Will be removed in 3.0.0. 1114 * Use {@link #balance(boolean)} instead. 1115 */ 1116 @Deprecated 1117 default boolean balancer(boolean force) throws IOException { 1118 return balance(force); 1119 } 1120 1121 /** 1122 * Invoke the balancer. Will run the balancer and if regions to move, it will 1123 * go ahead and do the reassignments. If there is region in transition, force parameter of true 1124 * would still run balancer. Can *not* run for other reasons. Check 1125 * logs. 1126 * @param force whether we should force balance even if there is region in transition 1127 * @return <code>true</code> if balancer ran, <code>false</code> otherwise. 1128 */ 1129 boolean balance(boolean force) throws IOException; 1130 1131 /** 1132 * Query the current state of the balancer. 1133 * 1134 * @return <code>true</code> if the balancer is enabled, <code>false</code> otherwise. 1135 */ 1136 boolean isBalancerEnabled() throws IOException; 1137 1138 /** 1139 * Clear all the blocks corresponding to this table from BlockCache. For expert-admins. 1140 * Calling this API will drop all the cached blocks specific to a table from BlockCache. 1141 * This can significantly impact the query performance as the subsequent queries will 1142 * have to retrieve the blocks from underlying filesystem. 1143 * 1144 * @param tableName table to clear block cache 1145 * @return CacheEvictionStats related to the eviction 1146 * @throws IOException if a remote or network exception occurs 1147 */ 1148 CacheEvictionStats clearBlockCache(final TableName tableName) throws IOException; 1149 1150 /** 1151 * Invoke region normalizer. Can NOT run for various reasons. Check logs. 1152 * 1153 * @return <code>true</code> if region normalizer ran, <code>false</code> otherwise. 1154 */ 1155 boolean normalize() throws IOException; 1156 1157 /** 1158 * Query the current state of the region normalizer. 1159 * 1160 * @return <code>true</code> if region normalizer is enabled, <code>false</code> otherwise. 1161 */ 1162 boolean isNormalizerEnabled() throws IOException; 1163 1164 /** 1165 * Turn region normalizer on or off. 1166 * 1167 * @return Previous normalizer value 1168 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #normalizerSwitch(boolean)}} 1169 * instead. 1170 */ 1171 @Deprecated 1172 default boolean setNormalizerRunning(boolean on) throws IOException { 1173 return normalizerSwitch(on); 1174 } 1175 1176 /** 1177 * Turn region normalizer on or off. 1178 * 1179 * @return Previous normalizer value 1180 */ 1181 boolean normalizerSwitch (boolean on) throws IOException; 1182 1183 /** 1184 * Enable/Disable the catalog janitor. 1185 * 1186 * @param enable if <code>true</code> enables the catalog janitor 1187 * @return the previous state 1188 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #catalogJanitorSwitch(boolean)}} 1189 * instead. 1190 */ 1191 @Deprecated 1192 default boolean enableCatalogJanitor(boolean enable) throws IOException { 1193 return catalogJanitorSwitch(enable); 1194 } 1195 1196 /** 1197 * Enable/Disable the catalog janitor/ 1198 * 1199 * @param onOrOff if <code>true</code> enables the catalog janitor 1200 * @return the previous state 1201 */ 1202 boolean catalogJanitorSwitch(boolean onOrOff) throws IOException; 1203 1204 /** 1205 * Ask for a scan of the catalog table. 1206 * 1207 * @return the number of entries cleaned 1208 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #runCatalogJanitor()}} 1209 * instead. 1210 */ 1211 @Deprecated 1212 default int runCatalogScan() throws IOException { 1213 return runCatalogJanitor(); 1214 } 1215 1216 /** 1217 * Ask for a scan of the catalog table. 1218 * 1219 * @return the number of entries cleaned 1220 */ 1221 int runCatalogJanitor() throws IOException; 1222 1223 /** 1224 * Query on the catalog janitor state (Enabled/Disabled?). 1225 * 1226 */ 1227 boolean isCatalogJanitorEnabled() throws IOException; 1228 1229 /** 1230 * Enable/Disable the cleaner chore. 1231 * 1232 * @param on if <code>true</code> enables the cleaner chore 1233 * @return the previous state 1234 * @throws IOException 1235 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #cleanerChoreSwitch(boolean)}} 1236 * instead. 1237 */ 1238 @Deprecated 1239 default boolean setCleanerChoreRunning(boolean on) throws IOException { 1240 return cleanerChoreSwitch(on); 1241 } 1242 1243 /** 1244 * Enable/Disable the cleaner chore. 1245 * 1246 * @param onOrOff if <code>true</code> enables the cleaner chore 1247 * @return the previous state 1248 * @throws IOException 1249 */ 1250 boolean cleanerChoreSwitch(boolean onOrOff) throws IOException; 1251 1252 /** 1253 * Ask for cleaner chore to run. 1254 * 1255 * @return <code>true</code> if cleaner chore ran, <code>false</code> otherwise 1256 * @throws IOException 1257 */ 1258 boolean runCleanerChore() throws IOException; 1259 1260 /** 1261 * Query on the cleaner chore state (Enabled/Disabled?). 1262 * 1263 * @throws IOException 1264 */ 1265 boolean isCleanerChoreEnabled() throws IOException; 1266 1267 /** 1268 * Merge two regions. Asynchronous operation. 1269 * 1270 * @param nameOfRegionA encoded or full name of region a 1271 * @param nameOfRegionB encoded or full name of region b 1272 * @param forcible <code>true</code> if do a compulsory merge, otherwise we will only merge two 1273 * adjacent regions 1274 * @throws IOException 1275 * @deprecated Since 2.0. Will be removed in 3.0. Use 1276 * {@link #mergeRegionsAsync(byte[], byte[], boolean)} instead. 1277 */ 1278 @Deprecated 1279 void mergeRegions(byte[] nameOfRegionA, byte[] nameOfRegionB, 1280 boolean forcible) throws IOException; 1281 1282 1283 /** 1284 * Merge two regions. Asynchronous operation. 1285 * 1286 * @param nameOfRegionA encoded or full name of region a 1287 * @param nameOfRegionB encoded or full name of region b 1288 * @param forcible <code>true</code> if do a compulsory merge, otherwise we will only merge 1289 * two adjacent regions 1290 * @throws IOException 1291 */ 1292 Future<Void> mergeRegionsAsync( 1293 byte[] nameOfRegionA, 1294 byte[] nameOfRegionB, 1295 boolean forcible) throws IOException; 1296 1297 /** 1298 * Merge regions. Asynchronous operation. 1299 * 1300 * @param nameofRegionsToMerge encoded or full name of daughter regions 1301 * @param forcible <code>true</code> if do a compulsory merge, otherwise we will only merge 1302 * adjacent regions 1303 * @throws IOException 1304 */ 1305 Future<Void> mergeRegionsAsync( 1306 byte[][] nameofRegionsToMerge, 1307 boolean forcible) throws IOException; 1308 1309 /** 1310 + Split a table. The method will execute split action for each region in table. 1311 + Asynchronous operation. 1312 * @param tableName table to split 1313 * @throws IOException if a remote or network exception occurs 1314 */ 1315 void split(TableName tableName) throws IOException; 1316 1317 /** 1318 * Split an individual region. Asynchronous operation. 1319 * 1320 * @param regionName region to split 1321 * @throws IOException if a remote or network exception occurs 1322 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. 1323 * Use {@link #splitRegionAsync(byte[], byte[])}. 1324 */ 1325 @Deprecated 1326 void splitRegion(byte[] regionName) throws IOException; 1327 1328 /** 1329 * Split a table. Asynchronous operation. 1330 * 1331 * @param tableName table to split 1332 * @param splitPoint the explicit position to split on 1333 * @throws IOException if a remote or network exception occurs 1334 */ 1335 void split(TableName tableName, byte[] splitPoint) 1336 throws IOException; 1337 1338 /** 1339 * Split an individual region. Asynchronous operation. 1340 * 1341 * @param regionName region to split 1342 * @param splitPoint the explicit position to split on 1343 * @throws IOException if a remote or network exception occurs 1344 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. 1345 * Use {@link #splitRegionAsync(byte[], byte[])}. 1346 */ 1347 @Deprecated 1348 void splitRegion(byte[] regionName, byte[] splitPoint) 1349 throws IOException; 1350 1351 /** 1352 * Split an individual region. Asynchronous operation. 1353 * @param regionName region to split 1354 * @param splitPoint the explicit position to split on 1355 * @throws IOException if a remote or network exception occurs 1356 */ 1357 Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint) 1358 throws IOException; 1359 1360 /** 1361 * Modify an existing table, more IRB friendly version. 1362 * 1363 * @param tableName name of table. 1364 * @param td modified description of the table 1365 * @throws IOException if a remote or network exception occurs 1366 * @deprecated since 2.0 version and will be removed in 3.0 version. 1367 * use {@link #modifyTable(TableDescriptor)} 1368 */ 1369 @Deprecated 1370 void modifyTable(TableName tableName, TableDescriptor td) 1371 throws IOException; 1372 1373 /** 1374 * Modify an existing table, more IRB friendly version. 1375 * @param td modified description of the table 1376 * @throws IOException if a remote or network exception occurs 1377 */ 1378 void modifyTable(TableDescriptor td) throws IOException; 1379 1380 /** 1381 * Modify an existing table, more IRB friendly version. Asynchronous operation. This means that 1382 * it may be a while before your schema change is updated across all of the table. 1383 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 1384 * It may throw ExecutionException if there was an error while executing the operation 1385 * or TimeoutException in case the wait timeout was not long enough to allow the 1386 * operation to complete. 1387 * 1388 * @param tableName name of table. 1389 * @param td modified description of the table 1390 * @throws IOException if a remote or network exception occurs 1391 * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the 1392 * operation to complete 1393 * @deprecated since 2.0 version and will be removed in 3.0 version. 1394 * use {@link #modifyTableAsync(TableDescriptor)} 1395 */ 1396 @Deprecated 1397 Future<Void> modifyTableAsync(TableName tableName, TableDescriptor td) 1398 throws IOException; 1399 1400 /** 1401 * Modify an existing table, more IRB (ruby) friendly version. Asynchronous operation. This means that 1402 * it may be a while before your schema change is updated across all of the table. 1403 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 1404 * It may throw ExecutionException if there was an error while executing the operation 1405 * or TimeoutException in case the wait timeout was not long enough to allow the 1406 * operation to complete. 1407 * 1408 * @param td description of the table 1409 * @throws IOException if a remote or network exception occurs 1410 * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the 1411 * operation to complete 1412 */ 1413 Future<Void> modifyTableAsync(TableDescriptor td) 1414 throws IOException; 1415 1416 /** 1417 * <p> 1418 * Shuts down the HBase cluster. 1419 * </p> 1420 * <p> 1421 * Notice that, a success shutdown call may ends with an error since the remote server has already 1422 * been shutdown. 1423 * </p> 1424 * @throws IOException if a remote or network exception occurs 1425 */ 1426 void shutdown() throws IOException; 1427 1428 /** 1429 * <p> 1430 * Shuts down the current HBase master only. Does not shutdown the cluster. 1431 * </p> 1432 * <p> 1433 * Notice that, a success stopMaster call may ends with an error since the remote server has 1434 * already been shutdown. 1435 * </p> 1436 * @throws IOException if a remote or network exception occurs 1437 * @see #shutdown() 1438 */ 1439 void stopMaster() throws IOException; 1440 1441 /** 1442 * Check whether Master is in maintenance mode. 1443 * 1444 * @throws IOException if a remote or network exception occurs 1445 */ 1446 boolean isMasterInMaintenanceMode() throws IOException; 1447 1448 /** 1449 * Stop the designated regionserver. 1450 * 1451 * @param hostnamePort Hostname and port delimited by a <code>:</code> as in 1452 * <code>example.org:1234</code> 1453 * @throws IOException if a remote or network exception occurs 1454 */ 1455 void stopRegionServer(String hostnamePort) throws IOException; 1456 1457 /** 1458 * Get whole cluster status, containing status about: 1459 * <pre> 1460 * hbase version 1461 * cluster id 1462 * primary/backup master(s) 1463 * master's coprocessors 1464 * live/dead regionservers 1465 * balancer 1466 * regions in transition 1467 * </pre> 1468 * @return cluster status 1469 * @throws IOException if a remote or network exception occurs 1470 * @deprecated since 2.0 version and will be removed in 3.0 version. 1471 * use {@link #getClusterMetrics()} 1472 */ 1473 @Deprecated 1474 default ClusterStatus getClusterStatus() throws IOException { 1475 return new ClusterStatus(getClusterMetrics()); 1476 } 1477 1478 /** 1479 * Get whole cluster metrics, containing status about: 1480 * <pre> 1481 * hbase version 1482 * cluster id 1483 * primary/backup master(s) 1484 * master's coprocessors 1485 * live/dead regionservers 1486 * balancer 1487 * regions in transition 1488 * </pre> 1489 * @return cluster metrics 1490 * @throws IOException if a remote or network exception occurs 1491 */ 1492 default ClusterMetrics getClusterMetrics() throws IOException { 1493 return getClusterMetrics(EnumSet.allOf(ClusterMetrics.Option.class)); 1494 } 1495 1496 /** 1497 * Get cluster status with a set of {@link Option} to get desired status. 1498 * @return cluster status 1499 * @throws IOException if a remote or network exception occurs 1500 */ 1501 ClusterMetrics getClusterMetrics(EnumSet<Option> options) throws IOException; 1502 1503 /** 1504 * @return current master server name 1505 * @throws IOException if a remote or network exception occurs 1506 */ 1507 default ServerName getMaster() throws IOException { 1508 return getClusterMetrics(EnumSet.of(Option.MASTER)).getMasterName(); 1509 } 1510 1511 /** 1512 * @return current backup master list 1513 * @throws IOException if a remote or network exception occurs 1514 */ 1515 default Collection<ServerName> getBackupMasters() throws IOException { 1516 return getClusterMetrics(EnumSet.of(Option.BACKUP_MASTERS)).getBackupMasterNames(); 1517 } 1518 1519 /** 1520 * @return current live region servers list 1521 * @throws IOException if a remote or network exception occurs 1522 */ 1523 default Collection<ServerName> getRegionServers() throws IOException { 1524 return getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().keySet(); 1525 } 1526 1527 /** 1528 * Get {@link RegionMetrics} of all regions hosted on a regionserver. 1529 * 1530 * @param serverName region server from which {@link RegionMetrics} is required. 1531 * @return a {@link RegionMetrics} list of all regions hosted on a region server 1532 * @throws IOException if a remote or network exception occurs 1533 */ 1534 default List<RegionMetrics> getRegionMetrics(ServerName serverName) throws IOException { 1535 return getRegionMetrics(serverName, null); 1536 } 1537 1538 /** 1539 * Get {@link RegionMetrics} of all regions hosted on a regionserver for a table. 1540 * 1541 * @param serverName region server from which {@link RegionMetrics} is required. 1542 * @param tableName get {@link RegionMetrics} of regions belonging to the table 1543 * @return region metrics map of all regions of a table hosted on a region server 1544 * @throws IOException if a remote or network exception occurs 1545 */ 1546 List<RegionMetrics> getRegionMetrics(ServerName serverName, 1547 TableName tableName) throws IOException; 1548 1549 /** 1550 * @return Configuration used by the instance. 1551 */ 1552 Configuration getConfiguration(); 1553 1554 /** 1555 * Create a new namespace. Blocks until namespace has been successfully created or an exception 1556 * is thrown. 1557 * 1558 * @param descriptor descriptor which describes the new namespace. 1559 */ 1560 void createNamespace(NamespaceDescriptor descriptor) 1561 throws IOException; 1562 1563 /** 1564 * Create a new namespace. 1565 * 1566 * @param descriptor descriptor which describes the new namespace 1567 * @return the result of the async create namespace operation. Use Future.get(long, TimeUnit) to 1568 * wait on the operation to complete. 1569 */ 1570 Future<Void> createNamespaceAsync(NamespaceDescriptor descriptor) 1571 throws IOException; 1572 1573 /** 1574 * Modify an existing namespace. Blocks until namespace has been successfully modified or an 1575 * exception is thrown. 1576 * 1577 * @param descriptor descriptor which describes the new namespace 1578 */ 1579 void modifyNamespace(NamespaceDescriptor descriptor) 1580 throws IOException; 1581 1582 /** 1583 * Modify an existing namespace. 1584 * 1585 * @param descriptor descriptor which describes the new namespace 1586 * @return the result of the async modify namespace operation. Use Future.get(long, TimeUnit) to 1587 * wait on the operation to complete. 1588 */ 1589 Future<Void> modifyNamespaceAsync(NamespaceDescriptor descriptor) 1590 throws IOException; 1591 1592 /** 1593 * Delete an existing namespace. Only empty namespaces (no tables) can be removed. 1594 * Blocks until namespace has been successfully deleted or an 1595 * exception is thrown. 1596 * 1597 * @param name namespace name 1598 */ 1599 void deleteNamespace(String name) throws IOException; 1600 1601 /** 1602 * Delete an existing namespace. Only empty namespaces (no tables) can be removed. 1603 * 1604 * @param name namespace name 1605 * @return the result of the async delete namespace operation. Use Future.get(long, TimeUnit) to 1606 * wait on the operation to complete. 1607 */ 1608 Future<Void> deleteNamespaceAsync(String name) throws IOException; 1609 1610 /** 1611 * Get a namespace descriptor by name. 1612 * 1613 * @param name name of namespace descriptor 1614 * @return A descriptor 1615 * @throws org.apache.hadoop.hbase.NamespaceNotFoundException 1616 * @throws IOException if a remote or network exception occurs 1617 */ 1618 NamespaceDescriptor getNamespaceDescriptor(String name) 1619 throws NamespaceNotFoundException, IOException; 1620 1621 /** 1622 * List available namespace descriptors. 1623 * 1624 * @return List of descriptors 1625 */ 1626 NamespaceDescriptor[] listNamespaceDescriptors() 1627 throws IOException; 1628 1629 /** 1630 * Get list of table descriptors by namespace. 1631 * 1632 * @param name namespace name 1633 * @return HTD[] the read-only tableDescriptors 1634 * @throws IOException 1635 * @deprecated since 2.0 version and will be removed in 3.0 version. 1636 * use {@link #listTableDescriptorsByNamespace(byte[])} 1637 */ 1638 @Deprecated 1639 HTableDescriptor[] listTableDescriptorsByNamespace(String name) 1640 throws IOException; 1641 1642 /** 1643 * Get list of table descriptors by namespace. 1644 * 1645 * @param name namespace name 1646 * @return returns a list of TableDescriptors 1647 * @throws IOException 1648 */ 1649 List<TableDescriptor> listTableDescriptorsByNamespace(byte[] name) 1650 throws IOException; 1651 1652 /** 1653 * Get list of table names by namespace. 1654 * 1655 * @param name namespace name 1656 * @return The list of table names in the namespace 1657 * @throws IOException 1658 */ 1659 TableName[] listTableNamesByNamespace(String name) 1660 throws IOException; 1661 1662 /** 1663 * Get the regions of a given table. 1664 * 1665 * @param tableName the name of the table 1666 * @return List of {@link HRegionInfo}. 1667 * @throws IOException 1668 * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0 1669 * (<a href="https://issues.apache.org/jira/browse/HBASE-17980">HBASE-17980</a>). 1670 * Use {@link #getRegions(TableName)}. 1671 */ 1672 @Deprecated 1673 List<HRegionInfo> getTableRegions(TableName tableName) 1674 throws IOException; 1675 1676 /** 1677 * Get the regions of a given table. 1678 * 1679 * @param tableName the name of the table 1680 * @return List of {@link RegionInfo}. 1681 * @throws IOException 1682 */ 1683 List<RegionInfo> getRegions(TableName tableName) throws IOException; 1684 1685 @Override 1686 void close() throws IOException; 1687 1688 /** 1689 * Get tableDescriptors. 1690 * 1691 * @param tableNames List of table names 1692 * @return HTD[] the read-only tableDescriptors 1693 * @throws IOException if a remote or network exception occurs 1694 * @deprecated since 2.0 version and will be removed in 3.0 version. 1695 * use {@link #listTableDescriptors(List)} 1696 */ 1697 @Deprecated 1698 HTableDescriptor[] getTableDescriptorsByTableName(List<TableName> tableNames) 1699 throws IOException; 1700 1701 /** 1702 * Get tableDescriptors. 1703 * 1704 * @param tableNames List of table names 1705 * @return returns a list of TableDescriptors 1706 * @throws IOException if a remote or network exception occurs 1707 */ 1708 List<TableDescriptor> listTableDescriptors(List<TableName> tableNames) 1709 throws IOException; 1710 1711 /** 1712 * Get tableDescriptors. 1713 * 1714 * @param names List of table names 1715 * @return HTD[] the read-only tableDescriptors 1716 * @throws IOException if a remote or network exception occurs 1717 * @deprecated since 2.0 version and will be removed in 3.0 version. 1718 * use {@link #listTableDescriptors(List)} 1719 */ 1720 @Deprecated 1721 HTableDescriptor[] getTableDescriptors(List<String> names) 1722 throws IOException; 1723 1724 /** 1725 * Abort a procedure. 1726 * @param procId ID of the procedure to abort 1727 * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted? 1728 * @return <code>true</code> if aborted, <code>false</code> if procedure already completed or does not exist 1729 * @throws IOException 1730 */ 1731 boolean abortProcedure( 1732 long procId, 1733 boolean mayInterruptIfRunning) throws IOException; 1734 1735 /** 1736 * Abort a procedure but does not block and wait for completion. 1737 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 1738 * It may throw ExecutionException if there was an error while executing the operation 1739 * or TimeoutException in case the wait timeout was not long enough to allow the 1740 * operation to complete. 1741 * 1742 * @param procId ID of the procedure to abort 1743 * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted? 1744 * @return <code>true</code> if aborted, <code>false</code> if procedure already completed or does not exist 1745 * @throws IOException 1746 */ 1747 Future<Boolean> abortProcedureAsync( 1748 long procId, 1749 boolean mayInterruptIfRunning) throws IOException; 1750 1751 /** 1752 * Get procedures. 1753 * @return procedure list in JSON 1754 * @throws IOException 1755 */ 1756 String getProcedures() throws IOException; 1757 1758 /** 1759 * Get locks. 1760 * @return lock list in JSON 1761 * @throws IOException if a remote or network exception occurs 1762 */ 1763 String getLocks() throws IOException; 1764 1765 /** 1766 * Roll the log writer. I.e. for filesystem based write ahead logs, start writing to a new file. 1767 * 1768 * Note that the actual rolling of the log writer is asynchronous and may not be complete when 1769 * this method returns. As a side effect of this call, the named region server may schedule 1770 * store flushes at the request of the wal. 1771 * 1772 * @param serverName The servername of the regionserver. 1773 * @throws IOException if a remote or network exception occurs 1774 * @throws org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException 1775 */ 1776 void rollWALWriter(ServerName serverName) throws IOException, FailedLogCloseException; 1777 1778 /** 1779 * Helper that delegates to getClusterMetrics().getMasterCoprocessorNames(). 1780 * @return an array of master coprocessors 1781 * @see org.apache.hadoop.hbase.ClusterMetrics#getMasterCoprocessorNames() 1782 * @deprecated since 2.0 version and will be removed in 3.0 version. 1783 * use {@link #getMasterCoprocessorNames()} 1784 */ 1785 @Deprecated 1786 default String[] getMasterCoprocessors() throws IOException { 1787 return getMasterCoprocessorNames().stream().toArray(size -> new String[size]); 1788 } 1789 1790 /** 1791 * Helper that delegates to getClusterMetrics().getMasterCoprocessorNames(). 1792 * @return an array of master coprocessors 1793 * @see org.apache.hadoop.hbase.ClusterMetrics#getMasterCoprocessorNames() 1794 */ 1795 default List<String> getMasterCoprocessorNames() throws IOException { 1796 return getClusterMetrics(EnumSet.of(Option.MASTER_COPROCESSORS)) 1797 .getMasterCoprocessorNames(); 1798 } 1799 1800 /** 1801 * Get the current compaction state of a table. It could be in a major compaction, a minor 1802 * compaction, both, or none. 1803 * 1804 * @param tableName table to examine 1805 * @return the current compaction state 1806 * @throws IOException if a remote or network exception occurs 1807 */ 1808 CompactionState getCompactionState(TableName tableName) throws IOException; 1809 1810 /** 1811 * Get the current compaction state of a table. It could be in a compaction, or none. 1812 * 1813 * @param tableName table to examine 1814 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 1815 * @return the current compaction state 1816 * @throws IOException if a remote or network exception occurs 1817 */ 1818 CompactionState getCompactionState(TableName tableName, 1819 CompactType compactType) throws IOException; 1820 1821 /** 1822 * Get the current compaction state of region. It could be in a major compaction, a minor 1823 * compaction, both, or none. 1824 * 1825 * @param regionName region to examine 1826 * @return the current compaction state 1827 * @throws IOException if a remote or network exception occurs 1828 */ 1829 CompactionState getCompactionStateForRegion(byte[] regionName) throws IOException; 1830 1831 /** 1832 * Get the timestamp of the last major compaction for the passed table 1833 * 1834 * The timestamp of the oldest HFile resulting from a major compaction of that table, 1835 * or 0 if no such HFile could be found. 1836 * 1837 * @param tableName table to examine 1838 * @return the last major compaction timestamp or 0 1839 * @throws IOException if a remote or network exception occurs 1840 */ 1841 long getLastMajorCompactionTimestamp(TableName tableName) throws IOException; 1842 1843 /** 1844 * Get the timestamp of the last major compaction for the passed region. 1845 * 1846 * The timestamp of the oldest HFile resulting from a major compaction of that region, 1847 * or 0 if no such HFile could be found. 1848 * 1849 * @param regionName region to examine 1850 * @return the last major compaction timestamp or 0 1851 * @throws IOException if a remote or network exception occurs 1852 */ 1853 long getLastMajorCompactionTimestampForRegion(byte[] regionName) throws IOException; 1854 1855 /** 1856 * Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be 1857 * taken. If the table is disabled, an offline snapshot is taken. Snapshots are considered unique 1858 * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even 1859 * a different type or with different parameters) will fail with a {@link 1860 * org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate naming. 1861 * Snapshot names follow the same naming constraints as tables in HBase. See {@link 1862 * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. 1863 * 1864 * @param snapshotName name of the snapshot to be created 1865 * @param tableName name of the table for which snapshot is created 1866 * @throws IOException if a remote or network exception occurs 1867 * @throws org.apache.hadoop.hbase.snapshot.SnapshotCreationException if snapshot creation failed 1868 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly 1869 */ 1870 void snapshot(String snapshotName, TableName tableName) 1871 throws IOException, SnapshotCreationException, IllegalArgumentException; 1872 1873 /** 1874 * Create a timestamp consistent snapshot for the given table. Snapshots are considered unique 1875 * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even 1876 * different type or with different parameters) will fail with a {@link SnapshotCreationException} 1877 * indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in 1878 * HBase. 1879 * 1880 * @param snapshotName name of the snapshot to be created 1881 * @param tableName name of the table for which snapshot is created 1882 * @throws IOException if a remote or network exception occurs 1883 * @throws SnapshotCreationException if snapshot creation failed 1884 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly 1885 */ 1886 void snapshot(byte[] snapshotName, TableName tableName) 1887 throws IOException, SnapshotCreationException, IllegalArgumentException; 1888 1889 /** 1890 * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the 1891 * snapshot</b>. Attempts to take a snapshot with the same name (even a different type or with 1892 * different parameters) will fail with a {@link SnapshotCreationException} indicating the 1893 * duplicate naming. Snapshot names follow the same naming constraints as tables in HBase. See 1894 * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. 1895 * 1896 * @param snapshotName name to give the snapshot on the filesystem. Must be unique from all other 1897 * snapshots stored on the cluster 1898 * @param tableName name of the table to snapshot 1899 * @param type type of snapshot to take 1900 * @throws IOException we fail to reach the master 1901 * @throws SnapshotCreationException if snapshot creation failed 1902 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly 1903 */ 1904 void snapshot(String snapshotName, 1905 TableName tableName, 1906 SnapshotType type) throws IOException, SnapshotCreationException, 1907 IllegalArgumentException; 1908 1909 /** 1910 * Take a snapshot and wait for the server to complete that snapshot (blocking). Only a single 1911 * snapshot should be taken at a time for an instance of HBase, or results may be undefined (you 1912 * can tell multiple HBase clusters to snapshot at the same time, but only one at a time for a 1913 * single cluster). Snapshots are considered unique based on <b>the name of the snapshot</b>. 1914 * Attempts to take a snapshot with the same name (even a different type or with different 1915 * parameters) will fail with a {@link SnapshotCreationException} indicating the duplicate naming. 1916 * Snapshot names follow the same naming constraints as tables in HBase. See {@link 1917 * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. You should probably 1918 * use {@link #snapshot(String, org.apache.hadoop.hbase.TableName)} or 1919 * {@link #snapshot(byte[], org.apache.hadoop.hbase.TableName)} unless you are sure about the type 1920 * of snapshot that you want to take. 1921 * 1922 * @param snapshot snapshot to take 1923 * @throws IOException or we lose contact with the master. 1924 * @throws SnapshotCreationException if snapshot failed to be taken 1925 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly 1926 */ 1927 void snapshot(SnapshotDescription snapshot) 1928 throws IOException, SnapshotCreationException, IllegalArgumentException; 1929 1930 /** 1931 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous) Only a 1932 * single snapshot should be taken at a time, or results may be undefined. 1933 * 1934 * @param snapshot snapshot to take 1935 * @throws IOException if the snapshot did not succeed or we lose contact with the master. 1936 * @throws SnapshotCreationException if snapshot creation failed 1937 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly 1938 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use 1939 * {@link #snapshotAsync(SnapshotDescription)} instead. 1940 */ 1941 @Deprecated 1942 default void takeSnapshotAsync(SnapshotDescription snapshot) 1943 throws IOException, SnapshotCreationException { 1944 snapshotAsync(snapshot); 1945 } 1946 1947 /** 1948 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous) Only a 1949 * single snapshot should be taken at a time, or results may be undefined. 1950 * 1951 * @param snapshot snapshot to take 1952 * @throws IOException if the snapshot did not succeed or we lose contact with the master. 1953 * @throws SnapshotCreationException if snapshot creation failed 1954 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly 1955 */ 1956 void snapshotAsync(SnapshotDescription snapshot) throws IOException, SnapshotCreationException; 1957 1958 /** 1959 * Check the current state of the passed snapshot. There are three possible states: <ol> 1960 * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li> 1961 * <li>finished with error - throws the exception that caused the snapshot to fail</li> </ol> The 1962 * cluster only knows about the most recent snapshot. Therefore, if another snapshot has been 1963 * run/started since the snapshot you are checking, you will receive an {@link 1964 * org.apache.hadoop.hbase.snapshot.UnknownSnapshotException}. 1965 * 1966 * @param snapshot description of the snapshot to check 1967 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still 1968 * running 1969 * @throws IOException if we have a network issue 1970 * @throws org.apache.hadoop.hbase.snapshot.HBaseSnapshotException if the snapshot failed 1971 * @throws org.apache.hadoop.hbase.snapshot.UnknownSnapshotException if the requested snapshot is 1972 * unknown 1973 */ 1974 boolean isSnapshotFinished(SnapshotDescription snapshot) 1975 throws IOException, HBaseSnapshotException, UnknownSnapshotException; 1976 1977 /** 1978 * Restore the specified snapshot on the original table. (The table must be disabled) If the 1979 * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to <code>true</code>, a 1980 * snapshot of the current table is taken before executing the restore operation. In case of 1981 * restore failure, the failsafe snapshot will be restored. If the restore completes without 1982 * problem the failsafe snapshot is deleted. 1983 * 1984 * @param snapshotName name of the snapshot to restore 1985 * @throws IOException if a remote or network exception occurs 1986 * @throws org.apache.hadoop.hbase.snapshot.RestoreSnapshotException if snapshot failed to be 1987 * restored 1988 * @throws IllegalArgumentException if the restore request is formatted incorrectly 1989 */ 1990 void restoreSnapshot(byte[] snapshotName) throws IOException, RestoreSnapshotException; 1991 1992 /** 1993 * Restore the specified snapshot on the original table. (The table must be disabled) If the 1994 * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to <code>true</code>, a 1995 * snapshot of the current table is taken before executing the restore operation. In case of 1996 * restore failure, the failsafe snapshot will be restored. If the restore completes without 1997 * problem the failsafe snapshot is deleted. 1998 * 1999 * @param snapshotName name of the snapshot to restore 2000 * @throws IOException if a remote or network exception occurs 2001 * @throws RestoreSnapshotException if snapshot failed to be restored 2002 * @throws IllegalArgumentException if the restore request is formatted incorrectly 2003 */ 2004 void restoreSnapshot(String snapshotName) throws IOException, RestoreSnapshotException; 2005 2006 /** 2007 * Restore the specified snapshot on the original table. (The table must be disabled) If the 2008 * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to <code>true</code>, a 2009 * snapshot of the current table is taken before executing the restore operation. In case of 2010 * restore failure, the failsafe snapshot will be restored. If the restore completes without 2011 * problem the failsafe snapshot is deleted. 2012 * 2013 * @param snapshotName name of the snapshot to restore 2014 * @throws IOException if a remote or network exception occurs 2015 * @throws RestoreSnapshotException if snapshot failed to be restored 2016 * @return the result of the async restore snapshot. You can use Future.get(long, TimeUnit) 2017 * to wait on the operation to complete. 2018 */ 2019 Future<Void> restoreSnapshotAsync(String snapshotName) 2020 throws IOException, RestoreSnapshotException; 2021 2022 /** 2023 * Restore the specified snapshot on the original table. (The table must be disabled) If 2024 * 'takeFailSafeSnapshot' is set to <code>true</code>, a snapshot of the current table is taken before 2025 * executing the restore operation. In case of restore failure, the failsafe snapshot will be 2026 * restored. If the restore completes without problem the failsafe snapshot is deleted. The 2027 * failsafe snapshot name is configurable by using the property 2028 * "hbase.snapshot.restore.failsafe.name". 2029 * 2030 * @param snapshotName name of the snapshot to restore 2031 * @param takeFailSafeSnapshot <code>true</code> if the failsafe snapshot should be taken 2032 * @throws IOException if a remote or network exception occurs 2033 * @throws RestoreSnapshotException if snapshot failed to be restored 2034 * @throws IllegalArgumentException if the restore request is formatted incorrectly 2035 */ 2036 void restoreSnapshot(byte[] snapshotName, boolean takeFailSafeSnapshot) 2037 throws IOException, RestoreSnapshotException; 2038 2039 /** 2040 * Restore the specified snapshot on the original table. (The table must be disabled) If 2041 * 'takeFailSafeSnapshot' is set to <code>true</code>, a snapshot of the current table is taken before 2042 * executing the restore operation. In case of restore failure, the failsafe snapshot will be 2043 * restored. If the restore completes without problem the failsafe snapshot is deleted. The 2044 * failsafe snapshot name is configurable by using the property 2045 * "hbase.snapshot.restore.failsafe.name". 2046 * 2047 * @param snapshotName name of the snapshot to restore 2048 * @param takeFailSafeSnapshot <code>true</code> if the failsafe snapshot should be taken 2049 * @throws IOException if a remote or network exception occurs 2050 * @throws RestoreSnapshotException if snapshot failed to be restored 2051 * @throws IllegalArgumentException if the restore request is formatted incorrectly 2052 */ 2053 void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot) 2054 throws IOException, RestoreSnapshotException; 2055 2056 /** 2057 * Restore the specified snapshot on the original table. (The table must be disabled) If 2058 * 'takeFailSafeSnapshot' is set to <code>true</code>, a snapshot of the current table is taken before 2059 * executing the restore operation. In case of restore failure, the failsafe snapshot will be 2060 * restored. If the restore completes without problem the failsafe snapshot is deleted. The 2061 * failsafe snapshot name is configurable by using the property 2062 * "hbase.snapshot.restore.failsafe.name". 2063 * @param snapshotName name of the snapshot to restore 2064 * @param takeFailSafeSnapshot <code>true</code> if the failsafe snapshot should be taken 2065 * @param restoreAcl <code>true</code> to restore acl of snapshot 2066 * @throws IOException if a remote or network exception occurs 2067 * @throws RestoreSnapshotException if snapshot failed to be restored 2068 * @throws IllegalArgumentException if the restore request is formatted incorrectly 2069 */ 2070 void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot, 2071 boolean restoreAcl) throws IOException, RestoreSnapshotException; 2072 2073 /** 2074 * Create a new table by cloning the snapshot content. 2075 * 2076 * @param snapshotName name of the snapshot to be cloned 2077 * @param tableName name of the table where the snapshot will be restored 2078 * @throws IOException if a remote or network exception occurs 2079 * @throws TableExistsException if table to be created already exists 2080 * @throws RestoreSnapshotException if snapshot failed to be cloned 2081 * @throws IllegalArgumentException if the specified table has not a valid name 2082 */ 2083 void cloneSnapshot(byte[] snapshotName, TableName tableName) 2084 throws IOException, TableExistsException, RestoreSnapshotException; 2085 2086 /** 2087 * Create a new table by cloning the snapshot content. 2088 * @param snapshotName name of the snapshot to be cloned 2089 * @param tableName name of the table where the snapshot will be restored 2090 * @param restoreAcl <code>true</code> to clone acl into newly created table 2091 * @throws IOException if a remote or network exception occurs 2092 * @throws TableExistsException if table to be created already exists 2093 * @throws RestoreSnapshotException if snapshot failed to be cloned 2094 * @throws IllegalArgumentException if the specified table has not a valid name 2095 */ 2096 void cloneSnapshot(String snapshotName, TableName tableName, boolean restoreAcl) 2097 throws IOException, TableExistsException, RestoreSnapshotException; 2098 2099 /** 2100 * Create a new table by cloning the snapshot content. 2101 * 2102 * @param snapshotName name of the snapshot to be cloned 2103 * @param tableName name of the table where the snapshot will be restored 2104 * @throws IOException if a remote or network exception occurs 2105 * @throws TableExistsException if table to be created already exists 2106 * @throws RestoreSnapshotException if snapshot failed to be cloned 2107 * @throws IllegalArgumentException if the specified table has not a valid name 2108 */ 2109 void cloneSnapshot(String snapshotName, TableName tableName) 2110 throws IOException, TableExistsException, RestoreSnapshotException; 2111 2112 /** 2113 * Create a new table by cloning the snapshot content, but does not block 2114 * and wait for it to be completely cloned. 2115 * You can use Future.get(long, TimeUnit) to wait on the operation to complete. 2116 * It may throw ExecutionException if there was an error while executing the operation 2117 * or TimeoutException in case the wait timeout was not long enough to allow the 2118 * operation to complete. 2119 * 2120 * @param snapshotName name of the snapshot to be cloned 2121 * @param tableName name of the table where the snapshot will be restored 2122 * @throws IOException if a remote or network exception occurs 2123 * @throws TableExistsException if table to be cloned already exists 2124 * @return the result of the async clone snapshot. You can use Future.get(long, TimeUnit) 2125 * to wait on the operation to complete. 2126 */ 2127 Future<Void> cloneSnapshotAsync(String snapshotName, TableName tableName) 2128 throws IOException, TableExistsException; 2129 2130 /** 2131 * Execute a distributed procedure on a cluster. 2132 * 2133 * @param signature A distributed procedure is uniquely identified by its signature (default the 2134 * root ZK node name of the procedure). 2135 * @param instance The instance name of the procedure. For some procedures, this parameter is 2136 * optional. 2137 * @param props Property/Value pairs of properties passing to the procedure 2138 * @throws IOException 2139 */ 2140 void execProcedure(String signature, String instance, Map<String, String> props) 2141 throws IOException; 2142 2143 /** 2144 * Execute a distributed procedure on a cluster. 2145 * 2146 * @param signature A distributed procedure is uniquely identified by its signature (default the 2147 * root ZK node name of the procedure). 2148 * @param instance The instance name of the procedure. For some procedures, this parameter is 2149 * optional. 2150 * @param props Property/Value pairs of properties passing to the procedure 2151 * @return data returned after procedure execution. null if no return data. 2152 * @throws IOException 2153 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use 2154 * {@link #execProcedureWithReturn(String, String, Map)} } instead. 2155 */ 2156 @Deprecated 2157 default byte[] execProcedureWithRet(String signature, String instance, Map<String, String> props) 2158 throws IOException { 2159 return execProcedureWithReturn(signature, instance, props); 2160 } 2161 2162 /** 2163 * Execute a distributed procedure on a cluster. 2164 * 2165 * @param signature A distributed procedure is uniquely identified by its signature (default the 2166 * root ZK node name of the procedure). 2167 * @param instance The instance name of the procedure. For some procedures, this parameter is 2168 * optional. 2169 * @param props Property/Value pairs of properties passing to the procedure 2170 * @return data returned after procedure execution. null if no return data. 2171 * @throws IOException 2172 */ 2173 byte[] execProcedureWithReturn(String signature, String instance, Map<String, String> props) 2174 throws IOException; 2175 2176 /** 2177 * Check the current state of the specified procedure. There are three possible states: <ol> 2178 * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li> 2179 * <li>finished with error - throws the exception that caused the procedure to fail</li> </ol> 2180 * 2181 * @param signature The signature that uniquely identifies a procedure 2182 * @param instance The instance name of the procedure 2183 * @param props Property/Value pairs of properties passing to the procedure 2184 * @return <code>true</code> if the specified procedure is finished successfully, <code>false</code> if it is still running 2185 * @throws IOException if the specified procedure finished with error 2186 */ 2187 boolean isProcedureFinished(String signature, String instance, Map<String, String> props) 2188 throws IOException; 2189 2190 /** 2191 * List completed snapshots. 2192 * 2193 * @return a list of snapshot descriptors for completed snapshots 2194 * @throws IOException if a network error occurs 2195 */ 2196 List<SnapshotDescription> listSnapshots() throws IOException; 2197 2198 /** 2199 * List all the completed snapshots matching the given regular expression. 2200 * 2201 * @param regex The regular expression to match against 2202 * @return list of SnapshotDescription 2203 * @throws IOException if a remote or network exception occurs 2204 * @deprecated since 2.0 version and will be removed in 3.0 version. 2205 * Use {@link #listSnapshots(Pattern)} instead. 2206 */ 2207 @Deprecated 2208 List<SnapshotDescription> listSnapshots(String regex) throws IOException; 2209 2210 /** 2211 * List all the completed snapshots matching the given pattern. 2212 * 2213 * @param pattern The compiled regular expression to match against 2214 * @return list of SnapshotDescription 2215 * @throws IOException if a remote or network exception occurs 2216 */ 2217 List<SnapshotDescription> listSnapshots(Pattern pattern) throws IOException; 2218 2219 /** 2220 * List all the completed snapshots matching the given table name regular expression and snapshot 2221 * name regular expression. 2222 * @param tableNameRegex The table name regular expression to match against 2223 * @param snapshotNameRegex The snapshot name regular expression to match against 2224 * @return list of completed SnapshotDescription 2225 * @throws IOException if a remote or network exception occurs 2226 * @deprecated since 2.0 version and will be removed in 3.0 version. 2227 * Use {@link #listTableSnapshots(Pattern, Pattern)} instead. 2228 */ 2229 @Deprecated 2230 List<SnapshotDescription> listTableSnapshots(String tableNameRegex, 2231 String snapshotNameRegex) throws IOException; 2232 2233 /** 2234 * List all the completed snapshots matching the given table name regular expression and snapshot 2235 * name regular expression. 2236 * @param tableNamePattern The compiled table name regular expression to match against 2237 * @param snapshotNamePattern The compiled snapshot name regular expression to match against 2238 * @return list of completed SnapshotDescription 2239 * @throws IOException if a remote or network exception occurs 2240 */ 2241 List<SnapshotDescription> listTableSnapshots(Pattern tableNamePattern, 2242 Pattern snapshotNamePattern) throws IOException; 2243 2244 /** 2245 * Delete an existing snapshot. 2246 * 2247 * @param snapshotName name of the snapshot 2248 * @throws IOException if a remote or network exception occurs 2249 */ 2250 void deleteSnapshot(byte[] snapshotName) throws IOException; 2251 2252 /** 2253 * Delete an existing snapshot. 2254 * 2255 * @param snapshotName name of the snapshot 2256 * @throws IOException if a remote or network exception occurs 2257 */ 2258 void deleteSnapshot(String snapshotName) throws IOException; 2259 2260 /** 2261 * Delete existing snapshots whose names match the pattern passed. 2262 * 2263 * @param regex The regular expression to match against 2264 * @throws IOException if a remote or network exception occurs 2265 * @deprecated since 2.0 version and will be removed in 3.0 version. 2266 * Use {@link #deleteSnapshots(Pattern)} instead. 2267 */ 2268 @Deprecated 2269 void deleteSnapshots(String regex) throws IOException; 2270 2271 /** 2272 * Delete existing snapshots whose names match the pattern passed. 2273 * 2274 * @param pattern pattern for names of the snapshot to match 2275 * @throws IOException if a remote or network exception occurs 2276 */ 2277 void deleteSnapshots(Pattern pattern) throws IOException; 2278 2279 /** 2280 * Delete all existing snapshots matching the given table name regular expression and snapshot 2281 * name regular expression. 2282 * @param tableNameRegex The table name regular expression to match against 2283 * @param snapshotNameRegex The snapshot name regular expression to match against 2284 * @throws IOException if a remote or network exception occurs 2285 * @deprecated since 2.0 version and will be removed in 3.0 version. 2286 * Use {@link #deleteTableSnapshots(Pattern, Pattern)} instead. 2287 */ 2288 @Deprecated 2289 void deleteTableSnapshots(String tableNameRegex, String snapshotNameRegex) throws IOException; 2290 2291 /** 2292 * Delete all existing snapshots matching the given table name regular expression and snapshot 2293 * name regular expression. 2294 * @param tableNamePattern The compiled table name regular expression to match against 2295 * @param snapshotNamePattern The compiled snapshot name regular expression to match against 2296 * @throws IOException if a remote or network exception occurs 2297 */ 2298 void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern) 2299 throws IOException; 2300 2301 /** 2302 * Apply the new quota settings. 2303 * 2304 * @param quota the quota settings 2305 * @throws IOException if a remote or network exception occurs 2306 */ 2307 void setQuota(QuotaSettings quota) throws IOException; 2308 2309 /** 2310 * Return a QuotaRetriever to list the quotas based on the filter. 2311 * @param filter the quota settings filter 2312 * @return the quota retriever 2313 * @throws IOException if a remote or network exception occurs 2314 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #getQuota(QuotaFilter)}. 2315 */ 2316 @Deprecated 2317 QuotaRetriever getQuotaRetriever(QuotaFilter filter) throws IOException; 2318 2319 /** 2320 * List the quotas based on the filter. 2321 * @param filter the quota settings filter 2322 * @return the QuotaSetting list 2323 * @throws IOException if a remote or network exception occurs 2324 */ 2325 List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException; 2326 2327 /** 2328 * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the active 2329 * master. <p> The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access 2330 * a published coprocessor {@link com.google.protobuf.Service} using standard protobuf service 2331 * invocations: </p> <div style="background-color: #cccccc; padding: 2px"> 2332 * <blockquote><pre> 2333 * CoprocessorRpcChannel channel = myAdmin.coprocessorService(); 2334 * MyService.BlockingInterface service = MyService.newBlockingStub(channel); 2335 * MyCallRequest request = MyCallRequest.newBuilder() 2336 * ... 2337 * .build(); 2338 * MyCallResponse response = service.myCall(null, request); 2339 * </pre></blockquote></div> 2340 * 2341 * @return A MasterCoprocessorRpcChannel instance 2342 */ 2343 CoprocessorRpcChannel coprocessorService(); 2344 2345 2346 /** 2347 * Creates and returns a {@link com.google.protobuf.RpcChannel} instance 2348 * connected to the passed region server. 2349 * 2350 * <p> 2351 * The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access a published 2352 * coprocessor {@link com.google.protobuf.Service} using standard protobuf service invocations: 2353 * </p> 2354 * 2355 * <div style="background-color: #cccccc; padding: 2px"> 2356 * <blockquote><pre> 2357 * CoprocessorRpcChannel channel = myAdmin.coprocessorService(serverName); 2358 * MyService.BlockingInterface service = MyService.newBlockingStub(channel); 2359 * MyCallRequest request = MyCallRequest.newBuilder() 2360 * ... 2361 * .build(); 2362 * MyCallResponse response = service.myCall(null, request); 2363 * </pre></blockquote></div> 2364 * 2365 * @param serverName the server name to which the endpoint call is made 2366 * @return A RegionServerCoprocessorRpcChannel instance 2367 */ 2368 CoprocessorRpcChannel coprocessorService(ServerName serverName); 2369 2370 2371 /** 2372 * Update the configuration and trigger an online config change 2373 * on the regionserver. 2374 * @param server : The server whose config needs to be updated. 2375 * @throws IOException 2376 */ 2377 void updateConfiguration(ServerName server) throws IOException; 2378 2379 2380 /** 2381 * Update the configuration and trigger an online config change 2382 * on all the regionservers. 2383 * @throws IOException 2384 */ 2385 void updateConfiguration() throws IOException; 2386 2387 /** 2388 * Get the info port of the current master if one is available. 2389 * @return master info port 2390 * @throws IOException 2391 */ 2392 default int getMasterInfoPort() throws IOException { 2393 return getClusterMetrics(EnumSet.of(Option.MASTER_INFO_PORT)).getMasterInfoPort(); 2394 } 2395 2396 /** 2397 * Return the set of supported security capabilities. 2398 * @throws IOException 2399 * @throws UnsupportedOperationException 2400 */ 2401 List<SecurityCapability> getSecurityCapabilities() throws IOException; 2402 2403 /** 2404 * Turn the Split or Merge switches on or off. 2405 * @param enabled enabled or not 2406 * @param synchronous If <code>true</code>, it waits until current split() call, if outstanding, 2407 * to return. 2408 * @param switchTypes switchType list {@link MasterSwitchType} 2409 * @return Previous switch value array 2410 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #splitSwitch(boolean, boolean)} 2411 * or {@link #mergeSwitch(boolean, boolean)} instead. 2412 */ 2413 @Deprecated 2414 default boolean[] setSplitOrMergeEnabled(boolean enabled, boolean synchronous, 2415 MasterSwitchType... switchTypes) throws IOException { 2416 boolean[] preValues = new boolean[switchTypes.length]; 2417 for (int i = 0; i < switchTypes.length; i++) { 2418 switch (switchTypes[i]) { 2419 case SPLIT: 2420 preValues[i] = splitSwitch(enabled, synchronous); 2421 break; 2422 case MERGE: 2423 preValues[i] = mergeSwitch(enabled, synchronous); 2424 break; 2425 default: 2426 throw new UnsupportedOperationException("Unsupported switch type:" + switchTypes[i]); 2427 } 2428 } 2429 return preValues; 2430 } 2431 2432 /** 2433 * Turn the split switch on or off. 2434 * @param enabled enabled or not 2435 * @param synchronous If <code>true</code>, it waits until current split() call, if outstanding, 2436 * to return. 2437 * @return Previous switch value 2438 */ 2439 boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException; 2440 2441 /** 2442 * Turn the merge switch on or off. 2443 * @param enabled enabled or not 2444 * @param synchronous If <code>true</code>, it waits until current merge() call, if outstanding, 2445 * to return. 2446 * @return Previous switch value 2447 */ 2448 boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException; 2449 2450 /** 2451 * Query the current state of the switch. 2452 * 2453 * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise. 2454 * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use 2455 * {@link #isSplitEnabled()} or {@link #isMergeEnabled()} instead. 2456 */ 2457 @Deprecated 2458 default boolean isSplitOrMergeEnabled(MasterSwitchType switchType) throws IOException { 2459 switch (switchType) { 2460 case SPLIT: 2461 return isSplitEnabled(); 2462 case MERGE: 2463 return isMergeEnabled(); 2464 default: 2465 break; 2466 } 2467 throw new UnsupportedOperationException("Unsupported switch type:" + switchType); 2468 } 2469 2470 /** 2471 * Query the current state of the split switch. 2472 * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise. 2473 */ 2474 boolean isSplitEnabled() throws IOException; 2475 2476 /** 2477 * Query the current state of the merge switch. 2478 * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise. 2479 */ 2480 boolean isMergeEnabled() throws IOException; 2481 2482 /** 2483 * Add a new replication peer for replicating data to slave cluster. 2484 * @param peerId a short name that identifies the peer 2485 * @param peerConfig configuration for the replication slave cluster 2486 * @throws IOException if a remote or network exception occurs 2487 */ 2488 default void addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig) 2489 throws IOException { 2490 addReplicationPeer(peerId, peerConfig, true); 2491 } 2492 2493 /** 2494 * Add a new replication peer for replicating data to slave cluster. 2495 * @param peerId a short name that identifies the peer 2496 * @param peerConfig configuration for the replication slave cluster 2497 * @param enabled peer state, true if ENABLED and false if DISABLED 2498 * @throws IOException if a remote or network exception occurs 2499 */ 2500 void addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled) 2501 throws IOException; 2502 2503 /** 2504 * Remove a peer and stop the replication. 2505 * @param peerId a short name that identifies the peer 2506 * @throws IOException if a remote or network exception occurs 2507 */ 2508 void removeReplicationPeer(String peerId) throws IOException; 2509 2510 /** 2511 * Restart the replication stream to the specified peer. 2512 * @param peerId a short name that identifies the peer 2513 * @throws IOException if a remote or network exception occurs 2514 */ 2515 void enableReplicationPeer(String peerId) throws IOException; 2516 2517 /** 2518 * Stop the replication stream to the specified peer. 2519 * @param peerId a short name that identifies the peer 2520 * @throws IOException if a remote or network exception occurs 2521 */ 2522 void disableReplicationPeer(String peerId) throws IOException; 2523 2524 /** 2525 * Returns the configured ReplicationPeerConfig for the specified peer. 2526 * @param peerId a short name that identifies the peer 2527 * @return ReplicationPeerConfig for the peer 2528 * @throws IOException if a remote or network exception occurs 2529 */ 2530 ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws IOException; 2531 2532 /** 2533 * Update the peerConfig for the specified peer. 2534 * @param peerId a short name that identifies the peer 2535 * @param peerConfig new config for the peer 2536 * @throws IOException if a remote or network exception occurs 2537 */ 2538 void updateReplicationPeerConfig(String peerId, 2539 ReplicationPeerConfig peerConfig) throws IOException; 2540 2541 /** 2542 * Append the replicable table column family config from the specified peer. 2543 * @param id a short that identifies the cluster 2544 * @param tableCfs A map from tableName to column family names 2545 * @throws ReplicationException if tableCfs has conflict with existing config 2546 * @throws IOException if a remote or network exception occurs 2547 */ 2548 void appendReplicationPeerTableCFs(String id, 2549 Map<TableName, List<String>> tableCfs) 2550 throws ReplicationException, IOException; 2551 2552 /** 2553 * Remove some table-cfs from config of the specified peer. 2554 * @param id a short name that identifies the cluster 2555 * @param tableCfs A map from tableName to column family names 2556 * @throws ReplicationException if tableCfs has conflict with existing config 2557 * @throws IOException if a remote or network exception occurs 2558 */ 2559 void removeReplicationPeerTableCFs(String id, 2560 Map<TableName, List<String>> tableCfs) 2561 throws ReplicationException, IOException; 2562 2563 /** 2564 * Return a list of replication peers. 2565 * @return a list of replication peers description 2566 * @throws IOException if a remote or network exception occurs 2567 */ 2568 List<ReplicationPeerDescription> listReplicationPeers() throws IOException; 2569 2570 /** 2571 * Return a list of replication peers. 2572 * @param pattern The compiled regular expression to match peer id 2573 * @return a list of replication peers description 2574 * @throws IOException if a remote or network exception occurs 2575 */ 2576 List<ReplicationPeerDescription> listReplicationPeers(Pattern pattern) throws IOException; 2577 2578 /** 2579 * Mark region server(s) as decommissioned to prevent additional regions from getting 2580 * assigned to them. Optionally unload the regions on the servers. If there are multiple servers 2581 * to be decommissioned, decommissioning them at the same time can prevent wasteful region 2582 * movements. Region unloading is asynchronous. 2583 * @param servers The list of servers to decommission. 2584 * @param offload True to offload the regions from the decommissioned servers 2585 */ 2586 void decommissionRegionServers(List<ServerName> servers, boolean offload) throws IOException; 2587 2588 /** 2589 * List region servers marked as decommissioned, which can not be assigned regions. 2590 * @return List of decommissioned region servers. 2591 */ 2592 List<ServerName> listDecommissionedRegionServers() throws IOException; 2593 2594 /** 2595 * Remove decommission marker from a region server to allow regions assignments. 2596 * Load regions onto the server if a list of regions is given. Region loading is 2597 * asynchronous. 2598 * @param server The server to recommission. 2599 * @param encodedRegionNames Regions to load onto the server. 2600 */ 2601 void recommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames) 2602 throws IOException; 2603 2604 /** 2605 * Find all table and column families that are replicated from this cluster 2606 * @return the replicated table-cfs list of this cluster. 2607 */ 2608 List<TableCFs> listReplicatedTableCFs() throws IOException; 2609 2610 /** 2611 * Enable a table's replication switch. 2612 * @param tableName name of the table 2613 * @throws IOException if a remote or network exception occurs 2614 */ 2615 void enableTableReplication(TableName tableName) throws IOException; 2616 2617 /** 2618 * Disable a table's replication switch. 2619 * @param tableName name of the table 2620 * @throws IOException if a remote or network exception occurs 2621 */ 2622 void disableTableReplication(TableName tableName) throws IOException; 2623 2624 /** 2625 * Clear compacting queues on a regionserver. 2626 * @param serverName the region server name 2627 * @param queues the set of queue name 2628 * @throws IOException if a remote or network exception occurs 2629 * @throws InterruptedException 2630 */ 2631 void clearCompactionQueues(ServerName serverName, Set<String> queues) 2632 throws IOException, InterruptedException; 2633 2634 /** 2635 * List dead region servers. 2636 * @return List of dead region servers. 2637 */ 2638 default List<ServerName> listDeadServers() throws IOException { 2639 return getClusterMetrics(EnumSet.of(Option.DEAD_SERVERS)).getDeadServerNames(); 2640 } 2641 2642 /** 2643 * Clear dead region servers from master. 2644 * @param servers list of dead region servers. 2645 * @throws IOException if a remote or network exception occurs 2646 * @return List of servers that are not cleared 2647 */ 2648 List<ServerName> clearDeadServers(final List<ServerName> servers) throws IOException; 2649}