HBASE-21843 RegionGroupingProvider breaks the meta wal file name pattern which may...
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / master / ClusterSchema.java
blob56a1f3378ded1d67e535368ca5a97a9d0411d9eb
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.apache.hadoop.hbase.master;
20 import java.io.IOException;
21 import java.io.InterruptedIOException;
22 import java.util.List;
24 import org.apache.hadoop.hbase.NamespaceDescriptor;
25 import org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch;
26 import org.apache.yetus.audience.InterfaceAudience;
27 import org.apache.hadoop.hbase.util.NonceKey;
29 /**
30 * View and edit the current cluster schema. Use this API making any modification to
31 * namespaces, tables, etc.
33 * <h2>Implementation Notes</h2>
34 * Nonces are for when operation is non-idempotent to ensure once-only semantic, even
35 * across process failures.
37 // ClusterSchema is introduced to encapsulate schema modification. Currently the different aspects
38 // are spread about the code base. This effort is about cleanup, shutting down access, and
39 // coalescing common code. In particular, we'd contain filesystem modification. Other
40 // benefits are to make all schema modification work the same way (one way to do an operation only
41 // rather than the current approach where how an operation is done varies with context) and to make
42 // it so clusterschema modification can stand apart from Master to faciliate standalone
43 // testing. It is part of the filesystem refactor project that undoes the dependency on a
44 // layout in HDFS that mimics our model of tables have regions have column families have files.
45 // With this Interface in place, with all modifications going via this route where no filesystem
46 // particulars are exposed, redoing our internals will take less effort.
48 // Currently ClusterSchema Interface will include namespace and table manipulation. Ideally a
49 // form of this Interface will go all the ways down to the file manipulation level but currently
50 // TBD.
52 // ClusterSchema is private to the Master; only the Master knows current cluster state and has
53 // means of editing/altering it.
55 // TODO: Remove Server argument when MasterServices are passed.
56 // TODO: We return Future<ProcedureInfo> in the below from most methods. It may change to return
57 // a ProcedureFuture subsequently.
58 @InterfaceAudience.Private
59 public interface ClusterSchema {
60 /**
61 * Timeout for cluster operations in milliseconds.
63 public static final String HBASE_MASTER_CLUSTER_SCHEMA_OPERATION_TIMEOUT_KEY =
64 "hbase.master.cluster.schema.operation.timeout";
65 /**
66 * Default operation timeout in milliseconds.
68 public static final int DEFAULT_HBASE_MASTER_CLUSTER_SCHEMA_OPERATION_TIMEOUT =
69 5 * 60 * 1000;
71 /**
72 * For internals use only. Do not use! Provisionally part of this Interface.
73 * Prefer the high-level APIs available elsewhere in this API.
74 * @return Instance of {@link TableNamespaceManager}
76 // TODO: Remove from here. Keep internal. This Interface is too high-level to host this accessor.
77 TableNamespaceManager getTableNamespaceManager();
79 /**
80 * Create a new Namespace.
81 * @param namespaceDescriptor descriptor for new Namespace
82 * @param nonceKey A unique identifier for this operation from the client or process.
83 * @param latch A latch to block on for precondition validation
84 * @return procedure id
85 * @throws IOException Throws {@link ClusterSchemaException} and {@link InterruptedIOException}
86 * as well as {@link IOException}
88 long createNamespace(NamespaceDescriptor namespaceDescriptor, NonceKey nonceKey, ProcedurePrepareLatch latch)
89 throws IOException;
91 /**
92 * Modify an existing Namespace.
93 * @param nonceKey A unique identifier for this operation from the client or process.
94 * @param latch A latch to block on for precondition validation
95 * @return procedure id
96 * @throws IOException Throws {@link ClusterSchemaException} and {@link InterruptedIOException}
97 * as well as {@link IOException}
99 long modifyNamespace(NamespaceDescriptor descriptor, NonceKey nonceKey, ProcedurePrepareLatch latch)
100 throws IOException;
103 * Delete an existing Namespace.
104 * Only empty Namespaces (no tables) can be removed.
105 * @param nonceKey A unique identifier for this operation from the client or process.
106 * @param latch A latch to block on for precondition validation
107 * @return procedure id
108 * @throws IOException Throws {@link ClusterSchemaException} and {@link InterruptedIOException}
109 * as well as {@link IOException}
111 long deleteNamespace(String name, NonceKey nonceKey, ProcedurePrepareLatch latch)
112 throws IOException;
115 * Get a Namespace
116 * @param name Name of the Namespace
117 * @return Namespace descriptor for <code>name</code>
118 * @throws IOException Throws {@link ClusterSchemaException} and {@link InterruptedIOException}
119 * as well as {@link IOException}
121 // No Future here because presumption is that the request will go against cached metadata so
122 // return immediately -- no need of running a Procedure.
123 NamespaceDescriptor getNamespace(String name) throws IOException;
126 * Get all Namespaces
127 * @return All Namespace descriptors
129 List<NamespaceDescriptor> getNamespaces() throws IOException;