1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
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.concurrent.Future;
25
26 import org.apache.hadoop.hbase.TableName;
27 import org.apache.hadoop.hbase.backup.BackupInfo;
28 import org.apache.hadoop.hbase.backup.BackupRequest;
29 import org.apache.hadoop.hbase.backup.RestoreRequest;
30 import org.apache.hadoop.hbase.backup.util.BackupSet;
31 import org.apache.hadoop.hbase.classification.InterfaceAudience;
32 import org.apache.hadoop.hbase.classification.InterfaceStability;
33 /**
34 * The administrative API for HBase Backup. Obtain an instance from
35 * an {@link Admin#getBackupAdmin()} and call {@link #close()} afterwards.
36 * <p>BackupAdmin can be used to create backups, restore data from backups and for
37 * other backup-related operations.
38 *
39 * @see Admin
40 * @since 2.0
41 */
42 @InterfaceAudience.Public
43 @InterfaceStability.Evolving
44
45 public interface BackupAdmin extends Closeable{
46
47 /**
48 * Backs up given list of tables fully. Synchronous operation.
49 *
50 * @param request BackupRequest instance which contains the following members:
51 * type whether the backup is full or incremental
52 * tableList list of tables to backup
53 * targetRootDir root directory for saving the backup
54 * workers number of parallel workers. -1 - system defined
55 * bandwidth bandwidth per worker in MB per second. -1 - unlimited
56 * @return the backup Id
57 */
58
59 public String backupTables(final BackupRequest userRequest) throws IOException;
60
61 /**
62 * Backs up given list of tables fully. Asynchronous operation.
63 *
64 * @param request BackupRequest instance which contains the following members:
65 * type whether the backup is full or incremental
66 * tableList list of tables to backup
67 * targetRootDir root dir for saving the backup
68 * workers number of paralle workers. -1 - system defined
69 * bandwidth bandwidth per worker in MB per sec. -1 - unlimited
70 * @return the backup Id future
71 */
72 public Future<String> backupTablesAsync(final BackupRequest userRequest) throws IOException;
73
74 /**
75 * Describe backup image command
76 * @param backupId - backup id
77 * @return backup info
78 * @throws IOException exception
79 */
80 public BackupInfo getBackupInfo(String backupId) throws IOException;
81
82 /**
83 * Show backup progress command
84 * @param backupId - backup id (may be null)
85 * @return backup progress (0-100%), -1 if no active sessions
86 * or session not found
87 * @throws IOException exception
88 */
89 public int getProgress(String backupId) throws IOException;
90
91 /**
92 * Delete backup image command
93 * @param backupIds - backup id
94 * @return total number of deleted sessions
95 * @throws IOException exception
96 */
97 public int deleteBackups(String[] backupIds) throws IOException;
98
99 /**
100 * Show backup history command
101 * @param n - last n backup sessions
102 * @return list of backup infos
103 * @throws IOException exception
104 */
105 public List<BackupInfo> getHistory(int n) throws IOException;
106
107 /**
108 * Backup sets list command - list all backup sets. Backup set is
109 * a named group of tables.
110 * @return all registered backup sets
111 * @throws IOException exception
112 */
113 public List<BackupSet> listBackupSets() throws IOException;
114
115 /**
116 * Backup set describe command. Shows list of tables in
117 * this particular backup set.
118 * @param name set name
119 * @return backup set description or null
120 * @throws IOException exception
121 */
122 public BackupSet getBackupSet(String name) throws IOException;
123
124 /**
125 * Delete backup set command
126 * @param name - backup set name
127 * @return true, if success, false - otherwise
128 * @throws IOException exception
129 */
130 public boolean deleteBackupSet(String name) throws IOException;
131
132 /**
133 * Add tables to backup set command
134 * @param name - name of backup set.
135 * @param tables - list of tables to be added to this set.
136 * @throws IOException exception
137 */
138 public void addToBackupSet(String name, TableName[] tables) throws IOException;
139
140 /**
141 * Remove tables from backup set
142 * @param name - name of backup set.
143 * @param tables - list of tables to be removed from this set.
144 * @throws IOException exception
145 */
146 public void removeFromBackupSet(String name, String[] tables) throws IOException;
147
148 /**
149 * Restore backup
150 * @param request - restore request
151 * @throws IOException exception
152 */
153 public void restore(RestoreRequest request) throws IOException;
154
155 }