Package org.apache.hadoop.hbase.client
Class TableDescriptorBuilder.ModifyableTableDescriptor
java.lang.Object
org.apache.hadoop.hbase.client.TableDescriptorBuilder.ModifyableTableDescriptor
- All Implemented Interfaces:
Comparable<TableDescriptorBuilder.ModifyableTableDescriptor>,TableDescriptor
- Enclosing class:
- TableDescriptorBuilder
private static final class TableDescriptorBuilder.ModifyableTableDescriptor
extends Object
implements TableDescriptor, Comparable<TableDescriptorBuilder.ModifyableTableDescriptor>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<byte[],ColumnFamilyDescriptor> Maps column family name to the respective FamilyDescriptorsprivate final TableNameA map which holds the metadata information of the table.Fields inherited from interface org.apache.hadoop.hbase.client.TableDescriptor
COMPARATOR, COMPARATOR_IGNORE_REPLICATION -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateprivateConstruct a table descriptor specifying a TableName objectprivateModifyableTableDescriptor(TableName name, Collection<ColumnFamilyDescriptor> families, Map<Bytes, Bytes> values) privateModifyableTableDescriptor(TableName name, TableDescriptor desc) Construct a table descriptor by cloning the descriptor passed as a parameter. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckHasCoprocessor(String className) intCompares the descriptor with another descriptor which is passed as a parameter.booleanCompare the contents of the descriptor with another one passed as a parameter.Returns an unmodifiable collection of all theColumnFamilyDescriptorof all the column families of the table.getColumnFamily(byte[] column) Returns the ColumnFamilyDescriptor for a specific column family with name as specified by the parameter column.intReturns the count of the column families of the table.Set<byte[]>Returns all the column family names of the current table.Return the list of attached co-processor represented by their name classNameReturns the durability setting for the table.The HDFS erasure coding policy for a table.This gets the class associated with the flush policy which determines the stores need to be flushed when flushing a region.longReturns the maximum size upto which a region can grow to after which a region split is triggered.longReturns the size of the memstore after which a flush to filesystem is triggered.intCheck if there is the target region count.longCheck if there is the target region size.private <T> TgetOrDefault(Bytes key, Function<String, T> function, T defaultValue) intintReturns the configured replicas per regionGet the region server group this table belongs to.This gets the class associated with the region split policy which determines when a region split should occur.Get the name of the tablebyte[]getValue(byte[] key) Getter for accessing the metadata associated with the key.Getter for accessing the metadata associated with the key.Getter for accessing the metadata associated with the key.Getter for fetching an unmodifiablevaluesmap.private StringBuildergetValues(boolean printDefaults) booleanhasColumnFamily(byte[] familyName) Checks to see if this table contains the given column familybooleanhasCoprocessor(String classNameToMatch) Check if the table has an attached co-processor represented by the name classNameinthashCode()Returns hash codebooleanReturns true if the read-replicas memstore replication is enabled.booleanCheck if the compaction enable flag of the table is true.booleanCheck if the region merge enable flag of the table is true.booleanChecks if this table ishbase:metaregion.booleanChecks if the table is ahbase:metatablebooleanCheck if normalization enable flag of the table is true.booleanCheck if the readOnly flag of the table is set.booleanCheck if the split enable flag of the table is true.Modifies the existing column family.private static TableDescriptorparseFrom(byte[] bytes) removeColumnFamily(byte[] column) Removes the ColumnFamilyDescriptor with name specified by the parameter column from the table descriptorvoidremoveCoprocessor(String className) Remove a coprocessor from those set on the tableremoveValue(byte[] key) Remove metadata represented by the key from thevaluesmapremoveValue(String key) Remove metadata represented by the key from thevaluesmapremoveValue(Bytes key) Remove metadata represented by the key from thevaluesmapAdds a column family.setCompactionEnabled(boolean isEnable) Setting the table compaction enable flag.setCoprocessor(String className) Add a table coprocessor to this table.Add a table coprocessor to this table.setCoprocessorToMap(String specStr) Add coprocessor to values MapsetDurability(Durability durability) Sets theDurabilitysetting for the table.setErasureCodingPolicy(String policy) Sets the HDFS erasure coding policy for the table.setFlushPolicyClassName(String clazz) This sets the class associated with the flush policy which determines determines the stores need to be flushed when flushing a region.setMaxFileSize(long maxFileSize) Sets the maximum size upto which a region can grow to after which a region split is triggered.setMaxFileSize(String maxFileSize) setMemStoreFlushSize(long memstoreFlushSize) Represents the maximum size of the memstore after which the contents of the memstore are flushed to the filesystem.setMemStoreFlushSize(String memStoreFlushSize) setMergeEnabled(boolean isEnable) Setting the table region merge enable flag.setNormalizationEnabled(boolean isEnable) Setting the table normalization enable flag.setNormalizerTargetRegionCount(int regionCount) Setting the target region count of table normalization .setNormalizerTargetRegionSize(long regionSize) Setting the target region size of table normalization.setPriority(int priority) setReadOnly(boolean readOnly) Setting the table as read only sets all the columns in the table as read only.setRegionMemStoreReplication(boolean memstoreReplication) Enable or Disable the memstore replication from the primary region to the replicas.setRegionReplication(int regionReplication) Sets the number of replicas per region.This sets the class associated with the region split policy which determines when a region split should occur.setSplitEnabled(boolean isEnable) Setting the table region split enable flag.setValue(byte[] key, byte[] value) Setter for storing metadata as a (key, value) pair invaluesmapSetter for storing metadata as a (key, value) pair invaluesmapprivate byte[]Returns the bytes in pb formatprivate static <T> BytestoBytesOrNull(T t, Function<T, byte[]> f) toString()Returns Name of this table and then a map of all of the column family descriptors.Returns Name of this table and then a map of all of the column family descriptors (with only the non-default column family attributes)Returns map of all table attributes formatted into string.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.client.TableDescriptor
hasGlobalReplicationScope, matchReplicationScope
-
Field Details
-
name
-
values
A map which holds the metadata information of the table. This metadata includes values like IS_META, SPLIT_POLICY, MAX_FILE_SIZE, READONLY, MEMSTORE_FLUSHSIZE etc... -
families
Maps column family name to the respective FamilyDescriptors
-
-
Constructor Details
-
ModifyableTableDescriptor
Construct a table descriptor specifying a TableName object- Parameters:
name- Table name.
-
ModifyableTableDescriptor
-
ModifyableTableDescriptor
Construct a table descriptor by cloning the descriptor passed as a parameter.Makes a deep copy of the supplied descriptor.
- Parameters:
name- The new namedesc- The descriptor.
-
ModifyableTableDescriptor
private ModifyableTableDescriptor(TableName name, Collection<ColumnFamilyDescriptor> families, Map<Bytes, Bytes> values)
-
-
Method Details
-
isMetaRegion
Checks if this table ishbase:metaregion.- Specified by:
isMetaRegionin interfaceTableDescriptor- Returns:
- true if this table is
hbase:metaregion
-
isMetaTable
Checks if the table is ahbase:metatable- Specified by:
isMetaTablein interfaceTableDescriptor- Returns:
- true if table is
hbase:metaregion.
-
getValue
Description copied from interface:TableDescriptorGetter for accessing the metadata associated with the key.- Specified by:
getValuein interfaceTableDescriptor- Parameters:
key- The key.- Returns:
- A clone value. Null if no mapping for the key
-
getValue
Description copied from interface:TableDescriptorGetter for accessing the metadata associated with the key.- Specified by:
getValuein interfaceTableDescriptor- Parameters:
key- The key.- Returns:
- Null if no mapping for the key
-
getValue
Description copied from interface:TableDescriptorGetter for accessing the metadata associated with the key.- Specified by:
getValuein interfaceTableDescriptor- Parameters:
key- The key.- Returns:
- A clone value. Null if no mapping for the key
-
getOrDefault
-
getValues
Getter for fetching an unmodifiablevaluesmap.- Specified by:
getValuesin interfaceTableDescriptor- Returns:
- unmodifiable map
values. - See Also:
-
setValue
Setter for storing metadata as a (key, value) pair invaluesmap- Parameters:
key- The key.value- The value. If null, removes the setting.- Returns:
- the modifyable TD
- See Also:
-
setValue
-
setValue
- Parameters:
key- The key.value- The value. If null, removes the setting.
-
setValue
Setter for storing metadata as a (key, value) pair invaluesmap- Parameters:
key- The key.value- The value. If null, removes the setting.
-
toBytesOrNull
-
removeValue
Remove metadata represented by the key from thevaluesmap- Parameters:
key- Key whose key and value we're to remove from TableDescriptor parameters.- Returns:
- the modifyable TD
-
removeValue
Remove metadata represented by the key from thevaluesmap- Parameters:
key- Key whose key and value we're to remove from TableDescriptor parameters.- Returns:
- the modifyable TD
-
removeValue
Remove metadata represented by the key from thevaluesmap- Parameters:
key- Key whose key and value we're to remove from TableDescriptor parameters.- Returns:
- the modifyable TD
-
isReadOnly
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.- Specified by:
isReadOnlyin interfaceTableDescriptor- Returns:
- true if all columns in the table should be read only
-
setReadOnly
Setting the table as read only sets all the columns in the table as read only. By default all tables are modifiable, but if the readOnly flag is set to true then the contents of the table can only be read but not modified.- Parameters:
readOnly- True if all of the columns in the table should be read only.- Returns:
- the modifyable TD
-
getErasureCodingPolicy
The HDFS erasure coding policy for a table. This will be set on the data dir of the table, and is an alternative to normal replication which takes less space at the cost of locality.- Specified by:
getErasureCodingPolicyin interfaceTableDescriptor- Returns:
- the current policy, or null if undefined
-
setErasureCodingPolicy
Sets the HDFS erasure coding policy for the table. This will be propagated to HDFS for the data dir of the table. Erasure coding is an alternative to normal replication which takes less space at the cost of locality. The policy must be available and enabled on the hdfs cluster before being set.- Parameters:
policy- the policy to set, or null to disable erasure coding- Returns:
- the modifyable TD
-
isCompactionEnabled
Check if the compaction enable flag of the table is true. If flag is false then no minor/major compactions will be done in real.- Specified by:
isCompactionEnabledin interfaceTableDescriptor- Returns:
- true if table compaction enabled
-
setCompactionEnabled
Setting the table compaction enable flag.- Parameters:
isEnable- True if enable compaction.- Returns:
- the modifyable TD
-
isSplitEnabled
Check if the split enable flag of the table is true. If flag is false then no split will be done.- Specified by:
isSplitEnabledin interfaceTableDescriptor- Returns:
- true if table region split enabled
-
setSplitEnabled
Setting the table region split enable flag.- Parameters:
isEnable- True if enable region split.- Returns:
- the modifyable TD
-
isMergeEnabled
Check if the region merge enable flag of the table is true. If flag is false then no merge will be done.- Specified by:
isMergeEnabledin interfaceTableDescriptor- Returns:
- true if table region merge enabled
-
setMergeEnabled
Setting the table region merge enable flag.- Parameters:
isEnable- True if enable region merge.- Returns:
- the modifyable TD
-
isNormalizationEnabled
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.- Specified by:
isNormalizationEnabledin interfaceTableDescriptor- Returns:
- true if region normalization is enabled for this table
-
getNormalizerTargetRegionCount
Check if there is the target region count. If so, the normalize plan will be calculated based on the target region count.- Specified by:
getNormalizerTargetRegionCountin interfaceTableDescriptor- Returns:
- target region count after normalize done
-
getNormalizerTargetRegionSize
Check if there is the target region size. If so, the normalize plan will be calculated based on the target region size.- Specified by:
getNormalizerTargetRegionSizein interfaceTableDescriptor- Returns:
- target region size after normalize done
-
setNormalizationEnabled
Setting the table normalization enable flag.- Parameters:
isEnable- True if enable normalization.- Returns:
- the modifyable TD
-
setNormalizerTargetRegionCount
public TableDescriptorBuilder.ModifyableTableDescriptor setNormalizerTargetRegionCount(int regionCount) Setting the target region count of table normalization .- Parameters:
regionCount- the target region count.- Returns:
- the modifyable TD
-
setNormalizerTargetRegionSize
public TableDescriptorBuilder.ModifyableTableDescriptor setNormalizerTargetRegionSize(long regionSize) Setting the target region size of table normalization.- Parameters:
regionSize- the target region size.- Returns:
- the modifyable TD
-
setDurability
Sets theDurabilitysetting for the table. This defaults to Durability.USE_DEFAULT.- Parameters:
durability- enum value- Returns:
- the modifyable TD
-
getDurability
Returns the durability setting for the table.- Specified by:
getDurabilityin interfaceTableDescriptor- Returns:
- durability setting for the table.
-
getTableName
Get the name of the table- Specified by:
getTableNamein interfaceTableDescriptor
-
setRegionSplitPolicyClassName
This sets the class associated with the region split policy which determines when a region split should occur. The class used by default is defined in org.apache.hadoop.hbase.regionserver.RegionSplitPolicy- Parameters:
clazz- the class name- Returns:
- the modifyable TD
-
getRegionSplitPolicyClassName
This gets the class associated with the region split policy which determines when a region split should occur. The class used by default is defined in org.apache.hadoop.hbase.regionserver.RegionSplitPolicy- Specified by:
getRegionSplitPolicyClassNamein interfaceTableDescriptor- Returns:
- the class name of the region split policy for this table. If this returns null, the default split policy is used.
-
getMaxFileSize
Returns the maximum size upto which a region can grow to after which a region split is triggered. The region size is represented by the size of the biggest store file in that region.- Specified by:
getMaxFileSizein interfaceTableDescriptor- Returns:
- max hregion size for table, -1 if not set.
- See Also:
-
setMaxFileSize
Sets the maximum size upto which a region can grow to after which a region split is triggered. The region size is represented by the size of the biggest store file in that region, i.e. If the biggest store file grows beyond the maxFileSize, then the region split is triggered. This defaults to a value of 256 MB.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
- Parameters:
maxFileSize- The maximum file size that a store file can grow to before a split is triggered.- Returns:
- the modifyable TD
-
setMaxFileSize
public TableDescriptorBuilder.ModifyableTableDescriptor setMaxFileSize(String maxFileSize) throws HBaseException - Throws:
HBaseException
-
getMemStoreFlushSize
Returns the size of the memstore after which a flush to filesystem is triggered.- Specified by:
getMemStoreFlushSizein interfaceTableDescriptor- Returns:
- memory cache flush size for each hregion, -1 if not set.
- See Also:
-
setMemStoreFlushSize
public TableDescriptorBuilder.ModifyableTableDescriptor setMemStoreFlushSize(long memstoreFlushSize) Represents the maximum size of the memstore after which the contents of the memstore are flushed to the filesystem. This defaults to a size of 64 MB.- Parameters:
memstoreFlushSize- memory cache flush size for each hregion- Returns:
- the modifyable TD
-
setMemStoreFlushSize
public TableDescriptorBuilder.ModifyableTableDescriptor setMemStoreFlushSize(String memStoreFlushSize) throws HBaseException - Throws:
HBaseException
-
setFlushPolicyClassName
This sets the class associated with the flush policy which determines determines the stores need to be flushed when flushing a region. The class used by default is defined in org.apache.hadoop.hbase.regionserver.FlushPolicy.- Parameters:
clazz- the class name- Returns:
- the modifyable TD
-
getFlushPolicyClassName
This gets the class associated with the flush policy which determines the stores need to be flushed when flushing a region. The class used by default is defined in org.apache.hadoop.hbase.regionserver.FlushPolicy.- Specified by:
getFlushPolicyClassNamein interfaceTableDescriptor- Returns:
- the class name of the flush policy for this table. If this returns null, the default flush policy is used.
-
setColumnFamily
public TableDescriptorBuilder.ModifyableTableDescriptor setColumnFamily(ColumnFamilyDescriptor family) Adds a column family. For the updating purpose please usemodifyColumnFamily(ColumnFamilyDescriptor)instead.- Parameters:
family- to add.- Returns:
- the modifyable TD
-
modifyColumnFamily
public TableDescriptorBuilder.ModifyableTableDescriptor modifyColumnFamily(ColumnFamilyDescriptor family) Modifies the existing column family.- Parameters:
family- to update- Returns:
- this (for chained invocation)
-
putColumnFamily
-
hasColumnFamily
Checks to see if this table contains the given column family- Specified by:
hasColumnFamilyin interfaceTableDescriptor- Parameters:
familyName- Family name or column name.- Returns:
- true if the table contains the specified family name
-
toString
Returns Name of this table and then a map of all of the column family descriptors. -
toStringCustomizedValues
Description copied from interface:TableDescriptorReturns Name of this table and then a map of all of the column family descriptors (with only the non-default column family attributes)- Specified by:
toStringCustomizedValuesin interfaceTableDescriptor- Returns:
- Name of this table and then a map of all of the column family descriptors (with only the non-default column family attributes)
-
toStringTableAttributes
Returns map of all table attributes formatted into string. -
getValues
-
equals
Compare the contents of the descriptor with another one passed as a parameter. Checks if the obj passed is an instance of ModifyableTableDescriptor, if yes then the contents of the descriptors are compared. -
hashCode
Returns hash code -
compareTo
Compares the descriptor with another descriptor which is passed as a parameter. This compares the content of the two descriptors and not the reference.- Specified by:
compareToin interfaceComparable<TableDescriptorBuilder.ModifyableTableDescriptor>- Parameters:
other- The MTD to compare- Returns:
- 0 if the contents of the descriptors are exactly matching, 1 if there is a mismatch in the contents
-
getColumnFamilies
Description copied from interface:TableDescriptorReturns an unmodifiable collection of all theColumnFamilyDescriptorof all the column families of the table.- Specified by:
getColumnFamiliesin interfaceTableDescriptor- Returns:
- An array of
ColumnFamilyDescriptorof all the column families.
-
getRegionReplication
Returns the configured replicas per region- Specified by:
getRegionReplicationin interfaceTableDescriptor
-
setRegionReplication
Sets the number of replicas per region.- Parameters:
regionReplication- the replication factor per region- Returns:
- the modifyable TD
-
hasRegionMemStoreReplication
Returns true if the read-replicas memstore replication is enabled.- Specified by:
hasRegionMemStoreReplicationin interfaceTableDescriptor
-
setRegionMemStoreReplication
public TableDescriptorBuilder.ModifyableTableDescriptor setRegionMemStoreReplication(boolean memstoreReplication) Enable or Disable the memstore replication from the primary region to the replicas. The replication will be used only for meta operations (e.g. flush, compaction, ...)- Parameters:
memstoreReplication- true if the new data written to the primary region should be replicated. false if the secondaries can tollerate to have new data only when the primary flushes the memstore.- Returns:
- the modifyable TD
-
setPriority
-
getPriority
- Specified by:
getPriorityin interfaceTableDescriptor
-
getColumnFamilyNames
Returns all the column family names of the current table. The map of TableDescriptor contains mapping of family name to ColumnFamilyDescriptor. This returns all the keys of the family map which represents the column family names of the table.- Specified by:
getColumnFamilyNamesin interfaceTableDescriptor- Returns:
- Immutable sorted set of the keys of the families.
-
getColumnFamily
Returns the ColumnFamilyDescriptor for a specific column family with name as specified by the parameter column.- Specified by:
getColumnFamilyin interfaceTableDescriptor- Parameters:
column- Column family name- Returns:
- Column descriptor for the passed family name or the family on passed in column.
-
removeColumnFamily
Removes the ColumnFamilyDescriptor with name specified by the parameter column from the table descriptor- Parameters:
column- Name of the column family to be removed.- Returns:
- Column descriptor for the passed family name or the family on passed in column.
-
setCoprocessor
public TableDescriptorBuilder.ModifyableTableDescriptor setCoprocessor(String className) throws IOException Add a table coprocessor to this table. The coprocessor type must be org.apache.hadoop.hbase.coprocessor.RegionObserver or Endpoint. It won't check if the class can be loaded or not. Whether a coprocessor is loadable or not will be determined when a region is opened.- Parameters:
className- Full class name.- Returns:
- the modifyable TD
- Throws:
IOException
-
setCoprocessor
public TableDescriptorBuilder.ModifyableTableDescriptor setCoprocessor(CoprocessorDescriptor cp) throws IOException Add a table coprocessor to this table. The coprocessor type must be org.apache.hadoop.hbase.coprocessor.RegionObserver or Endpoint. It won't check if the class can be loaded or not. Whether a coprocessor is loadable or not will be determined when a region is opened.- Returns:
- the modifyable TD
- Throws:
IOException- any illegal parameter key/value
-
checkHasCoprocessor
- Throws:
IOException
-
setCoprocessorToMap
Add coprocessor to values Map- Parameters:
specStr- The Coprocessor specification all in in one String- Returns:
- Returns
this
-
hasCoprocessor
Check if the table has an attached co-processor represented by the name className- Specified by:
hasCoprocessorin interfaceTableDescriptor- Parameters:
classNameToMatch- - Class name of the co-processor- Returns:
- true of the table has a co-processor className
-
getCoprocessorDescriptors
Return the list of attached co-processor represented by their name className- Specified by:
getCoprocessorDescriptorsin interfaceTableDescriptor- Returns:
- The list of co-processors classNames
-
removeCoprocessor
Remove a coprocessor from those set on the table- Parameters:
className- Class name of the co-processor
-
toByteArray
Returns the bytes in pb format -
parseFrom
- Parameters:
bytes- A pb serializedTableDescriptorBuilder.ModifyableTableDescriptorinstance with pb magic prefix- Returns:
- An instance of
TableDescriptorBuilder.ModifyableTableDescriptormade frombytes - Throws:
DeserializationException- See Also:
-
getColumnFamilyCount
Description copied from interface:TableDescriptorReturns the count of the column families of the table.- Specified by:
getColumnFamilyCountin interfaceTableDescriptor- Returns:
- Count of column families of the table
-
getRegionServerGroup
Description copied from interface:TableDescriptorGet the region server group this table belongs to. The regions of this table will be placed only on the region servers within this group. If not present, will be placed onRSGroupInfo.DEFAULT_GROUP.- Specified by:
getRegionServerGroupin interfaceTableDescriptor
-