Revert "HBASE-12911 Client-side metrics"

This reverts commit 06989fd1f9.
This commit is contained in:
Nick Dimiduk 2015-08-10 17:13:09 -07:00
parent 06989fd1f9
commit e4106b4c4a
13 changed files with 3 additions and 484 deletions

View File

@ -126,10 +126,6 @@
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-hadoop-compat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>

View File

@ -175,11 +175,4 @@ public interface Connection extends Abortable, Closeable {
*/
boolean isClosed();
/**
* Retrieve the metrics instance for this connection.
*
* @return a MetricsConnection instance for examining connection metrics.
*/
public MetricsConnection getConnectionMetrics();
}

View File

@ -130,11 +130,6 @@ abstract class ConnectionAdapter implements ClusterConnection {
return wrappedConnection.getAdmin();
}
@Override
public MetricsConnection getConnectionMetrics() {
return wrappedConnection.getConnectionMetrics();
}
@Override
public boolean isMasterRunning() throws MasterNotRunningException,
ZooKeeperConnectionException {

View File

@ -118,7 +118,6 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
private final AsyncProcess asyncProcess;
// single tracker per connection
private final ServerStatisticTracker stats;
private final MetricsConnection metrics;
private volatile boolean closed;
private volatile boolean aborted;
@ -155,11 +154,11 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
// Client rpc instance.
private RpcClient rpcClient;
private final MetaCache metaCache;
private MetaCache metaCache = new MetaCache();
private int refCount;
protected User user;
private User user;
private RpcRetryingCallerFactory rpcCallerFactory;
@ -237,13 +236,11 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
} else {
nonceGenerator = new NoNonceGenerator();
}
this.stats = ServerStatisticTracker.create(conf);
stats = ServerStatisticTracker.create(conf);
this.asyncProcess = createAsyncProcess(this.conf);
this.interceptor = (new RetryingCallerInterceptorFactory(conf)).build();
this.rpcCallerFactory = RpcRetryingCallerFactory.instantiate(conf, interceptor, this.stats);
this.backoffPolicy = ClientBackoffPolicyFactory.create(conf);
this.metrics = new MetricsConnection(new MetricsConnectionWrapperImpl(this));
this.metaCache = new MetaCache(this.metrics);
}
/**
@ -365,11 +362,6 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
return new HBaseAdmin(this);
}
@Override
public MetricsConnection getConnectionMetrics() {
return this.metrics;
}
private ExecutorService getBatchPool() {
if (batchPool == null) {
synchronized (this) {

View File

@ -59,12 +59,6 @@ public class MetaCache {
// The access to this attribute must be protected by a lock on cachedRegionLocations
private final Set<ServerName> cachedServers = new ConcurrentSkipListSet<ServerName>();
private final MetricsConnection metrics;
public MetaCache(MetricsConnection metrics) {
this.metrics = metrics;
}
/**
* Search the cache for a location that fits our table and row key.
* Return null if no suitable region is located.
@ -80,7 +74,6 @@ public class MetaCache {
Entry<byte[], RegionLocations> e = tableLocations.floorEntry(row);
if (e == null) {
metrics.incrMetaCacheMiss();
return null;
}
RegionLocations possibleRegion = e.getValue();
@ -101,12 +94,10 @@ public class MetaCache {
// HConstants.EMPTY_END_ROW) check itself will pass.
if (Bytes.equals(endKey, HConstants.EMPTY_END_ROW) ||
Bytes.compareTo(endKey, 0, endKey.length, row, 0, row.length) > 0) {
metrics.incrMetaCacheHit();
return possibleRegion;
}
// Passed all the way through, so we got nothing - complete cache miss
metrics.incrMetaCacheMiss();
return null;
}

View File

@ -1,48 +0,0 @@
/**
* 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.client;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
/**
* This class is for maintaining the various connection statistics and publishing them through
* the metrics interfaces.
*/
@InterfaceStability.Evolving
@InterfaceAudience.Private
public class MetricsConnection {
private final MetricsConnectionWrapper wrapper;
private final MetricsConnectionSource source;
public MetricsConnection(MetricsConnectionWrapper wrapper) {
this.wrapper = wrapper;
this.source = CompatibilitySingletonFactory.getInstance(MetricsConnectionSourceFactory.class)
.createConnection(this.wrapper);
}
public void incrMetaCacheHit() {
source.incrMetaCacheHit();
}
public void incrMetaCacheMiss() {
source.incrMetaCacheMiss();
}
}

View File

