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