1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 package org.apache.hadoop.hbase.client;
20
21 import java.io.Closeable;
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.regex.Pattern;
26
27 import org.apache.hadoop.conf.Configuration;
28 import org.apache.hadoop.hbase.Abortable;
29 import org.apache.hadoop.hbase.ClusterStatus;
30 import org.apache.hadoop.hbase.HColumnDescriptor;
31 import org.apache.hadoop.hbase.HRegionInfo;
32 import org.apache.hadoop.hbase.HTableDescriptor;
33 import org.apache.hadoop.hbase.NamespaceDescriptor;
34 import org.apache.hadoop.hbase.ServerName;
35 import org.apache.hadoop.hbase.TableExistsException;
36 import org.apache.hadoop.hbase.TableName;
37 import org.apache.hadoop.hbase.TableNotFoundException;
38 import org.apache.hadoop.hbase.classification.InterfaceAudience;
39 import org.apache.hadoop.hbase.classification.InterfaceStability;
40 import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
41 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
42 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
43 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos;
44 import org.apache.hadoop.hbase.quotas.QuotaFilter;
45 import org.apache.hadoop.hbase.quotas.QuotaRetriever;
46 import org.apache.hadoop.hbase.quotas.QuotaSettings;
47 import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
48 import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
49 import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
50 import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
51 import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException;
52 import org.apache.hadoop.hbase.util.Pair;
53
54 /**
55 * The administrative API for HBase. Obtain an instance from an {@link Connection#getAdmin()} and
56 * call {@link #close()} afterwards.
57 * <p>Admin can be used to create, drop, list, enable and disable tables, add and drop table
58 * column families and other administrative operations.
59 *
60 * @see ConnectionFactory
61 * @see Connection
62 * @see Table
63 * @since 0.99.0
64 */
65 @InterfaceAudience.Public
66 @InterfaceStability.Evolving
67 public interface Admin extends Abortable, Closeable {
68 int getOperationTimeout();
69
70 @Override
71 void abort(String why, Throwable e);
72
73 @Override
74 boolean isAborted();
75
76 /**
77 * @return Connection used by this object.
78 */
79 Connection getConnection();
80
81 /**
82 * @param tableName Table to check.
83 * @return True if table exists already.
84 * @throws IOException
85 */
86 boolean tableExists(final TableName tableName) throws IOException;
87
88 /**
89 * List all the userspace tables.
90 *
91 * @return - returns an array of HTableDescriptors
92 * @throws IOException if a remote or network exception occurs
93 */
94 HTableDescriptor[] listTables() throws IOException;
95
96 /**
97 * List all the userspace tables matching the given pattern.
98 *
99 * @param pattern The compiled regular expression to match against
100 * @return - returns an array of HTableDescriptors
101 * @throws IOException if a remote or network exception occurs
102 * @see #listTables()
103 */
104 HTableDescriptor[] listTables(Pattern pattern) throws IOException;
105
106 /**
107 * List all the userspace tables matching the given regular expression.
108 *
109 * @param regex The regular expression to match against
110 * @return - returns an array of HTableDescriptors
111 * @throws IOException if a remote or network exception occurs
112 * @see #listTables(java.util.regex.Pattern)
113 */
114 HTableDescriptor[] listTables(String regex) throws IOException;
115
116 /**
117 * List all the tables matching the given pattern.
118 *
119 * @param pattern The compiled regular expression to match against
120 * @param includeSysTables False to match only against userspace tables
121 * @return - returns an array of HTableDescriptors
122 * @throws IOException if a remote or network exception occurs
123 * @see #listTables()
124 */
125 HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables)
126 throws IOException;
127
128 /**
129 * List all the tables matching the given pattern.
130 *
131 * @param regex The regular expression to match against
132 * @param includeSysTables False to match only against userspace tables
133 * @return - returns an array of HTableDescriptors
134 * @throws IOException if a remote or network exception occurs
135 * @see #listTables(java.util.regex.Pattern, boolean)
136 */
137 HTableDescriptor[] listTables(String regex, boolean includeSysTables)
138 throws IOException;
139
140 /**
141 * List all of the names of userspace tables.
142 *
143 * @return TableName[] table names
144 * @throws IOException if a remote or network exception occurs
145 */
146 TableName[] listTableNames() throws IOException;
147
148 /**
149 * List all of the names of userspace tables.
150 * @param pattern The regular expression to match against
151 * @return TableName[] table names
152 * @throws IOException if a remote or network exception occurs
153 */
154 TableName[] listTableNames(Pattern pattern) throws IOException;
155
156 /**
157 * List all of the names of userspace tables.
158 * @param regex The regular expression to match against
159 * @return TableName[] table names
160 * @throws IOException if a remote or network exception occurs
161 */
162 TableName[] listTableNames(String regex) throws IOException;
163
164 /**
165 * List all of the names of userspace tables.
166 * @param pattern The regular expression to match against
167 * @param includeSysTables False to match only against userspace tables
168 * @return TableName[] table names
169 * @throws IOException if a remote or network exception occurs
170 */
171 TableName[] listTableNames(final Pattern pattern, final boolean includeSysTables)
172 throws IOException;
173
174 /**
175 * List all of the names of userspace tables.
176 * @param regex The regular expression to match against
177 * @param includeSysTables False to match only against userspace tables
178 * @return TableName[] table names
179 * @throws IOException if a remote or network exception occurs
180 */
181 TableName[] listTableNames(final String regex, final boolean includeSysTables)
182 throws IOException;
183
184 /**
185 * Method for getting the tableDescriptor
186 *
187 * @param tableName as a {@link TableName}
188 * @return the tableDescriptor
189 * @throws org.apache.hadoop.hbase.TableNotFoundException
190 * @throws IOException if a remote or network exception occurs
191 */
192 HTableDescriptor getTableDescriptor(final TableName tableName)
193 throws TableNotFoundException, IOException;
194
195 /**
196 * Creates a new table. Synchronous operation.
197 *
198 * @param desc table descriptor for table
199 * @throws IllegalArgumentException if the table name is reserved
200 * @throws MasterNotRunningException if master is not running
201 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
202 * threads, the table may have been created between test-for-existence and attempt-at-creation).
203 * @throws IOException if a remote or network exception occurs
204 */
205 void createTable(HTableDescriptor desc) throws IOException;
206
207 /**
208 * Creates a new table with the specified number of regions. The start key specified will become
209 * the end key of the first region of the table, and the end key specified will become the start
210 * key of the last region of the table (the first region has a null start key and the last region
211 * has a null end key). BigInteger math will be used to divide the key range specified into enough
212 * segments to make the required number of total regions. Synchronous operation.
213 *
214 * @param desc table descriptor for table
215 * @param startKey beginning of key range
216 * @param endKey end of key range
217 * @param numRegions the total number of regions to create
218 * @throws IllegalArgumentException if the table name is reserved
219 * @throws MasterNotRunningException if master is not running
220 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
221 * threads, the table may have been created between test-for-existence and attempt-at-creation).
222 * @throws IOException
223 */
224 void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
225 throws IOException;
226
227 /**
228 * Creates a new table with an initial set of empty regions defined by the specified split keys.
229 * The total number of regions created will be the number of split keys plus one. Synchronous
230 * operation. Note : Avoid passing empty split key.
231 *
232 * @param desc table descriptor for table
233 * @param splitKeys array of split keys for the initial regions of the table
234 * @throws IllegalArgumentException if the table name is reserved, if the split keys are repeated
235 * and if the split key has empty byte array.
236 * @throws MasterNotRunningException if master is not running
237 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
238 * threads, the table may have been created between test-for-existence and attempt-at-creation).
239 * @throws IOException
240 */
241 void createTable(final HTableDescriptor desc, byte[][] splitKeys) throws IOException;
242
243 /**
244 * Creates a new table but does not block and wait for it to come online. Asynchronous operation.
245 * To check if the table exists, use {@link #isTableAvailable} -- it is not safe to create an
246 * HTable instance to this table before it is available. Note : Avoid passing empty split key.
247 *
248 * @param desc table descriptor for table
249 * @throws IllegalArgumentException Bad table name, if the split keys are repeated and if the
250 * split key has empty byte array.
251 * @throws MasterNotRunningException if master is not running
252 * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
253 * threads, the table may have been created between test-for-existence and attempt-at-creation).
254 * @throws IOException
255 */
256 void createTableAsync(final HTableDescriptor desc, final byte[][] splitKeys) throws IOException;
257
258 /**
259 * Deletes a table. Synchronous operation.
260 *
261 * @param tableName name of table to delete
262 * @throws IOException if a remote or network exception occurs
263 */
264 void deleteTable(final TableName tableName) throws IOException;
265
266 /**
267 * Deletes tables matching the passed in pattern and wait on completion. Warning: Use this method
268 * carefully, there is no prompting and the effect is immediate. Consider using {@link
269 * #listTables(java.lang.String)} and {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
270 *
271 * @param regex The regular expression to match table names against
272 * @return Table descriptors for tables that couldn't be deleted
273 * @throws IOException
274 * @see #deleteTables(java.util.regex.Pattern)
275 * @see #deleteTable(org.apache.hadoop.hbase.TableName)
276 */
277 HTableDescriptor[] deleteTables(String regex) throws IOException;
278
279 /**
280 * Delete tables matching the passed in pattern and wait on completion. Warning: Use this method
281 * carefully, there is no prompting and the effect is immediate. Consider using {@link
282 * #listTables(java.util.regex.Pattern) } and
283 * {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
284 *
285 * @param pattern The pattern to match table names against
286 * @return Table descriptors for tables that couldn't be deleted
287 * @throws IOException
288 */
289 HTableDescriptor[] deleteTables(Pattern pattern) throws IOException;
290
291 /**
292 * Truncate a table.
293 * Synchronous operation.
294 *
295 * @param tableName name of table to truncate
296 * @param preserveSplits True if the splits should be preserved
297 * @throws IOException if a remote or network exception occurs
298 */
299 public void truncateTable(final TableName tableName, final boolean preserveSplits)
300 throws IOException;
301
302 /**
303 * Enable a table. May timeout. Use {@link #enableTableAsync(org.apache.hadoop.hbase.TableName)}
304 * and {@link #isTableEnabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in
305 * disabled state for it to be enabled.
306 *
307 * @param tableName name of the table
308 * @throws IOException if a remote or network exception occurs There could be couple types of
309 * IOException TableNotFoundException means the table doesn't exist. TableNotDisabledException
310 * means the table isn't in disabled state.
311 * @see #isTableEnabled(org.apache.hadoop.hbase.TableName)
312 * @see #disableTable(org.apache.hadoop.hbase.TableName)
313 * @see #enableTableAsync(org.apache.hadoop.hbase.TableName)
314 */
315 void enableTable(final TableName tableName) throws IOException;
316
317 /**
318 * Brings a table on-line (enables it). Method returns immediately though enable of table may
319 * take some time to complete, especially if the table is large (All regions are opened as part of
320 * enabling process). Check {@link #isTableEnabled(org.apache.hadoop.hbase.TableName)} to learn
321 * when table is fully online. If table is taking too long to online, check server logs.
322 *
323 * @param tableName
324 * @throws IOException
325 * @since 0.90.0
326 */
327 void enableTableAsync(final TableName tableName) throws IOException;
328
329 /**
330 * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method
331 * carefully, there is no prompting and the effect is immediate. Consider using {@link
332 * #listTables(java.lang.String)} and {@link #enableTable(org.apache.hadoop.hbase.TableName)}
333 *
334 * @param regex The regular expression to match table names against
335 * @throws IOException
336 * @see #enableTables(java.util.regex.Pattern)
337 * @see #enableTable(org.apache.hadoop.hbase.TableName)
338 */
339 HTableDescriptor[] enableTables(String regex) throws IOException;
340
341 /**
342 * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method
343 * carefully, there is no prompting and the effect is immediate. Consider using {@link
344 * #listTables(java.util.regex.Pattern) } and
345 * {@link #enableTable(org.apache.hadoop.hbase.TableName)}
346 *
347 * @param pattern The pattern to match table names against
348 * @throws IOException
349 */
350 HTableDescriptor[] enableTables(Pattern pattern) throws IOException;
351
352 /**
353 * Starts the disable of a table. If it is being served, the master will tell the servers to stop
354 * serving it. This method returns immediately. The disable of a table can take some time if the
355 * table is large (all regions are closed as part of table disable operation). Call {@link
356 * #isTableDisabled(org.apache.hadoop.hbase.TableName)} to check for when disable completes. If
357 * table is taking too long to online, check server logs.
358 *
359 * @param tableName name of table
360 * @throws IOException if a remote or network exception occurs
361 * @see #isTableDisabled(org.apache.hadoop.hbase.TableName)
362 * @see #isTableEnabled(org.apache.hadoop.hbase.TableName)
363 * @since 0.90.0
364 */
365 void disableTableAsync(final TableName tableName) throws IOException;
366
367 /**
368 * Disable table and wait on completion. May timeout eventually. Use {@link
369 * #disableTableAsync(org.apache.hadoop.hbase.TableName)} and
370 * {@link #isTableDisabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in
371 * enabled state for it to be disabled.
372 *
373 * @param tableName
374 * @throws IOException There could be couple types of IOException TableNotFoundException means the
375 * table doesn't exist. TableNotEnabledException means the table isn't in enabled state.
376 */
377 void disableTable(final TableName tableName) throws IOException;
378
379 /**
380 * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method
381 * carefully, there is no prompting and the effect is immediate. Consider using {@link
382 * #listTables(java.lang.String)} and {@link #disableTable(org.apache.hadoop.hbase.TableName)}
383 *
384 * @param regex The regular expression to match table names against
385 * @return Table descriptors for tables that couldn't be disabled
386 * @throws IOException
387 * @see #disableTables(java.util.regex.Pattern)
388 * @see #disableTable(org.apache.hadoop.hbase.TableName)
389 */
390 HTableDescriptor[] disableTables(String regex) throws IOException;
391
392 /**
393 * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method
394 * carefully, there is no prompting and the effect is immediate. Consider using {@link
395 * #listTables(java.util.regex.Pattern) } and
396 * {@link #disableTable(org.apache.hadoop.hbase.TableName)}
397 *
398 * @param pattern The pattern to match table names against
399 * @return Table descriptors for tables that couldn't be disabled
400 * @throws IOException
401 */
402 HTableDescriptor[] disableTables(Pattern pattern) throws IOException;
403
404 /**
405 * @param tableName name of table to check
406 * @return true if table is on-line
407 * @throws IOException if a remote or network exception occurs
408 */
409 boolean isTableEnabled(TableName tableName) throws IOException;
410
411 /**
412 * @param tableName name of table to check
413 * @return true if table is off-line
414 * @throws IOException if a remote or network exception occurs
415 */
416 boolean isTableDisabled(TableName tableName) throws IOException;
417
418 /**
419 * @param tableName name of table to check
420 * @return true if all regions of the table are available
421 * @throws IOException if a remote or network exception occurs
422 */
423 boolean isTableAvailable(TableName tableName) throws IOException;
424
425 /**
426 * Use this api to check if the table has been created with the specified number of splitkeys
427 * which was used while creating the given table. Note : If this api is used after a table's
428 * region gets splitted, the api may return false.
429 *
430 * @param tableName name of table to check
431 * @param splitKeys keys to check if the table has been created with all split keys
432 * @throws IOException if a remote or network excpetion occurs
433 */
434 boolean isTableAvailable(TableName tableName, byte[][] splitKeys) throws IOException;
435
436 /**
437 * Get the status of alter command - indicates how many regions have received the updated schema
438 * Asynchronous operation.
439 *
440 * @param tableName TableName instance
441 * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
442 * yet to be updated Pair.getSecond() is the total number of regions of the table
443 * @throws IOException if a remote or network exception occurs
444 */
445 Pair<Integer, Integer> getAlterStatus(final TableName tableName) throws IOException;
446
447 /**
448 * Get the status of alter command - indicates how many regions have received the updated schema
449 * Asynchronous operation.
450 *
451 * @param tableName name of the table to get the status of
452 * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
453 * yet to be updated Pair.getSecond() is the total number of regions of the table
454 * @throws IOException if a remote or network exception occurs
455 */
456 Pair<Integer, Integer> getAlterStatus(final byte[] tableName) throws IOException;
457
458 /**
459 * Add a column to an existing table. Asynchronous operation.
460 *
461 * @param tableName name of the table to add column to
462 * @param column column descriptor of column to be added
463 * @throws IOException if a remote or network exception occurs
464 */
465 void addColumn(final TableName tableName, final HColumnDescriptor column) throws IOException;
466
467 /**
468 * Delete a column from a table. Asynchronous operation.
469 *
470 * @param tableName name of table
471 * @param columnName name of column to be deleted
472 * @throws IOException if a remote or network exception occurs
473 */
474 void deleteColumn(final TableName tableName, final byte[] columnName) throws IOException;
475
476 /**
477 * Modify an existing column family on a table. Asynchronous operation.
478 *
479 * @param tableName name of table
480 * @param descriptor new column descriptor to use
481 * @throws IOException if a remote or network exception occurs
482 */
483 void modifyColumn(final TableName tableName, final HColumnDescriptor descriptor)
484 throws IOException;
485
486 /**
487 * Close a region. For expert-admins. Runs close on the regionserver. The master will not be
488 * informed of the close.
489 *
490 * @param regionname region name to close
491 * @param serverName If supplied, we'll use this location rather than the one currently in
492 * <code>hbase:meta</code>
493 * @throws IOException if a remote or network exception occurs
494 */
495 void closeRegion(final String regionname, final String serverName) throws IOException;
496
497 /**
498 * Close a region. For expert-admins Runs close on the regionserver. The master will not be
499 * informed of the close.
500 *
501 * @param regionname region name to close
502 * @param serverName The servername of the regionserver. If passed null we will use servername
503 * found in the hbase:meta table. A server name is made of host, port and startcode. Here is an
504 * example: <code> host187.example.com,60020,1289493121758</code>
505 * @throws IOException if a remote or network exception occurs
506 */
507 void closeRegion(final byte[] regionname, final String serverName) throws IOException;
508
509 /**
510 * For expert-admins. Runs close on the regionserver. Closes a region based on the encoded region
511 * name. The region server name is mandatory. If the servername is provided then based on the
512 * online regions in the specified regionserver the specified region will be closed. The master
513 * will not be informed of the close. Note that the regionname is the encoded regionname.
514 *
515 * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
516 * suffix: e.g. if regionname is
517 * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
518 * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
519 * @param serverName The servername of the regionserver. A server name is made of host, port and
520 * startcode. This is mandatory. Here is an example:
521 * <code> host187.example.com,60020,1289493121758</code>
522 * @return true if the region was closed, false if not.
523 * @throws IOException if a remote or network exception occurs
524 */
525 boolean closeRegionWithEncodedRegionName(final String encodedRegionName, final String serverName)
526 throws IOException;
527
528 /**
529 * Close a region. For expert-admins Runs close on the regionserver. The master will not be
530 * informed of the close.
531 *
532 * @param sn
533 * @param hri
534 * @throws IOException
535 */
536 void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException;
537
538 /**
539 * Get all the online regions on a region server.
540 */
541 List<HRegionInfo> getOnlineRegions(final ServerName sn) throws IOException;
542
543 /**
544 * Flush a table. Synchronous operation.
545 *
546 * @param tableName table to flush
547 * @throws IOException if a remote or network exception occurs
548 */
549 void flush(final TableName tableName) throws IOException;
550
551 /**
552 * Flush an individual region. Synchronous operation.
553 *
554 * @param regionName region to flush
555 * @throws IOException if a remote or network exception occurs
556 */
557 void flushRegion(final byte[] regionName) throws IOException;
558
559 /**
560 * Compact a table. Asynchronous operation.
561 *
562 * @param tableName table to compact
563 * @throws IOException if a remote or network exception occurs
564 */
565 void compact(final TableName tableName) throws IOException;
566
567 /**
568 * Compact an individual region. Asynchronous operation.
569 *
570 * @param regionName region to compact
571 * @throws IOException if a remote or network exception occurs
572 */
573 void compactRegion(final byte[] regionName) throws IOException;
574
575 /**
576 * Compact a column family within a table. Asynchronous operation.
577 *
578 * @param tableName table to compact
579 * @param columnFamily column family within a table
580 * @throws IOException if a remote or network exception occurs
581 */
582 void compact(final TableName tableName, final byte[] columnFamily)
583 throws IOException;
584
585 /**
586 * Compact a column family within a region. Asynchronous operation.
587 *
588 * @param regionName region to compact
589 * @param columnFamily column family within a region
590 * @throws IOException if a remote or network exception occurs
591 */
592 void compactRegion(final byte[] regionName, final byte[] columnFamily)
593 throws IOException;
594
595 /**
596 * Major compact a table. Asynchronous operation.
597 *
598 * @param tableName table to major compact
599 * @throws IOException if a remote or network exception occurs
600 */
601 void majorCompact(TableName tableName) throws IOException;
602
603 /**
604 * Major compact a table or an individual region. Asynchronous operation.
605 *
606 * @param regionName region to major compact
607 * @throws IOException if a remote or network exception occurs
608 */
609 void majorCompactRegion(final byte[] regionName) throws IOException;
610
611 /**
612 * Major compact a column family within a table. Asynchronous operation.
613 *
614 * @param tableName table to major compact
615 * @param columnFamily column family within a table
616 * @throws IOException if a remote or network exception occurs
617 */
618 void majorCompact(TableName tableName, final byte[] columnFamily)
619 throws IOException;
620
621 /**
622 * Major compact a column family within region. Asynchronous operation.
623 *
624 * @param regionName egion to major compact
625 * @param columnFamily column family within a region
626 * @throws IOException if a remote or network exception occurs
627 */
628 void majorCompactRegion(final byte[] regionName, final byte[] columnFamily)
629 throws IOException;
630
631 /**
632 * Compact all regions on the region server
633 * @param sn the region server name
634 * @param major if it's major compaction
635 * @throws IOException
636 * @throws InterruptedException
637 */
638 public void compactRegionServer(final ServerName sn, boolean major)
639 throws IOException, InterruptedException;
640
641 /**
642 * Move the region <code>r</code> to <code>dest</code>.
643 *
644 * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
645 * suffix: e.g. if regionname is
646 * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
647 * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
648 * @param destServerName The servername of the destination regionserver. If passed the empty byte
649 * array we'll assign to a random server. A server name is made of host, port and startcode.
650 * Here is an example: <code> host187.example.com,60020,1289493121758</code>
651 * @throws UnknownRegionException Thrown if we can't find a region named
652 * <code>encodedRegionName</code>
653 */
654 void move(final byte[] encodedRegionName, final byte[] destServerName)
655 throws IOException;
656
657 /**
658 * @param regionName Region name to assign.
659 */
660 void assign(final byte[] regionName)
661 throws IOException;
662
663 /**
664 * Unassign a region from current hosting regionserver. Region will then be assigned to a
665 * regionserver chosen at random. Region could be reassigned back to the same server. Use {@link
666 * #move(byte[], byte[])} if you want to control the region movement.
667 *
668 * @param regionName Region to unassign. Will clear any existing RegionPlan if one found.
669 * @param force If true, force unassign (Will remove region from regions-in-transition too if
670 * present. If results in double assignment use hbck -fix to resolve. To be used by experts).
671 */
672 void unassign(final byte[] regionName, final boolean force)
673 throws IOException;
674
675 /**
676 * Offline specified region from master's in-memory state. It will not attempt to reassign the
677 * region as in unassign. This API can be used when a region not served by any region server and
678 * still online as per Master's in memory state. If this API is incorrectly used on active region
679 * then master will loose track of that region. This is a special method that should be used by
680 * experts or hbck.
681 *
682 * @param regionName Region to offline.
683 * @throws IOException
684 */
685 void offline(final byte[] regionName) throws IOException;
686
687 /**
688 * Turn the load balancer on or off.
689 *
690 * @param synchronous If true, it waits until current balance() call, if outstanding, to return.
691 * @return Previous balancer value
692 */
693 boolean setBalancerRunning(final boolean on, final boolean synchronous)
694 throws IOException;
695
696 /**
697 * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the
698 * reassignments. Can NOT run for various reasons. Check logs.
699 *
700 * @return True if balancer ran, false otherwise.
701 */
702 boolean balancer() throws IOException;
703
704 /**
705 * Query the current state of the balancer
706 *
707 * @return true if the balancer is enabled, false otherwise.
708 */
709 boolean isBalancerEnabled() throws IOException;
710
711 /**
712 * Enable/Disable the catalog janitor
713 *
714 * @param enable if true enables the catalog janitor
715 * @return the previous state
716 */
717 boolean enableCatalogJanitor(boolean enable) throws IOException;
718
719 /**
720 * Ask for a scan of the catalog table
721 *
722 * @return the number of entries cleaned
723 */
724 int runCatalogScan() throws IOException;
725
726 /**
727 * Query on the catalog janitor state (Enabled/Disabled?)
728 *
729 */
730 boolean isCatalogJanitorEnabled() throws IOException;
731
732 /**
733 * Merge two regions. Asynchronous operation.
734 *
735 * @param encodedNameOfRegionA encoded name of region a
736 * @param encodedNameOfRegionB encoded name of region b
737 * @param forcible true if do a compulsory merge, otherwise we will only merge two adjacent
738 * regions
739 * @throws IOException
740 */
741 void mergeRegions(final byte[] encodedNameOfRegionA, final byte[] encodedNameOfRegionB,
742 final boolean forcible) throws IOException;
743
744 /**
745 * Split a table. Asynchronous operation.
746 *
747 * @param tableName table to split
748 * @throws IOException if a remote or network exception occurs
749 */
750 void split(final TableName tableName) throws IOException;
751
752 /**
753 * Split an individual region. Asynchronous operation.
754 *
755 * @param regionName region to split
756 * @throws IOException if a remote or network exception occurs
757 */
758 void splitRegion(final byte[] regionName) throws IOException;
759
760 /**
761 * Split a table. Asynchronous operation.
762 *
763 * @param tableName table to split
764 * @param splitPoint the explicit position to split on
765 * @throws IOException if a remote or network exception occurs
766 */
767 void split(final TableName tableName, final byte[] splitPoint)
768 throws IOException;
769
770 /**
771 * Split an individual region. Asynchronous operation.
772 *
773 * @param regionName region to split
774 * @param splitPoint the explicit position to split on
775 * @throws IOException if a remote or network exception occurs
776 */
777 void splitRegion(final byte[] regionName, final byte[] splitPoint)
778 throws IOException;
779
780 /**
781 * Modify an existing table, more IRB friendly version. Asynchronous operation. This means that
782 * it may be a while before your schema change is updated across all of the table.
783 *
784 * @param tableName name of table.
785 * @param htd modified description of the table
786 * @throws IOException if a remote or network exception occurs
787 */
788 void modifyTable(final TableName tableName, final HTableDescriptor htd)
789 throws IOException;
790
791 /**
792 * Shuts down the HBase cluster
793 *
794 * @throws IOException if a remote or network exception occurs
795 */
796 void shutdown() throws IOException;
797
798 /**
799 * Shuts down the current HBase master only. Does not shutdown the cluster.
800 *
801 * @throws IOException if a remote or network exception occurs
802 * @see #shutdown()
803 */
804 void stopMaster() throws IOException;
805
806 /**
807 * Stop the designated regionserver
808 *
809 * @param hostnamePort Hostname and port delimited by a <code>:</code> as in
810 * <code>example.org:1234</code>
811 * @throws IOException if a remote or network exception occurs
812 */
813 void stopRegionServer(final String hostnamePort) throws IOException;
814
815 /**
816 * @return cluster status
817 * @throws IOException if a remote or network exception occurs
818 */
819 ClusterStatus getClusterStatus() throws IOException;
820
821 /**
822 * @return Configuration used by the instance.
823 */
824 Configuration getConfiguration();
825
826 /**
827 * Create a new namespace
828 *
829 * @param descriptor descriptor which describes the new namespace
830 * @throws IOException
831 */
832 void createNamespace(final NamespaceDescriptor descriptor)
833 throws IOException;
834
835 /**
836 * Modify an existing namespace
837 *
838 * @param descriptor descriptor which describes the new namespace
839 * @throws IOException
840 */
841 void modifyNamespace(final NamespaceDescriptor descriptor)
842 throws IOException;
843
844 /**
845 * Delete an existing namespace. Only empty namespaces (no tables) can be removed.
846 *
847 * @param name namespace name
848 * @throws IOException
849 */
850 void deleteNamespace(final String name) throws IOException;
851
852 /**
853 * Get a namespace descriptor by name
854 *
855 * @param name name of namespace descriptor
856 * @return A descriptor
857 * @throws IOException
858 */
859 NamespaceDescriptor getNamespaceDescriptor(final String name)
860 throws IOException;
861
862 /**
863 * List available namespace descriptors
864 *
865 * @return List of descriptors
866 * @throws IOException
867 */
868 NamespaceDescriptor[] listNamespaceDescriptors()
869 throws IOException;
870
871 /**
872 * Get list of table descriptors by namespace
873 *
874 * @param name namespace name
875 * @return A descriptor
876 * @throws IOException
877 */
878 HTableDescriptor[] listTableDescriptorsByNamespace(final String name)
879 throws IOException;
880
881 /**
882 * Get list of table names by namespace
883 *
884 * @param name namespace name
885 * @return The list of table names in the namespace
886 * @throws IOException
887 */
888 TableName[] listTableNamesByNamespace(final String name)
889 throws IOException;
890
891 /**
892 * Get the regions of a given table.
893 *
894 * @param tableName the name of the table
895 * @return List of {@link HRegionInfo}.
896 * @throws IOException
897 */
898 List<HRegionInfo> getTableRegions(final TableName tableName)
899 throws IOException;
900
901 @Override
902 void close() throws IOException;
903
904 /**
905 * Get tableDescriptors
906 *
907 * @param tableNames List of table names
908 * @return HTD[] the tableDescriptor
909 * @throws IOException if a remote or network exception occurs
910 */
911 HTableDescriptor[] getTableDescriptorsByTableName(List<TableName> tableNames)
912 throws IOException;
913
914 /**
915 * Get tableDescriptors
916 *
917 * @param names List of table names
918 * @return HTD[] the tableDescriptor
919 * @throws IOException if a remote or network exception occurs
920 */
921 HTableDescriptor[] getTableDescriptors(List<String> names)
922 throws IOException;
923
924 /**
925 * Roll the log writer. I.e. for filesystem based write ahead logs, start writing to a new file.
926 *
927 * Note that the actual rolling of the log writer is asynchronous and may not be complete when
928 * this method returns. As a side effect of this call, the named region server may schedule
929 * store flushes at the request of the wal.
930 *
931 * @param serverName The servername of the regionserver.
932 * @throws IOException if a remote or network exception occurs
933 * @throws org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException
934 */
935 void rollWALWriter(ServerName serverName) throws IOException, FailedLogCloseException;
936
937 /**
938 * Helper delegage to getClusterStatus().getMasterCoprocessors().
939 * @return an array of master coprocessors
940 * @see org.apache.hadoop.hbase.ClusterStatus#getMasterCoprocessors()
941 */
942 String[] getMasterCoprocessors() throws IOException;
943
944 /**
945 * Get the current compaction state of a table. It could be in a major compaction, a minor
946 * compaction, both, or none.
947 *
948 * @param tableName table to examine
949 * @return the current compaction state
950 * @throws IOException if a remote or network exception occurs
951 */
952 AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(final TableName tableName)
953 throws IOException;
954
955 /**
956 * Get the current compaction state of region. It could be in a major compaction, a minor
957 * compaction, both, or none.
958 *
959 * @param regionName region to examine
960 * @return the current compaction state
961 * @throws IOException if a remote or network exception occurs
962 */
963 AdminProtos.GetRegionInfoResponse.CompactionState getCompactionStateForRegion(
964 final byte[] regionName) throws IOException;
965
966 /**
967 * Get the timestamp of the last major compaction for the passed table
968 *
969 * The timestamp of the oldest HFile resulting from a major compaction of that table,
970 * or 0 if no such HFile could be found.
971 *
972 * @param tableName table to examine
973 * @return the last major compaction timestamp or 0
974 * @throws IOException if a remote or network exception occurs
975 */
976 long getLastMajorCompactionTimestamp(final TableName tableName)
977 throws IOException;
978
979 /**
980 * Get the timestamp of the last major compaction for the passed region.
981 *
982 * The timestamp of the oldest HFile resulting from a major compaction of that region,
983 * or 0 if no such HFile could be found.
984 *
985 * @param regionName region to examine
986 * @return the last major compaction timestamp or 0
987 * @throws IOException if a remote or network exception occurs
988 */
989 long getLastMajorCompactionTimestampForRegion(final byte[] regionName)
990 throws IOException;
991
992 /**
993 * Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be
994 * taken. If the table is disabled, an offline snapshot is taken. Snapshots are considered unique
995 * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even
996 * a different type or with different parameters) will fail with a {@link
997 * org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate naming.
998 * Snapshot names follow the same naming constraints as tables in HBase. See {@link
999 * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1000 *
1001 * @param snapshotName name of the snapshot to be created
1002 * @param tableName name of the table for which snapshot is created
1003 * @throws IOException if a remote or network exception occurs
1004 * @throws org.apache.hadoop.hbase.snapshot.SnapshotCreationException if snapshot creation failed
1005 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1006 */
1007 void snapshot(final String snapshotName, final TableName tableName)
1008 throws IOException, SnapshotCreationException, IllegalArgumentException;
1009
1010 /**
1011 * public void snapshot(final String snapshotName, Create a timestamp consistent snapshot for the
1012 * given table. final byte[] tableName) throws IOException, Snapshots are considered unique based
1013 * on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even a
1014 * different type or with different parameters) will fail with a {@link SnapshotCreationException}
1015 * indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in
1016 * HBase.
1017 *
1018 * @param snapshotName name of the snapshot to be created
1019 * @param tableName name of the table for which snapshot is created
1020 * @throws IOException if a remote or network exception occurs
1021 * @throws SnapshotCreationException if snapshot creation failed
1022 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1023 */
1024 void snapshot(final byte[] snapshotName, final TableName tableName)
1025 throws IOException, SnapshotCreationException, IllegalArgumentException;
1026
1027 /**
1028 * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the
1029 * snapshot</b>. Attempts to take a snapshot with the same name (even a different type or with
1030 * different parameters) will fail with a {@link SnapshotCreationException} indicating the
1031 * duplicate naming. Snapshot names follow the same naming constraints as tables in HBase. See
1032 * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1033 *
1034 * @param snapshotName name to give the snapshot on the filesystem. Must be unique from all other
1035 * snapshots stored on the cluster
1036 * @param tableName name of the table to snapshot
1037 * @param type type of snapshot to take
1038 * @throws IOException we fail to reach the master
1039 * @throws SnapshotCreationException if snapshot creation failed
1040 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1041 */
1042 void snapshot(final String snapshotName,
1043 final TableName tableName,
1044 HBaseProtos.SnapshotDescription.Type type) throws IOException, SnapshotCreationException,
1045 IllegalArgumentException;
1046
1047 /**
1048 * Take a snapshot and wait for the server to complete that snapshot (blocking). Only a single
1049 * snapshot should be taken at a time for an instance of HBase, or results may be undefined (you
1050 * can tell multiple HBase clusters to snapshot at the same time, but only one at a time for a
1051 * single cluster). Snapshots are considered unique based on <b>the name of the snapshot</b>.
1052 * Attempts to take a snapshot with the same name (even a different type or with different
1053 * parameters) will fail with a {@link SnapshotCreationException} indicating the duplicate naming.
1054 * Snapshot names follow the same naming constraints as tables in HBase. See {@link
1055 * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. You should probably
1056 * use {@link #snapshot(String, org.apache.hadoop.hbase.TableName)} or
1057 * {@link #snapshot(byte[], org.apache.hadoop.hbase.TableName)} unless you are sure about the type
1058 * of snapshot that you want to take.
1059 *
1060 * @param snapshot snapshot to take
1061 * @throws IOException or we lose contact with the master.
1062 * @throws SnapshotCreationException if snapshot failed to be taken
1063 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1064 */
1065 void snapshot(HBaseProtos.SnapshotDescription snapshot)
1066 throws IOException, SnapshotCreationException, IllegalArgumentException;
1067
1068 /**
1069 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous) Only a
1070 * single snapshot should be taken at a time, or results may be undefined.
1071 *
1072 * @param snapshot snapshot to take
1073 * @return response from the server indicating the max time to wait for the snapshot
1074 * @throws IOException if the snapshot did not succeed or we lose contact with the master.
1075 * @throws SnapshotCreationException if snapshot creation failed
1076 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1077 */
1078 MasterProtos.SnapshotResponse takeSnapshotAsync(HBaseProtos.SnapshotDescription snapshot)
1079 throws IOException, SnapshotCreationException;
1080
1081 /**
1082 * Check the current state of the passed snapshot. There are three possible states: <ol>
1083 * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li>
1084 * <li>finished with error - throws the exception that caused the snapshot to fail</li> </ol> The
1085 * cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
1086 * run/started since the snapshot your are checking, you will recieve an {@link
1087 * org.apache.hadoop.hbase.snapshot.UnknownSnapshotException}.
1088 *
1089 * @param snapshot description of the snapshot to check
1090 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
1091 * running
1092 * @throws IOException if we have a network issue
1093 * @throws org.apache.hadoop.hbase.snapshot.HBaseSnapshotException if the snapshot failed
1094 * @throws org.apache.hadoop.hbase.snapshot.UnknownSnapshotException if the requested snapshot is
1095 * unknown
1096 */
1097 boolean isSnapshotFinished(final HBaseProtos.SnapshotDescription snapshot)
1098 throws IOException, HBaseSnapshotException, UnknownSnapshotException;
1099
1100 /**
1101 * Restore the specified snapshot on the original table. (The table must be disabled) If the
1102 * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a
1103 * snapshot of the current table is taken before executing the restore operation. In case of
1104 * restore failure, the failsafe snapshot will be restored. If the restore completes without
1105 * problem the failsafe snapshot is deleted.
1106 *
1107 * @param snapshotName name of the snapshot to restore
1108 * @throws IOException if a remote or network exception occurs
1109 * @throws org.apache.hadoop.hbase.snapshot.RestoreSnapshotException if snapshot failed to be
1110 * restored
1111 * @throws IllegalArgumentException if the restore request is formatted incorrectly
1112 */
1113 void restoreSnapshot(final byte[] snapshotName) throws IOException, RestoreSnapshotException;
1114
1115 /**
1116 * Restore the specified snapshot on the original table. (The table must be disabled) If the
1117 * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a
1118 * snapshot of the current table is taken before executing the restore operation. In case of
1119 * restore failure, the failsafe snapshot will be restored. If the restore completes without
1120 * problem the failsafe snapshot is deleted.
1121 *
1122 * @param snapshotName name of the snapshot to restore
1123 * @throws IOException if a remote or network exception occurs
1124 * @throws RestoreSnapshotException if snapshot failed to be restored
1125 * @throws IllegalArgumentException if the restore request is formatted incorrectly
1126 */
1127 void restoreSnapshot(final String snapshotName) throws IOException, RestoreSnapshotException;
1128
1129 /**
1130 * Restore the specified snapshot on the original table. (The table must be disabled) If
1131 * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before
1132 * executing the restore operation. In case of restore failure, the failsafe snapshot will be
1133 * restored. If the restore completes without problem the failsafe snapshot is deleted. The
1134 * failsafe snapshot name is configurable by using the property
1135 * "hbase.snapshot.restore.failsafe.name".
1136 *
1137 * @param snapshotName name of the snapshot to restore
1138 * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken
1139 * @throws IOException if a remote or network exception occurs
1140 * @throws RestoreSnapshotException if snapshot failed to be restored
1141 * @throws IllegalArgumentException if the restore request is formatted incorrectly
1142 */
1143 void restoreSnapshot(final byte[] snapshotName, final boolean takeFailSafeSnapshot)
1144 throws IOException, RestoreSnapshotException;
1145
1146 /**
1147 * Restore the specified snapshot on the original table. (The table must be disabled) If
1148 * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before
1149 * executing the restore operation. In case of restore failure, the failsafe snapshot will be
1150 * restored. If the restore completes without problem the failsafe snapshot is deleted. The
1151 * failsafe snapshot name is configurable by using the property
1152 * "hbase.snapshot.restore.failsafe.name".
1153 *
1154 * @param snapshotName name of the snapshot to restore
1155 * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken
1156 * @throws IOException if a remote or network exception occurs
1157 * @throws RestoreSnapshotException if snapshot failed to be restored
1158 * @throws IllegalArgumentException if the restore request is formatted incorrectly
1159 */
1160 void restoreSnapshot(final String snapshotName, boolean takeFailSafeSnapshot)
1161 throws IOException, RestoreSnapshotException;
1162
1163 /**
1164 * Create a new table by cloning the snapshot content.
1165 *
1166 * @param snapshotName name of the snapshot to be cloned
1167 * @param tableName name of the table where the snapshot will be restored
1168 * @throws IOException if a remote or network exception occurs
1169 * @throws TableExistsException if table to be created already exists
1170 * @throws RestoreSnapshotException if snapshot failed to be cloned
1171 * @throws IllegalArgumentException if the specified table has not a valid name
1172 */
1173 void cloneSnapshot(final byte[] snapshotName, final TableName tableName)
1174 throws IOException, TableExistsException, RestoreSnapshotException;
1175
1176 /**
1177 * Create a new table by cloning the snapshot content.
1178 *
1179 * @param snapshotName name of the snapshot to be cloned
1180 * @param tableName name of the table where the snapshot will be restored
1181 * @throws IOException if a remote or network exception occurs
1182 * @throws TableExistsException if table to be created already exists
1183 * @throws RestoreSnapshotException if snapshot failed to be cloned
1184 * @throws IllegalArgumentException if the specified table has not a valid name
1185 */
1186 void cloneSnapshot(final String snapshotName, final TableName tableName)
1187 throws IOException, TableExistsException, RestoreSnapshotException;
1188
1189 /**
1190 * Execute a distributed procedure on a cluster.
1191 *
1192 * @param signature A distributed procedure is uniquely identified by its signature (default the
1193 * root ZK node name of the procedure).
1194 * @param instance The instance name of the procedure. For some procedures, this parameter is
1195 * optional.
1196 * @param props Property/Value pairs of properties passing to the procedure
1197 * @throws IOException
1198 */
1199 void execProcedure(String signature, String instance, Map<String, String> props)
1200 throws IOException;
1201
1202 /**
1203 * Execute a distributed procedure on a cluster.
1204 *
1205 * @param signature A distributed procedure is uniquely identified by its signature (default the
1206 * root ZK node name of the procedure).
1207 * @param instance The instance name of the procedure. For some procedures, this parameter is
1208 * optional.
1209 * @param props Property/Value pairs of properties passing to the procedure
1210 * @return data returned after procedure execution. null if no return data.
1211 * @throws IOException
1212 */
1213 byte[] execProcedureWithRet(String signature, String instance, Map<String, String> props)
1214 throws IOException;
1215
1216 /**
1217 * Check the current state of the specified procedure. There are three possible states: <ol>
1218 * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li>
1219 * <li>finished with error - throws the exception that caused the procedure to fail</li> </ol>
1220 *
1221 * @param signature The signature that uniquely identifies a procedure
1222 * @param instance The instance name of the procedure
1223 * @param props Property/Value pairs of properties passing to the procedure
1224 * @return true if the specified procedure is finished successfully, false if it is still running
1225 * @throws IOException if the specified procedure finished with error
1226 */
1227 boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
1228 throws IOException;
1229
1230 /**
1231 * List completed snapshots.
1232 *
1233 * @return a list of snapshot descriptors for completed snapshots
1234 * @throws IOException if a network error occurs
1235 */
1236 List<HBaseProtos.SnapshotDescription> listSnapshots() throws IOException;
1237
1238 /**
1239 * List all the completed snapshots matching the given regular expression.
1240 *
1241 * @param regex The regular expression to match against
1242 * @return - returns a List of SnapshotDescription
1243 * @throws IOException if a remote or network exception occurs
1244 */
1245 List<HBaseProtos.SnapshotDescription> listSnapshots(String regex) throws IOException;
1246
1247 /**
1248 * List all the completed snapshots matching the given pattern.
1249 *
1250 * @param pattern The compiled regular expression to match against
1251 * @return - returns a List of SnapshotDescription
1252 * @throws IOException if a remote or network exception occurs
1253 */
1254 List<HBaseProtos.SnapshotDescription> listSnapshots(Pattern pattern) throws IOException;
1255
1256 /**
1257 * Delete an existing snapshot.
1258 *
1259 * @param snapshotName name of the snapshot
1260 * @throws IOException if a remote or network exception occurs
1261 */
1262 void deleteSnapshot(final byte[] snapshotName) throws IOException;
1263
1264 /**
1265 * Delete an existing snapshot.
1266 *
1267 * @param snapshotName name of the snapshot
1268 * @throws IOException if a remote or network exception occurs
1269 */
1270 void deleteSnapshot(final String snapshotName) throws IOException;
1271
1272 /**
1273 * Delete existing snapshots whose names match the pattern passed.
1274 *
1275 * @param regex The regular expression to match against
1276 * @throws IOException if a remote or network exception occurs
1277 */
1278 void deleteSnapshots(final String regex) throws IOException;
1279
1280 /**
1281 * Delete existing snapshots whose names match the pattern passed.
1282 *
1283 * @param pattern pattern for names of the snapshot to match
1284 * @throws IOException if a remote or network exception occurs
1285 */
1286 void deleteSnapshots(final Pattern pattern) throws IOException;
1287
1288 /**
1289 * Apply the new quota settings.
1290 * @param quota the quota settings
1291 * @throws IOException if a remote or network exception occurs
1292 */
1293 void setQuota(final QuotaSettings quota) throws IOException;
1294
1295 /**
1296 * Return a QuotaRetriever to list the quotas based on the filter.
1297 * @param filter the quota settings filter
1298 * @return the quota retriever
1299 * @throws IOException if a remote or network exception occurs
1300 */
1301 QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOException;
1302
1303 /**
1304 * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the active
1305 * master. <p> The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access
1306 * a published coprocessor {@link com.google.protobuf.Service} using standard protobuf service
1307 * invocations: </p> <div style="background-color: #cccccc; padding: 2px">
1308 * <blockquote><pre>
1309 * CoprocessorRpcChannel channel = myAdmin.coprocessorService();
1310 * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
1311 * MyCallRequest request = MyCallRequest.newBuilder()
1312 * ...
1313 * .build();
1314 * MyCallResponse response = service.myCall(null, request);
1315 * </pre></blockquote></div>
1316 *
1317 * @return A MasterCoprocessorRpcChannel instance
1318 */
1319 CoprocessorRpcChannel coprocessorService();
1320
1321
1322 /**
1323 * Creates and returns a {@link com.google.protobuf.RpcChannel} instance
1324 * connected to the passed region server.
1325 *
1326 * <p>
1327 * The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access a published
1328 * coprocessor {@link com.google.protobuf.Service} using standard protobuf service invocations:
1329 * </p>
1330 *
1331 * <div style="background-color: #cccccc; padding: 2px">
1332 * <blockquote><pre>
1333 * CoprocessorRpcChannel channel = myAdmin.coprocessorService(serverName);
1334 * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
1335 * MyCallRequest request = MyCallRequest.newBuilder()
1336 * ...
1337 * .build();
1338 * MyCallResponse response = service.myCall(null, request);
1339 * </pre></blockquote></div>
1340 *
1341 * @param sn the server name to which the endpoint call is made
1342 * @return A RegionServerCoprocessorRpcChannel instance
1343 */
1344 CoprocessorRpcChannel coprocessorService(ServerName sn);
1345
1346
1347 /**
1348 * Update the configuration and trigger an online config change
1349 * on the regionserver
1350 * @param server : The server whose config needs to be updated.
1351 * @throws IOException
1352 */
1353 void updateConfiguration(ServerName server) throws IOException;
1354
1355
1356 /**
1357 * Update the configuration and trigger an online config change
1358 * on all the regionservers
1359 * @throws IOException
1360 */
1361 void updateConfiguration() throws IOException;
1362
1363 /**
1364 * Get the info port of the current master if one is available.
1365 * @return master info port
1366 * @throws IOException
1367 */
1368 public int getMasterInfoPort() throws IOException;
1369 }