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
Modifier and TypeFieldDescriptionprivate final Map<byte[],
ColumnFamilyDescriptor> Maps column family name to the respective FamilyDescriptorsprivate final TableName
A 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
ModifierConstructorDescriptionprivate
private
Construct a table descriptor specifying a TableName objectprivate
ModifyableTableDescriptor
(TableName name, Collection<ColumnFamilyDescriptor> families, Map<Bytes, Bytes> values) private
ModifyableTableDescriptor
(TableName name, TableDescriptor desc) Construct a table descriptor by cloning the descriptor passed as a parameter. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkHasCoprocessor
(String className) int
Compares the descriptor with another descriptor which is passed as a parameter.boolean
Compare the contents of the descriptor with another one passed as a parameter.Returns an unmodifiable collection of all theColumnFamilyDescriptor
of 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.int
Returns 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.long
Returns the maximum size upto which a region can grow to after which a region split is triggered.long
Returns the size of the memstore after which a flush to filesystem is triggered.int
Check if there is the target region count.long
Check if there is the target region size.private <T> T
getOrDefault
(Bytes key, Function<String, T> function, T defaultValue) int
int
Returns 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 unmodifiablevalues
map.private StringBuilder
getValues
(boolean printDefaults) boolean
hasColumnFamily
(byte[] familyName) Checks to see if this table contains the given column familyboolean
hasCoprocessor
(String classNameToMatch) Check if the table has an attached co-processor represented by the name classNameint
hashCode()
Returns hash codeboolean
Returns true if the read-replicas memstore replication is enabled.boolean
Check if the compaction enable flag of the table is true.boolean
Check if the region merge enable flag of the table is true.boolean
Checks if this table ishbase:meta
region.boolean
Checks if the table is ahbase:meta
tableboolean
Check if normalization enable flag of the table is true.boolean
Check if the readOnly flag of the table is set.boolean
Check if the split enable flag of the table is true.Modifies the existing column family.private static TableDescriptor
parseFrom
(byte[] bytes) removeColumnFamily
(byte[] column) Removes the ColumnFamilyDescriptor with name specified by the parameter column from the table descriptorvoid
removeCoprocessor
(String className) Remove a coprocessor from those set on the tableremoveValue
(byte[] key) Remove metadata represented by the key from thevalues
mapremoveValue
(String key) Remove metadata represented by the key from thevalues
mapremoveValue
(Bytes key) Remove metadata represented by the key from thevalues
mapAdds 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 theDurability
setting 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 invalues
mapSetter for storing metadata as a (key, value) pair invalues
mapprivate byte[]
Returns the bytes in pb formatprivate static <T> Bytes
toBytesOrNull
(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, wait
Methods 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:meta
region.- Specified by:
isMetaRegion
in interfaceTableDescriptor
- Returns:
- true if this table is
hbase:meta
region
-
isMetaTable
Checks if the table is ahbase:meta
table- Specified by:
isMetaTable
in interfaceTableDescriptor
- Returns:
- true if table is
hbase:meta
region.
-
getValue
Description copied from interface:TableDescriptor
Getter for accessing the metadata associated with the key.- Specified by:
getValue
in interfaceTableDescriptor
- Parameters:
key
- The key.- Returns:
- A clone value. Null if no mapping for the key
-
getValue
Description copied from interface:TableDescriptor
Getter for accessing the metadata associated with the key.- Specified by:
getValue
in interfaceTableDescriptor
- Parameters:
key
- The key.- Returns:
- Null if no mapping for the key
-
getValue
Description copied from interface:TableDescriptor
Getter for accessing the metadata associated with the key.- Specified by:
getValue
in interfaceTableDescriptor
- Parameters:
key
- The key.- Returns:
- A clone value. Null if no mapping for the key
-
getOrDefault
-
getValues
Getter for fetching an unmodifiablevalues
map.- Specified by:
getValues
in interfaceTableDescriptor
- Returns:
- unmodifiable map
values
. - See Also:
-
setValue
Setter for storing metadata as a (key, value) pair invalues
map- 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 invalues
map- Parameters:
key
- The key.value
- The value. If null, removes the setting.
-
toBytesOrNull
-
removeValue
Remove metadata represented by the key from thevalues
map- 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 thevalues
map- 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 thevalues
map- 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:
isReadOnly
in 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:
getErasureCodingPolicy
in 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:
isCompactionEnabled
in 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:
isSplitEnabled
in 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:
isMergeEnabled
in 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:
isNormalizationEnabled
in 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:
getNormalizerTargetRegionCount
in 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:
getNormalizerTargetRegionSize
in 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 theDurability
setting 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:
getDurability
in interfaceTableDescriptor
- Returns:
- durability setting for the table.
-
getTableName
Get the name of the table- Specified by:
getTableName
in 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:
getRegionSplitPolicyClassName
in 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:
getMaxFileSize
in 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:
getMemStoreFlushSize
in 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:
getFlushPolicyClassName
in 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:
hasColumnFamily
in 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:TableDescriptor
Returns 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:
toStringCustomizedValues
in 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:
compareTo
in 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:TableDescriptor
Returns an unmodifiable collection of all theColumnFamilyDescriptor
of all the column families of the table.- Specified by:
getColumnFamilies
in interfaceTableDescriptor
- Returns:
- An array of
ColumnFamilyDescriptor
of all the column families.
-
getRegionReplication
Returns the configured replicas per region- Specified by:
getRegionReplication
in 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:
hasRegionMemStoreReplication
in 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:
getPriority
in 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:
getColumnFamilyNames
in 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:
getColumnFamily
in 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:
hasCoprocessor
in 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:
getCoprocessorDescriptors
in 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.ModifyableTableDescriptor
instance with pb magic prefix- Returns:
- An instance of
TableDescriptorBuilder.ModifyableTableDescriptor
made frombytes
- Throws:
DeserializationException
- See Also:
-
getColumnFamilyCount
Description copied from interface:TableDescriptor
Returns the count of the column families of the table.- Specified by:
getColumnFamilyCount
in interfaceTableDescriptor
- Returns:
- Count of column families of the table
-
getRegionServerGroup
Description copied from interface:TableDescriptor
Get 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:
getRegionServerGroup
in interfaceTableDescriptor
-