Class RegionCoprocessorHost.RegionEnvironment
- All Implemented Interfaces:
RegionCoprocessorEnvironment
,CoprocessorEnvironment<RegionCoprocessor>
- Direct Known Subclasses:
RegionCoprocessorHost.RegionEnvironmentForCoreCoprocessors
- Enclosing class:
- RegionCoprocessorHost
-
Field Summary
Modifier and TypeFieldDescriptionprivate final MetricRegistry
private Region
private final RpcQuotaManager
private final RegionServerServices
(package private) ConcurrentMap<String,
Object> Fields inherited from class org.apache.hadoop.hbase.coprocessor.BaseEnvironment
impl, priority
-
Constructor Summary
ConstructorDescriptionRegionEnvironment
(RegionCoprocessor impl, int priority, int seq, org.apache.hadoop.conf.Configuration conf, Region region, RegionServerServices services, ConcurrentMap<String, Object> sharedData) Constructor -
Method Summary
Modifier and TypeMethodDescriptioncheckBatchQuota
(Region region, int numWrites, int numReads) Check the quota for the current (rpc-context) user.checkBatchQuota
(Region region, OperationQuota.OperationType type) Check the quota for the current (rpc-context) user.checkScanQuota
(Scan scan, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) Check the quota for the current (rpc-context) user.createConnection
(org.apache.hadoop.conf.Configuration conf) Creates a cluster connection using the passed Configuration.Returns a CellBuilder so that coprocessors can build cells.Returns the hosts' Connection to the Cluster.Returns a MetricRegistry that can be used to track metrics at the region server level.Returns Interface to Map of regions online on this RegionServerRegionCoprocessorEnvironment.getServerName()
}.Returns the regionReturns region information for the region this coprocessor is running onReturns an RpcQuotaManager that can be used to apply quota checks against the workloads generated by the coprocessor.Returns Hosting Server's ServerNameReturns shared data between all instances of this coprocessorvoid
shutdown()
Clean up the environmentMethods inherited from class org.apache.hadoop.hbase.coprocessor.BaseEnvironment
getClassLoader, getConfiguration, getHBaseVersion, getInstance, getLoadSequence, getPriority, getVersion, startup
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.CoprocessorEnvironment
getClassLoader, getConfiguration, getHBaseVersion, getInstance, getLoadSequence, getPriority, getVersion
-
Field Details
-
region
-
metricRegistry
-
services
-
rpcQuotaManager
-
-
Constructor Details
-
RegionEnvironment
public RegionEnvironment(RegionCoprocessor impl, int priority, int seq, org.apache.hadoop.conf.Configuration conf, Region region, RegionServerServices services, ConcurrentMap<String, Object> sharedData) Constructor- Parameters:
impl
- the coprocessor instancepriority
- chaining priority
-
-
Method Details
-
getRegion
Returns the region- Specified by:
getRegion
in interfaceRegionCoprocessorEnvironment
-
getOnlineRegions
Description copied from interface:RegionCoprocessorEnvironment
Returns Interface to Map of regions online on this RegionServerRegionCoprocessorEnvironment.getServerName()
}.- Specified by:
getOnlineRegions
in interfaceRegionCoprocessorEnvironment
-
getConnection
Description copied from interface:RegionCoprocessorEnvironment
Returns the hosts' Connection to the Cluster. Do not close! This is a shared connection with the hosting server. ThrowsUnsupportedOperationException
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, useConnectionFactory
orRegionCoprocessorEnvironment.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
RegionCoprocessorEnvironment.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 interfaceRegionCoprocessorEnvironment
- Returns:
- The host's Connection to the Cluster.
- See Also:
-
createConnection
Description copied from interface:RegionCoprocessorEnvironment
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 thanConnectionFactory.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 interfaceRegionCoprocessorEnvironment
- Returns:
- Connection created using the passed conf.
- Throws:
IOException
-
getServerName
Description copied from interface:RegionCoprocessorEnvironment
Returns Hosting Server's ServerName- Specified by:
getServerName
in interfaceRegionCoprocessorEnvironment
-
shutdown
Description copied from class:BaseEnvironment
Clean up the environment- Overrides:
shutdown
in classBaseEnvironment<RegionCoprocessor>
-
getRegionInfo
Description copied from interface:RegionCoprocessorEnvironment
Returns region information for the region this coprocessor is running on- Specified by:
getRegionInfo
in interfaceRegionCoprocessorEnvironment
-
getMetricRegistryForRegionServer
Description copied from interface:RegionCoprocessorEnvironment
Returns a MetricRegistry that can be used to track metrics at the region server level. All metrics tracked at this level will be shared by all the coprocessor instances of the same class in the same region server process. Note that there will be one region coprocessor environment per region in the server, but all of these instances will share the same MetricRegistry. The metric instances (like Counter, Timer, etc) will also be shared among all of the region coprocessor instances.See ExampleRegionObserverWithMetrics class in the hbase-examples modules to see examples of how metrics can be instantiated and used.
- Specified by:
getMetricRegistryForRegionServer
in interfaceRegionCoprocessorEnvironment
- Returns:
- A MetricRegistry for the coprocessor class to track and export metrics.
-
getCellBuilder
Description copied from interface:RegionCoprocessorEnvironment
Returns a CellBuilder so that coprocessors can build cells. These cells can also include tags. Note that this builder does not support updating seqId of the cells- Specified by:
getCellBuilder
in interfaceRegionCoprocessorEnvironment
- Returns:
- the RawCellBuilder
-
getRpcQuotaManager
Description copied from interface:RegionCoprocessorEnvironment
Returns an RpcQuotaManager that can be used to apply quota checks against the workloads generated by the coprocessor.- Specified by:
getRpcQuotaManager
in interfaceRegionCoprocessorEnvironment
- Returns:
- the RpcQuotaManager
-
checkScanQuota
public OperationQuota checkScanQuota(Scan scan, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) throws IOException, RpcThrottlingException Description copied from interface:RegionCoprocessorEnvironment
Check the quota for the current (rpc-context) user. Returns the OperationQuota used to get the available quota and to report the data/usage of the operation.- Specified by:
checkScanQuota
in interfaceRegionCoprocessorEnvironment
- Parameters:
scan
- the scan to be estimated against the quotamaxBlockBytesScanned
- the maximum bytes scanned in a single RPC call by the scannerprevBlockBytesScannedDifference
- the difference between BBS of the previous two next calls- Returns:
- the OperationQuota
- Throws:
RpcThrottlingException
- if the operation cannot be executed due to quota exceeded.IOException
-
checkBatchQuota
public OperationQuota checkBatchQuota(Region region, OperationQuota.OperationType type) throws IOException, RpcThrottlingException Description copied from interface:RegionCoprocessorEnvironment
Check the quota for the current (rpc-context) user. Returns the OperationQuota used to get the available quota and to report the data/usage of the operation. This method does not support scans because estimating a scan's workload is more complicated than estimating the workload of a get/put.- Specified by:
checkBatchQuota
in interfaceRegionCoprocessorEnvironment
- Parameters:
region
- the region where the operation will be performedtype
- the operation type- Returns:
- the OperationQuota
- Throws:
RpcThrottlingException
- if the operation cannot be executed due to quota exceeded.IOException
-
checkBatchQuota
public OperationQuota checkBatchQuota(Region region, int numWrites, int numReads) throws IOException, RpcThrottlingException Description copied from interface:RegionCoprocessorEnvironment
Check the quota for the current (rpc-context) user. Returns the OperationQuota used to get the available quota and to report the data/usage of the operation. This method does not support scans because estimating a scan's workload is more complicated than estimating the workload of a get/put.- Specified by:
checkBatchQuota
in interfaceRegionCoprocessorEnvironment
- Parameters:
region
- the region where the operation will be performednumWrites
- number of writes to count against quotanumReads
- number of reads to count against quota- Returns:
- the OperationQuota
- Throws:
RpcThrottlingException
- if the operation cannot be executed due to quota exceeded.IOException
-