org.apache.hadoop.hbase.regionserver.metrics
Class SchemaConfigured

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured
All Implemented Interfaces:
HeapSize, SchemaMetrics.SchemaAware
Direct Known Subclasses:
AbstractHFileReader, AbstractHFileWriter, HFileBlock, HFileBlockIndex.BlockIndexWriter, Store, StoreFile, StoreFile.Reader

public class SchemaConfigured
extends Object
implements HeapSize, SchemaMetrics.SchemaAware

A base class for objects that are associated with a particular table and column family. Provides a way to obtain the schema metrics object.

Due to the variety of things that can be associated with a table/CF, there are many ways to initialize this base class, either in the constructor, or from another similar object. For example, an HFile reader configures HFile blocks it reads with its own table/CF name.


Field Summary
static int SCHEMA_CONFIGURED_UNALIGNED_HEAP_SIZE
          Estimated heap size of this object.
 
Constructor Summary
SchemaConfigured()
          Default constructor.
SchemaConfigured(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path path)
          Initialize table and column family name from an HFile path.
SchemaConfigured(org.apache.hadoop.conf.Configuration conf, String tableName, String cfName)
          Used when we know table and column family name.
SchemaConfigured(org.apache.hadoop.fs.Path path)
          Used when we know an HFile path to deduce table and CF name from, but do not have a configuration.
SchemaConfigured(SchemaMetrics.SchemaAware that)
           
 
Method Summary
static SchemaConfigured createUnknown()
          Creates an instance corresponding to an unknown table and column family.
 String getColumnFamilyName()
           
 SchemaMetrics getSchemaMetrics()
           
 String getTableName()
           
 long heapSize()
           
protected  boolean isSchemaConfigured()
           
 void passSchemaMetricsTo(SchemaConfigured target)
          Configures the given object (e.g.
static void resetSchemaMetricsConf(SchemaConfigured target)
          Reset schema metrics configuration in this particular instance.
 String schemaConfAsJSON()
           
protected  void schemaConfigurationChanged()
          A hook method called when schema configuration changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMA_CONFIGURED_UNALIGNED_HEAP_SIZE

public static final int SCHEMA_CONFIGURED_UNALIGNED_HEAP_SIZE
Estimated heap size of this object. We don't count table name and column family name characters because these strings are shared among many objects. We need unaligned size to reuse this in subclasses.

Constructor Detail

SchemaConfigured

public SchemaConfigured()
Default constructor. Only use when column/family name are not known at construction (i.e. for HFile blocks).


SchemaConfigured

public SchemaConfigured(org.apache.hadoop.conf.Configuration conf,
                        org.apache.hadoop.fs.Path path)
Initialize table and column family name from an HFile path. If configuration is null, SchemaMetrics.configureGlobally(Configuration) should have been called already.


SchemaConfigured

public SchemaConfigured(org.apache.hadoop.fs.Path path)
Used when we know an HFile path to deduce table and CF name from, but do not have a configuration.

Parameters:
path - an HFile path

SchemaConfigured

public SchemaConfigured(org.apache.hadoop.conf.Configuration conf,
                        String tableName,
                        String cfName)
Used when we know table and column family name. If configuration is null, SchemaMetrics.configureGlobally(Configuration) should have been called already.


SchemaConfigured

public SchemaConfigured(SchemaMetrics.SchemaAware that)
Method Detail

createUnknown

public static SchemaConfigured createUnknown()
Creates an instance corresponding to an unknown table and column family. Used in unit tests.


getTableName

public String getTableName()
Specified by:
getTableName in interface SchemaMetrics.SchemaAware

getColumnFamilyName

public String getColumnFamilyName()
Specified by:
getColumnFamilyName in interface SchemaMetrics.SchemaAware

getSchemaMetrics

public SchemaMetrics getSchemaMetrics()
Specified by:
getSchemaMetrics in interface SchemaMetrics.SchemaAware

passSchemaMetricsTo

public void passSchemaMetricsTo(SchemaConfigured target)
Configures the given object (e.g. an HFile block) with the current table and column family name, and the associated collection of metrics. Please note that this method configures the other object, not this object.


resetSchemaMetricsConf

public static void resetSchemaMetricsConf(SchemaConfigured target)
Reset schema metrics configuration in this particular instance. Used when legitimately need to re-initialize the object with another table/CF. This is a static method because its use is discouraged and reserved for when it is really necessary (e.g. writing HFiles in a temp direcdtory on compaction).


heapSize

public long heapSize()
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.

schemaConfAsJSON

public String schemaConfAsJSON()

isSchemaConfigured

protected boolean isSchemaConfigured()

schemaConfigurationChanged

protected void schemaConfigurationChanged()
A hook method called when schema configuration changes. Can be used to update schema-aware member fields.



Copyright © 2012 The Apache Software Foundation. All Rights Reserved.