ramkrish86 commented on a change in pull request #1552: URL: https://github.com/apache/hbase/pull/1552#discussion_r414464537
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsStoreWrapperImpl.java ########## @@ -0,0 +1,194 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.regionserver; + +import java.io.Closeable; +import java.io.IOException; +import java.util.OptionalDouble; +import java.util.OptionalLong; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import org.apache.hadoop.hbase.CompatibilitySingletonFactory; +import org.apache.hadoop.metrics2.MetricsExecutor; +import org.apache.yetus.audience.InterfaceAudience; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + [email protected] +public class MetricsStoreWrapperImpl implements MetricsStoreWrapper, Closeable { + + private final HStore store; + private static final Logger LOG = LoggerFactory.getLogger(MetricsStoreWrapperImpl.class); + + public static final int PERIOD = 45; + public static final String UNKNOWN = "unknown"; + private ScheduledExecutorService executor; + private Runnable runnable; + // add others also. check if anything is redundant + private long numStoreFiles; + private long memstoreSize; + private long storeFileSize; + private long getsFromMemstore; + private long getsOnStore; + private long getsOnFile; + private long numReferenceFiles; + private long minStoreFileAge; + private long maxStoreFileAge; + private long avgStoreFileAge; + private long numHFiles; + private int storeRefCount; + + private ScheduledFuture<?> storeMetricUpdateTask; + + public MetricsStoreWrapperImpl(HStore store) { + this.store = store; + this.executor = CompatibilitySingletonFactory.getInstance(MetricsExecutor.class).getExecutor(); + this.runnable = new HStoreMetricsWrapperRunnable(); + this.storeMetricUpdateTask = + this.executor.scheduleWithFixedDelay(this.runnable, PERIOD, PERIOD, TimeUnit.SECONDS); + } + + @Override + public void close() throws IOException { + storeMetricUpdateTask.cancel(true); + } + + @Override + public String getStoreName() { + return store.getColumnFamilyName(); + } + + @Override + public String getRegionName() { + return store.getRegionInfo().getRegionNameAsString(); + } + + @Override + public String getTableName() { + return store.getRegionInfo().getTable().getNameAsString(); + } + + @Override + public String getNamespace() { + return store.getTableName().getNamespaceAsString(); + } + + @Override + public long getNumStoreFiles() { + return numStoreFiles; + } + + @Override + public long getMemStoreSize() { + // todo : change this - we need to expose data, heapsize and offheapdatasize Review comment: For now lets be it this way. All other metrics has to be changed. We can do it that time. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
