Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EC8C1200B32 for ; Thu, 9 Jun 2016 04:26:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EB241160A2E; Thu, 9 Jun 2016 02:26:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E907F160A5C for ; Thu, 9 Jun 2016 04:26:14 +0200 (CEST) Received: (qmail 20670 invoked by uid 500); 9 Jun 2016 02:26:13 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 20574 invoked by uid 99); 9 Jun 2016 02:26:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 02:26:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B5EC0E08BD; Thu, 9 Jun 2016 02:26:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dhutchis@apache.org To: commits@accumulo.apache.org Date: Thu, 09 Jun 2016 02:26:15 -0000 Message-Id: <1a62721da9434ac5a8584a9f5e4f2137@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/5] accumulo git commit: Merge branch '1.6' into 1.7 archived-at: Thu, 09 Jun 2016 02:26:16 -0000 Merge branch '1.6' into 1.7 Conflicts: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/7f124337 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7f124337 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7f124337 Branch: refs/heads/master Commit: 7f12433735f9535b3f06dc2744d596192f414406 Parents: e743695 67605d7 Author: Dylan Hutchison Authored: Wed Jun 8 19:21:28 2016 -0700 Committer: Dylan Hutchison Committed: Wed Jun 8 19:21:28 2016 -0700 ---------------------------------------------------------------------- .../org/apache/accumulo/tserver/metrics/TabletServerMBean.java | 2 +- .../apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java | 2 +- .../accumulo/tserver/metrics/TabletServerMetricsUtil.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f124337/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java ---------------------------------------------------------------------- diff --cc server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java index 42b2a9c,0000000..465e50a mode 100644,000000..100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java @@@ -1,175 -1,0 +1,175 @@@ +/* + * 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.accumulo.tserver.metrics; + +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import javax.management.StandardMBean; + +import org.apache.accumulo.server.metrics.AbstractMetricsImpl; +import org.apache.accumulo.tserver.TabletServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TabletServerMBeanImpl extends AbstractMetricsImpl implements TabletServerMBean { + private static final Logger log = LoggerFactory.getLogger(TabletServerMBeanImpl.class); + private static final String METRICS_PREFIX = "tserver"; + private ObjectName OBJECT_NAME = null; + + private final TabletServerMetricsUtil util; + + TabletServerMBeanImpl(TabletServer server) { + util = new TabletServerMetricsUtil(server); + try { + OBJECT_NAME = new ObjectName("accumulo.server.metrics:service=TServerInfo,name=TabletServerMBean,instance=" + Thread.currentThread().getName()); + } catch (MalformedObjectNameException e) { + log.error("Exception setting MBean object name", e); + } + } + + @Override + public void register() throws Exception { + // Do this because interface not in same package. + StandardMBean mbean = new StandardMBean(this, TabletServerMBean.class, false); + register(mbean); + } + + @Override + public long getEntries() { + if (isEnabled()) { + return util.getEntries(); + } + return 0; + } + + @Override + public long getEntriesInMemory() { + if (isEnabled()) { + return util.getEntriesInMemory(); + } + return 0; + } + + @Override - public long getIngest() { ++ public double getIngest() { + if (isEnabled()) { + return util.getIngest(); + } + return 0; + } + + @Override + public int getMajorCompactions() { + if (isEnabled()) { + return util.getMajorCompactions(); + } + return 0; + } + + @Override + public int getMajorCompactionsQueued() { + if (isEnabled()) { + return util.getMajorCompactionsQueued(); + } + return 0; + } + + @Override + public int getMinorCompactions() { + if (isEnabled()) { + return util.getMinorCompactions(); + } + return 0; + } + + @Override + public int getMinorCompactionsQueued() { + if (isEnabled()) { + return util.getMinorCompactionsQueued(); + } + return 0; + } + + @Override + public int getOnlineCount() { + if (isEnabled()) + return util.getOnlineCount(); + return 0; + } + + @Override + public int getOpeningCount() { + if (isEnabled()) + return util.getOpeningCount(); + return 0; + } + + @Override + public long getQueries() { + if (isEnabled()) { + return util.getQueries(); + } + return 0; + } + + @Override + public int getUnopenedCount() { + if (isEnabled()) + return util.getUnopenedCount(); + return 0; + } + + @Override + public String getName() { + if (isEnabled()) + return util.getName(); + return ""; + } + + @Override + public long getTotalMinorCompactions() { + if (isEnabled()) + return util.getTotalMinorCompactions(); + return 0; + } + + @Override + public double getHoldTime() { + if (isEnabled()) + return util.getHoldTime(); + return 0; + } + + @Override + public double getAverageFilesPerTablet() { + if (isEnabled()) { + return util.getAverageFilesPerTablet(); + } + return 0; + } + + @Override + protected ObjectName getObjectName() { + return OBJECT_NAME; + } + + @Override + protected String getMetricsPrefix() { + return METRICS_PREFIX; + } + +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/7f124337/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMetricsUtil.java ---------------------------------------------------------------------- diff --cc server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMetricsUtil.java index 5905aea,0000000..339ebf2 mode 100644,000000..100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMetricsUtil.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMetricsUtil.java @@@ -1,138 -1,0 +1,138 @@@ +/* + * 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.accumulo.tserver.metrics; + +import org.apache.accumulo.tserver.TabletServer; +import org.apache.accumulo.tserver.tablet.Tablet; + +/** + * Wrapper around extracting metrics from a TabletServer instance + * + * Necessary to support both old custom JMX metrics and Hadoop Metrics2 + */ +public class TabletServerMetricsUtil { + + private final TabletServer tserver; + + public TabletServerMetricsUtil(TabletServer tserver) { + this.tserver = tserver; + } + + public long getEntries() { + long result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + result += tablet.getNumEntries(); + } + return result; + } + + public long getEntriesInMemory() { + long result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + result += tablet.getNumEntriesInMemory(); + } + return result; + } + - public long getIngest() { - long result = 0; ++ public double getIngest() { ++ double result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { - result += tablet.getNumEntriesInMemory(); ++ result += tablet.ingestRate(); + } + return result; + } + + public int getMajorCompactions() { + int result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + if (tablet.isMajorCompactionRunning()) + result++; + } + return result; + } + + public int getMajorCompactionsQueued() { + int result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + if (tablet.isMajorCompactionQueued()) + result++; + } + return result; + } + + public int getMinorCompactions() { + int result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + if (tablet.isMinorCompactionRunning()) + result++; + } + return result; + } + + public int getMinorCompactionsQueued() { + int result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + if (tablet.isMinorCompactionQueued()) + result++; + } + return result; + } + + public int getOnlineCount() { + return tserver.getOnlineTablets().size(); + } + + public int getOpeningCount() { + return tserver.getOpeningCount(); + } + + public long getQueries() { + long result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + result += tablet.totalQueries(); + } + return result; + } + + public int getUnopenedCount() { + return tserver.getUnopenedCount(); + } + + public String getName() { + return tserver.getClientAddressString(); + } + + public long getTotalMinorCompactions() { + return tserver.getTotalMinorCompactions(); + } + + public double getHoldTime() { + return tserver.getHoldTimeMillis() / 1000.; + } + + public double getAverageFilesPerTablet() { + int count = 0; + long result = 0; + for (Tablet tablet : tserver.getOnlineTablets()) { + result += tablet.getDatafiles().size(); + count++; + } + if (count == 0) + return 0; + return result / (double) count; + } +}