-ROOT- or
* hbase:meta , if the table is read only, the maximum size of the memstore,
* when the region split should occur, coprocessors associated with it etc...
+ * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
+ * use {@link TableDescriptorBuilder} to build {@link HTableDescriptor}.
*/
+@Deprecated
@InterfaceAudience.Public
-public class HTableDescriptor implements Comparable hbase:meta or -ROOT-
- *
- * @see #isMetaRegion()
- */
- public static final String IS_META = "IS_META";
- private static final Bytes IS_META_KEY =
- new Bytes(Bytes.toBytes(IS_META));
-
- /**
- * INTERNAL Used by HBase Shell interface to access this metadata
- * attribute which denotes if the deferred log flush option is enabled.
- * @deprecated Use {@link #DURABILITY} instead.
- */
- @Deprecated
- public static final String DEFERRED_LOG_FLUSH = "DEFERRED_LOG_FLUSH";
- @Deprecated
- private static final Bytes DEFERRED_LOG_FLUSH_KEY =
- new Bytes(Bytes.toBytes(DEFERRED_LOG_FLUSH));
-
- /**
- * INTERNAL {@link Durability} setting for the table.
- */
- public static final String DURABILITY = "DURABILITY";
- private static final Bytes DURABILITY_KEY =
- new Bytes(Bytes.toBytes("DURABILITY"));
-
- /**
- * INTERNAL number of region replicas for the table.
- */
- public static final String REGION_REPLICATION = "REGION_REPLICATION";
- private static final Bytes REGION_REPLICATION_KEY =
- new Bytes(Bytes.toBytes(REGION_REPLICATION));
-
- /**
- * INTERNAL flag to indicate whether or not the memstore should be replicated
- * for read-replicas (CONSISTENCY => TIMELINE).
- */
- public static final String REGION_MEMSTORE_REPLICATION = "REGION_MEMSTORE_REPLICATION";
- private static final Bytes REGION_MEMSTORE_REPLICATION_KEY =
- new Bytes(Bytes.toBytes(REGION_MEMSTORE_REPLICATION));
-
- /**
- * INTERNAL Used by shell/rest interface to access this metadata
- * attribute which denotes if the table should be treated by region normalizer.
- *
- * @see #isNormalizationEnabled()
- */
- public static final String NORMALIZATION_ENABLED = "NORMALIZATION_ENABLED";
- private static final Bytes NORMALIZATION_ENABLED_KEY =
- new Bytes(Bytes.toBytes(NORMALIZATION_ENABLED));
-
- /** Default durability for HTD is USE_DEFAULT, which defaults to HBase-global default value */
- private static final Durability DEFAULT_DURABLITY = Durability.USE_DEFAULT;
-
- public static final String PRIORITY = "PRIORITY";
- private static final Bytes PRIORITY_KEY =
- new Bytes(Bytes.toBytes(PRIORITY));
-
- /** Relative priority of the table used for rpc scheduling */
- private static final int DEFAULT_PRIORITY = HConstants.NORMAL_QOS;
-
- /*
- * The below are ugly but better than creating them each time till we
- * replace booleans being saved as Strings with plain booleans. Need a
- * migration script to do this. TODO.
- */
- private static final Bytes FALSE =
- new Bytes(Bytes.toBytes(Boolean.FALSE.toString()));
-
- private static final Bytes TRUE =
- new Bytes(Bytes.toBytes(Boolean.TRUE.toString()));
-
- private static final boolean DEFAULT_DEFERRED_LOG_FLUSH = false;
-
- /**
- * Constant that denotes whether the table is READONLY by default and is false
- */
- public static final boolean DEFAULT_READONLY = false;
-
- /**
- * Constant that denotes whether the table is compaction enabled by default
- */
- public static final boolean DEFAULT_COMPACTION_ENABLED = true;
-
- /**
- * Constant that denotes whether the table is normalized by default.
- */
- public static final boolean DEFAULT_NORMALIZATION_ENABLED = false;
-
- /**
- * Constant that denotes the maximum default size of the memstore after which
- * the contents are flushed to the store files
- */
- public static final long DEFAULT_MEMSTORE_FLUSH_SIZE = 1024*1024*128L;
-
- public static final int DEFAULT_REGION_REPLICATION = 1;
-
- public static final boolean DEFAULT_REGION_MEMSTORE_REPLICATION = true;
-
- private final static Maphbase:meta and -ROOT-.
- */
- @InterfaceAudience.Private
- protected HTableDescriptor(final TableName name, HColumnDescriptor[] families) {
- setName(name);
- for(HColumnDescriptor descriptor : families) {
- this.families.put(descriptor.getName(), descriptor);
- }
- }
-
- /**
- * INTERNAL Private constructor used internally creating table descriptors for
- * catalog tables, hbase:meta and -ROOT-.
- */
- protected HTableDescriptor(final TableName name, HColumnDescriptor[] families,
- Map
* Makes a deep copy of the supplied descriptor.
- * Can make a modifiable descriptor from an UnmodifyableHTableDescriptor.
+ * Can make a modifiable descriptor from an ImmutableHTableDescriptor.
* @param desc The descriptor.
*/
public HTableDescriptor(final HTableDescriptor desc) {
- this(desc.name, desc);
+ this(desc.getTableName(), desc.getFamilies(), desc.getValues(), desc.getConfiguration());
}
/**
@@ -361,36 +94,25 @@ public class HTableDescriptor implements Comparable
* Makes a deep copy of the supplied descriptor.
- * Can make a modifiable descriptor from an UnmodifyableHTableDescriptor.
+ * Can make a modifiable descriptor from an ImmutableHTableDescriptor.
* @param name Table name.
* @param desc The descriptor.
*/
public HTableDescriptor(final TableName name, final HTableDescriptor desc) {
- super();
- setName(name);
- setMetaFlags(this.name);
- for (HColumnDescriptor c: desc.families.values()) {
- this.families.put(c.getName(), new HColumnDescriptor(c));
- }
- for (Map.Entry
+ * Makes a deep copy of the supplied descriptor.
+ * TODO: make this private after removing the HTableDescriptor
+ * @param desc The descriptor.
+ */
+ @InterfaceAudience.Private
+ protected ModifyableTableDescriptor(final TableDescriptor desc) {
+ this(desc.getTableName(), desc.getFamilies(), desc.getValues(), desc.getConfiguration());
+ }
+
+ // TODO: make this private after removing the HTableDescriptor
+ @InterfaceAudience.Private
+ public ModifyableTableDescriptor(final TableName name, final Collection
+ * This is not an absolute value and might vary. Assume that a single row
+ * exceeds the maxFileSize then the storeFileSize will be greater than
+ * maxFileSize since a single row cannot be split across multiple regions
+ * -ROOT- region
*/
+ @Override
public boolean isRootRegion() {
- if (this.root == null) {
- this.root = isSomething(IS_ROOT_KEY, false)? Boolean.TRUE: Boolean.FALSE;
- }
- return this.root.booleanValue();
- }
-
- /**
- * INTERNAL Used to denote if the current table represents
- * -ROOT- region. This is used internally by the
- * HTableDescriptor constructors
- *
- * @param isRoot true if this is the -ROOT- region
- */
- protected void setRootRegion(boolean isRoot) {
- // TODO: Make the value a boolean rather than String of boolean.
- setValue(IS_ROOT_KEY, isRoot? TRUE: FALSE);
+ return delegatee.isRootRegion();
}
/**
@@ -424,37 +132,9 @@ public class HTableDescriptor implements Comparable hbase:meta
* region
*/
+ @Override
public boolean isMetaRegion() {
- if (this.meta == null) {
- this.meta = calculateIsMetaRegion();
- }
- return this.meta.booleanValue();
- }
-
- private synchronized Boolean calculateIsMetaRegion() {
- byte [] value = getValue(IS_META_KEY);
- return (value != null)? Boolean.valueOf(Bytes.toString(value)): Boolean.FALSE;
- }
-
- private boolean isSomething(final Bytes key,
- final boolean valueIfNull) {
- byte [] value = getValue(key);
- if (value != null) {
- return Boolean.valueOf(Bytes.toString(value));
- }
- return valueIfNull;
- }
-
- /**
- * INTERNAL Used to denote if the current table represents
- * -ROOT- or hbase:meta region. This is used
- * internally by the HTableDescriptor constructors
- *
- * @param isMeta true if its either -ROOT- or
- * hbase:meta region
- */
- protected void setMetaRegion(boolean isMeta) {
- setValue(IS_META_KEY, isMeta? TRUE: FALSE);
+ return delegatee.isMetaRegion();
}
/**
@@ -462,8 +142,9 @@ public class HTableDescriptor implements Comparable hbase:meta region.
*/
+ @Override
public boolean isMetaTable() {
- return isMetaRegion() && !isRootRegion();
+ return delegatee.isMetaTable();
}
/**
@@ -471,17 +152,10 @@ public class HTableDescriptor implements Comparablethis
- */
- private HTableDescriptor addCoprocessorToMap(final String specStr) {
- if (specStr == null) return this;
- // generate a coprocessor key
- int maxCoprocessorNumber = 0;
- Matcher keyMatcher;
- for (Map.Entryspec or null if no match or classpath found
- */
- private static String getCoprocessorClassNameFromSpecStr(final String spec) {
- Matcher matcher = HConstants.CP_HTD_ATTR_VALUE_PATTERN.matcher(spec);
- // Classname is the 2nd field
- return matcher != null && matcher.matches()? matcher.group(2).trim(): null;
+ return delegatee.getCoprocessors();
}
/**
@@ -1411,97 +756,34 @@ public class HTableDescriptor implements Comparable> newMasterCaller()
.action(
(controller, stub) -> this
@@ -373,7 +372,7 @@ public class AsyncHBaseAdmin implements AsyncAdmin {
return;
}
if (!tableSchemas.isEmpty()) {
- future.complete(ProtobufUtil.convertToHTableDesc(tableSchemas.get(0)));
+ future.complete(ProtobufUtil.convertToTableDesc(tableSchemas.get(0)));
} else {
future.completeExceptionally(new TableNotFoundException(tableName.getNameAsString()));
}
@@ -382,12 +381,12 @@ public class AsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture
-ROOT- or
+ * hbase:meta , if the table is read only, the maximum size of the memstore,
+ * when the region split should occur, coprocessors associated with it etc...
+ */
+@InterfaceAudience.Public
+public interface TableDescriptor {
+
+ /**
+ * Returns an array all the {@link HColumnDescriptor} of the column families
+ * of the table.
+ *
+ * @return Array of all the HColumnDescriptors of the current table
+ *
+ * @see #getFamilies()
+ */
+ HColumnDescriptor[] getColumnFamilies();
+
+ /**
+ * Returns the count of the column families of the table.
+ *
+ * @return Count of column families of the table
+ */
+ int getColumnFamilyCount();
+
+ /**
+ * Getter for fetching an unmodifiable map.
+ *
+ * @return an unmodifiable map
+ */
+ Map hbase:meta region.
+ *
+ * @return true if this table is hbase:meta region
+ */
+ boolean isMetaRegion();
+
+ /**
+ * Checks if the table is a hbase:meta table
+ *
+ * @return true if table is hbase:meta region.
+ */
+ boolean isMetaTable();
+
+ /**
+ * Check if normalization enable flag of the table is true. If flag is false
+ * then no region normalizer won't attempt to normalize this table.
+ *
+ * @return true if region normalization is enabled for this table
+ */
+ boolean isNormalizationEnabled();
+
+ /**
+ * Check if the readOnly flag of the table is set. If the readOnly flag is set
+ * then the contents of the table can only be read from but not modified.
+ *
+ * @return true if all columns in the table should be read only
+ */
+ boolean isReadOnly();
+
+ /**
+ * Check if the descriptor represents a -ROOT- region.
+ *
+ * @return true if this is a -ROOT- region
+ */
+ boolean isRootRegion();
+
+}
diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
new file mode 100644
index 0000000000..a372cedcd5
--- /dev/null
+++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java
@@ -0,0 +1,1639 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.Coprocessor;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
+import org.apache.hadoop.hbase.util.Bytes;
+
+@InterfaceAudience.Public
+public class TableDescriptorBuilder {
+
+ private static final Log LOG = LogFactory.getLog(TableDescriptorBuilder.class);
+
+ public static final String SPLIT_POLICY = "SPLIT_POLICY";
+
+ /**
+ * INTERNAL Used by HBase Shell interface to access this metadata
+ * attribute which denotes the maximum size of the store file after which a
+ * region split occurs.
+ */
+ public static final String MAX_FILESIZE = "MAX_FILESIZE";
+ private static final Bytes MAX_FILESIZE_KEY
+ = new Bytes(Bytes.toBytes(MAX_FILESIZE));
+
+ public static final String OWNER = "OWNER";
+ public static final Bytes OWNER_KEY
+ = new Bytes(Bytes.toBytes(OWNER));
+
+ /**
+ * INTERNAL Used by rest interface to access this metadata attribute
+ * which denotes if the table is Read Only.
+ */
+ public static final String READONLY = "READONLY";
+ private static final Bytes READONLY_KEY
+ = new Bytes(Bytes.toBytes(READONLY));
+
+ /**
+ * INTERNAL Used by HBase Shell interface to access this metadata
+ * attribute which denotes if the table is compaction enabled.
+ */
+ public static final String COMPACTION_ENABLED = "COMPACTION_ENABLED";
+ private static final Bytes COMPACTION_ENABLED_KEY
+ = new Bytes(Bytes.toBytes(COMPACTION_ENABLED));
+
+ /**
+ * INTERNAL Used by HBase Shell interface to access this metadata
+ * attribute which represents the maximum size of the memstore after which its
+ * contents are flushed onto the disk.
+ */
+ public static final String MEMSTORE_FLUSHSIZE = "MEMSTORE_FLUSHSIZE";
+ private static final Bytes MEMSTORE_FLUSHSIZE_KEY
+ = new Bytes(Bytes.toBytes(MEMSTORE_FLUSHSIZE));
+
+ public static final String FLUSH_POLICY = "FLUSH_POLICY";
+
+ /**
+ * INTERNAL Used by rest interface to access this metadata attribute
+ * which denotes if the table is a -ROOT- region or not.
+ */
+ public static final String IS_ROOT = "IS_ROOT";
+ private static final Bytes IS_ROOT_KEY
+ = new Bytes(Bytes.toBytes(IS_ROOT));
+
+ /**
+ * INTERNAL Used by rest interface to access this metadata attribute
+ * which denotes if it is a catalog table, either hbase:meta or -ROOT-
+ * .
+ */
+ public static final String IS_META = "IS_META";
+ private static final Bytes IS_META_KEY
+ = new Bytes(Bytes.toBytes(IS_META));
+
+ /**
+ * INTERNAL {@link Durability} setting for the table.
+ */
+ public static final String DURABILITY = "DURABILITY";
+ private static final Bytes DURABILITY_KEY
+ = new Bytes(Bytes.toBytes("DURABILITY"));
+
+ /**
+ * INTERNAL number of region replicas for the table.
+ */
+ public static final String REGION_REPLICATION = "REGION_REPLICATION";
+ private static final Bytes REGION_REPLICATION_KEY
+ = new Bytes(Bytes.toBytes(REGION_REPLICATION));
+
+ /**
+ * INTERNAL flag to indicate whether or not the memstore should be
+ * replicated for read-replicas (CONSISTENCY => TIMELINE).
+ */
+ public static final String REGION_MEMSTORE_REPLICATION = "REGION_MEMSTORE_REPLICATION";
+ private static final Bytes REGION_MEMSTORE_REPLICATION_KEY
+ = new Bytes(Bytes.toBytes(REGION_MEMSTORE_REPLICATION));
+
+ /**
+ * INTERNAL Used by shell/rest interface to access this metadata
+ * attribute which denotes if the table should be treated by region
+ * normalizer.
+ */
+ public static final String NORMALIZATION_ENABLED = "NORMALIZATION_ENABLED";
+ private static final Bytes NORMALIZATION_ENABLED_KEY
+ = new Bytes(Bytes.toBytes(NORMALIZATION_ENABLED));
+
+ /**
+ * Default durability for HTD is USE_DEFAULT, which defaults to HBase-global
+ * default value
+ */
+ private static final Durability DEFAULT_DURABLITY = Durability.USE_DEFAULT;
+
+ public static final String PRIORITY = "PRIORITY";
+ private static final Bytes PRIORITY_KEY
+ = new Bytes(Bytes.toBytes(PRIORITY));
+
+ /**
+ * Relative priority of the table used for rpc scheduling
+ */
+ private static final int DEFAULT_PRIORITY = HConstants.NORMAL_QOS;
+
+ /*
+ * The below are ugly but better than creating them each time till we
+ * replace booleans being saved as Strings with plain booleans. Need a
+ * migration script to do this. TODO.
+ */
+ private static final Bytes FALSE
+ = new Bytes(Bytes.toBytes(Boolean.FALSE.toString()));
+
+ private static final Bytes TRUE
+ = new Bytes(Bytes.toBytes(Boolean.TRUE.toString()));
+
+ /**
+ * Constant that denotes whether the table is READONLY by default and is false
+ */
+ public static final boolean DEFAULT_READONLY = false;
+
+ /**
+ * Constant that denotes whether the table is compaction enabled by default
+ */
+ public static final boolean DEFAULT_COMPACTION_ENABLED = true;
+
+ /**
+ * Constant that denotes whether the table is normalized by default.
+ */
+ public static final boolean DEFAULT_NORMALIZATION_ENABLED = false;
+
+ /**
+ * Constant that denotes the maximum default size of the memstore after which
+ * the contents are flushed to the store files
+ */
+ public static final long DEFAULT_MEMSTORE_FLUSH_SIZE = 1024 * 1024 * 128L;
+
+ public static final int DEFAULT_REGION_REPLICATION = 1;
+
+ public static final boolean DEFAULT_REGION_MEMSTORE_REPLICATION = true;
+
+ private final static Map -ROOT-
+ * or hbase:meta , if the table is read only, the
+ * maximum size of the memstore, when the region split should occur,
+ * coprocessors associated with it etc... TODO: make this private after
+ * removing the HTableDescriptor
+ */
+ @InterfaceAudience.Private
+ public static class ModifyableTableDescriptor
+ implements TableDescriptor, Comparable -ROOT- region.
+ *
+ * @return true if this is a -ROOT- region
+ */
+ @Override
+ public boolean isRootRegion() {
+ return isSomething(IS_ROOT_KEY, false);
+ }
+
+ /**
+ * Checks if this table is hbase:meta region.
+ *
+ * @return true if this table is hbase:meta region
+ */
+ @Override
+ public boolean isMetaRegion() {
+ return isSomething(IS_META_KEY, false);
+ }
+
+ private boolean isSomething(final Bytes key,
+ final boolean valueIfNull) {
+ byte[] value = getValue(key);
+ if (value != null) {
+ return Boolean.valueOf(Bytes.toString(value));
+ }
+ return valueIfNull;
+ }
+
+ /**
+ * Checks if the table is a hbase:meta table
+ *
+ * @return true if table is hbase:meta region.
+ */
+ @Override
+ public boolean isMetaTable() {
+ return isMetaRegion() && !isRootRegion();
+ }
+
+ /**
+ * Getter for accessing the metadata associated with the key
+ *
+ * @param key The key.
+ * @return The value.
+ * @see #values
+ */
+ @Override
+ public byte[] getValue(byte[] key) {
+ return getValue(new Bytes(key));
+ }
+
+ private byte[] getValue(final Bytes key) {
+ Bytes ibw = values.get(key);
+ if (ibw == null) {
+ return null;
+ }
+ return ibw.get();
+ }
+
+ /**
+ * Getter for accessing the metadata associated with the key
+ *
+ * @param key The key.
+ * @return The value.
+ * @see #values
+ */
+ public String getValue(String key) {
+ byte[] value = getValue(Bytes.toBytes(key));
+ if (value == null) {
+ return null;
+ }
+ return Bytes.toString(value);
+ }
+
+ /**
+ * Getter for fetching an unmodifiable {@link #values} map.
+ *
+ * @return unmodifiable map {@link #values}.
+ * @see #values
+ */
+ @Override
+ public Mapthis
+ */
+ private ModifyableTableDescriptor addCoprocessorToMap(final String specStr) {
+ if (specStr == null) {
+ return this;
+ }
+ // generate a coprocessor key
+ int maxCoprocessorNumber = 0;
+ Matcher keyMatcher;
+ for (Map.Entryspec or null if no match
+ * or classpath found
+ */
+ private static String getCoprocessorClassNameFromSpecStr(final String spec) {
+ Matcher matcher = HConstants.CP_HTD_ATTR_VALUE_PATTERN.matcher(spec);
+ // Classname is the 2nd field
+ return matcher != null && matcher.matches() ? matcher.group(2).trim() : null;
+ }
+
+ /**
+ * Remove a coprocessor from those set on the table
+ *
+ * @param className Class name of the co-processor
+ */
+ public void removeCoprocessor(String className) {
+ Bytes match = null;
+ Matcher keyMatcher;
+ Matcher valueMatcher;
+ for (Map.Entrybytes
+ * @throws DeserializationException
+ * @see #toByteArray()
+ */
+ public static TableDescriptor parseFrom(final byte[] bytes)
+ throws DeserializationException {
+ if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
+ throw new DeserializationException("Expected PB encoded ModifyableTableDescriptor");
+ }
+ int pblen = ProtobufUtil.lengthOfPBMagic();
+ HBaseProtos.TableSchema.Builder builder = HBaseProtos.TableSchema.newBuilder();
+ try {
+ ProtobufUtil.mergeFrom(builder, bytes, pblen, bytes.length - pblen);
+ return ProtobufUtil.convertToTableDesc(builder.build());
+ } catch (IOException e) {
+ throw new DeserializationException(e);
+ }
+ }
+
+ /**
+ * Getter for accessing the configuration value by key
+ */
+ @Override
+ public String getConfigurationValue(String key) {
+ return configuration.get(key);
+ }
+
+ /**
+ * Getter for fetching an unmodifiable {@link #configuration} map.
+ */
+ @Override
+ public Mapts.
+ * @deprecated Use {@link #convertToTableDesc} after removing the HTableDescriptor
*/
+ @Deprecated
public static HTableDescriptor convertToHTableDesc(final TableSchema ts) {
Listts.
+ */
+ public static TableDescriptor convertToTableDesc(final TableSchema ts) {
+ TableDescriptorBuilder builder
+ = TableDescriptorBuilder.newBuilder(ProtobufUtil.toTableName(ts.getTableName()));
+ ts.getColumnFamiliesList()
+ .stream()
+ .map(ProtobufUtil::convertToHColumnDesc)
+ .forEach(builder::addFamily);
+ ts.getAttributesList()
+ .forEach(a -> builder.setValue(a.getFirst().toByteArray(), a.getSecond().toByteArray()));
+ ts.getConfigurationList()
+ .forEach(a -> builder.setConfiguration(a.getName(), a.getValue()));
+ return builder.build();
+ }
+
+ /**
* Creates {@link CompactionState} from
* {@link org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState}
* state
diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
index a513d6650e..366e050b06 100644
--- hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
+++ hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
@@ -45,6 +45,7 @@ import org.apache.hadoop.hbase.client.RegionCoprocessorServiceExec;
import org.apache.hadoop.hbase.client.Row;
import org.apache.hadoop.hbase.client.RowMutations;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.replication.ReplicationSerDeHelper;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.ByteArrayComparable;
@@ -1244,7 +1245,7 @@ public final class RequestConverter {
* @return a CreateTableRequest
*/
public static CreateTableRequest buildCreateTableRequest(
- final HTableDescriptor hTableDesc,
+ final TableDescriptor hTableDesc,
final byte [][] splitKeys,
final long nonceGroup,
final long nonce) {
diff --git hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestImmutableHTableDescriptor.java hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestImmutableHTableDescriptor.java
new file mode 100644
index 0000000000..91ef72a043
--- /dev/null
+++ hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestImmutableHTableDescriptor.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Consumer;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.util.BuilderStyleTest;
+import org.apache.hadoop.hbase.util.Bytes;
+import static org.junit.Assert.fail;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+@Category({ClientTests.class, SmallTests.class})
+public class TestImmutableHTableDescriptor {
+ @Rule
+ public TestName name = new TestName();
+ private static final Listhbase:rsgroup catalog table */
private final static HTableDescriptor RSGROUP_TABLE_DESC;
static {
- RSGROUP_TABLE_DESC = new HTableDescriptor(RSGROUP_TABLE_NAME_BYTES);
+ RSGROUP_TABLE_DESC = new HTableDescriptor(RSGROUP_TABLE_NAME);
RSGROUP_TABLE_DESC.addFamily(new HColumnDescriptor(META_FAMILY_BYTES));
RSGROUP_TABLE_DESC.setRegionSplitPolicyClassName(DisabledRegionSplitPolicy.class.getName());
try {
diff --git hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
index d6bd43b4b5..6ef162b77f 100644
--- hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
+++ hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
@@ -189,7 +189,7 @@ public class TestRSGroups extends TestRSGroupsBase {
final byte[] tableName = Bytes.toBytes(tablePrefix + "_testCreateAndAssign");
admin.modifyNamespace(NamespaceDescriptor.create("default")
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, "default").build());
- final HTableDescriptor desc = new HTableDescriptor(tableName);
+ final HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
desc.addFamily(new HColumnDescriptor("f"));
admin.createTable(desc);
//wait for created table to be assigned
diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java hbase-server/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
index d34701fb6f..f744ecbd7d 100644
--- hbase-server/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
@@ -176,7 +176,7 @@ public class RestoreTool {
LOG.debug("Found descriptor " + tableDescriptor + " through " + incrBackupId);
TableName newTableName = newTableNames[i];
- HTableDescriptor newTableDescriptor = admin.getTableDescriptor(newTableName);
+ HTableDescriptor newTableDescriptor = new HTableDescriptor(admin.getTableDescriptor(newTableName));
List