HADOOP-9559. Merging change r1604225 from trunk to branch-2.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1604227 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6e3f0e216e
commit
be0fae3996
|
@ -239,6 +239,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
HADOOP-10716. Cannot use more than 1 har filesystem.
|
HADOOP-10716. Cannot use more than 1 har filesystem.
|
||||||
(Rushabh Shah via cnauroth)
|
(Rushabh Shah via cnauroth)
|
||||||
|
|
||||||
|
HADOOP-9559. When metrics system is restarted MBean names get incorrectly
|
||||||
|
flagged as dupes. (Mostafa Elhemali and Mike Liddell via cnauroth)
|
||||||
|
|
||||||
BREAKDOWN OF HADOOP-10514 SUBTASKS AND RELATED JIRAS
|
BREAKDOWN OF HADOOP-10514 SUBTASKS AND RELATED JIRAS
|
||||||
|
|
||||||
HADOOP-10520. Extended attributes definition and FileSystem APIs for
|
HADOOP-10520. Extended attributes definition and FileSystem APIs for
|
||||||
|
|
|
@ -30,6 +30,7 @@ import javax.management.ObjectName;
|
||||||
import javax.management.ReflectionException;
|
import javax.management.ReflectionException;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -228,6 +229,12 @@ class MetricsSourceAdapter implements DynamicMBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
ObjectName getMBeanName() {
|
||||||
|
return mbeanName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateInfoCache() {
|
private void updateInfoCache() {
|
||||||
LOG.debug("Updating info cache...");
|
LOG.debug("Updating info cache...");
|
||||||
infoCache = infoBuilder.reset(lastRecs).get();
|
infoCache = infoBuilder.reset(lastRecs).get();
|
||||||
|
|
|
@ -32,6 +32,7 @@ import javax.management.ObjectName;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.*;
|
||||||
|
|
||||||
|
@ -577,6 +578,11 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
|
||||||
return allSources.get(name);
|
return allSources.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
MetricsSourceAdapter getSourceAdapter(String name) {
|
||||||
|
return sources.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
private InitMode initMode() {
|
private InitMode initMode() {
|
||||||
LOG.debug("from system property: "+ System.getProperty(MS_INIT_MODE_KEY));
|
LOG.debug("from system property: "+ System.getProperty(MS_INIT_MODE_KEY));
|
||||||
LOG.debug("from environment variable: "+ System.getenv(MS_INIT_MODE_KEY));
|
LOG.debug("from environment variable: "+ System.getenv(MS_INIT_MODE_KEY));
|
||||||
|
|
|
@ -102,6 +102,11 @@ public enum DefaultMetricsSystem {
|
||||||
return INSTANCE.newObjectName(name);
|
return INSTANCE.newObjectName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InterfaceAudience.Private
|
||||||
|
public static void removeMBeanName(ObjectName name) {
|
||||||
|
INSTANCE.removeObjectName(name.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public static String sourceName(String name, boolean dupOK) {
|
public static String sourceName(String name, boolean dupOK) {
|
||||||
return INSTANCE.newSourceName(name, dupOK);
|
return INSTANCE.newSourceName(name, dupOK);
|
||||||
|
@ -118,6 +123,10 @@ public enum DefaultMetricsSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized void removeObjectName(String name) {
|
||||||
|
mBeanNames.map.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized String newSourceName(String name, boolean dupOK) {
|
synchronized String newSourceName(String name, boolean dupOK) {
|
||||||
if (sourceNames.map.containsKey(name)) {
|
if (sourceNames.map.containsKey(name)) {
|
||||||
if (dupOK) {
|
if (dupOK) {
|
||||||
|
|
|
@ -82,6 +82,7 @@ public class MBeans {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Error unregistering "+ mbeanName, e);
|
LOG.warn("Error unregistering "+ mbeanName, e);
|
||||||
}
|
}
|
||||||
|
DefaultMetricsSystem.removeMBeanName(mbeanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static private ObjectName getMBeanName(String serviceName, String nameName) {
|
static private ObjectName getMBeanName(String serviceName, String nameName) {
|
||||||
|
|
|
@ -360,6 +360,24 @@ public class TestMetricsSystemImpl {
|
||||||
ms.register(ts);
|
ms.register(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void testStartStopStart() {
|
||||||
|
DefaultMetricsSystem.shutdown(); // Clear pre-existing source names.
|
||||||
|
MetricsSystemImpl ms = new MetricsSystemImpl("test");
|
||||||
|
TestSource ts = new TestSource("ts");
|
||||||
|
ms.start();
|
||||||
|
ms.register("ts", "", ts);
|
||||||
|
MetricsSourceAdapter sa = ms.getSourceAdapter("ts");
|
||||||
|
assertNotNull(sa);
|
||||||
|
assertNotNull(sa.getMBeanName());
|
||||||
|
ms.stop();
|
||||||
|
ms.shutdown();
|
||||||
|
ms.start();
|
||||||
|
sa = ms.getSourceAdapter("ts");
|
||||||
|
assertNotNull(sa);
|
||||||
|
assertNotNull(sa.getMBeanName());
|
||||||
|
ms.stop();
|
||||||
|
ms.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
private void checkMetricsRecords(List<MetricsRecord> recs) {
|
private void checkMetricsRecords(List<MetricsRecord> recs) {
|
||||||
LOG.debug(recs);
|
LOG.debug(recs);
|
||||||
|
|
Loading…
Reference in New Issue