001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase;
019
020import java.io.IOException;
021import java.util.Map;
022
023import org.apache.yetus.audience.InterfaceAudience;
024import org.apache.hadoop.hbase.client.TableDescriptor;
025
026/**
027 * Get, remove and modify table descriptors.
028 * Used by servers to host descriptors.
029 */
030@InterfaceAudience.Private
031public interface TableDescriptors {
032  /**
033   * @param tableName
034   * @return TableDescriptor for tablename
035   * @throws IOException
036   */
037  TableDescriptor get(final TableName tableName)
038      throws IOException;
039
040  /**
041   * Get Map of all NamespaceDescriptors for a given namespace.
042   * @return Map of all descriptors.
043   * @throws IOException
044   */
045  Map<String, TableDescriptor> getByNamespace(String name)
046  throws IOException;
047
048  /**
049   * Get Map of all TableDescriptors. Populates the descriptor cache as a
050   * side effect.
051   * Notice: the key of map is the table name which contains namespace. It was generated by
052   * {@link TableName#getNameWithNamespaceInclAsString()}.
053   * @return Map of all descriptors.
054   * @throws IOException
055   */
056  Map<String, TableDescriptor> getAll() throws IOException;
057
058  /**
059   * Add or update descriptor
060   * @param htd Descriptor to set into TableDescriptors
061   * @throws IOException
062   */
063  void add(final TableDescriptor htd)
064  throws IOException;
065
066  /**
067   * @param tablename
068   * @return Instance of table descriptor or null if none found.
069   * @throws IOException
070   */
071  TableDescriptor remove(final TableName tablename)
072  throws IOException;
073
074  /**
075   * Enables the tabledescriptor cache
076   */
077  void setCacheOn() throws IOException;
078
079  /**
080   * Disables the tabledescriptor cache
081   */
082  void setCacheOff() throws IOException;
083}