@ -1,99 +0,0 @@
/**
* 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.client;
import com.google.common.base.Preconditions;
import java.util.concurrent.ThreadPoolExecutor;
public class MetricsConnectionWrapperImpl implements MetricsConnectionWrapper {
private final ConnectionImplementation conn;
public MetricsConnectionWrapperImpl(ConnectionImplementation connection) {
Preconditions.checkNotNull(connection);
this.conn = connection;
}
@Override public String getId() {
return conn.toString();
}
@Override public String getUserName() {
return conn.user == null ? "" : conn.user.toString();
}
@Override public String getClusterId() {
return conn.clusterId;
}
@Override public String getZookeeperQuorum() {
try {
return conn.getKeepAliveZooKeeperWatcher().getQuorum();
} catch (Exception e) {
return "";
}
}
@Override public String getZookeeperBaseNode() {
try {
return conn.getKeepAliveZooKeeperWatcher().getBaseZNode();
} catch (Exception e) {
return "";
}
}
@Override public int getMetaLookupPoolActiveCount() {
if (conn.getCurrentMetaLookupPool() == null) {
return 0;
}
ThreadPoolExecutor tpe = (ThreadPoolExecutor) conn.getCurrentMetaLookupPool();
return tpe.getActiveCount();
}
@Override public int getMetaLookupPoolLargestPoolSize() {
if (conn.getCurrentMetaLookupPool() == null) {
return 0;
}
ThreadPoolExecutor tpe = (ThreadPoolExecutor) conn.getCurrentMetaLookupPool();
return tpe.getLargestPoolSize();
}
@Override public String getBatchPoolId() {
if (conn.getCurrentBatchPool() == null) {
return "";
}
return Integer.toHexString(conn.getCurrentBatchPool().hashCode());
}
@Override public int getBatchPoolActiveCount() {
if (conn.getCurrentBatchPool() == null) {
return 0;
}
ThreadPoolExecutor tpe = (ThreadPoolExecutor) conn.getCurrentBatchPool();
return tpe.getActiveCount();
}
@Override public int getBatchPoolLargestPoolSize() {
if (conn.getCurrentBatchPool() == null) {
return 0;
}
ThreadPoolExecutor tpe = (ThreadPoolExecutor) conn.getCurrentBatchPool();
return tpe.getLargestPoolSize();
}
}

View File

@ -1,87 +0,0 @@
/**
* 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.client;
import org.apache.hadoop.hbase.metrics.BaseSource;
public interface MetricsConnectionSource extends BaseSource {
/**
* The name of the metrics
*/
String METRICS_NAME = "Connection";
/**
* The name of the metrics context that metrics will be under.
*/
String METRICS_CONTEXT = "connection";
/**
* Description
*/
String METRICS_DESCRIPTION = "Metrics about HBase Connection";
/**
* The name of the metrics context that metrics will be under in jmx
*/
String METRICS_JMX_CONTEXT = "Client,sub=";
/**
* Increment number of meta cache hits
*/
void incrMetaCacheHit();
/**
* Increment number of meta cache misses
*/
void incrMetaCacheMiss();
// Strings used for exporting to metrics system.
String CONNECTION_ID_NAME = "connectionId";
String CONNECTION_ID_DESC = "The connection's process-unique identifier.";
String USER_NAME_NAME = "userName";
String USER_NAME_DESC = "The user on behalf of whom the Connection is acting.";
String CLUSTER_ID_NAME = "clusterId";
String CLUSTER_ID_DESC = "Cluster Id";
String ZOOKEEPER_QUORUM_NAME = "zookeeperQuorum";
String ZOOKEEPER_QUORUM_DESC = "Zookeeper Quorum";
String ZOOKEEPER_ZNODE_NAME = "zookeeperBaseZNode";
String ZOOKEEPER_ZNODE_DESC = "Base ZNode for this cluster.";
String META_CACHE_HIT_NAME = "metaCacheHit";
String META_CACHE_HIT_DESC =
"A counter on the number of times this connection's meta cache has a valid region location.";
String META_CACHE_MISS_NAME = "metaCacheMiss";
String META_CACHE_MISS_DESC =
"A counter on the number of times this connection does not know where to find a region.";
String META_LOOKUP_POOL_ACTIVE_THREAD_NAME = "metaLookupPoolActiveThreads";
String META_LOOKUP_POOL_ACTIVE_THREAD_DESC =
"The approximate number of threads actively resolving region locations from META.";
String META_LOOKUP_POOL_LARGEST_SIZE_NAME = "metaLookupPoolLargestSize";
String META_LOOKUP_POOL_LARGEST_SIZE_DESC =
"The largest number of threads that have ever simultaneously been in the pool.";
String BATCH_POOL_ID_NAME = "batchPoolId";
String BATCH_POOL_ID_DESC = "The connection's batch pool's unique identifier.";
String BATCH_POOL_ACTIVE_THREAD_NAME = "batchPoolActiveThreads";
String BATCH_POOL_ACTIVE_THREAD_DESC =
"The approximate number of threads executing table operations.";
String BATCH_POOL_LARGEST_SIZE_NAME = "batchPoolLargestSize";
String BATCH_POOL_LARGEST_SIZE_DESC =
"The largest number of threads that have ever simultaneously been in the pool.";
}

