From 01bdee029af5a1ed1bb43cf53a8c642c388efa9c Mon Sep 17 00:00:00 2001 From: eclark Date: Thu, 15 Aug 2013 22:04:24 +0000 Subject: [PATCH] HBASE-9194 Break HMaster metrics into multiple contexts git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1514513 13f79535-47bb-0310-9956-ffa450edef68 --- .../MetricsAssignmentManagerSource.java | 75 ++++ .../master/MetricsMasterFileSystemSource.java | 64 ++++ .../hbase/master/MetricsMasterSource.java | 53 +-- .../hbase/master/MetricsSnapshotSource.java | 56 +++ .../balancer/MetricsBalancerSource.java | 51 +++ .../MetricsAssignmentManagerSourceImpl.java | 74 ++++ .../MetricsMasterFilesystemSourceImpl.java | 69 ++++ .../hbase/master/MetricsMasterSourceImpl.java | 71 +--- .../master/MetricsSnapshotSourceImpl.java | 64 ++++ .../balancer/MetricsBalancerSourceImpl.java | 57 ++++ ...base.master.MetricsAssignmentManagerSource | 1 + ...hbase.master.MetricsMasterFileSystemSource | 1 + ....hadoop.hbase.master.MetricsSnapshotSource | 1 + ...base.master.balancer.MetricsBalancerSource | 1 + .../MetricsAssignmentManagerSourceImpl.java | 73 ++++ .../MetricsMasterFilesystemSourceImpl.java | 69 ++++ .../hbase/master/MetricsMasterSourceImpl.java | 70 ---- .../master/MetricsSnapshotSourceImpl.java | 64 ++++ .../balancer/MetricsBalancerSourceImpl.java | 57 ++++ ...base.master.MetricsAssignmentManagerSource | 1 + ...hbase.master.MetricsMasterFileSystemSource | 1 + ....hadoop.hbase.master.MetricsSnapshotSource | 1 + ...base.master.balancer.MetricsBalancerSource | 1 + .../hbase/master/AssignmentManager.java | 320 +++++++++--------- .../apache/hadoop/hbase/master/HMaster.java | 2 +- .../hadoop/hbase/master/MasterFileSystem.java | 12 +- .../master/MetricsAssignmentManager.java | 63 ++++ .../hadoop/hbase/master/MetricsMaster.java | 70 +--- .../hbase/master/MetricsMasterFileSystem.java | 50 +++ .../hadoop/hbase/master/MetricsSnapshot.java | 54 +++ .../master/balancer/BaseLoadBalancer.java | 11 + .../master/balancer/MetricsBalancer.java | 41 +++ .../balancer/StochasticLoadBalancer.java | 1 + .../master/snapshot/CloneSnapshotHandler.java | 11 +- .../DisabledTableSnapshotHandler.java | 4 +- .../snapshot/EnabledTableSnapshotHandler.java | 4 +- .../snapshot/RestoreSnapshotHandler.java | 11 +- .../master/snapshot/SnapshotManager.java | 8 +- .../master/snapshot/TakeSnapshotHandler.java | 11 +- .../hbase/master/TestCatalogJanitor.java | 2 +- 40 files changed, 1199 insertions(+), 451 deletions(-) create mode 100644 hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSource.java create mode 100644 hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystemSource.java create mode 100644 hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSource.java create mode 100644 hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSource.java create mode 100644 hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java create mode 100644 hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java create mode 100644 hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java create mode 100644 hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java create mode 100644 hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource create mode 100644 hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource create mode 100644 hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource create mode 100644 hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource create mode 100644 hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java create mode 100644 hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java create mode 100644 hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java create mode 100644 hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java create mode 100644 hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource create mode 100644 hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource create mode 100644 hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource create mode 100644 hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManager.java create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystem.java create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshot.java create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancer.java diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSource.java new file mode 100644 index 00000000000..92fd111cb57 --- /dev/null +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSource.java @@ -0,0 +1,75 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSource; + +public interface MetricsAssignmentManagerSource extends BaseSource { + + /** + * The name of the metrics + */ + String METRICS_NAME = "AssignmentManger"; + + /** + * The context metrics will be under. + */ + String METRICS_CONTEXT = "master"; + + /** + * The name of the metrics context that metrics will be under in jmx + */ + String METRICS_JMX_CONTEXT = "Master,sub=" + METRICS_NAME; + + /** + * Description + */ + String METRICS_DESCRIPTION = "Metrics about HBase master assingment manager."; + + String RIT_COUNT_NAME = "ritCount"; + String RIT_COUNT_OVER_THRESHOLD_NAME = "ritCountOverThreshold"; + String RIT_OLDEST_AGE_NAME = "ritOldestAge"; + String ASSIGN_TIME_NAME = "assign"; + String BULK_ASSIGN_TIME_NAME = "bulkAssign"; + + void updateAssignmentTime(long time); + + void updateBulkAssignTime(long time); + + /** + * Set the number of regions in transition. + * + * @param ritCount count of the regions in transition. + */ + void setRIT(int ritCount); + + /** + * Set the count of the number of regions that have been in transition over the threshold time. + * + * @param ritCountOverThreshold number of regions in transition for longer than threshold. + */ + void setRITCountOverThreshold(int ritCountOverThreshold); + + /** + * Set the oldest region in transition. + * + * @param age age of the oldest RIT. + */ + void setRITOldestAge(long age); +} diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystemSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystemSource.java new file mode 100644 index 00000000000..071a9672f48 --- /dev/null +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystemSource.java @@ -0,0 +1,64 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSource; + +public interface MetricsMasterFileSystemSource extends BaseSource { + + /** + * The name of the metrics + */ + String METRICS_NAME = "FileSystem"; + + /** + * The context metrics will be under. + */ + String METRICS_CONTEXT = "master"; + + /** + * The name of the metrics context that metrics will be under in jmx + */ + String METRICS_JMX_CONTEXT = "Master,sub=" + METRICS_NAME; + + /** + * Description + */ + String METRICS_DESCRIPTION = "Metrics about HBase master file system."; + + String META_SPLIT_TIME_NAME = "metaHlogSplitTime"; + String META_SPLIT_SIZE_NAME = "metaHlogSplitSize"; + String SPLIT_TIME_NAME = "hlogSplitTime"; + String SPLIT_SIZE_NAME = "hlogSplitSize"; + + String META_SPLIT_TIME_DESC = "Time it takes to finish splitMetaLog()"; + String META_SPLIT_SIZE_DESC = "Size of META HLog files being split"; + String SPLIT_TIME_DESC = "Time it takes to finish HLog.splitLog()"; + String SPLIT_SIZE_DESC = "Size of HLog files being split"; + + + void updateMetaWALSplitTime(long time); + + void updateMetaWALSplitSize(long size); + + void updateSplitTime(long time); + + void updateSplitSize(long size); + +} diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSource.java index 14a62f06f19..64df5701ead 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSource.java @@ -55,17 +55,9 @@ public interface MetricsMasterSource extends BaseSource { String SERVER_NAME_NAME = "serverName"; String CLUSTER_ID_NAME = "clusterId"; String IS_ACTIVE_MASTER_NAME = "isActiveMaster"; - String SPLIT_TIME_NAME = "hlogSplitTime"; - String SPLIT_SIZE_NAME = "hlogSplitSize"; - String SNAPSHOT_TIME_NAME = "snapshotTime"; - String SNAPSHOT_RESTORE_TIME_NAME = "snapshotRestoreTime"; - String SNAPSHOT_CLONE_TIME_NAME = "snapshotCloneTime"; - String META_SPLIT_TIME_NAME = "metaHlogSplitTime"; - String META_SPLIT_SIZE_NAME = "metaHlogSplitSize"; + + String CLUSTER_REQUESTS_NAME = "clusterRequests"; - String RIT_COUNT_NAME = "ritCount"; - String RIT_COUNT_OVER_THRESHOLD_NAME = "ritCountOverThreshold"; - String RIT_OLDEST_AGE_NAME = "ritOldestAge"; String MASTER_ACTIVE_TIME_DESC = "Master Active Time"; String MASTER_START_TIME_DESC = "Master Start Time"; String AVERAGE_LOAD_DESC = "AverageLoad"; @@ -75,13 +67,8 @@ public interface MetricsMasterSource extends BaseSource { String SERVER_NAME_DESC = "Server Name"; String CLUSTER_ID_DESC = "Cluster Id"; String IS_ACTIVE_MASTER_DESC = "Is Active Master"; - String SPLIT_TIME_DESC = "Time it takes to finish HLog.splitLog()"; - String SPLIT_SIZE_DESC = "Size of HLog files being split"; - String SNAPSHOT_TIME_DESC = "Time it takes to finish snapshot()"; - String SNAPSHOT_RESTORE_TIME_DESC = "Time it takes to finish restoreSnapshot()"; - String SNAPSHOT_CLONE_TIME_DESC = "Time it takes to finish cloneSnapshot()"; - String META_SPLIT_TIME_DESC = "Time it takes to finish splitMetaLog()"; - String META_SPLIT_SIZE_DESC = "Size of META HLog files being split"; + + /** * Increment the number of requests the cluster has seen. @@ -90,39 +77,7 @@ public interface MetricsMasterSource extends BaseSource { */ void incRequests(final int inc); - /** - * Set the number of regions in transition. - * - * @param ritCount count of the regions in transition. - */ - void setRIT(int ritCount); - - /** - * Set the count of the number of regions that have been in transition over the threshold time. - * - * @param ritCountOverThreshold number of regions in transition for longer than threshold. - */ - void setRITCountOverThreshold(int ritCountOverThreshold); - - /** - * Set the oldest region in transition. - * - * @param age age of the oldest RIT. - */ - void setRITOldestAge(long age); - - void updateSplitTime(long time); - - void updateSplitSize(long size); - - void updateSnapshotTime(long time); - - void updateSnapshotCloneTime(long time); - - void updateSnapshotRestoreTime(long time); - void updateMetaWALSplitTime(long time); - void updateMetaWALSplitSize(long size); } diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSource.java new file mode 100644 index 00000000000..371a316132c --- /dev/null +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSource.java @@ -0,0 +1,56 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSource; + +public interface MetricsSnapshotSource extends BaseSource { + /** + * The name of the metrics + */ + String METRICS_NAME = "Snapshots"; + + /** + * The context metrics will be under. + */ + String METRICS_CONTEXT = "master"; + + /** + * The name of the metrics context that metrics will be under in jmx + */ + String METRICS_JMX_CONTEXT = "Master,sub=" + METRICS_NAME; + + /** + * Description + */ + String METRICS_DESCRIPTION = "Metrics about HBase master server"; + + String SNAPSHOT_TIME_NAME = "snapshotTime"; + String SNAPSHOT_RESTORE_TIME_NAME = "snapshotRestoreTime"; + String SNAPSHOT_CLONE_TIME_NAME = "snapshotCloneTime"; + String SNAPSHOT_TIME_DESC = "Time it takes to finish snapshot()"; + String SNAPSHOT_RESTORE_TIME_DESC = "Time it takes to finish restoreSnapshot()"; + String SNAPSHOT_CLONE_TIME_DESC = "Time it takes to finish cloneSnapshot()"; + + void updateSnapshotTime(long time); + + void updateSnapshotCloneTime(long time); + + void updateSnapshotRestoreTime(long time); +} diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSource.java new file mode 100644 index 00000000000..1c9a61e0a88 --- /dev/null +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSource.java @@ -0,0 +1,51 @@ +/** + * 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.master.balancer; + +import org.apache.hadoop.hbase.metrics.BaseSource; + +public interface MetricsBalancerSource extends BaseSource { + + /** + * The name of the metrics + */ + String METRICS_NAME = "Balancer"; + + /** + * The context metrics will be under. + */ + String METRICS_CONTEXT = "master"; + + /** + * The name of the metrics context that metrics will be under in jmx + */ + String METRICS_JMX_CONTEXT = "Master,sub=" + METRICS_NAME; + + String BALANCE_CLUSTER = "balancerCluster"; + String MISC_INVOATION_COUNT = "miscInvocationCount"; + + /** + * Description + */ + String METRICS_DESCRIPTION = "Metrics about HBase master balancer"; + + void updateBalanceCluster(long time); + + void incrMiscInvocations(); +} diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java new file mode 100644 index 00000000000..8f8869b6756 --- /dev/null +++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java @@ -0,0 +1,74 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong; +import org.apache.hadoop.metrics2.lib.MetricMutableHistogram; + +public class MetricsAssignmentManagerSourceImpl extends BaseSourceImpl implements MetricsAssignmentManagerSource { + + private MetricMutableGaugeLong ritGauge; + private MetricMutableGaugeLong ritCountOverThresholdGauge; + private MetricMutableGaugeLong ritOldestAgeGauge; + private MetricMutableHistogram assignTimeHisto; + private MetricMutableHistogram bulkAssignTimeHisto; + + public MetricsAssignmentManagerSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsAssignmentManagerSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + @Override + public void init() { + super.init(); + ritGauge = metricsRegistry.newGauge(RIT_COUNT_NAME, "", 0l); + ritCountOverThresholdGauge = metricsRegistry.newGauge(RIT_COUNT_OVER_THRESHOLD_NAME, "", 0l); + ritOldestAgeGauge = metricsRegistry.newGauge(RIT_OLDEST_AGE_NAME, "", 0l); + assignTimeHisto = metricsRegistry.newHistogram(ASSIGN_TIME_NAME); + bulkAssignTimeHisto = metricsRegistry.newHistogram(BULK_ASSIGN_TIME_NAME); + } + + @Override + public void updateAssignmentTime(long time) { + assignTimeHisto.add(time); + } + + @Override + public void updateBulkAssignTime(long time) { + bulkAssignTimeHisto.add(time); + } + + public void setRIT(int ritCount) { + ritGauge.set(ritCount); + } + + public void setRITCountOverThreshold(int ritCount) { + ritCountOverThresholdGauge.set(ritCount); + } + + public void setRITOldestAge(long ritCount) { + ritOldestAgeGauge.set(ritCount); + } +} diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java new file mode 100644 index 00000000000..40c1e640c59 --- /dev/null +++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java @@ -0,0 +1,69 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MetricMutableHistogram; + +public class MetricsMasterFilesystemSourceImpl extends BaseSourceImpl implements MetricsMasterFileSystemSource { + + private MetricMutableHistogram splitSizeHisto; + private MetricMutableHistogram splitTimeHisto; + private MetricMutableHistogram metaSplitTimeHisto; + private MetricMutableHistogram metaSplitSizeHisto; + + public MetricsMasterFilesystemSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsMasterFilesystemSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + @Override + public void init() { + splitSizeHisto = metricsRegistry.newHistogram(SPLIT_SIZE_NAME, SPLIT_SIZE_DESC); + splitTimeHisto = metricsRegistry.newHistogram(SPLIT_TIME_NAME, SPLIT_TIME_DESC); + metaSplitTimeHisto = metricsRegistry.newHistogram(META_SPLIT_TIME_NAME, META_SPLIT_TIME_DESC); + metaSplitSizeHisto = metricsRegistry.newHistogram(META_SPLIT_SIZE_NAME, META_SPLIT_SIZE_DESC); + } + + @Override + public void updateSplitTime(long time) { + splitTimeHisto.add(time); + } + + @Override + public void updateSplitSize(long size) { + splitSizeHisto.add(size); + } + + + @Override + public void updateMetaWALSplitTime(long time) { + metaSplitTimeHisto.add(time); + } + + @Override + public void updateMetaWALSplitSize(long size) { + metaSplitSizeHisto.add(size); + } +} diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java index 46503077149..373644a908f 100644 --- a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java +++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java @@ -40,16 +40,7 @@ public class MetricsMasterSourceImpl private final MetricsMasterWrapper masterWrapper; private MetricMutableCounterLong clusterRequestsCounter; - private MetricMutableGaugeLong ritGauge; - private MetricMutableGaugeLong ritCountOverThresholdGauge; - private MetricMutableGaugeLong ritOldestAgeGauge; - private MetricMutableHistogram splitTimeHisto; - private MetricMutableHistogram splitSizeHisto; - private MetricMutableStat snapshotTimeHisto; - private MetricMutableStat snapshotCloneTimeHisto; - private MetricMutableStat snapshotRestoreTimeHisto; - private MetricMutableHistogram metaSplitTimeHisto; - private MetricMutableHistogram metaSplitSizeHisto; + public MetricsMasterSourceImpl(MetricsMasterWrapper masterWrapper) { this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT, masterWrapper); @@ -68,72 +59,12 @@ public class MetricsMasterSourceImpl public void init() { super.init(); clusterRequestsCounter = metricsRegistry.newCounter(CLUSTER_REQUESTS_NAME, "", 0l); - ritGauge = metricsRegistry.newGauge(RIT_COUNT_NAME, "", 0l); - ritCountOverThresholdGauge = metricsRegistry.newGauge(RIT_COUNT_OVER_THRESHOLD_NAME, "", 0l); - ritOldestAgeGauge = metricsRegistry.newGauge(RIT_OLDEST_AGE_NAME, "", 0l); - splitSizeHisto = metricsRegistry.newHistogram(SPLIT_SIZE_NAME, SPLIT_SIZE_DESC); - splitTimeHisto = metricsRegistry.newHistogram(SPLIT_TIME_NAME, SPLIT_TIME_DESC); - snapshotTimeHisto = metricsRegistry.newStat( - SNAPSHOT_TIME_NAME, SNAPSHOT_TIME_DESC, "Ops", "Time", true); - snapshotCloneTimeHisto = metricsRegistry.newStat( - SNAPSHOT_CLONE_TIME_NAME, SNAPSHOT_CLONE_TIME_DESC, "Ops", "Time", true); - snapshotRestoreTimeHisto = metricsRegistry.newStat( - SNAPSHOT_RESTORE_TIME_NAME, SNAPSHOT_RESTORE_TIME_DESC, "Ops", "Time", true); - metaSplitTimeHisto = metricsRegistry.newHistogram(META_SPLIT_TIME_NAME, META_SPLIT_TIME_DESC); - metaSplitSizeHisto = metricsRegistry.newHistogram(META_SPLIT_SIZE_NAME, META_SPLIT_SIZE_DESC); } public void incRequests(final int inc) { this.clusterRequestsCounter.incr(inc); } - public void setRIT(int ritCount) { - ritGauge.set(ritCount); - } - - public void setRITCountOverThreshold(int ritCount) { - ritCountOverThresholdGauge.set(ritCount); - } - - public void setRITOldestAge(long ritCount) { - ritOldestAgeGauge.set(ritCount); - } - - @Override - public void updateSplitTime(long time) { - splitTimeHisto.add(time); - } - - @Override - public void updateSplitSize(long size) { - splitSizeHisto.add(size); - } - - @Override - public void updateSnapshotTime(long time) { - snapshotTimeHisto.add(time); - } - - @Override - public void updateSnapshotCloneTime(long time) { - snapshotCloneTimeHisto.add(time); - } - - @Override - public void updateSnapshotRestoreTime(long time) { - snapshotRestoreTimeHisto.add(time); - } - - @Override - public void updateMetaWALSplitTime(long time) { - metaSplitTimeHisto.add(time); - } - - @Override - public void updateMetaWALSplitSize(long size) { - metaSplitSizeHisto.add(size); - } - /** * Method to export all the metrics. * diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java new file mode 100644 index 00000000000..6b43d30a432 --- /dev/null +++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java @@ -0,0 +1,64 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MetricMutableHistogram; + +public class MetricsSnapshotSourceImpl extends BaseSourceImpl implements MetricsSnapshotSource { + + private MetricMutableHistogram snapshotTimeHisto; + private MetricMutableHistogram snapshotCloneTimeHisto; + private MetricMutableHistogram snapshotRestoreTimeHisto; + + public MetricsSnapshotSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsSnapshotSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + @Override + public void init() { + snapshotTimeHisto = metricsRegistry.newHistogram( + SNAPSHOT_TIME_NAME, SNAPSHOT_TIME_DESC); + snapshotCloneTimeHisto = metricsRegistry.newHistogram( + SNAPSHOT_CLONE_TIME_NAME, SNAPSHOT_CLONE_TIME_DESC); + snapshotRestoreTimeHisto = metricsRegistry.newHistogram( + SNAPSHOT_RESTORE_TIME_NAME, SNAPSHOT_RESTORE_TIME_DESC); + } + + @Override + public void updateSnapshotTime(long time) { + snapshotTimeHisto.add(time); + } + + @Override + public void updateSnapshotCloneTime(long time) { + snapshotCloneTimeHisto.add(time); + } + + @Override + public void updateSnapshotRestoreTime(long time) { + snapshotRestoreTimeHisto.add(time); + } +} diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java new file mode 100644 index 00000000000..4311330efb3 --- /dev/null +++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java @@ -0,0 +1,57 @@ +/** + * 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.master.balancer; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MetricMutableCounterLong; +import org.apache.hadoop.metrics2.lib.MetricMutableHistogram; + +public class MetricsBalancerSourceImpl extends BaseSourceImpl implements MetricsBalancerSource{ + + private MetricMutableHistogram blanceClusterHisto; + private MetricMutableCounterLong miscCount; + + public MetricsBalancerSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsBalancerSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + + @Override + public void init() { + blanceClusterHisto = metricsRegistry.newHistogram(BALANCE_CLUSTER); + miscCount = metricsRegistry.newCounter(MISC_INVOATION_COUNT, "", 0L); + + } + + @Override + public void updateBalanceCluster(long time) { + blanceClusterHisto.add(time); + } + + @Override + public void incrMiscInvocations() { + miscCount.incr(); + } +} diff --git a/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource new file mode 100644 index 00000000000..8ee4289125f --- /dev/null +++ b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.MetricsAssignmentManagerSourceImpl diff --git a/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource new file mode 100644 index 00000000000..d4b4b6f89be --- /dev/null +++ b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.MetricsMasterFilesystemSourceImpl \ No newline at end of file diff --git a/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource new file mode 100644 index 00000000000..fb5dd1a9950 --- /dev/null +++ b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.MetricsSnapshotSourceImpl diff --git a/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource new file mode 100644 index 00000000000..92699d20ccf --- /dev/null +++ b/hbase-hadoop1-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.balancer.MetricsBalancerSourceImpl \ No newline at end of file diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java new file mode 100644 index 00000000000..0d0c43a659b --- /dev/null +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java @@ -0,0 +1,73 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MutableGaugeLong; +import org.apache.hadoop.metrics2.lib.MutableHistogram; + + +public class MetricsAssignmentManagerSourceImpl extends BaseSourceImpl implements MetricsAssignmentManagerSource { + + private MutableGaugeLong ritGauge; + private MutableGaugeLong ritCountOverThresholdGauge; + private MutableGaugeLong ritOldestAgeGauge; + private MutableHistogram assignTimeHisto; + private MutableHistogram bulkAssignTimeHisto; + + public MetricsAssignmentManagerSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsAssignmentManagerSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + public void init() { + ritGauge = metricsRegistry.newGauge(RIT_COUNT_NAME, "", 0l); + ritCountOverThresholdGauge = metricsRegistry.newGauge(RIT_COUNT_OVER_THRESHOLD_NAME, "", 0l); + ritOldestAgeGauge = metricsRegistry.newGauge(RIT_OLDEST_AGE_NAME, "", 0l); + assignTimeHisto = metricsRegistry.newHistogram(ASSIGN_TIME_NAME); + bulkAssignTimeHisto = metricsRegistry.newHistogram(BULK_ASSIGN_TIME_NAME); + } + + @Override + public void updateAssignmentTime(long time) { + assignTimeHisto.add(time); + } + + @Override + public void updateBulkAssignTime(long time) { + bulkAssignTimeHisto.add(time); + } + + public void setRIT(int ritCount) { + ritGauge.set(ritCount); + } + + public void setRITCountOverThreshold(int ritCount) { + ritCountOverThresholdGauge.set(ritCount); + } + + public void setRITOldestAge(long ritCount) { + ritOldestAgeGauge.set(ritCount); + } +} diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java new file mode 100644 index 00000000000..2e062c2e3c1 --- /dev/null +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFilesystemSourceImpl.java @@ -0,0 +1,69 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MutableHistogram; + +public class MetricsMasterFilesystemSourceImpl extends BaseSourceImpl implements MetricsMasterFileSystemSource { + + private MutableHistogram splitSizeHisto; + private MutableHistogram splitTimeHisto; + private MutableHistogram metaSplitTimeHisto; + private MutableHistogram metaSplitSizeHisto; + + public MetricsMasterFilesystemSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsMasterFilesystemSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + @Override + public void init() { + splitSizeHisto = metricsRegistry.newHistogram(SPLIT_SIZE_NAME, SPLIT_SIZE_DESC); + splitTimeHisto = metricsRegistry.newHistogram(SPLIT_TIME_NAME, SPLIT_TIME_DESC); + metaSplitTimeHisto = metricsRegistry.newHistogram(META_SPLIT_TIME_NAME, META_SPLIT_TIME_DESC); + metaSplitSizeHisto = metricsRegistry.newHistogram(META_SPLIT_SIZE_NAME, META_SPLIT_SIZE_DESC); + } + + @Override + public void updateSplitTime(long time) { + splitTimeHisto.add(time); + } + + @Override + public void updateSplitSize(long size) { + splitSizeHisto.add(size); + } + + + @Override + public void updateMetaWALSplitTime(long time) { + metaSplitTimeHisto.add(time); + } + + @Override + public void updateMetaWALSplitSize(long size) { + metaSplitSizeHisto.add(size); + } +} diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java index 7fced1660e0..01026acb94b 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterSourceImpl.java @@ -37,16 +37,6 @@ public class MetricsMasterSourceImpl private final MetricsMasterWrapper masterWrapper; private MutableCounterLong clusterRequestsCounter; - private MutableGaugeLong ritGauge; - private MutableGaugeLong ritCountOverThresholdGauge; - private MutableGaugeLong ritOldestAgeGauge; - private MutableHistogram splitTimeHisto; - private MutableHistogram splitSizeHisto; - private MutableStat snapshotTimeHisto; - private MutableStat snapshotCloneTimeHisto; - private MutableStat snapshotRestoreTimeHisto; - private MutableHistogram metaSplitTimeHisto; - private MutableHistogram metaSplitSizeHisto; public MetricsMasterSourceImpl(MetricsMasterWrapper masterWrapper) { this(METRICS_NAME, @@ -70,72 +60,12 @@ public class MetricsMasterSourceImpl public void init() { super.init(); clusterRequestsCounter = metricsRegistry.newCounter(CLUSTER_REQUESTS_NAME, "", 0l); - ritGauge = metricsRegistry.newGauge(RIT_COUNT_NAME, "", 0l); - ritCountOverThresholdGauge = metricsRegistry.newGauge(RIT_COUNT_OVER_THRESHOLD_NAME, "", 0l); - ritOldestAgeGauge = metricsRegistry.newGauge(RIT_OLDEST_AGE_NAME, "", 0l); - splitSizeHisto = metricsRegistry.newHistogram(SPLIT_SIZE_NAME, SPLIT_SIZE_DESC); - splitTimeHisto = metricsRegistry.newHistogram(SPLIT_TIME_NAME, SPLIT_TIME_DESC); - snapshotTimeHisto = metricsRegistry.newStat( - SNAPSHOT_TIME_NAME, SNAPSHOT_TIME_DESC, "Ops", "Time", true); - snapshotCloneTimeHisto = metricsRegistry.newStat( - SNAPSHOT_CLONE_TIME_NAME, SNAPSHOT_CLONE_TIME_DESC, "Ops", "Time", true); - snapshotRestoreTimeHisto = metricsRegistry.newStat( - SNAPSHOT_RESTORE_TIME_NAME, SNAPSHOT_RESTORE_TIME_DESC, "Ops", "Time", true); - metaSplitTimeHisto = metricsRegistry.newHistogram(META_SPLIT_TIME_NAME, META_SPLIT_TIME_DESC); - metaSplitSizeHisto = metricsRegistry.newHistogram(META_SPLIT_SIZE_NAME, META_SPLIT_SIZE_DESC); } public void incRequests(final int inc) { this.clusterRequestsCounter.incr(inc); } - public void setRIT(int ritCount) { - ritGauge.set(ritCount); - } - - public void setRITCountOverThreshold(int ritCount) { - ritCountOverThresholdGauge.set(ritCount); - } - - public void setRITOldestAge(long ritCount) { - ritOldestAgeGauge.set(ritCount); - } - - @Override - public void updateSplitTime(long time) { - splitTimeHisto.add(time); - } - - @Override - public void updateSplitSize(long size) { - splitSizeHisto.add(size); - } - - @Override - public void updateSnapshotTime(long time) { - snapshotTimeHisto.add(time); - } - - @Override - public void updateSnapshotCloneTime(long time) { - snapshotCloneTimeHisto.add(time); - } - - @Override - public void updateSnapshotRestoreTime(long time) { - snapshotRestoreTimeHisto.add(time); - } - - @Override - public void updateMetaWALSplitTime(long time) { - metaSplitTimeHisto.add(time); - } - - @Override - public void updateMetaWALSplitSize(long size) { - metaSplitSizeHisto.add(size); - } - @Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java new file mode 100644 index 00000000000..29c9c0a2686 --- /dev/null +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshotSourceImpl.java @@ -0,0 +1,64 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MutableHistogram; + +public class MetricsSnapshotSourceImpl extends BaseSourceImpl implements MetricsSnapshotSource { + + private MutableHistogram snapshotTimeHisto; + private MutableHistogram snapshotCloneTimeHisto; + private MutableHistogram snapshotRestoreTimeHisto; + + public MetricsSnapshotSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsSnapshotSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + @Override + public void init() { + snapshotTimeHisto = metricsRegistry.newHistogram( + SNAPSHOT_TIME_NAME, SNAPSHOT_TIME_DESC); + snapshotCloneTimeHisto = metricsRegistry.newHistogram( + SNAPSHOT_CLONE_TIME_NAME, SNAPSHOT_CLONE_TIME_DESC); + snapshotRestoreTimeHisto = metricsRegistry.newHistogram( + SNAPSHOT_RESTORE_TIME_NAME, SNAPSHOT_RESTORE_TIME_DESC); + } + + @Override + public void updateSnapshotTime(long time) { + snapshotTimeHisto.add(time); + } + + @Override + public void updateSnapshotCloneTime(long time) { + snapshotCloneTimeHisto.add(time); + } + + @Override + public void updateSnapshotRestoreTime(long time) { + snapshotRestoreTimeHisto.add(time); + } +} diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java new file mode 100644 index 00000000000..6e43e58eac2 --- /dev/null +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancerSourceImpl.java @@ -0,0 +1,57 @@ +/** + * 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.master.balancer; + +import org.apache.hadoop.hbase.metrics.BaseSourceImpl; +import org.apache.hadoop.metrics2.lib.MutableCounterLong; +import org.apache.hadoop.metrics2.lib.MutableHistogram; + +public class MetricsBalancerSourceImpl extends BaseSourceImpl implements MetricsBalancerSource{ + + private MutableHistogram blanceClusterHisto; + private MutableCounterLong miscCount; + + public MetricsBalancerSourceImpl() { + this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT); + } + + public MetricsBalancerSourceImpl(String metricsName, + String metricsDescription, + String metricsContext, String metricsJmxContext) { + super(metricsName, metricsDescription, metricsContext, metricsJmxContext); + } + + + @Override + public void init() { + blanceClusterHisto = metricsRegistry.newHistogram(BALANCE_CLUSTER); + miscCount = metricsRegistry.newCounter(MISC_INVOATION_COUNT, "", 0L); + + } + + @Override + public void updateBalanceCluster(long time) { + blanceClusterHisto.add(time); + } + + @Override + public void incrMiscInvocations() { + miscCount.incr(); + } +} diff --git a/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource new file mode 100644 index 00000000000..8ee4289125f --- /dev/null +++ b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsAssignmentManagerSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.MetricsAssignmentManagerSourceImpl diff --git a/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource new file mode 100644 index 00000000000..d4b4b6f89be --- /dev/null +++ b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsMasterFileSystemSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.MetricsMasterFilesystemSourceImpl \ No newline at end of file diff --git a/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource new file mode 100644 index 00000000000..fb5dd1a9950 --- /dev/null +++ b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.MetricsSnapshotSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.MetricsSnapshotSourceImpl diff --git a/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource new file mode 100644 index 00000000000..92699d20ccf --- /dev/null +++ b/hbase-hadoop2-compat/src/main/resources/META-INF/services/org.apache.hadoop.hbase.master.balancer.MetricsBalancerSource @@ -0,0 +1 @@ +org.apache.hadoop.hbase.master.balancer.MetricsBalancerSourceImpl \ No newline at end of file diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index 390e6d44ca8..0a666fc13a4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -123,6 +123,8 @@ public class AssignmentManager extends ZooKeeperListener { private LoadBalancer balancer; + private final MetricsAssignmentManager metricsAssignmentManager; + private final TableLockManager tableLockManager; final private KeyLocker locker = new KeyLocker(); @@ -182,9 +184,6 @@ public class AssignmentManager extends ZooKeeperListener { private List ignoreStatesRSOffline = Arrays.asList( EventType.RS_ZK_REGION_FAILED_OPEN, EventType.RS_ZK_REGION_CLOSED); - // metrics instance to send metrics for RITs - MetricsMaster metricsMaster; - private final RegionStates regionStates; // The threshold to use bulk assigning. Using bulk assignment @@ -273,7 +272,6 @@ public class AssignmentManager extends ZooKeeperListener { int maxThreads = conf.getInt("hbase.assignment.threads.max", 30); this.threadPoolExecutorService = Threads.getBoundedCachedThreadPool( maxThreads, 60L, TimeUnit.SECONDS, Threads.newDaemonThreadFactory("AM.")); - this.metricsMaster = metricsMaster;// can be null only with tests. this.regionStates = new RegionStates(server, serverManager); this.bulkAssignWaitTillAllAssigned = @@ -286,6 +284,8 @@ public class AssignmentManager extends ZooKeeperListener { zkEventWorkers = Threads.getBoundedCachedThreadPool(workers, 60L, TimeUnit.SECONDS, threadFactory); this.tableLockManager = tableLockManager; + + this.metricsAssignmentManager = new MetricsAssignmentManager(); } void startTimeOutMonitor() { @@ -1533,170 +1533,175 @@ public class AssignmentManager extends ZooKeeperListener { * @return true if successful */ boolean assign(final ServerName destination, final List regions) { - int regionCount = regions.size(); - if (regionCount == 0) { - return true; - } - LOG.debug("Assigning " + regionCount + " region(s) to " + destination.toString()); - Set encodedNames = new HashSet(regionCount); - for (HRegionInfo region : regions) { - encodedNames.add(region.getEncodedName()); - } - - List failedToOpenRegions = new ArrayList(); - Map locks = locker.acquireLocks(encodedNames); + long startTime = EnvironmentEdgeManager.currentTimeMillis(); try { - AtomicInteger counter = new AtomicInteger(0); - Map offlineNodesVersions = new ConcurrentHashMap(); - OfflineCallback cb = new OfflineCallback( - watcher, destination, counter, offlineNodesVersions); - Map plans = new HashMap(regions.size()); - List states = new ArrayList(regions.size()); + int regionCount = regions.size(); + if (regionCount == 0) { + return true; + } + LOG.debug("Assigning " + regionCount + " region(s) to " + destination.toString()); + Set encodedNames = new HashSet(regionCount); for (HRegionInfo region : regions) { - String encodedRegionName = region.getEncodedName(); - RegionState state = forceRegionStateToOffline(region, true); - if (state != null && asyncSetOfflineInZooKeeper(state, cb, destination)) { - RegionPlan plan = new RegionPlan(region, state.getServerName(), destination); - plans.put(encodedRegionName, plan); - states.add(state); - } else { - LOG.warn("failed to force region state to offline or " - + "failed to set it offline in ZK, will reassign later: " + region); - failedToOpenRegions.add(region); // assign individually later - Lock lock = locks.remove(encodedRegionName); - lock.unlock(); - } + encodedNames.add(region.getEncodedName()); } - // Wait until all unassigned nodes have been put up and watchers set. - int total = states.size(); - for (int oldCounter = 0; !server.isStopped();) { - int count = counter.get(); - if (oldCounter != count) { - LOG.info(destination.toString() + " unassigned znodes=" + count + - " of total=" + total); - oldCounter = count; - } - if (count >= total) break; - Threads.sleep(5); - } - - if (server.isStopped()) { - return false; - } - - // Add region plans, so we can updateTimers when one region is opened so - // that unnecessary timeout on RIT is reduced. - this.addPlans(plans); - - List>> regionOpenInfos = - new ArrayList>>(states.size()); - for (RegionState state: states) { - HRegionInfo region = state.getRegion(); - String encodedRegionName = region.getEncodedName(); - Integer nodeVersion = offlineNodesVersions.get(encodedRegionName); - if (nodeVersion == null || nodeVersion == -1) { - LOG.warn("failed to offline in zookeeper: " + region); - failedToOpenRegions.add(region); // assign individually later - Lock lock = locks.remove(encodedRegionName); - lock.unlock(); - } else { - regionStates.updateRegionState(region, - RegionState.State.PENDING_OPEN, destination); - List favoredNodes = ServerName.EMPTY_SERVER_LIST; - if (this.shouldAssignRegionsWithFavoredNodes) { - favoredNodes = ((FavoredNodeLoadBalancer)this.balancer).getFavoredNodes(region); - } - regionOpenInfos.add(new Triple>( - region, nodeVersion, favoredNodes)); - } - } - - // Move on to open regions. + List failedToOpenRegions = new ArrayList(); + Map locks = locker.acquireLocks(encodedNames); try { - // Send OPEN RPC. If it fails on a IOE or RemoteException, the - // TimeoutMonitor will pick up the pieces. - long maxWaitTime = System.currentTimeMillis() + - this.server.getConfiguration(). - getLong("hbase.regionserver.rpc.startup.waittime", 60000); - for (int i = 1; i <= maximumAttempts && !server.isStopped(); i++) { - try { - List regionOpeningStateList = serverManager - .sendRegionOpen(destination, regionOpenInfos); - if (regionOpeningStateList == null) { - // Failed getting RPC connection to this server - return false; + AtomicInteger counter = new AtomicInteger(0); + Map offlineNodesVersions = new ConcurrentHashMap(); + OfflineCallback cb = new OfflineCallback( + watcher, destination, counter, offlineNodesVersions); + Map plans = new HashMap(regions.size()); + List states = new ArrayList(regions.size()); + for (HRegionInfo region : regions) { + String encodedRegionName = region.getEncodedName(); + RegionState state = forceRegionStateToOffline(region, true); + if (state != null && asyncSetOfflineInZooKeeper(state, cb, destination)) { + RegionPlan plan = new RegionPlan(region, state.getServerName(), destination); + plans.put(encodedRegionName, plan); + states.add(state); + } else { + LOG.warn("failed to force region state to offline or " + + "failed to set it offline in ZK, will reassign later: " + region); + failedToOpenRegions.add(region); // assign individually later + Lock lock = locks.remove(encodedRegionName); + lock.unlock(); + } + } + + // Wait until all unassigned nodes have been put up and watchers set. + int total = states.size(); + for (int oldCounter = 0; !server.isStopped();) { + int count = counter.get(); + if (oldCounter != count) { + LOG.info(destination.toString() + " unassigned znodes=" + count + + " of total=" + total); + oldCounter = count; + } + if (count >= total) break; + Threads.sleep(5); + } + + if (server.isStopped()) { + return false; + } + + // Add region plans, so we can updateTimers when one region is opened so + // that unnecessary timeout on RIT is reduced. + this.addPlans(plans); + + List>> regionOpenInfos = + new ArrayList>>(states.size()); + for (RegionState state: states) { + HRegionInfo region = state.getRegion(); + String encodedRegionName = region.getEncodedName(); + Integer nodeVersion = offlineNodesVersions.get(encodedRegionName); + if (nodeVersion == null || nodeVersion == -1) { + LOG.warn("failed to offline in zookeeper: " + region); + failedToOpenRegions.add(region); // assign individually later + Lock lock = locks.remove(encodedRegionName); + lock.unlock(); + } else { + regionStates.updateRegionState(region, + RegionState.State.PENDING_OPEN, destination); + List favoredNodes = ServerName.EMPTY_SERVER_LIST; + if (this.shouldAssignRegionsWithFavoredNodes) { + favoredNodes = ((FavoredNodeLoadBalancer)this.balancer).getFavoredNodes(region); } - for (int k = 0, n = regionOpeningStateList.size(); k < n; k++) { - RegionOpeningState openingState = regionOpeningStateList.get(k); - if (openingState != RegionOpeningState.OPENED) { - HRegionInfo region = regionOpenInfos.get(k).getFirst(); - if (openingState == RegionOpeningState.ALREADY_OPENED) { - processAlreadyOpenedRegion(region, destination); - } else if (openingState == RegionOpeningState.FAILED_OPENING) { - // Failed opening this region, reassign it later - failedToOpenRegions.add(region); - } else { - LOG.warn("THIS SHOULD NOT HAPPEN: unknown opening state " - + openingState + " in assigning region " + region); + regionOpenInfos.add(new Triple>( + region, nodeVersion, favoredNodes)); + } + } + + // Move on to open regions. + try { + // Send OPEN RPC. If it fails on a IOE or RemoteException, the + // TimeoutMonitor will pick up the pieces. + long maxWaitTime = System.currentTimeMillis() + + this.server.getConfiguration(). + getLong("hbase.regionserver.rpc.startup.waittime", 60000); + for (int i = 1; i <= maximumAttempts && !server.isStopped(); i++) { + try { + List regionOpeningStateList = serverManager + .sendRegionOpen(destination, regionOpenInfos); + if (regionOpeningStateList == null) { + // Failed getting RPC connection to this server + return false; + } + for (int k = 0, n = regionOpeningStateList.size(); k < n; k++) { + RegionOpeningState openingState = regionOpeningStateList.get(k); + if (openingState != RegionOpeningState.OPENED) { + HRegionInfo region = regionOpenInfos.get(k).getFirst(); + if (openingState == RegionOpeningState.ALREADY_OPENED) { + processAlreadyOpenedRegion(region, destination); + } else if (openingState == RegionOpeningState.FAILED_OPENING) { + // Failed opening this region, reassign it later + failedToOpenRegions.add(region); + } else { + LOG.warn("THIS SHOULD NOT HAPPEN: unknown opening state " + + openingState + " in assigning region " + region); + } } } - } - break; - } catch (IOException e) { - if (e instanceof RemoteException) { - e = ((RemoteException)e).unwrapRemoteException(); - } - if (e instanceof RegionServerStoppedException) { - LOG.warn("The region server was shut down, ", e); - // No need to retry, the region server is a goner. - return false; - } else if (e instanceof ServerNotRunningYetException) { - long now = System.currentTimeMillis(); - if (now < maxWaitTime) { - LOG.debug("Server is not yet up; waiting up to " + - (maxWaitTime - now) + "ms", e); - Thread.sleep(100); - i--; // reset the try count + break; + } catch (IOException e) { + if (e instanceof RemoteException) { + e = ((RemoteException)e).unwrapRemoteException(); + } + if (e instanceof RegionServerStoppedException) { + LOG.warn("The region server was shut down, ", e); + // No need to retry, the region server is a goner. + return false; + } else if (e instanceof ServerNotRunningYetException) { + long now = System.currentTimeMillis(); + if (now < maxWaitTime) { + LOG.debug("Server is not yet up; waiting up to " + + (maxWaitTime - now) + "ms", e); + Thread.sleep(100); + i--; // reset the try count + continue; + } + } else if (e instanceof java.net.SocketTimeoutException + && this.serverManager.isServerOnline(destination)) { + // In case socket is timed out and the region server is still online, + // the openRegion RPC could have been accepted by the server and + // just the response didn't go through. So we will retry to + // open the region on the same server. + if (LOG.isDebugEnabled()) { + LOG.debug("Bulk assigner openRegion() to " + destination + + " has timed out, but the regions might" + + " already be opened on it.", e); + } continue; } - } else if (e instanceof java.net.SocketTimeoutException - && this.serverManager.isServerOnline(destination)) { - // In case socket is timed out and the region server is still online, - // the openRegion RPC could have been accepted by the server and - // just the response didn't go through. So we will retry to - // open the region on the same server. - if (LOG.isDebugEnabled()) { - LOG.debug("Bulk assigner openRegion() to " + destination - + " has timed out, but the regions might" - + " already be opened on it.", e); - } - continue; + throw e; } - throw e; } + } catch (IOException e) { + // Can be a socket timeout, EOF, NoRouteToHost, etc + LOG.info("Unable to communicate with the region server in order" + + " to assign regions", e); + return false; + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } finally { + for (Lock lock : locks.values()) { + lock.unlock(); } - } catch (IOException e) { - // Can be a socket timeout, EOF, NoRouteToHost, etc - LOG.info("Unable to communicate with the region server in order" + - " to assign regions", e); - return false; - } catch (InterruptedException e) { - throw new RuntimeException(e); } - } finally { - for (Lock lock : locks.values()) { - lock.unlock(); - } - } - if (!failedToOpenRegions.isEmpty()) { - for (HRegionInfo region : failedToOpenRegions) { - invokeAssign(region); + if (!failedToOpenRegions.isEmpty()) { + for (HRegionInfo region : failedToOpenRegions) { + invokeAssign(region); + } } + LOG.debug("Bulk assigning done for " + destination.toString()); + return true; + } finally { + metricsAssignmentManager.updateBulkAssignTime(EnvironmentEdgeManager.currentTimeMillis() - startTime); } - LOG.debug("Bulk assigning done for " + destination.toString()); - return true; } /** @@ -1821,6 +1826,8 @@ public class AssignmentManager extends ZooKeeperListener { */ private void assign(RegionState state, final boolean setOfflineInZK, final boolean forceNewPlan) { + long startTime = EnvironmentEdgeManager.currentTimeMillis(); + try { RegionState currentState = state; int versionOfOfflineNode = -1; RegionPlan plan = null; @@ -2029,6 +2036,9 @@ public class AssignmentManager extends ZooKeeperListener { if (!tomActivated) { regionStates.updateRegionState(region, RegionState.State.FAILED_OPEN); } + } finally { + metricsAssignmentManager.updateAssignmentTime(EnvironmentEdgeManager.currentTimeMillis() - startTime); + } } private void processAlreadyOpenedRegion(HRegionInfo region, ServerName sn) { @@ -2804,10 +2814,10 @@ public class AssignmentManager extends ZooKeeperListener { oldestRITTime = ritTime; } } - if (this.metricsMaster != null) { - this.metricsMaster.updateRITOldestAge(oldestRITTime); - this.metricsMaster.updateRITCount(totalRITs); - this.metricsMaster.updateRITCountOverThreshold(totalRITsOverThreshold); + if (this.metricsAssignmentManager != null) { + this.metricsAssignmentManager.updateRITOldestAge(oldestRITTime); + this.metricsAssignmentManager.updateRITCount(totalRITs); + this.metricsAssignmentManager.updateRITCountOverThreshold(totalRITsOverThreshold); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 0c5cdb65806..4c6b667b1f2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -764,7 +764,7 @@ MasterServices, Server { this.masterActiveTime = System.currentTimeMillis(); // TODO: Do this using Dependency Injection, using PicoContainer, Guice or Spring. - this.fileSystemManager = new MasterFileSystem(this, this, metricsMaster, masterRecovery); + this.fileSystemManager = new MasterFileSystem(this, this, masterRecovery); this.tableDescriptors = new FSTableDescriptors(this.fileSystemManager.getFileSystem(), diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java index 9ec88c0b80d..7e874d737bb 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java @@ -72,7 +72,7 @@ public class MasterFileSystem { // master status Server master; // metrics for master - MetricsMaster metricsMaster; + private final MetricsMasterFileSystem metricsMasterFilesystem = new MetricsMasterFileSystem(); // Persisted unique cluster ID private ClusterId clusterId; // Keep around for convenience. @@ -103,13 +103,11 @@ public class MasterFileSystem { } }; - public MasterFileSystem(Server master, MasterServices services, - MetricsMaster metricsMaster, boolean masterRecovery) + public MasterFileSystem(Server master, MasterServices services, boolean masterRecovery) throws IOException { this.conf = master.getConfiguration(); this.master = master; this.services = services; - this.metricsMaster = metricsMaster; // Set filesystem to be that of this.rootdir else we get complaints about // mismatched filesystems if hbase.rootdir is hdfs and fs.defaultFS is // default localfs. Presumption is that rootdir is fully-qualified before @@ -410,11 +408,11 @@ public class MasterFileSystem { splitLogSize = splitLogManager.splitLogDistributed(serverNames, logDirs, filter); splitTime = EnvironmentEdgeManager.currentTimeMillis() - splitTime; - if (this.metricsMaster != null) { + if (this.metricsMasterFilesystem != null) { if (filter == META_FILTER) { - this.metricsMaster.addMetaWALSplit(splitTime, splitLogSize); + this.metricsMasterFilesystem.addMetaWALSplit(splitTime, splitLogSize); } else { - this.metricsMaster.addSplit(splitTime, splitLogSize); + this.metricsMasterFilesystem.addSplit(splitTime, splitLogSize); } } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManager.java new file mode 100644 index 00000000000..7b2423c7d9f --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManager.java @@ -0,0 +1,63 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.CompatibilitySingletonFactory; + +public class MetricsAssignmentManager { + + private final MetricsAssignmentManagerSource assignmentManagerSource; + + public MetricsAssignmentManager() { + assignmentManagerSource = CompatibilitySingletonFactory.getInstance( + MetricsAssignmentManagerSource.class); + } + + public void updateAssignmentTime(long time) { + assignmentManagerSource.updateAssignmentTime(time); + } + + public void updateBulkAssignTime(long time) { + assignmentManagerSource.updateBulkAssignTime(time); + } + + /** + * set new value for number of regions in transition. + * @param ritCount + */ + public void updateRITCount(int ritCount) { + assignmentManagerSource.setRIT(ritCount); + } + + /** + * update RIT count that are in this state for more than the threshold + * as defined by the property rit.metrics.threshold.time. + * @param ritCountOverThreshold + */ + public void updateRITCountOverThreshold(int ritCountOverThreshold) { + assignmentManagerSource.setRITCountOverThreshold(ritCountOverThreshold); + } + /** + * update the timestamp for oldest region in transition metrics. + * @param timestamp + */ + public void updateRITOldestAge(long timestamp) { + assignmentManagerSource.setRITOldestAge(timestamp); + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMaster.java index 8f7d7c50aaf..a608b127366 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMaster.java @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.hadoop.hbase.master; import org.apache.commons.logging.Log; @@ -48,79 +49,10 @@ public class MetricsMaster { return masterSource; } - /** - * Record a single instance of a split - * @param time time that the split took - * @param size length of original HLogs that were split - */ - public synchronized void addSplit(long time, long size) { - masterSource.updateSplitTime(time); - masterSource.updateSplitSize(size); - } - - /** - * Record a single instance of a split - * @param time time that the split took - * @param size length of original HLogs that were split - */ - public synchronized void addMetaWALSplit(long time, long size) { - masterSource.updateMetaWALSplitTime(time); - masterSource.updateMetaWALSplitSize(size); - } - /** * @param inc How much to add to requests. */ public void incrementRequests(final int inc) { masterSource.incRequests(inc); - - } - - /** - * set new value for number of regions in transition. - * @param ritCount - */ - public void updateRITCount(int ritCount) { - masterSource.setRIT(ritCount); - } - - /** - * update RIT count that are in this state for more than the threshold - * as defined by the property rit.metrics.threshold.time. - * @param ritCountOverThreshold - */ - public void updateRITCountOverThreshold(int ritCountOverThreshold) { - masterSource.setRITCountOverThreshold(ritCountOverThreshold); - } - /** - * update the timestamp for oldest region in transition metrics. - * @param timestamp - */ - public void updateRITOldestAge(long timestamp) { - masterSource.setRITOldestAge(timestamp); - } - - /** - * Record a single instance of a snapshot - * @param time time that the snapshot took - */ - public void addSnapshot(long time) { - masterSource.updateSnapshotTime(time); - } - - /** - * Record a single instance of a snapshot - * @param time time that the snapshot restore took - */ - public void addSnapshotRestore(long time) { - masterSource.updateSnapshotRestoreTime(time); - } - - /** - * Record a single instance of a snapshot cloned table - * @param time time that the snapshot clone took - */ - public void addSnapshotClone(long time) { - masterSource.updateSnapshotCloneTime(time); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystem.java new file mode 100644 index 00000000000..34547ef5858 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterFileSystem.java @@ -0,0 +1,50 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.CompatibilitySingletonFactory; + +public class MetricsMasterFileSystem { + + private final MetricsMasterFileSystemSource source; + + public MetricsMasterFileSystem() { + source = CompatibilitySingletonFactory.getInstance(MetricsMasterFileSystemSource.class); + } + + /** + * Record a single instance of a split + * @param time time that the split took + * @param size length of original HLogs that were split + */ + public synchronized void addSplit(long time, long size) { + source.updateSplitTime(time); + source.updateSplitSize(size); + } + + /** + * Record a single instance of a split + * @param time time that the split took + * @param size length of original HLogs that were split + */ + public synchronized void addMetaWALSplit(long time, long size) { + source.updateMetaWALSplitTime(time); + source.updateMetaWALSplitSize(size); + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshot.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshot.java new file mode 100644 index 00000000000..2d7c7979ee3 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsSnapshot.java @@ -0,0 +1,54 @@ +/** + * 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.master; + +import org.apache.hadoop.hbase.CompatibilitySingletonFactory; + +public class MetricsSnapshot { + + private final MetricsSnapshotSource source; + + public MetricsSnapshot() { + source = CompatibilitySingletonFactory.getInstance(MetricsSnapshotSource.class); + } + + /** + * Record a single instance of a snapshot + * @param time time that the snapshot took + */ + public void addSnapshot(long time) { + source.updateSnapshotTime(time); + } + + /** + * Record a single instance of a snapshot + * @param time time that the snapshot restore took + */ + public void addSnapshotRestore(long time) { + source.updateSnapshotRestoreTime(time); + } + + /** + * Record a single instance of a snapshot cloned table + * @param time time that the snapshot clone took + */ + public void addSnapshotClone(long time) { + source.updateSnapshotCloneTime(time); + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 74d6d8027f4..0b50627b09e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -342,6 +342,8 @@ public abstract class BaseLoadBalancer implements LoadBalancer { private Configuration config; private static final Random RANDOM = new Random(System.currentTimeMillis()); private static final Log LOG = LogFactory.getLog(BaseLoadBalancer.class); + + protected final MetricsBalancer metricsBalancer = new MetricsBalancer(); protected MasterServices services; @Override @@ -409,6 +411,8 @@ public abstract class BaseLoadBalancer implements LoadBalancer { */ public Map> roundRobinAssignment(List regions, List servers) { + metricsBalancer.incrMiscInvocations(); + if (regions.isEmpty() || servers.isEmpty()) { return null; } @@ -452,6 +456,8 @@ public abstract class BaseLoadBalancer implements LoadBalancer { */ public Map immediateAssignment(List regions, List servers) { + metricsBalancer.incrMiscInvocations(); + Map assignments = new TreeMap(); for (HRegionInfo region : regions) { assignments.put(region, randomAssignment(region, servers)); @@ -463,6 +469,8 @@ public abstract class BaseLoadBalancer implements LoadBalancer { * Used to assign a single region to a random server. */ public ServerName randomAssignment(HRegionInfo regionInfo, List servers) { + metricsBalancer.incrMiscInvocations(); + if (servers == null || servers.isEmpty()) { LOG.warn("Wanted to do random assignment but no servers to assign to"); return null; @@ -489,6 +497,9 @@ public abstract class BaseLoadBalancer implements LoadBalancer { */ public Map> retainAssignment(Map regions, List servers) { + // Update metrics + metricsBalancer.incrMiscInvocations(); + // Group all of the old assignments by their hostname. // We can't group directly by ServerName since the servers all have // new start-codes. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancer.java new file mode 100644 index 00000000000..518c2f07d0a --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/MetricsBalancer.java @@ -0,0 +1,41 @@ +/** + * 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.master.balancer; + +import org.apache.hadoop.hbase.CompatibilitySingletonFactory; + +/** + * Faced for exposing metrics about the balancer. + */ +public class MetricsBalancer { + + private final MetricsBalancerSource source; + + public MetricsBalancer() { + source = CompatibilitySingletonFactory.getInstance(MetricsBalancerSource.class); + } + + public void balanceCluster(long time) { + source.updateBalanceCluster(time); + } + + public void incrMiscInvocations() { + source.incrMiscInvocations(); + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 7609e5a6034..cd4f3cbc9d9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -246,6 +246,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { long endTime = EnvironmentEdgeManager.currentTimeMillis(); + metricsBalancer.balanceCluster(endTime - startTime); if (initCost > currentCost) { List plans = createRegionPlans(cluster); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java index e8e23c6ea1f..e58db54b040 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java @@ -36,7 +36,7 @@ import org.apache.hadoop.hbase.TableExistsException; import org.apache.hadoop.hbase.errorhandling.ForeignException; import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; import org.apache.hadoop.hbase.master.MasterServices; -import org.apache.hadoop.hbase.master.MetricsMaster; +import org.apache.hadoop.hbase.master.MetricsSnapshot; import org.apache.hadoop.hbase.master.SnapshotSentinel; import org.apache.hadoop.hbase.master.handler.CreateTableHandler; import org.apache.hadoop.hbase.monitoring.MonitoredTask; @@ -48,7 +48,6 @@ import org.apache.hadoop.hbase.snapshot.RestoreSnapshotHelper; import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; import com.google.common.base.Preconditions; -import org.apache.hadoop.hbase.util.FSUtils; /** * Handler to Clone a snapshot. @@ -65,17 +64,15 @@ public class CloneSnapshotHandler extends CreateTableHandler implements Snapshot private final SnapshotDescription snapshot; private final ForeignExceptionDispatcher monitor; - private final MetricsMaster metricsMaster; + private final MetricsSnapshot metricsSnapshot = new MetricsSnapshot(); private final MonitoredTask status; private volatile boolean stopped = false; public CloneSnapshotHandler(final MasterServices masterServices, - final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor, - final MetricsMaster metricsMaster) { + final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor) { super(masterServices, masterServices.getMasterFileSystem(), hTableDescriptor, masterServices.getConfiguration(), null, masterServices); - this.metricsMaster = metricsMaster; // Snapshot information this.snapshot = snapshot; @@ -145,7 +142,7 @@ public class CloneSnapshotHandler extends CreateTableHandler implements Snapshot } else { status.markComplete("Snapshot '"+ snapshot.getName() +"' clone completed and table enabled!"); } - metricsMaster.addSnapshotClone(status.getCompletionTimestamp() - status.getStartTime()); + metricsSnapshot.addSnapshotClone(status.getCompletionTimestamp() - status.getStartTime()); super.completed(exception); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/DisabledTableSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/DisabledTableSnapshotHandler.java index 5228b24485b..dc3ed6851f2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/DisabledTableSnapshotHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/DisabledTableSnapshotHandler.java @@ -64,8 +64,8 @@ public class DisabledTableSnapshotHandler extends TakeSnapshotHandler { * @param masterServices master services provider */ public DisabledTableSnapshotHandler(SnapshotDescription snapshot, - final MasterServices masterServices, final MetricsMaster metricsMaster) { - super(snapshot, masterServices, metricsMaster); + final MasterServices masterServices) { + super(snapshot, masterServices); // setup the timer timeoutInjector = TakeSnapshotUtils.getMasterTimerAndBindToMonitor(snapshot, conf, monitor); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java index b78373a0b19..5c25581b4f2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/EnabledTableSnapshotHandler.java @@ -50,8 +50,8 @@ public class EnabledTableSnapshotHandler extends TakeSnapshotHandler { private final ProcedureCoordinator coordinator; public EnabledTableSnapshotHandler(SnapshotDescription snapshot, MasterServices master, - final SnapshotManager manager, final MetricsMaster metricsMaster) { - super(snapshot, master, metricsMaster); + final SnapshotManager manager) { + super(snapshot, master); this.coordinator = manager.getCoordinator(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java index 392fe3b6ff4..b8f0ac5892b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java @@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher; import org.apache.hadoop.hbase.executor.EventType; import org.apache.hadoop.hbase.master.MasterFileSystem; import org.apache.hadoop.hbase.master.MasterServices; -import org.apache.hadoop.hbase.master.MetricsMaster; +import org.apache.hadoop.hbase.master.MetricsSnapshot; import org.apache.hadoop.hbase.master.SnapshotSentinel; import org.apache.hadoop.hbase.master.handler.TableEventHandler; import org.apache.hadoop.hbase.monitoring.MonitoredTask; @@ -48,7 +48,6 @@ import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils; import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException; import org.apache.hadoop.hbase.snapshot.RestoreSnapshotHelper; import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; -import org.apache.hadoop.hbase.util.FSUtils; /** * Handler to Restore a snapshot. @@ -64,16 +63,14 @@ public class RestoreSnapshotHandler extends TableEventHandler implements Snapsho private final SnapshotDescription snapshot; private final ForeignExceptionDispatcher monitor; - private final MetricsMaster metricsMaster; + private final MetricsSnapshot metricsSnapshot = new MetricsSnapshot(); private final MonitoredTask status; private volatile boolean stopped = false; public RestoreSnapshotHandler(final MasterServices masterServices, - final SnapshotDescription snapshot, final HTableDescriptor htd, - final MetricsMaster metricsMaster) throws IOException { + final SnapshotDescription snapshot, final HTableDescriptor htd) throws IOException { super(EventType.C_M_RESTORE_SNAPSHOT, htd.getTableName(), masterServices, masterServices); - this.metricsMaster = metricsMaster; // Snapshot information this.snapshot = snapshot; @@ -153,7 +150,7 @@ public class RestoreSnapshotHandler extends TableEventHandler implements Snapsho } else { status.markComplete("Restore snapshot '"+ snapshot.getName() +"'!"); } - metricsMaster.addSnapshotRestore(status.getCompletionTimestamp() - status.getStartTime()); + metricsSnapshot.addSnapshotRestore(status.getCompletionTimestamp() - status.getStartTime()); super.completed(exception); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java index de474e2977c..f8a40b9ebb2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java @@ -450,7 +450,7 @@ public class SnapshotManager implements Stoppable { // Take the snapshot of the disabled table DisabledTableSnapshotHandler handler = - new DisabledTableSnapshotHandler(snapshot, master, metricsMaster); + new DisabledTableSnapshotHandler(snapshot, master); snapshotTable(snapshot, handler); } @@ -466,7 +466,7 @@ public class SnapshotManager implements Stoppable { // Take the snapshot of the enabled table EnabledTableSnapshotHandler handler = - new EnabledTableSnapshotHandler(snapshot, master, this, metricsMaster); + new EnabledTableSnapshotHandler(snapshot, master, this); snapshotTable(snapshot, handler); } @@ -645,7 +645,7 @@ public class SnapshotManager implements Stoppable { try { CloneSnapshotHandler handler = - new CloneSnapshotHandler(master, snapshot, hTableDescriptor, metricsMaster).prepare(); + new CloneSnapshotHandler(master, snapshot, hTableDescriptor).prepare(); this.executorService.submit(handler); this.restoreHandlers.put(tableName, handler); } catch (Exception e) { @@ -738,7 +738,7 @@ public class SnapshotManager implements Stoppable { try { RestoreSnapshotHandler handler = - new RestoreSnapshotHandler(master, snapshot, hTableDescriptor, metricsMaster).prepare(); + new RestoreSnapshotHandler(master, snapshot, hTableDescriptor).prepare(); this.executorService.submit(handler); restoreHandlers.put(tableName, handler); } catch (Exception e) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java index 91cd8bcb3e7..f51cc568393 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java @@ -41,13 +41,12 @@ import org.apache.hadoop.hbase.errorhandling.ForeignExceptionSnare; import org.apache.hadoop.hbase.executor.EventHandler; import org.apache.hadoop.hbase.executor.EventType; import org.apache.hadoop.hbase.master.MasterServices; -import org.apache.hadoop.hbase.master.MetricsMaster; +import org.apache.hadoop.hbase.master.MetricsSnapshot; import org.apache.hadoop.hbase.master.SnapshotSentinel; import org.apache.hadoop.hbase.master.TableLockManager; import org.apache.hadoop.hbase.master.TableLockManager.TableLock; import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.monitoring.TaskMonitor; -import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils; import org.apache.hadoop.hbase.snapshot.SnapshotCreationException; @@ -72,7 +71,7 @@ public abstract class TakeSnapshotHandler extends EventHandler implements Snapsh // none of these should ever be null protected final MasterServices master; - protected final MetricsMaster metricsMaster; + protected final MetricsSnapshot metricsSnapshot = new MetricsSnapshot(); protected final SnapshotDescription snapshot; protected final Configuration conf; protected final FileSystem fs; @@ -90,14 +89,12 @@ public abstract class TakeSnapshotHandler extends EventHandler implements Snapsh * @param snapshot descriptor of the snapshot to take * @param masterServices master services provider */ - public TakeSnapshotHandler(SnapshotDescription snapshot, final MasterServices masterServices, - final MetricsMaster metricsMaster) { + public TakeSnapshotHandler(SnapshotDescription snapshot, final MasterServices masterServices) { super(masterServices, EventType.C_M_SNAPSHOT_TABLE); assert snapshot != null : "SnapshotDescription must not be nul1"; assert masterServices != null : "MasterServices must not be nul1"; this.master = masterServices; - this.metricsMaster = metricsMaster; this.snapshot = snapshot; this.snapshotTable = TableName.valueOf(snapshot.getTable()); this.conf = this.master.getConfiguration(); @@ -187,7 +184,7 @@ public abstract class TakeSnapshotHandler extends EventHandler implements Snapsh completeSnapshot(this.snapshotDir, this.workingDir, this.fs); status.markComplete("Snapshot " + snapshot.getName() + " of table " + snapshotTable + " completed"); - metricsMaster.addSnapshot(status.getCompletionTimestamp() - status.getStartTime()); + metricsSnapshot.addSnapshot(status.getCompletionTimestamp() - status.getStartTime()); } catch (Exception e) { status.abort("Failed to complete snapshot " + snapshot.getName() + " on table " + snapshotTable + " because " + e.getMessage()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java index c49e9df2f3b..d2255ce6335 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java @@ -178,7 +178,7 @@ public class TestCatalogJanitor { private final AssignmentManager asm; MockMasterServices(final Server server) throws IOException { - this.mfs = new MasterFileSystem(server, this, null, false); + this.mfs = new MasterFileSystem(server, this, false); this.asm = Mockito.mock(AssignmentManager.class); }