Search in sources :

Example 1 with LossyCounting

use of org.apache.hadoop.hbase.util.LossyCounting in project hbase by apache.

the class MetaTableMetrics method start.

@Override
public void start(CoprocessorEnvironment env) throws IOException {
    observer = new ExampleRegionObserverMeta();
    if (env instanceof RegionCoprocessorEnvironment && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable() != null && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable().equals(TableName.META_TABLE_NAME)) {
        RegionCoprocessorEnvironment regionCoprocessorEnv = (RegionCoprocessorEnvironment) env;
        registry = regionCoprocessorEnv.getMetricRegistryForRegionServer();
        LossyCounting.LossyCountingListener<String> listener = key -> {
            registry.remove(key);
            metrics.remove(key);
        };
        final Configuration conf = regionCoprocessorEnv.getConfiguration();
        clientMetricsLossyCounting = new LossyCounting<>("clientMetaMetrics", conf, listener);
        regionMetricsLossyCounting = new LossyCounting<>("regionMetaMetrics", conf, listener);
        // only be active mode when this region holds meta table.
        active = true;
    }
}
Also used : LossyCounting(org.apache.hadoop.hbase.util.LossyCounting) TableName(org.apache.hadoop.hbase.TableName) ImmutableMap(org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap) Put(org.apache.hadoop.hbase.client.Put) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Get(org.apache.hadoop.hbase.client.Get) Set(java.util.Set) CoprocessorEnvironment(org.apache.hadoop.hbase.CoprocessorEnvironment) IOException(java.io.IOException) Row(org.apache.hadoop.hbase.client.Row) StringUtils(org.apache.commons.lang3.StringUtils) List(java.util.List) Delete(org.apache.hadoop.hbase.client.Delete) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) Configuration(org.apache.hadoop.conf.Configuration) Optional(java.util.Optional) MetricRegistry(org.apache.hadoop.hbase.metrics.MetricRegistry) WALEdit(org.apache.hadoop.hbase.wal.WALEdit) Durability(org.apache.hadoop.hbase.client.Durability) RpcServer(org.apache.hadoop.hbase.ipc.RpcServer) Cell(org.apache.hadoop.hbase.Cell) Bytes(org.apache.hadoop.hbase.util.Bytes) LossyCounting(org.apache.hadoop.hbase.util.LossyCounting) Configuration(org.apache.hadoop.conf.Configuration)

Aggregations

IOException (java.io.IOException)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Configuration (org.apache.hadoop.conf.Configuration)1 Cell (org.apache.hadoop.hbase.Cell)1 CoprocessorEnvironment (org.apache.hadoop.hbase.CoprocessorEnvironment)1 TableName (org.apache.hadoop.hbase.TableName)1 Delete (org.apache.hadoop.hbase.client.Delete)1 Durability (org.apache.hadoop.hbase.client.Durability)1 Get (org.apache.hadoop.hbase.client.Get)1 Put (org.apache.hadoop.hbase.client.Put)1 Row (org.apache.hadoop.hbase.client.Row)1 RpcServer (org.apache.hadoop.hbase.ipc.RpcServer)1 MetricRegistry (org.apache.hadoop.hbase.metrics.MetricRegistry)1 Bytes (org.apache.hadoop.hbase.util.Bytes)1 LossyCounting (org.apache.hadoop.hbase.util.LossyCounting)1 WALEdit (org.apache.hadoop.hbase.wal.WALEdit)1