View File

@ -1,32 +0,0 @@
/**
* 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.client;
/**
* Interface of a factory to create Metrics Sources used inside of Connections.
*/
public interface MetricsConnectionSourceFactory {
/**
* Given a wrapper create a {@link MetricsConnectionSource}.
*
* @param wrapper The wrapped Connection
* @return a Metrics Source.
*/
public MetricsConnectionSource createConnection(MetricsConnectionWrapper wrapper);
}

View File

@ -1,50 +0,0 @@
/**
* 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.client;
/**
* This is the interface that will expose Connection information to hadoop1/hadoop2
* implementations of the {@link MetricsConnectionSource}.
*/
public interface MetricsConnectionWrapper {
/** Get the connection's unique identifier */
String getId();
/** Get the User's name. */
String getUserName();
/** Get the Cluster ID */
String getClusterId();
/** Get the Zookeeper Quorum Info */
String getZookeeperQuorum();
/** Get the base ZNode for this cluster. */
String getZookeeperBaseNode();
int getMetaLookupPoolActiveCount();
int getMetaLookupPoolLargestPoolSize();
String getBatchPoolId();
int getBatchPoolActiveCount();
int getBatchPoolLargestPoolSize();
}

View File

@ -1,28 +0,0 @@
/**
* 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.client;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
@InterfaceAudience.Private
public class MetricsConnectionSourceFactoryImpl implements MetricsConnectionSourceFactory {
@Override public MetricsConnectionSource createConnection(MetricsConnectionWrapper wrapper) {
return new MetricsConnectionSourceImpl(wrapper);
}
}

View File

@ -1,86 +0,0 @@
/**
* 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.client;
import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
import org.apache.hadoop.metrics2.MetricsCollector;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.metrics2.lib.Interns;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
public class MetricsConnectionSourceImpl
extends BaseSourceImpl implements MetricsConnectionSource {
// wrapper for access statistics collected in Connection instance
private final MetricsConnectionWrapper wrapper;
// Hadoop Metric2 objects for additional monitoring
private final MutableCounterLong metaCacheHit;
private final MutableCounterLong metaCacheMiss;
public MetricsConnectionSourceImpl(MetricsConnectionWrapper wrapper) {
this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT,
METRICS_JMX_CONTEXT + wrapper.getId(), wrapper);
}
public MetricsConnectionSourceImpl(String metricsName, String metricsDescription,
String metricsContext, String metricsJmxContext, MetricsConnectionWrapper wrapper) {
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
this.wrapper = wrapper;
metaCacheHit = getMetricsRegistry().newCounter(META_CACHE_HIT_NAME, META_CACHE_HIT_DESC, 0l);
metaCacheMiss =
getMetricsRegistry().newCounter(META_CACHE_MISS_NAME, META_CACHE_MISS_DESC, 0l);
}
@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName);
if (wrapper != null) {
mrb.addGauge(Interns.info(META_LOOKUP_POOL_LARGEST_SIZE_NAME,
META_LOOKUP_POOL_LARGEST_SIZE_DESC), wrapper.getMetaLookupPoolLargestPoolSize())
.addGauge(Interns.info(META_LOOKUP_POOL_ACTIVE_THREAD_NAME,
META_LOOKUP_POOL_ACTIVE_THREAD_DESC), wrapper.getMetaLookupPoolActiveCount())
.tag(Interns.info(BATCH_POOL_ID_NAME, BATCH_POOL_ID_DESC), wrapper.getBatchPoolId())
.addGauge(Interns.info(BATCH_POOL_ACTIVE_THREAD_NAME, BATCH_POOL_ACTIVE_THREAD_DESC),
wrapper.getBatchPoolActiveCount())
.addGauge(Interns.info(BATCH_POOL_LARGEST_SIZE_NAME, BATCH_POOL_LARGEST_SIZE_DESC),
wrapper.getBatchPoolLargestPoolSize())
.tag(Interns.info(CONNECTION_ID_NAME, CONNECTION_ID_DESC), wrapper.getId())
.tag(Interns.info(USER_NAME_NAME, USER_NAME_DESC), wrapper.getUserName())
.tag(Interns.info(CLUSTER_ID_NAME, CLUSTER_ID_DESC), wrapper.getClusterId())
.tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC),
wrapper.getZookeeperQuorum())
.tag(Interns.info(ZOOKEEPER_ZNODE_NAME, ZOOKEEPER_ZNODE_DESC),
wrapper.getZookeeperBaseNode());
}
metricsRegistry.snapshot(mrb, all);
}
@Override public void incrMetaCacheHit() {
metaCacheHit.incr();
}
@Override public void incrMetaCacheMiss() {
metaCacheMiss.incr();
}
}

View File

@ -1,18 +0,0 @@
# 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.
#
org.apache.hadoop.hbase.client.MetricsConnectionSourceFactoryImpl