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
20 package org.apache.hadoop.hbase.client;
21
22 import org.apache.hadoop.classification.InterfaceAudience;
23 import org.apache.hadoop.classification.InterfaceStability;
24 import org.apache.hadoop.hbase.HColumnDescriptor;
25 import org.apache.hadoop.hbase.HTableDescriptor;
26
27 /**
28 * Read-only table descriptor.
29 */
30 @InterfaceAudience.Public
31 @InterfaceStability.Evolving
32 public class UnmodifyableHTableDescriptor extends HTableDescriptor {
33 /** Default constructor */
34 public UnmodifyableHTableDescriptor() {
35 super();
36 }
37
38 /*
39 * Create an unmodifyable copy of an HTableDescriptor
40 * @param desc
41 */
42 UnmodifyableHTableDescriptor(final HTableDescriptor desc) {
43 super(desc.getTableName(), getUnmodifyableFamilies(desc), desc.getValues());
44 }
45
46
47 /*
48 * @param desc
49 * @return Families as unmodifiable array.
50 */
51 private static HColumnDescriptor[] getUnmodifyableFamilies(
52 final HTableDescriptor desc) {
53 HColumnDescriptor [] f = new HColumnDescriptor[desc.getFamilies().size()];
54 int i = 0;
55 for (HColumnDescriptor c: desc.getFamilies()) {
56 f[i++] = c;
57 }
58 return f;
59 }
60
61 /**
62 * Does NOT add a column family. This object is immutable
63 * @param family HColumnDescriptor of familyto add.
64 */
65 @Override
66 public void addFamily(final HColumnDescriptor family) {
67 throw new UnsupportedOperationException("HTableDescriptor is read-only");
68 }
69
70 /**
71 * @param column
72 * @return Column descriptor for the passed family name or the family on
73 * passed in column.
74 */
75 @Override
76 public HColumnDescriptor removeFamily(final byte [] column) {
77 throw new UnsupportedOperationException("HTableDescriptor is read-only");
78 }
79
80 /**
81 * @see org.apache.hadoop.hbase.HTableDescriptor#setReadOnly(boolean)
82 */
83 @Override
84 public void setReadOnly(boolean readOnly) {
85 throw new UnsupportedOperationException("HTableDescriptor is read-only");
86 }
87
88 /**
89 * @see org.apache.hadoop.hbase.HTableDescriptor#setValue(byte[], byte[])
90 */
91 @Override
92 public void setValue(byte[] key, byte[] value) {
93 throw new UnsupportedOperationException("HTableDescriptor is read-only");
94 }
95
96 /**
97 * @see org.apache.hadoop.hbase.HTableDescriptor#setValue(java.lang.String, java.lang.String)
98 */
99 @Override
100 public void setValue(String key, String value) {
101 throw new UnsupportedOperationException("HTableDescriptor is read-only");
102 }
103
104 /**
105 * @see org.apache.hadoop.hbase.HTableDescriptor#setMaxFileSize(long)
106 */
107 @Override
108 public void setMaxFileSize(long maxFileSize) {
109 throw new UnsupportedOperationException("HTableDescriptor is read-only");
110 }
111
112 /**
113 * @see org.apache.hadoop.hbase.HTableDescriptor#setMemStoreFlushSize(long)
114 */
115 @Override
116 public void setMemStoreFlushSize(long memstoreFlushSize) {
117 throw new UnsupportedOperationException("HTableDescriptor is read-only");
118 }
119
120 // /**
121 // * @see org.apache.hadoop.hbase.HTableDescriptor#addIndex(org.apache.hadoop.hbase.client.tableindexed.IndexSpecification)
122 // */
123 // @Override
124 // public void addIndex(IndexSpecification index) {
125 // throw new UnsupportedOperationException("HTableDescriptor is read-only");
126 // }
127 }