Class MasterCoprocessorHost.MasterEnvironment

java.lang.Object
org.apache.hadoop.hbase.coprocessor.BaseEnvironment<MasterCoprocessor>
org.apache.hadoop.hbase.master.MasterCoprocessorHost.MasterEnvironment
All Implemented Interfaces:
MasterCoprocessorEnvironment, CoprocessorEnvironment<MasterCoprocessor>
Direct Known Subclasses:
MasterCoprocessorHost.MasterEnvironmentForCoreCoprocessors
Enclosing class:
MasterCoprocessorHost

Coprocessor environment extension providing access to master related services.
  • Field Details

  • Constructor Details

  • Method Details

    • getServerName

      Description copied from interface: MasterCoprocessorEnvironment
      Returns Hosting Server's ServerName
      Specified by:
      getServerName in interface MasterCoprocessorEnvironment
    • getConnection

      Description copied from interface: MasterCoprocessorEnvironment
      Returns the hosts' Connection to the Cluster. Do not close! This is a shared connection with the hosting server. Throws UnsupportedOperationException if you try to close or abort it. For light-weight usage only. Heavy-duty usage will pull down the hosting RegionServer responsiveness as well as that of other Coprocessors making use of this Connection. Use to create table on start or to do administrative operations. Coprocessors should create their own Connections if heavy usage to avoid impinging on hosting Server operation. To create a Connection or if a Coprocessor requires a region with a particular Configuration, use ConnectionFactory or MasterCoprocessorEnvironment.createConnection(Configuration)}.

      Be aware that operations that make use of this Connection are executed as the RegionServer User, the hbase super user that started this server process. Exercise caution running operations as this User (See MasterCoprocessorEnvironment.createConnection(Configuration)} to run as other than the RegionServer User).

      Be careful RPC'ing from a Coprocessor context. RPC's will fail, stall, retry, and/or crawl because the remote side is not online, is struggling or it is on the other side of a network partition. Any use of Connection from inside a Coprocessor must be able to handle all such hiccups.

      Specified by:
      getConnection in interface MasterCoprocessorEnvironment
      Returns:
      The host's Connection to the Cluster.
      See Also:
    • createConnection

      public Connection createConnection(org.apache.hadoop.conf.Configuration conf) throws IOException
      Description copied from interface: MasterCoprocessorEnvironment
      Creates a cluster connection using the passed Configuration. Creating a Connection is a heavy-weight operation. The resultant Connection's cache of region locations will be empty. Therefore you should cache and reuse Connections rather than create a Connection on demand. Create on start of your Coprocessor. You will have to cast the CoprocessorEnvironment appropriately to get at this API at start time because Coprocessor start method is passed a subclass of this CoprocessorEnvironment or fetch Connection using a synchronized accessor initializing the Connection on first access. Close the returned Connection when done to free resources. Using this API rather than ConnectionFactory.createConnection(Configuration) returns a Connection that will short-circuit RPC if the target is a local resource. Use ConnectionFactory if you don't need this ability.

      Be careful RPC'ing from a Coprocessor context. RPC's will fail, stall, retry, and/or crawl because the remote side is not online, is struggling or it is on the other side of a network partition. Any use of Connection from inside a Coprocessor must be able to handle all such hiccups.

      Specified by:
      createConnection in interface MasterCoprocessorEnvironment
      Returns:
      Connection created using the passed conf.
      Throws:
      IOException
    • getMetricRegistryForMaster

      Description copied from interface: MasterCoprocessorEnvironment
      Returns a MetricRegistry that can be used to track metrics at the master level.

      See ExampleMasterObserverWithMetrics class in the hbase-examples modules for examples of how metrics can be instantiated and used.

      Specified by:
      getMetricRegistryForMaster in interface MasterCoprocessorEnvironment
      Returns:
      A MetricRegistry for the coprocessor class to track and export metrics.
    • shutdown

      public void shutdown()
      Description copied from class: BaseEnvironment
      Clean up the environment
      Overrides:
      shutdown in class BaseEnvironment<MasterCoprocessor>