View Javadoc

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  
23  import org.apache.hadoop.classification.InterfaceAudience;
24  import org.apache.hadoop.hbase.HColumnDescriptor;
25  import org.apache.hadoop.hbase.HRegionInfo;
26  import org.apache.hadoop.hbase.HTableDescriptor;
27  import org.apache.hadoop.hbase.Server;
28  import org.apache.hadoop.hbase.TableDescriptors;
29  import org.apache.hadoop.hbase.exceptions.TableNotDisabledException;
30  import org.apache.hadoop.hbase.exceptions.TableNotFoundException;
31  import org.apache.hadoop.hbase.executor.ExecutorService;
32  
33  import com.google.protobuf.Service;
34  
35  /**
36   * Services Master supplies
37   */
38  @InterfaceAudience.Private
39  public interface MasterServices extends Server {
40    /**
41     * @return Master's instance of the {@link AssignmentManager}
42     */
43    public AssignmentManager getAssignmentManager();
44  
45    /**
46     * @return Master's filesystem {@link MasterFileSystem} utility class.
47     */
48    public MasterFileSystem getMasterFileSystem();
49  
50    /**
51     * @return Master's {@link ServerManager} instance.
52     */
53    public ServerManager getServerManager();
54  
55    /**
56     * @return Master's instance of {@link ExecutorService}
57     */
58    public ExecutorService getExecutorService();
59  
60    /**
61     * @return Master's instance of {@link TableLockManager}
62     */
63    public TableLockManager getTableLockManager();
64  
65    /**
66     * @return Master's instance of {@link MasterCoprocessorHost}
67     */
68    public MasterCoprocessorHost getCoprocessorHost();
69  
70    /**
71     * Check table is modifiable; i.e. exists and is offline.
72     * @param tableName Name of table to check.
73     * @throws TableNotDisabledException
74     * @throws TableNotFoundException
75     * @throws IOException
76     */
77    // We actually throw the exceptions mentioned in the
78    public void checkTableModifiable(final byte [] tableName)
79        throws IOException, TableNotFoundException, TableNotDisabledException;
80  
81    /**
82     * Create a table using the given table definition.
83     * @param desc The table definition
84     * @param splitKeys Starting row keys for the initial table regions.  If null
85     *     a single region is created.
86     */
87    public void createTable(HTableDescriptor desc, byte [][] splitKeys)
88        throws IOException;
89  
90    /**
91     * Delete a table
92     * @param tableName The table name
93     * @throws IOException
94     */
95    public void deleteTable(final byte[] tableName) throws IOException;
96  
97    /**
98     * Modify the descriptor of an existing table
99     * @param tableName The table name
100    * @param descriptor The updated table descriptor
101    * @throws IOException
102    */
103   public void modifyTable(final byte[] tableName, final HTableDescriptor descriptor)
104       throws IOException;
105 
106   /**
107    * Enable an existing table
108    * @param tableName The table name
109    * @throws IOException
110    */
111   public void enableTable(final byte[] tableName) throws IOException;
112 
113   /**
114    * Disable an existing table
115    * @param tableName The table name
116    * @throws IOException
117    */
118   public void disableTable(final byte[] tableName) throws IOException;
119 
120   /**
121    * Add a new column to an existing table
122    * @param tableName The table name
123    * @param column The column definition
124    * @throws IOException
125    */
126   public void addColumn(final byte[] tableName, final HColumnDescriptor column)
127       throws IOException;
128 
129   /**
130    * Modify the column descriptor of an existing column in an existing table
131    * @param tableName The table name
132    * @param descriptor The updated column definition
133    * @throws IOException
134    */
135   public void modifyColumn(byte[] tableName, HColumnDescriptor descriptor)
136       throws IOException;
137 
138   /**
139    * Delete a column from an existing table
140    * @param tableName The table name
141    * @param columnName The column name
142    * @throws IOException
143    */
144   public void deleteColumn(final byte[] tableName, final byte[] columnName)
145       throws IOException;
146 
147   /**
148    * @return Return table descriptors implementation.
149    */
150   public TableDescriptors getTableDescriptors();
151 
152   /**
153    * @return true if master enables ServerShutdownHandler;
154    */
155   public boolean isServerShutdownHandlerEnabled();
156 
157   /**
158    * Registers a new protocol buffer {@link Service} subclass as a master coprocessor endpoint to
159    * be available for handling
160    * {@link org.apache.hadoop.hbase.MasterAdminProtocol#execMasterService(com.google.protobuf.RpcController,
161    * org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceRequest)} calls.
162    *
163    * <p>
164    * Only a single instance may be registered for a given {@link Service} subclass (the
165    * instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}.
166    * After the first registration, subsequent calls with the same service name will fail with
167    * a return value of {@code false}.
168    * </p>
169    * @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
170    * @return {@code true} if the registration was successful, {@code false}
171    * otherwise
172    */
173   public boolean registerService(Service instance);
174 
175   /**
176    * Merge two regions. The real implementation is on the regionserver, master
177    * just move the regions together and send MERGE RPC to regionserver
178    * @param region_a region to merge
179    * @param region_b region to merge
180    * @param forcible true if do a compulsory merge, otherwise we will only merge
181    *          two adjacent regions
182    * @throws IOException
183    */
184   public void dispatchMergingRegions(final HRegionInfo region_a,
185       final HRegionInfo region_b, final boolean forcible) throws IOException;
186 
187 }