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.master; 20 21 import java.io.IOException; 22 import java.util.List; 23 24 import org.apache.hadoop.classification.InterfaceAudience; 25 import org.apache.hadoop.hbase.TableName; 26 import org.apache.hadoop.hbase.HColumnDescriptor; 27 import org.apache.hadoop.hbase.HRegionInfo; 28 import org.apache.hadoop.hbase.HTableDescriptor; 29 import org.apache.hadoop.hbase.NamespaceDescriptor; 30 import org.apache.hadoop.hbase.Server; 31 import org.apache.hadoop.hbase.TableDescriptors; 32 import org.apache.hadoop.hbase.TableNotDisabledException; 33 import org.apache.hadoop.hbase.TableNotFoundException; 34 import org.apache.hadoop.hbase.executor.ExecutorService; 35 36 import com.google.protobuf.Service; 37 38 /** 39 * Services Master supplies 40 */ 41 @InterfaceAudience.Private 42 public interface MasterServices extends Server { 43 /** 44 * @return Master's instance of the {@link AssignmentManager} 45 */ 46 AssignmentManager getAssignmentManager(); 47 48 /** 49 * @return Master's filesystem {@link MasterFileSystem} utility class. 50 */ 51 MasterFileSystem getMasterFileSystem(); 52 53 /** 54 * @return Master's {@link ServerManager} instance. 55 */ 56 ServerManager getServerManager(); 57 58 /** 59 * @return Master's instance of {@link ExecutorService} 60 */ 61 ExecutorService getExecutorService(); 62 63 /** 64 * @return Master's instance of {@link TableLockManager} 65 */ 66 TableLockManager getTableLockManager(); 67 68 /** 69 * @return Master's instance of {@link MasterCoprocessorHost} 70 */ 71 MasterCoprocessorHost getCoprocessorHost(); 72 73 /** 74 * Check table is modifiable; i.e. exists and is offline. 75 * @param tableName Name of table to check. 76 * @throws TableNotDisabledException 77 * @throws TableNotFoundException 78 * @throws IOException 79 */ 80 // We actually throw the exceptions mentioned in the 81 void checkTableModifiable(final TableName tableName) 82 throws IOException, TableNotFoundException, TableNotDisabledException; 83 84 /** 85 * Create a table using the given table definition. 86 * @param desc The table definition 87 * @param splitKeys Starting row keys for the initial table regions. If null 88 * a single region is created. 89 */ 90 void createTable(HTableDescriptor desc, byte[][] splitKeys) 91 throws IOException; 92 93 /** 94 * Delete a table 95 * @param tableName The table name 96 * @throws IOException 97 */ 98 void deleteTable(final TableName tableName) throws IOException; 99 100 /** 101 * Modify the descriptor of an existing table 102 * @param tableName The table name 103 * @param descriptor The updated table descriptor 104 * @throws IOException 105 */ 106 void modifyTable(final TableName tableName, final HTableDescriptor descriptor) 107 throws IOException; 108 109 /** 110 * Enable an existing table 111 * @param tableName The table name 112 * @throws IOException 113 */ 114 void enableTable(final TableName tableName) throws IOException; 115 116 /** 117 * Disable an existing table 118 * @param tableName The table name 119 * @throws IOException 120 */ 121 void disableTable(final TableName tableName) throws IOException; 122 123 124 /** 125 * Add a new column to an existing table 126 * @param tableName The table name 127 * @param column The column definition 128 * @throws IOException 129 */ 130 void addColumn(final TableName tableName, final HColumnDescriptor column) 131 throws IOException; 132 133 /** 134 * Modify the column descriptor of an existing column in an existing table 135 * @param tableName The table name 136 * @param descriptor The updated column definition 137 * @throws IOException 138 */ 139 void modifyColumn(TableName tableName, HColumnDescriptor descriptor) 140 throws IOException; 141 142 /** 143 * Delete a column from an existing table 144 * @param tableName The table name 145 * @param columnName The column name 146 * @throws IOException 147 */ 148 void deleteColumn(final TableName tableName, final byte[] columnName) 149 throws IOException; 150 151 /** 152 * @return Return table descriptors implementation. 153 */ 154 TableDescriptors getTableDescriptors(); 155 156 /** 157 * @return true if master enables ServerShutdownHandler; 158 */ 159 boolean isServerShutdownHandlerEnabled(); 160 161 /** 162 * Registers a new protocol buffer {@link Service} subclass as a master coprocessor endpoint. 163 * 164 * <p> 165 * Only a single instance may be registered for a given {@link Service} subclass (the 166 * instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}. 167 * After the first registration, subsequent calls with the same service name will fail with 168 * a return value of {@code false}. 169 * </p> 170 * @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint 171 * @return {@code true} if the registration was successful, {@code false} 172 * otherwise 173 */ 174 boolean registerService(Service instance); 175 176 /** 177 * Merge two regions. The real implementation is on the regionserver, master 178 * just move the regions together and send MERGE RPC to regionserver 179 * @param region_a region to merge 180 * @param region_b region to merge 181 * @param forcible true if do a compulsory merge, otherwise we will only merge 182 * two adjacent regions 183 * @throws IOException 184 */ 185 void dispatchMergingRegions( 186 final HRegionInfo region_a, final HRegionInfo region_b, final boolean forcible 187 ) throws IOException; 188 189 /** 190 * @return true if master is initialized 191 */ 192 boolean isInitialized(); 193 194 /** 195 * Create a new namespace 196 * @param descriptor descriptor which describes the new namespace 197 * @throws IOException 198 */ 199 public void createNamespace(NamespaceDescriptor descriptor) throws IOException; 200 201 /** 202 * Modify an existing namespace 203 * @param descriptor descriptor which updates the existing namespace 204 * @throws IOException 205 */ 206 public void modifyNamespace(NamespaceDescriptor descriptor) throws IOException; 207 208 /** 209 * Delete an existing namespace. Only empty namespaces (no tables) can be removed. 210 * @param name namespace name 211 * @throws IOException 212 */ 213 public void deleteNamespace(String name) throws IOException; 214 215 /** 216 * Get a namespace descriptor by name 217 * @param name name of namespace descriptor 218 * @return A descriptor 219 * @throws IOException 220 */ 221 public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException; 222 223 /** 224 * List available namespace descriptors 225 * @return A descriptor 226 * @throws IOException 227 */ 228 public List<NamespaceDescriptor> listNamespaceDescriptors() throws IOException; 229 230 /** 231 * Get list of table descriptors by namespace 232 * @param name namespace name 233 * @return descriptors 234 * @throws IOException 235 */ 236 public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException; 237 238 /** 239 * Get list of table names by namespace 240 * @param name namespace name 241 * @return table names 242 * @throws IOException 243 */ 244 public List<TableName> listTableNamesByNamespace(String name) throws IOException; 245 }