1 /** 2 * Copyright 2010 The Apache Software Foundation 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 package org.apache.hadoop.hbase.master; 21 22 import java.io.IOException; 23 24 import org.apache.hadoop.hbase.HColumnDescriptor; 25 import org.apache.hadoop.hbase.HTableDescriptor; 26 import org.apache.hadoop.hbase.Server; 27 import org.apache.hadoop.hbase.TableDescriptors; 28 import org.apache.hadoop.hbase.executor.ExecutorService; 29 import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; 30 31 /** 32 * Services Master supplies 33 */ 34 public interface MasterServices extends Server { 35 /** 36 * @return Master's instance of the {@link AssignmentManager} 37 */ 38 public AssignmentManager getAssignmentManager(); 39 40 /** 41 * @return Master's filesystem {@link MasterFileSystem} utility class. 42 */ 43 public MasterFileSystem getMasterFileSystem(); 44 45 /** 46 * @return Master's {@link ServerManager} instance. 47 */ 48 public ServerManager getServerManager(); 49 50 /** 51 * @return Master's instance of {@link ExecutorService} 52 */ 53 public ExecutorService getExecutorService(); 54 55 /** 56 * Check table is modifiable; i.e. exists and is offline. 57 * @param tableName Name of table to check. 58 * @throws TableNotDisabledException 59 * @throws TableNotFoundException 60 */ 61 public void checkTableModifiable(final byte [] tableName) throws IOException; 62 63 /** 64 * Create a table using the given table definition. 65 * @param desc The table definition 66 * @param splitKeys Starting row keys for the initial table regions. If null 67 * a single region is created. 68 */ 69 public void createTable(HTableDescriptor desc, byte [][] splitKeys) 70 throws IOException; 71 72 /** 73 * Delete a table 74 * @param tableName The table name 75 * @throws IOException 76 */ 77 public void deleteTable(final byte[] tableName) throws IOException; 78 79 /** 80 * Modify the descriptor of an existing table 81 * @param tableName The table name 82 * @param descriptor The updated table descriptor 83 * @throws IOException 84 */ 85 public void modifyTable(final byte[] tableName, final HTableDescriptor descriptor) 86 throws IOException; 87 88 /** 89 * Enable an existing table 90 * @param tableName The table name 91 * @throws IOException 92 */ 93 public void enableTable(final byte[] tableName) throws IOException; 94 95 /** 96 * Disable an existing table 97 * @param tableName The table name 98 * @throws IOException 99 */ 100 public void disableTable(final byte[] tableName) throws IOException; 101 102 /** 103 * Add a new column to an existing table 104 * @param tableName The table name 105 * @param column The column definition 106 * @throws IOException 107 */ 108 public void addColumn(final byte[] tableName, final HColumnDescriptor column) 109 throws IOException; 110 111 /** 112 * Modify the column descriptor of an existing column in an existing table 113 * @param tableName The table name 114 * @param descriptor The updated column definition 115 * @throws IOException 116 */ 117 public void modifyColumn(byte[] tableName, HColumnDescriptor descriptor) 118 throws IOException; 119 120 /** 121 * Delete a column from an existing table 122 * @param tableName The table name 123 * @param columnName The column name 124 * @throws IOException 125 */ 126 public void deleteColumn(final byte[] tableName, final byte[] columnName) 127 throws IOException; 128 129 /** 130 * @return Return table descriptors implementation. 131 */ 132 public TableDescriptors getTableDescriptors(); 133 134 /** 135 * @return true if master enables ServerShutdownHandler; 136 */ 137 public boolean isServerShutdownHandlerEnabled(); 138 139 /** 140 * @return true if master thinks that meta hlogs should be split separately 141 */ 142 public boolean shouldSplitMetaSeparately(); 143 144 /** 145 * @return returns the master coprocessor host 146 */ 147 public MasterCoprocessorHost getCoprocessorHost(); 148 149 /** 150 * Registers a new CoprocessorProtocol subclass and instance to 151 * be available for handling 152 * {@link HMaster#execCoprocessor(org.apache.hadoop.hbase.client.coprocessor.Exec)} calls. 153 * 154 * <p> 155 * Only a single protocol type/handler combination may be registered. 156 * 157 * After the first registration, subsequent calls with the same protocol type 158 * will fail with a return value of {@code false}. 159 * </p> 160 * @param protocol a {@code CoprocessorProtocol} subinterface defining the 161 * protocol methods 162 * @param handler an instance implementing the interface 163 * @param <T> the protocol type 164 * @return {@code true} if the registration was successful, {@code false} 165 * otherwise 166 */ 167 public <T extends CoprocessorProtocol> boolean registerProtocol( 168 Class<T> protocol, T handler); 169 }