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 3D1FF200C2B for ; Thu, 2 Mar 2017 13:38:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3AD6D160B6F; Thu, 2 Mar 2017 12:38:06 +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 82A25160B61 for ; Thu, 2 Mar 2017 13:38:05 +0100 (CET) Received: (qmail 96334 invoked by uid 500); 2 Mar 2017 12:38:04 -0000 Mailing-List: contact dev-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 dev@accumulo.apache.org Received: (qmail 96322 invoked by uid 99); 2 Mar 2017 12:38:04 -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, 02 Mar 2017 12:38:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3C719DFCA1; Thu, 2 Mar 2017 12:38:04 +0000 (UTC) From: milleruntime To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request #225: ACCUMULO-4593 Move metrics config to templates d... Content-Type: text/plain Message-Id: <20170302123804.3C719DFCA1@git1-us-west.apache.org> Date: Thu, 2 Mar 2017 12:38:04 +0000 (UTC) archived-at: Thu, 02 Mar 2017 12:38:06 -0000 Github user milleruntime commented on a diff in the pull request: https://github.com/apache/accumulo/pull/225#discussion_r103914280 --- Diff: server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsConfiguration.java --- @@ -148,46 +148,35 @@ public Configuration getMetricsConfiguration() { } private void loadConfiguration() { - String accumuloConfDir = getEnvironmentConfiguration().getString("ACCUMULO_CONF_DIR"); - if (null != accumuloConfDir) { - // Try to load the metrics properties file - File mFile = new File(accumuloConfDir, metricsFileName); - if (mFile.exists()) { - if (log.isDebugEnabled()) - log.debug("Loading config file: " + mFile.getAbsolutePath()); - try { - xConfig = new XMLConfiguration(mFile); - xConfig.append(getEnvironmentConfiguration()); - xConfig.addConfigurationListener(new MetricsConfigListener()); - xConfig.setReloadingStrategy(new FileChangedReloadingStrategy()); - - // Start a background Thread that checks a property from the XMLConfiguration - // every so often to force the FileChangedReloadingStrategy to fire. - if (null == watcher || !watcher.isAlive()) { - watcher = new MetricsConfigWatcher(); - watcher.start(); - } - notFound = false; - alreadyWarned = false; - } catch (ConfigurationException ce) { - log.error("Error reading accumulo-metrics.xml file."); - notFound = true; - return; - } - } else { - if (!alreadyWarned) - log.warn("Unable to find metrics file: " + mFile.getAbsolutePath()); - alreadyWarned = true; - notFound = true; - return; - } - } else { + URL metricsUrl = MetricsConfiguration.class.getClassLoader().getResource("accumulo-metrics.xml"); + if (metricsUrl == null) { if (!alreadyWarned) - log.warn("ACCUMULO_CONF_DIR variable not found in environment. Metrics collection will be disabled."); + log.warn("accumulo-metrics.xml was not found on classpath. Metrics collection will be disabled."); alreadyWarned = true; --- End diff -- With the above simplification, looks like you don't need the `alreadyWarned` boolean anymore. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---