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