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 */
029@InterfaceAudience.Private
030public interface TableDescriptors {
031  /**
032   * @return TableDescriptor for tablename
033   */
034  TableDescriptor get(final TableName tableName) throws IOException;
035
036  /**
037   * Get Map of all NamespaceDescriptors for a given namespace.
038   * @return Map of all descriptors.
039   */
040  Map<String, TableDescriptor> getByNamespace(String name) throws IOException;
041
042  /**
043   * Get Map of all TableDescriptors. Populates the descriptor cache as a
044   * side effect.
045   * Notice: the key of map is the table name which contains namespace. It was generated by
046   * {@link TableName#getNameWithNamespaceInclAsString()}.
047   * @return Map of all descriptors.
048   */
049  Map<String, TableDescriptor> getAll() throws IOException;
050
051  /**
052   * Add or update descriptor
053   * @param htd Descriptor to set into TableDescriptors
054   */
055  void update(final TableDescriptor htd) throws IOException;
056
057  /**
058   * @return Instance of table descriptor or null if none found.
059   */
060  TableDescriptor remove(final TableName tablename) throws IOException;
061
062  /**
063   * Enables the tabledescriptor cache
064   */
065  void setCacheOn() throws IOException;
066
067  /**
068   * Disables the tabledescriptor cache
069   */
070  void setCacheOff() throws IOException;
071}