HADOOP-7306. Start metrics system even if config files are missing. Contributed by Luke Lu.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1125216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2a0bbd9979
commit
4977f4bfe3
@ -167,6 +167,9 @@ Trunk (unreleased changes)
|
||||
HADOOP-7301. FSDataInputStream should expose a getWrappedStream method.
|
||||
(Jonathan Hsieh via eli)
|
||||
|
||||
HADOOP-7306. Start metrics system even if config files are missing
|
||||
(Luke Lu via todd)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
@ -50,7 +50,6 @@
|
||||
* Metrics configuration for MetricsSystemImpl
|
||||
*/
|
||||
class MetricsConfig extends SubsetConfiguration {
|
||||
|
||||
static final Log LOG = LogFactory.getLog(MetricsConfig.class);
|
||||
|
||||
static final String DEFAULT_FILE_NAME = "hadoop-metrics2.properties";
|
||||
@ -123,8 +122,10 @@ static MetricsConfig loadFirst(String prefix, String... fileNames) {
|
||||
throw new MetricsConfigException(e);
|
||||
}
|
||||
}
|
||||
throw new MetricsConfigException("Cannot locate configuration: tried "+
|
||||
LOG.warn("Cannot locate configuration: tried "+
|
||||
Joiner.on(",").join(fileNames));
|
||||
// default to an empty configuration
|
||||
return new MetricsConfig(new PropertiesConfiguration(), prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,7 +154,7 @@ public synchronized MetricsSystem init(String prefix) {
|
||||
case NORMAL:
|
||||
try { start(); }
|
||||
catch (MetricsConfigException e) {
|
||||
// Usually because hadoop-metrics2.properties is missing
|
||||
// Configuration errors (e.g., typos) should not be fatal.
|
||||
// We can always start the metrics system later via JMX.
|
||||
LOG.warn("Metrics system not started: "+ e.getMessage());
|
||||
LOG.debug("Stacktrace: ", e);
|
||||
@ -532,7 +532,10 @@ private void initSystemMBean() {
|
||||
@Override
|
||||
public synchronized boolean shutdown() {
|
||||
LOG.debug("refCount="+ refCount);
|
||||
if (refCount <= 0) LOG.debug("Redundant shutdown", new Throwable());
|
||||
if (refCount <= 0) {
|
||||
LOG.debug("Redundant shutdown", new Throwable());
|
||||
return true; // already shutdown
|
||||
}
|
||||
if (--refCount > 0) return false;
|
||||
if (monitoring) {
|
||||
try { stop(); }
|
||||
|
@ -109,18 +109,11 @@ private void testInstances(MetricsConfig c) throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Should throw if missing config files
|
||||
* Should not throw if missing config files
|
||||
*/
|
||||
@Test public void testMissingFiles() {
|
||||
try {
|
||||
MetricsConfig.create("JobTracker", "non-existent.properties");
|
||||
}
|
||||
catch (MetricsConfigException e) {
|
||||
assertTrue("expected the 'cannot locate configuration' exception",
|
||||
e.getMessage().startsWith("Cannot locate configuration"));
|
||||
return;
|
||||
}
|
||||
fail("should've thrown");
|
||||
MetricsConfig config = MetricsConfig.create("JobTracker", "non-existent.properties");
|
||||
assertTrue(config.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user