You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by hi...@apache.org on 2012/10/09 23:38:57 UTC
svn commit: r1396345 - in /incubator/ambari/branches/AMBARI-666: ./
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/
ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/
ambari-server/src/main/java/org/apache/am...
Author: hitesh
Date: Tue Oct 9 21:38:56 2012
New Revision: 1396345
URL: http://svn.apache.org/viewvc?rev=1396345&view=rev
Log:
AMBARI-835. Update JMXPropertyProvider. (Contributed by Tom Beerbower)
Added:
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/HostMappingProvider.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/StreamProvider.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java (with props)
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_datanode_jmx.json
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_namenode_jmx.json
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_tasktracker_jmx.json
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHelper.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXHelperTest.java
Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1396345&r1=1396344&r2=1396345&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Tue Oct 9 21:38:56 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
NEW FEATURES
+ AMBARI-835. Update JMXPropertyProvider. (Tom Beerbower via hitesh)
+
AMBARI-832. Merge ambari-api with ambari-server (mahadev)
AMBARI-822. Implement an agent simulator for unit testing. (jitendra)
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java?rev=1396345&r1=1396344&r2=1396345&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java Tue Oct 9 21:38:56 2012
@@ -88,7 +88,7 @@ public abstract class ResourceProviderIm
// Components
protected static final PropertyId COMPONENT_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name", "ServiceComponentInfo");
protected static final PropertyId COMPONENT_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("service_name", "ServiceComponentInfo");
- protected static final PropertyId COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("service_name", "ServiceComponentInfo");
+ protected static final PropertyId COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("component_name", "ServiceComponentInfo");
protected static final PropertyId COMPONENT_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("state", "ServiceComponentInfo");
// Hosts
protected static final PropertyId HOST_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name", "Hosts");
@@ -101,7 +101,7 @@ public abstract class ResourceProviderIm
// Host Components
protected static final PropertyId HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name", "HostRoles");
protected static final PropertyId HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("service_name", "HostRoles");
- protected static final PropertyId HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("service_name", "HostRoles");
+ protected static final PropertyId HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("component_name", "HostRoles");
protected static final PropertyId HOST_COMPONENT_HOST_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("host_name", "HostRoles");
protected static final PropertyId HOST_COMPONENT_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("state", "HostRoles");
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java Tue Oct 9 21:38:56 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.utilities.StreamProvider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * URL based implementation of a stream provider.
+ */
+public class URLStreamProvider implements StreamProvider {
+ @Override
+ public InputStream readFrom(String spec) throws IOException {
+ URLConnection connection = new URL(spec).openConnection();
+ connection.setDoOutput(true);
+ return connection.getInputStream();
+ }
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/HostMappingProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/HostMappingProvider.java?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/HostMappingProvider.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/HostMappingProvider.java Tue Oct 9 21:38:56 2012
@@ -0,0 +1,28 @@
+/**
+ * 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.ambari.server.controller.jmx;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public interface HostMappingProvider {
+ public Map<String, String> getHostMap();
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/HostMappingProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHelper.java?rev=1396345&r1=1396344&r2=1396345&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHelper.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHelper.java Tue Oct 9 21:38:56 2012
@@ -29,18 +29,4 @@ import java.net.URLConnection;
*/
public class JMXHelper {
- public static JMXMetrics getJMXMetrics(String target, String bean) {
- String s = "http://" + target + "/jmx?qry=" + (bean == null ? "Hadoop:*" : bean);
- try {
- URLConnection connection = new URL(s).openConnection();
-
- connection.setDoOutput(true);
-
- return new ObjectMapper().readValue(connection.getInputStream(),
- JMXMetrics.class);
-
- } catch (IOException e) {
- throw new IllegalStateException("Can't get metric " + ".", e);
- }
- }
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java?rev=1396345&r1=1396344&r2=1396345&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java Tue Oct 9 21:38:56 2012
@@ -18,15 +18,17 @@
package org.apache.ambari.server.controller.jmx;
-import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.utilities.StreamProvider;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.spi.PropertyId;
import org.apache.ambari.server.controller.spi.PropertyProvider;
import org.apache.ambari.server.controller.spi.Request;
import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.codehaus.jackson.map.ObjectMapper;
+import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -37,12 +39,19 @@ import java.util.Set;
*/
public class JMXPropertyProvider implements PropertyProvider {
+ protected static final PropertyId HOST_COMPONENT_HOST_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("host_name", "HostRoles");
+ protected static final PropertyId HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("component_name", "HostRoles");
+
+ private static final String CATEGORY_KEY = "tag.context";
+
/**
* Map of property ids supported by this provider.
*/
private final Set<PropertyId> propertyIds;
- private final Map<String, String> hosts;
+ private final StreamProvider streamProvider;
+
+ private final HostMappingProvider mappingProvider;
private static final Map<String, String> JMX_PORTS = new HashMap<String, String>();
@@ -54,13 +63,32 @@ public class JMXPropertyProvider impleme
JMX_PORTS.put("TASKTRACKER", "50060");
}
- private JMXPropertyProvider(Resource.Type type, Map<String, String> hosts) {
- this.hosts = hosts;
- this.propertyIds = PropertyHelper.getPropertyIds(type, "JMX");
+
+ // ----- Constructors ------------------------------------------------------
+
+ /**
+ * Create a JMX property provider.
+ *
+ * @param propertyIds the property ids provided by this provider
+ * @param streamProvider the stream provider
+ * @param mappingProvider the provider of host mapping information
+ */
+ public JMXPropertyProvider(Set<PropertyId> propertyIds,
+ StreamProvider streamProvider,
+ HostMappingProvider mappingProvider) {
+ this.propertyIds = propertyIds;
+ this.streamProvider = streamProvider;
+ this.mappingProvider = mappingProvider;
}
+
+ // ----- PropertyProvider --------------------------------------------------
+
@Override
- public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate) {
+ public Set<Resource> populateResources(Set<Resource> resources,
+ Request request,
+ Predicate predicate)
+ throws AmbariException {
Set<Resource> keepers = new HashSet<Resource>();
for (Resource resource : resources) {
if (populateResource(resource, request, predicate)) {
@@ -76,40 +104,55 @@ public class JMXPropertyProvider impleme
}
- private boolean populateResource(Resource resource, Request request, Predicate predicate) {
+ // ----- helper methods ----------------------------------------------------
+
+ /**
+ * Populate a resource by obtaining the requested JMX properties.
+ *
+ * @param resource the resource to be populated
+ * @param request the request
+ * @param predicate the predicate
+ *
+ * @return true if the resource was successfully populated with the requested properties
+ *
+ * @throws AmbariException thrown if the resource cannot be populated
+ */
+ private boolean populateResource(Resource resource,
+ Request request,
+ Predicate predicate)
+ throws AmbariException {
if (getPropertyIds().isEmpty()) {
return true;
}
- Set<PropertyId> ids = new HashSet<PropertyId>(request.getPropertyIds());
- if (ids == null || ids.isEmpty()) {
- ids = getPropertyIds();
- } else {
- if (predicate != null) {
- ids.addAll(PredicateHelper.getPropertyIds(predicate));
- }
- ids.retainAll(getPropertyIds());
- }
+ Set<PropertyId> ids = PropertyHelper.getRequestPropertyIds(this, request, predicate);
- String hostName = hosts.get(resource.getPropertyValue(new PropertyIdImpl("host_name", "HostRoles", false)));
- String port = JMX_PORTS.get(resource.getPropertyValue(new PropertyIdImpl("component_name", "HostRoles", false)));
+ Map<String, String> hosts = mappingProvider.getHostMap();
- String jmxSource = hostName + ":" + port;
+ String hostName = hosts.get(resource.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID));
+ String port = JMX_PORTS.get(resource.getPropertyValue(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID));
- if (hostName == null || port == null || jmxSource == null) {
+ if (hostName == null || port == null) {
return true;
}
- JMXMetrics metrics = JMXHelper.getJMXMetrics(jmxSource, null);
+ JMXMetrics metrics;
+
+ String spec = getSpec(hostName + ":" + port);
+
+ try {
+ metrics = new ObjectMapper().readValue(streamProvider.readFrom(spec), JMXMetrics.class);
+ } catch (IOException e) {
+ throw new AmbariException("Can't get metrics : " + spec, e);
+ }
for (Map<String, String> propertyMap : metrics.getBeans()) {
- String category = propertyMap.get("tag.context");
+ String category = propertyMap.get(CATEGORY_KEY);
if (category != null) {
for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
- String name = entry.getKey();
- PropertyIdImpl propertyId = new PropertyIdImpl(name, category, false);
+ PropertyId propertyId = PropertyHelper.getPropertyId(entry.getKey(), category);
if (ids.contains(propertyId)) {
resource.setProperty(propertyId, entry.getValue());
@@ -121,12 +164,13 @@ public class JMXPropertyProvider impleme
}
/**
- * Factory method.
+ * Get the spec to locate the JMX stream from the given source
+ *
+ * @param jmxSource the source (host and port)
*
- * @param type the {@link Resource.Type resource type}
- * @return a new {@link PropertyProvider} instance
+ * @return the spec
*/
- public static PropertyProvider create(Resource.Type type, Map<String, String> hosts) {
- return new JMXPropertyProvider(type, hosts);
+ protected static String getSpec(String jmxSource) {
+ return "http://" + jmxSource + "/jmx?qry=Hadoop:*";
}
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java?rev=1396345&r1=1396344&r2=1396345&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java Tue Oct 9 21:38:56 2012
@@ -19,7 +19,9 @@ package org.apache.ambari.server.control
import org.apache.ambari.server.controller.internal.PropertyIdImpl;
import org.apache.ambari.server.controller.internal.RequestImpl;
+import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
import org.apache.ambari.server.controller.spi.Request;
import org.apache.ambari.server.controller.spi.Resource;
import org.codehaus.jackson.map.ObjectMapper;
@@ -28,6 +30,7 @@ import org.codehaus.jackson.type.TypeRef
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -78,6 +81,33 @@ public class PropertyHelper {
}
/**
+ * Get the set of property id required to satisfy the given request for the given property
+ * provider and predicate.
+ *
+ * @param provider the property provider
+ * @param request the request
+ * @param predicate the predicate
+ *
+ * @return the set of property ids needed to satisfy the request
+ */
+ public static Set<PropertyId> getRequestPropertyIds(PropertyProvider provider,
+ Request request,
+ Predicate predicate) {
+ Set<PropertyId> requestPropertyIds = new HashSet<PropertyId>(request.getPropertyIds());
+ Set<PropertyId> providerPropertyIds = new HashSet<PropertyId>(provider.getPropertyIds());
+
+ if (requestPropertyIds == null || requestPropertyIds.isEmpty()) {
+ return providerPropertyIds;
+ }
+
+ if (predicate != null) {
+ requestPropertyIds.addAll(PredicateHelper.getPropertyIds(predicate));
+ }
+ requestPropertyIds.retainAll(providerPropertyIds);
+ return requestPropertyIds;
+ }
+
+ /**
* Factory method to create a create request from the given set of property maps.
* Each map contains the properties to be used to create a resource. Multiple maps in the
* set should result in multiple creates.
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/StreamProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/StreamProvider.java?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/StreamProvider.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/StreamProvider.java Tue Oct 9 21:38:56 2012
@@ -0,0 +1,29 @@
+/**
+ * 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.ambari.server.controller.utilities;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A provider of input stream from a property source.
+ */
+public interface StreamProvider {
+ public InputStream readFrom(String spec) throws IOException;
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/StreamProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXHelperTest.java?rev=1396345&r1=1396344&r2=1396345&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXHelperTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXHelperTest.java Tue Oct 9 21:38:56 2012
@@ -17,9 +17,14 @@
*/
package org.apache.ambari.server.controller.jmx;
+import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Ignore;
import org.junit.Test;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+
/**
*
*/
@@ -31,7 +36,20 @@ public class JMXHelperTest {
String target = "ec2-107-22-86-120.compute-1.amazonaws.com:50070";
- JMXMetrics metrics = JMXHelper.getJMXMetrics(target, null);
+ JMXMetrics result;
+ String s = "http://" + target + "/jmx?qry=" + (null == null ? "Hadoop:*" : null);
+ try {
+ URLConnection connection = new URL(s).openConnection();
+
+ connection.setDoOutput(true);
+
+ result = new ObjectMapper().readValue(connection.getInputStream(),
+ JMXMetrics.class);
+
+ } catch (IOException e) {
+ throw new IllegalStateException("Can't get metric " + ".", e);
+ }
+ JMXMetrics metrics = result;
//TODO : assertions
}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java Tue Oct 9 21:38:56 2012
@@ -0,0 +1,154 @@
+/**
+ * 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.ambari.server.controller.jmx;
+
+import org.apache.ambari.server.controller.internal.ResourceImpl;
+import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.controller.utilities.StreamProvider;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * JMX property provider tests.
+ */
+public class JMXPropertyProviderTest {
+
+ private static Map<String, String> HOST_MAPPING = new HashMap<String, String>();
+
+ static {
+ HOST_MAPPING.put("domU-12-31-39-0E-34-E1.compute-1.internal", "ec2-50-17-129-192.compute-1.amazonaws.com");
+ HOST_MAPPING.put("ip-10-190-186-15.ec2.internal", "ec2-23-21-8-226.compute-1.amazonaws.com");
+ HOST_MAPPING.put("domU-12-31-39-14-EE-B3.compute-1.internal", "ec2-23-23-71-42.compute-1.amazonaws.com");
+ HOST_MAPPING.put("ip-10-110-157-51.ec2.internal", "ec2-107-22-121-67.compute-1.amazonaws.com");
+ }
+
+ private static Map<String, String> FILE_MAPPING = new HashMap<String, String>();
+
+ static {
+ FILE_MAPPING.put("http://ec2-23-21-8-226.compute-1.amazonaws.com:50070/jmx?qry=Hadoop:*", "hdfs_namenode_jmx.json");
+ FILE_MAPPING.put("http://ec2-23-23-71-42.compute-1.amazonaws.com:50075/jmx?qry=Hadoop:*", "hdfs_datanode_jmx.json");
+ FILE_MAPPING.put("http://ec2-23-23-71-42.compute-1.amazonaws.com:50030/jmx?qry=Hadoop:*", "mapreduce_jobtracker_jmx.json");
+ }
+
+ @Test
+ public void testGetResources() throws Exception {
+
+ Set< PropertyId > propertyIds = PropertyHelper.getPropertyIds(Resource.Type.HostComponent, "JMX");
+ TestStreamProvider streamProvider = new TestStreamProvider();
+ TestHostMappingProvider mappingProvider = new TestHostMappingProvider();
+
+ PropertyProvider propertyProvider = new JMXPropertyProvider(propertyIds,
+ streamProvider,
+ mappingProvider);
+
+ // namenode
+ Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+
+ resource.setProperty(JMXPropertyProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "ip-10-190-186-15.ec2.internal");
+ resource.setProperty(JMXPropertyProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "NAMENODE");
+
+ // request with an empty set should get all supported properties
+ Request request = PropertyHelper.getReadRequest(Collections.<PropertyId>emptySet());
+
+ Assert.assertEquals(1, propertyProvider.populateResources(Collections.singleton(resource), request, null).size());
+
+ Assert.assertEquals(JMXPropertyProvider.getSpec("ec2-23-21-8-226.compute-1.amazonaws.com:50070"), streamProvider.getLastSpec());
+
+ // see test/resources/hdfs_namenode_jmx.json for values
+ Assert.assertEquals("1084287", resource.getPropertyValue(PropertyHelper.getPropertyId("ReceivedBytes", "rpc")));
+ Assert.assertEquals("173", resource.getPropertyValue(PropertyHelper.getPropertyId("CreateFileOps", "dfs")));
+ Assert.assertEquals("405.8686", resource.getPropertyValue(PropertyHelper.getPropertyId("memHeapUsedM", "jvm")));
+
+
+ // datanode
+ resource = new ResourceImpl(Resource.Type.HostComponent);
+
+ resource.setProperty(JMXPropertyProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "domU-12-31-39-14-EE-B3.compute-1.internal");
+ resource.setProperty(JMXPropertyProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "DATANODE");
+
+ // request with an empty set should get all supported properties
+ request = PropertyHelper.getReadRequest(Collections.<PropertyId>emptySet());
+
+ propertyProvider.populateResources(Collections.singleton(resource), request, null);
+
+ Assert.assertEquals(JMXPropertyProvider.getSpec("ec2-23-23-71-42.compute-1.amazonaws.com:50075"), streamProvider.getLastSpec());
+
+ // see test/resources/hdfs_datanode_jmx.json for values
+ Assert.assertEquals("0", resource.getPropertyValue(PropertyHelper.getPropertyId("ReceivedBytes", "rpc")));
+ Assert.assertEquals("16.870667", resource.getPropertyValue(PropertyHelper.getPropertyId("memHeapUsedM", "jvm")));
+
+
+ // jobtracker
+ resource = new ResourceImpl(Resource.Type.HostComponent);
+
+ resource.setProperty(JMXPropertyProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "domU-12-31-39-14-EE-B3.compute-1.internal");
+ resource.setProperty(JMXPropertyProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "JOBTRACKER");
+
+ // only ask for one property
+ request = PropertyHelper.getReadRequest(Collections.singleton(PropertyHelper.getPropertyId("threadsWaiting", "jvm")));
+
+ propertyProvider.populateResources(Collections.singleton(resource), request, null);
+
+ Assert.assertEquals(JMXPropertyProvider.getSpec("ec2-23-23-71-42.compute-1.amazonaws.com:50030"), streamProvider.getLastSpec());
+
+ // see test/resources/mapreduce_jobtracker_jmx.json for values
+ // resource should now contain 3 properties... host name, component name, and jvm.threadsWaiting (from request)
+ Assert.assertEquals(3, PropertyHelper.getProperties(resource).size());
+ Assert.assertEquals("59", resource.getPropertyValue(PropertyHelper.getPropertyId("threadsWaiting", "jvm")));
+ Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("gcCount", "jvm")));
+ }
+
+
+ public static class TestStreamProvider implements StreamProvider {
+ private String lastSpec;
+
+ @Override
+ public InputStream readFrom(String spec) throws IOException {
+ lastSpec = spec;
+ String filename = FILE_MAPPING.get(spec);
+ if (filename == null) {
+ throw new IOException("Can't find JMX source for " + spec);
+ }
+ InputStream resourceAsStream = ClassLoader.getSystemResourceAsStream(filename);
+ return resourceAsStream;
+ }
+
+ public String getLastSpec() {
+ return lastSpec;
+ }
+ }
+
+ public static class TestHostMappingProvider implements HostMappingProvider {
+ @Override
+ public Map<String, String> getHostMap() {
+ return HOST_MAPPING;
+ }
+ }
+}
Propchange: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_datanode_jmx.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_datanode_jmx.json?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_datanode_jmx.json (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_datanode_jmx.json Tue Oct 9 21:38:56 2012
@@ -0,0 +1,136 @@
+{
+ "beans" : [ {
+ "name" : "Hadoop:service=DataNode,name=DataNode",
+ "modelerType" : "DataNode",
+ "tag.context" : "dfs",
+ "tag.sessionId" : null,
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "bytes_written" : 0,
+ "bytes_read" : 0,
+ "blocks_written" : 0,
+ "blocks_read" : 0,
+ "blocks_replicated" : 0,
+ "blocks_removed" : 0,
+ "blocks_verified" : 0,
+ "block_verification_failures" : 0,
+ "blocks_get_local_pathinfo" : 0,
+ "reads_from_local_client" : 0,
+ "reads_from_remote_client" : 0,
+ "writes_from_local_client" : 0,
+ "writes_from_remote_client" : 0,
+ "readBlockOp_num_ops" : 0,
+ "readBlockOp_avg_time" : 0.0,
+ "writeBlockOp_num_ops" : 0,
+ "writeBlockOp_avg_time" : 0.0,
+ "blockChecksumOp_num_ops" : 0,
+ "blockChecksumOp_avg_time" : 0.0,
+ "copyBlockOp_num_ops" : 0,
+ "copyBlockOp_avg_time" : 0.0,
+ "replaceBlockOp_num_ops" : 0,
+ "replaceBlockOp_avg_time" : 0.0,
+ "heartBeats_num_ops" : 1201,
+ "heartBeats_avg_time" : 3.3333333333333335,
+ "blockReports_num_ops" : 0,
+ "blockReports_avg_time" : 0.0
+ }, {
+ "name" : "Hadoop:service=DataNode,name=MetricsSystem,sub=Stats",
+ "modelerType" : "MetricsSystem,sub=Stats",
+ "tag.context" : "metricssystem",
+ "num_sources" : 5,
+ "num_sinks" : 1,
+ "sink.ganglia.latency_num_ops" : 360,
+ "sink.ganglia.latency_avg_time" : 2.0,
+ "sink.ganglia.dropped" : 0,
+ "sink.ganglia.qsize" : 0,
+ "snapshot_num_ops" : 2165,
+ "snapshot_avg_time" : 0.16666666666666669,
+ "snapshot_stdev_time" : 0.408248290463863,
+ "snapshot_imin_time" : 0.0,
+ "snapshot_imax_time" : 1.0,
+ "snapshot_min_time" : 0.0,
+ "snapshot_max_time" : 11.0,
+ "publish_num_ops" : 360,
+ "publish_avg_time" : 0.0,
+ "publish_stdev_time" : 0.0,
+ "publish_imin_time" : 0.0,
+ "publish_imax_time" : 1.401298464324817E-45,
+ "publish_min_time" : 0.0,
+ "publish_max_time" : 1.0,
+ "dropped_pub_all" : 0
+ }, {
+ "name" : "Hadoop:service=DataNode,name=jvm",
+ "modelerType" : "jvm",
+ "tag.context" : "jvm",
+ "tag.processName" : "DataNode",
+ "tag.sessionId" : null,
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "memNonHeapUsedM" : 19.757858,
+ "memNonHeapCommittedM" : 23.1875,
+ "memHeapUsedM" : 16.870667,
+ "memHeapCommittedM" : 111.6875,
+ "gcCount" : 5,
+ "gcTimeMillis" : 37,
+ "threadsNew" : 0,
+ "threadsRunnable" : 14,
+ "threadsBlocked" : 0,
+ "threadsWaiting" : 10,
+ "threadsTimedWaiting" : 8,
+ "threadsTerminated" : 0,
+ "logFatal" : 0,
+ "logError" : 0,
+ "logWarn" : 0,
+ "logInfo" : 3
+ }, {
+ "name" : "Hadoop:service=DataNode,name=RpcActivityForPort8010",
+ "modelerType" : "RpcActivityForPort8010",
+ "tag.context" : "rpc",
+ "tag.port" : "8010",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "rpcAuthenticationSuccesses" : 0,
+ "rpcAuthenticationFailures" : 0,
+ "rpcAuthorizationSuccesses" : 0,
+ "rpcAuthorizationFailures" : 0,
+ "ReceivedBytes" : 0,
+ "SentBytes" : 0,
+ "RpcQueueTime_num_ops" : 0,
+ "RpcQueueTime_avg_time" : 0.0,
+ "RpcProcessingTime_num_ops" : 0,
+ "RpcProcessingTime_avg_time" : 0.0,
+ "NumOpenConnections" : 0,
+ "callQueueLen" : 0
+ }, {
+ "name" : "Hadoop:service=DataNode,name=DataNodeInfo",
+ "modelerType" : "org.apache.hadoop.hdfs.server.datanode.DataNode",
+ "HostName" : "ip-10-190-186-15.ec2.internal",
+ "Version" : "1.0.3.14",
+ "RpcPort" : "8010",
+ "HttpPort" : null,
+ "NamenodeAddress" : "domu-12-31-39-0e-34-e1.compute-1.internal",
+ "VolumeInfo" : "{\"/grid/1/hadoop/hdfs/data/current\":{\"freeSpace\":421091414016,\"usedSpace\":12705792,\"reservedSpace\":1073741824},\"/grid/0/hadoop/hdfs/data/current\":{\"freeSpace\":421092061184,\"usedSpace\":12042240,\"reservedSpace\":1073741824}}"
+ }, {
+ "name" : "Hadoop:service=DataNode,name=RpcDetailedActivityForPort8010",
+ "modelerType" : "RpcDetailedActivityForPort8010",
+ "tag.context" : "rpcdetailed",
+ "tag.port" : "8010",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal"
+ }, {
+ "name" : "Hadoop:service=DataNode,name=MetricsSystem,sub=Control",
+ "modelerType" : "org.apache.hadoop.metrics2.impl.MetricsSystemImpl"
+ }, {
+ "name" : "Hadoop:service=DataNode,name=ugi",
+ "modelerType" : "ugi",
+ "tag.context" : "ugi",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "loginSuccess_num_ops" : 0,
+ "loginSuccess_avg_time" : 0.0,
+ "loginFailure_num_ops" : 0,
+ "loginFailure_avg_time" : 0.0
+ }, {
+ "name" : "Hadoop:service=DataNode,name=FSDatasetState-UndefinedStorageId418811627",
+ "modelerType" : "org.apache.hadoop.hdfs.server.datanode.FSDataset",
+ "Remaining" : 842183475200,
+ "Capacity" : 885570207744,
+ "DfsUsed" : 24748032,
+ "StorageInfo" : "FSDataset{dirpath='/grid/0/hadoop/hdfs/data/current,/grid/1/hadoop/hdfs/data/current'}"
+ } ]
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_namenode_jmx.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_namenode_jmx.json?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_namenode_jmx.json (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/hdfs_namenode_jmx.json Tue Oct 9 21:38:56 2012
@@ -0,0 +1,215 @@
+{
+ "beans" : [ {
+ "name" : "Hadoop:service=NameNode,name=MetricsSystem,sub=Stats",
+ "modelerType" : "MetricsSystem,sub=Stats",
+ "tag.context" : "metricssystem",
+ "num_sources" : 6,
+ "num_sinks" : 1,
+ "sink.ganglia.latency_num_ops" : 179,
+ "sink.ganglia.latency_avg_time" : 3.0,
+ "sink.ganglia.dropped" : 0,
+ "sink.ganglia.qsize" : 0,
+ "snapshot_num_ops" : 1253,
+ "snapshot_avg_time" : 0.0,
+ "snapshot_stdev_time" : 0.0,
+ "snapshot_imin_time" : 0.0,
+ "snapshot_imax_time" : 1.401298464324817E-45,
+ "snapshot_min_time" : 0.0,
+ "snapshot_max_time" : 7.0,
+ "publish_num_ops" : 179,
+ "publish_avg_time" : 0.0,
+ "publish_stdev_time" : 0.0,
+ "publish_imin_time" : 0.0,
+ "publish_imax_time" : 1.401298464324817E-45,
+ "publish_min_time" : 0.0,
+ "publish_max_time" : 1.0,
+ "dropped_pub_all" : 0
+ }, {
+ "name" : "Hadoop:service=NameNode,name=FSNamesystemMetrics",
+ "modelerType" : "FSNamesystemMetrics",
+ "tag.context" : "dfs",
+ "tag.hostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "FilesTotal" : 244,
+ "BlocksTotal" : 170,
+ "CapacityTotalGB" : 2474,
+ "CapacityUsedGB" : 0,
+ "CapacityRemainingGB" : 2353,
+ "TotalLoad" : 21,
+ "CorruptBlocks" : 0,
+ "ExcessBlocks" : 0,
+ "PendingDeletionBlocks" : 0,
+ "PendingReplicationBlocks" : 0,
+ "UnderReplicatedBlocks" : 0,
+ "ScheduledReplicationBlocks" : 0,
+ "MissingBlocks" : 0,
+ "BlockCapacity" : 4194304
+ }, {
+ "name" : "Hadoop:service=NameNode,name=NameNodeInfo",
+ "modelerType" : "org.apache.hadoop.hdfs.server.namenode.FSNamesystem",
+ "Threads" : 122,
+ "HostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "Total" : 2656710623232,
+ "Version" : "1.0.3.14, r",
+ "UpgradeFinalized" : true,
+ "Used" : 76009472,
+ "Free" : 2526547447808,
+ "Safemode" : "",
+ "NonDfsUsedSpace" : 130087165952,
+ "PercentUsed" : 0.002861037,
+ "PercentRemaining" : 95.10059,
+ "TotalBlocks" : 170,
+ "TotalFiles" : 244,
+ "LiveNodes" : "{\"ip-10-110-157-51.ec2.internal\":{\"usedSpace\":24748032,\"lastContact\":0},\"ip-10-190-186-15.ec2.internal\":{\"usedSpace\":24748032,\"lastContact\":0},\"domU-12-31-39-14-EE-B3.compute-1.internal\":{\"usedSpace\":26513408,\"lastContact\":2}}",
+ "DeadNodes" : "{}",
+ "DecomNodes" : "{}",
+ "NameDirStatuses" : "{\"failed\":{},\"active\":{\"/grid/1/hadoop/hdfs/namenode\":\"IMAGE_AND_EDITS\",\"/grid/0/hadoop/hdfs/namenode\":\"IMAGE_AND_EDITS\"}}"
+ }, {
+ "name" : "Hadoop:service=NameNode,name=MetricsSystem,sub=Control",
+ "modelerType" : "org.apache.hadoop.metrics2.impl.MetricsSystemImpl"
+ }, {
+ "name" : "Hadoop:service=NameNode,name=RpcDetailedActivityForPort8020",
+ "modelerType" : "RpcDetailedActivityForPort8020",
+ "tag.context" : "rpcdetailed",
+ "tag.port" : "8020",
+ "tag.hostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "getProtocolVersion_num_ops" : 75,
+ "getProtocolVersion_avg_time" : 0.0,
+ "getFileInfo_num_ops" : 605,
+ "getFileInfo_avg_time" : 0.0,
+ "getListing_num_ops" : 185,
+ "getListing_avg_time" : 0.0,
+ "versionRequest_num_ops" : 3,
+ "versionRequest_avg_time" : 0.33333333333333337,
+ "register_num_ops" : 3,
+ "register_avg_time" : 1.6666666666666667,
+ "blocksBeingWrittenReport_num_ops" : 3,
+ "blocksBeingWrittenReport_avg_time" : 0.33333333333333337,
+ "sendHeartbeat_num_ops" : 1757,
+ "sendHeartbeat_avg_time" : 0.0,
+ "blockReport_num_ops" : 5,
+ "blockReport_avg_time" : 1.0,
+ "mkdirs_num_ops" : 106,
+ "mkdirs_avg_time" : 0.0,
+ "setSafeMode_num_ops" : 2,
+ "setSafeMode_avg_time" : 0.0,
+ "setPermission_num_ops" : 36,
+ "setPermission_avg_time" : 9.0,
+ "create_num_ops" : 173,
+ "create_avg_time" : 10.0,
+ "renewLease_num_ops" : 157,
+ "renewLease_avg_time" : 0.0,
+ "addBlock_num_ops" : 170,
+ "addBlock_avg_time" : 0.5,
+ "blockReceived_num_ops" : 501,
+ "blockReceived_avg_time" : 0.33333333333333337,
+ "complete_num_ops" : 171,
+ "complete_avg_time" : 0.5,
+ "setOwner_num_ops" : 5,
+ "setOwner_avg_time" : 1.0,
+ "delete_num_ops" : 26,
+ "delete_avg_time" : 2.6666666666666665,
+ "setReplication_num_ops" : 6,
+ "setReplication_avg_time" : 1.0,
+ "getBlockLocations_num_ops" : 45,
+ "getBlockLocations_avg_time" : 1.0,
+ "rename_num_ops" : 14,
+ "rename_avg_time" : 1.0,
+ "fsync_num_ops" : 4,
+ "fsync_avg_time" : 6.333333333333334,
+ "getEditLogSize_num_ops" : 5,
+ "getEditLogSize_avg_time" : 0.0,
+ "rollEditLog_num_ops" : 1,
+ "rollEditLog_avg_time" : 39.0,
+ "rollFsImage_num_ops" : 1,
+ "rollFsImage_avg_time" : 53.0
+ }, {
+ "name" : "Hadoop:service=NameNode,name=FSNamesystemState",
+ "modelerType" : "org.apache.hadoop.hdfs.server.namenode.FSNamesystem",
+ "CapacityTotal" : 2656710623232,
+ "CapacityUsed" : 76009472,
+ "CapacityRemaining" : 2526547447808,
+ "TotalLoad" : 21,
+ "BlocksTotal" : 170,
+ "FilesTotal" : 244,
+ "PendingReplicationBlocks" : 0,
+ "UnderReplicatedBlocks" : 0,
+ "ScheduledReplicationBlocks" : 0,
+ "FSState" : "Operational"
+ }, {
+ "name" : "Hadoop:service=NameNode,name=RpcActivityForPort8020",
+ "modelerType" : "RpcActivityForPort8020",
+ "tag.context" : "rpc",
+ "tag.port" : "8020",
+ "tag.hostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "rpcAuthenticationSuccesses" : 0,
+ "rpcAuthenticationFailures" : 0,
+ "rpcAuthorizationSuccesses" : 263,
+ "rpcAuthorizationFailures" : 0,
+ "ReceivedBytes" : 1084287,
+ "SentBytes" : 653597,
+ "RpcQueueTime_num_ops" : 4059,
+ "RpcQueueTime_avg_time" : 0.0,
+ "RpcProcessingTime_num_ops" : 4059,
+ "RpcProcessingTime_avg_time" : 0.0,
+ "NumOpenConnections" : 0,
+ "callQueueLen" : 0
+ }, {
+ "name" : "Hadoop:service=NameNode,name=jvm",
+ "modelerType" : "jvm",
+ "tag.context" : "jvm",
+ "tag.processName" : "NameNode",
+ "tag.sessionId" : null,
+ "tag.hostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "memNonHeapUsedM" : 21.10804,
+ "memNonHeapCommittedM" : 23.1875,
+ "memHeapUsedM" : 405.8686,
+ "memHeapCommittedM" : 1664.0,
+ "gcCount" : 1,
+ "gcTimeMillis" : 88,
+ "threadsNew" : 0,
+ "threadsRunnable" : 10,
+ "threadsBlocked" : 0,
+ "threadsWaiting" : 104,
+ "threadsTimedWaiting" : 8,
+ "threadsTerminated" : 0,
+ "logFatal" : 0,
+ "logError" : 0,
+ "logWarn" : 0,
+ "logInfo" : 3
+ }, {
+ "name" : "Hadoop:service=NameNode,name=ugi",
+ "modelerType" : "ugi",
+ "tag.context" : "ugi",
+ "tag.hostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "loginSuccess_num_ops" : 0,
+ "loginSuccess_avg_time" : 0.0,
+ "loginFailure_num_ops" : 0,
+ "loginFailure_avg_time" : 0.0
+ }, {
+ "name" : "Hadoop:service=NameNode,name=NameNode",
+ "modelerType" : "NameNode",
+ "tag.context" : "dfs",
+ "tag.sessionId" : null,
+ "tag.hostName" : "domU-12-31-39-0E-34-E1.compute-1.internal",
+ "FilesCreated" : 301,
+ "FilesAppended" : 0,
+ "GetBlockLocations" : 45,
+ "FilesRenamed" : 14,
+ "GetListingOps" : 185,
+ "CreateFileOps" : 173,
+ "FilesDeleted" : 58,
+ "DeleteFileOps" : 26,
+ "FileInfoOps" : 605,
+ "AddBlockOps" : 170,
+ "Transactions_num_ops" : 735,
+ "Transactions_avg_time" : 0.0,
+ "Syncs_num_ops" : 536,
+ "Syncs_avg_time" : 4.666666666666667,
+ "JournalTransactionsBatchedInSync" : 5,
+ "blockReport_num_ops" : 5,
+ "blockReport_avg_time" : 1.0,
+ "SafemodeTime" : 852,
+ "fsImageLoadTime" : 839,
+ "FilesInGetListingOps" : 415
+ } ]
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json Tue Oct 9 21:38:56 2012
@@ -0,0 +1,197 @@
+{
+ "beans" : [ {
+ "name" : "Hadoop:service=JobTracker,name=JobTrackerMetrics",
+ "modelerType" : "JobTrackerMetrics",
+ "tag.context" : "mapred",
+ "tag.sessionId" : "",
+ "tag.hostName" : "domU-12-31-39-14-EE-B3.compute-1.internal",
+ "map_slots" : 9,
+ "reduce_slots" : 3,
+ "blacklisted_maps" : 0,
+ "blacklisted_reduces" : 0,
+ "maps_launched" : 4,
+ "maps_completed" : 4,
+ "maps_failed" : 0,
+ "reduces_launched" : 2,
+ "reduces_completed" : 2,
+ "reduces_failed" : 0,
+ "jobs_submitted" : 4,
+ "jobs_completed" : 4,
+ "waiting_maps" : 0,
+ "waiting_reduces" : 0,
+ "reserved_map_slots" : 0,
+ "reserved_reduce_slots" : 0,
+ "occupied_map_slots" : 0,
+ "occupied_reduce_slots" : 0,
+ "jobs_failed" : 0,
+ "jobs_killed" : 0,
+ "jobs_preparing" : 0,
+ "jobs_running" : 0,
+ "running_maps" : 0,
+ "running_reduces" : 0,
+ "maps_killed" : 0,
+ "reduces_killed" : 0,
+ "trackers" : 3,
+ "trackers_blacklisted" : 0,
+ "trackers_graylisted" : 0,
+ "trackers_decommissioned" : 0,
+ "heartbeats" : 3241
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=RpcActivityForPort50300",
+ "modelerType" : "RpcActivityForPort50300",
+ "tag.context" : "rpc",
+ "tag.port" : "50300",
+ "tag.hostName" : "domU-12-31-39-14-EE-B3.compute-1.internal",
+ "rpcAuthenticationSuccesses" : 0,
+ "rpcAuthenticationFailures" : 0,
+ "rpcAuthorizationSuccesses" : 10,
+ "rpcAuthorizationFailures" : 0,
+ "ReceivedBytes" : 1147255,
+ "SentBytes" : 429162,
+ "RpcQueueTime_num_ops" : 3543,
+ "RpcQueueTime_avg_time" : 0.3,
+ "RpcProcessingTime_num_ops" : 3543,
+ "RpcProcessingTime_avg_time" : 0.20000000000000004,
+ "NumOpenConnections" : 0,
+ "callQueueLen" : 0
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=ugi",
+ "modelerType" : "ugi",
+ "tag.context" : "ugi",
+ "tag.hostName" : "domU-12-31-39-14-EE-B3.compute-1.internal",
+ "loginSuccess_num_ops" : 0,
+ "loginSuccess_avg_time" : 0.0,
+ "loginFailure_num_ops" : 0,
+ "loginFailure_avg_time" : 0.0
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=JobTrackerInfo",
+ "modelerType" : "org.apache.hadoop.mapred.JobTracker",
+ "Hostname" : "domU-12-31-39-14-EE-B3",
+ "Version" : "1.0.3.14, r",
+ "ConfigVersion" : "default",
+ "ThreadCount" : 75,
+ "SummaryJson" : "{\"nodes\":3,\"alive\":3,\"blacklisted\":0,\"graylisted\":0,\"slots\":{\"map_slots\":9,\"map_slots_used\":0,\"reduce_slots\":3,\"reduce_slots_used\":0},\"jobs\":4}",
+ "AliveNodesInfoJson" : "[{\"hostname\":\"ip-10-190-186-15.ec2.internal\",\"last_seen\":1349799458856,\"health\":\"OK\",\"slots\":{\"map_slots\":3,\"map_slots_used\":0,\"reduce_slots\":1,\"reduce_slots_used\":0},\"failures\":0},{\"hostname\":\"domU-12-31-39-14-EE-B3.compute-1.internal\",\"last_seen\":1349799460095,\"health\":\"OK\",\"slots\":{\"map_slots\":3,\"map_slots_used\":0,\"reduce_slots\":1,\"reduce_slots_used\":0},\"failures\":0},{\"hostname\":\"ip-10-110-157-51.ec2.internal\",\"last_seen\":1349799459495,\"health\":\"OK\",\"slots\":{\"map_slots\":3,\"map_slots_used\":0,\"reduce_slots\":1,\"reduce_slots_used\":0},\"failures\":0}]",
+ "BlacklistedNodesInfoJson" : "[]",
+ "GraylistedNodesInfoJson" : "[]",
+ "QueueInfoJson" : "{\"default\":{\"state\":\"running\",\"info\":\"Queue configuration\\nCapacity Percentage: 100.0%\\nUser Limit: 100%\\nPriority Supported: NO\\n-------------\\nMap tasks\\nCapacity: 9 slots\\nUsed capacity: 0 (0.0% of Capacity)\\nRunning tasks: 0\\n-------------\\nReduce tasks\\nCapacity: 3 slots\\nUsed capacity: 0 (0.0% of Capacity)\\nRunning tasks: 0\\n-------------\\nJob info\\nNumber of Waiting Jobs: 0\\nNumber of Initializing Jobs: 0\\nNumber of users who have submitted jobs: 0\\n\"}}"
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=MetricsSystem,sub=Control",
+ "modelerType" : "org.apache.hadoop.metrics2.impl.MetricsSystemImpl"
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=RpcDetailedActivityForPort50300",
+ "modelerType" : "RpcDetailedActivityForPort50300",
+ "tag.context" : "rpcdetailed",
+ "tag.port" : "50300",
+ "tag.hostName" : "domU-12-31-39-14-EE-B3.compute-1.internal",
+ "getProtocolVersion_num_ops" : 13,
+ "getProtocolVersion_avg_time" : 0.0,
+ "jobsToComplete_num_ops" : 1,
+ "jobsToComplete_avg_time" : 0.0,
+ "getBuildVersion_num_ops" : 3,
+ "getBuildVersion_avg_time" : 0.0,
+ "getSystemDir_num_ops" : 3,
+ "getSystemDir_avg_time" : 0.0,
+ "heartbeat_num_ops" : 3241,
+ "heartbeat_avg_time" : 0.20000000000000004,
+ "getStagingAreaDir_num_ops" : 4,
+ "getStagingAreaDir_avg_time" : 0.0,
+ "getNewJobId_num_ops" : 4,
+ "getNewJobId_avg_time" : 0.0,
+ "getQueueAdmins_num_ops" : 4,
+ "getQueueAdmins_avg_time" : 0.0,
+ "submitJob_num_ops" : 4,
+ "submitJob_avg_time" : 59.0,
+ "getJobProfile_num_ops" : 76,
+ "getJobProfile_avg_time" : 0.0,
+ "getJobStatus_num_ops" : 126,
+ "getJobStatus_avg_time" : 0.0,
+ "getTaskCompletionEvents_num_ops" : 47,
+ "getTaskCompletionEvents_avg_time" : 0.0,
+ "getJobCounters_num_ops" : 7,
+ "getJobCounters_avg_time" : 0.6666666666666666,
+ "getMapTaskReports_num_ops" : 2,
+ "getMapTaskReports_avg_time" : 0.0,
+ "getReduceTaskReports_num_ops" : 2,
+ "getReduceTaskReports_avg_time" : 0.0,
+ "getDelegationToken_num_ops" : 6,
+ "getDelegationToken_avg_time" : 1.5
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=jvm",
+ "modelerType" : "jvm",
+ "tag.context" : "jvm",
+ "tag.processName" : "JobTracker",
+ "tag.sessionId" : "",
+ "tag.hostName" : "domU-12-31-39-14-EE-B3.compute-1.internal",
+ "memNonHeapUsedM" : 23.058548,
+ "memNonHeapCommittedM" : 24.125,
+ "memHeapUsedM" : 75.27263,
+ "memHeapCommittedM" : 185.1875,
+ "gcCount" : 3,
+ "gcTimeMillis" : 70,
+ "threadsNew" : 0,
+ "threadsRunnable" : 6,
+ "threadsBlocked" : 0,
+ "threadsWaiting" : 59,
+ "threadsTimedWaiting" : 10,
+ "threadsTerminated" : 0,
+ "logFatal" : 0,
+ "logError" : 0,
+ "logWarn" : 0,
+ "logInfo" : 3
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=QueueMetrics,q=default",
+ "modelerType" : "QueueMetrics,q=default",
+ "tag.context" : "mapred",
+ "tag.sessionId" : "",
+ "tag.Queue" : "default",
+ "tag.hostName" : "domU-12-31-39-14-EE-B3.compute-1.internal",
+ "maps_launched" : 4,
+ "maps_completed" : 4,
+ "maps_failed" : 0,
+ "reduces_launched" : 2,
+ "reduces_completed" : 2,
+ "reduces_failed" : 0,
+ "jobs_submitted" : 4,
+ "jobs_completed" : 4,
+ "waiting_maps" : 0,
+ "waiting_reduces" : 0,
+ "reserved_map_slots" : 0,
+ "reserved_reduce_slots" : 0,
+ "jobs_failed" : 0,
+ "jobs_killed" : 0,
+ "jobs_preparing" : 0,
+ "jobs_running" : 0,
+ "maps_killed" : 0,
+ "reduces_killed" : 0,
+ "running_0" : 0,
+ "running_60" : 0,
+ "running_300" : 0,
+ "running_1440" : 0
+ }, {
+ "name" : "Hadoop:service=JobTracker,name=MetricsSystem,sub=Stats",
+ "modelerType" : "MetricsSystem,sub=Stats",
+ "tag.context" : "metricssystem",
+ "num_sources" : 6,
+ "num_sinks" : 1,
+ "sink.ganglia.latency_num_ops" : 328,
+ "sink.ganglia.latency_avg_time" : 3.0,
+ "sink.ganglia.dropped" : 0,
+ "sink.ganglia.qsize" : 0,
+ "snapshot_num_ops" : 2302,
+ "snapshot_avg_time" : 0.14285714285714285,
+ "snapshot_stdev_time" : 0.37796447300922725,
+ "snapshot_imin_time" : 0.0,
+ "snapshot_imax_time" : 1.0,
+ "snapshot_min_time" : 0.0,
+ "snapshot_max_time" : 1.0,
+ "publish_num_ops" : 328,
+ "publish_avg_time" : 0.0,
+ "publish_stdev_time" : 0.0,
+ "publish_imin_time" : 0.0,
+ "publish_imax_time" : 1.401298464324817E-45,
+ "publish_min_time" : 0.0,
+ "publish_max_time" : 1.0,
+ "dropped_pub_all" : 0
+ } ]
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_tasktracker_jmx.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_tasktracker_jmx.json?rev=1396345&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_tasktracker_jmx.json (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/mapreduce_tasktracker_jmx.json Tue Oct 9 21:38:56 2012
@@ -0,0 +1,122 @@
+{
+ "beans" : [ {
+ "name" : "Hadoop:service=TaskTracker,name=TaskTrackerMetrics",
+ "modelerType" : "TaskTrackerMetrics",
+ "tag.context" : "mapred",
+ "tag.sessionId" : "",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "maps_running" : 0,
+ "reduces_running" : 0,
+ "mapTaskSlots" : 3,
+ "reduceTaskSlots" : 1,
+ "tasks_completed" : 0,
+ "tasks_failed_timeout" : 0,
+ "tasks_failed_ping" : 0
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=TaskTrackerInfo",
+ "modelerType" : "org.apache.hadoop.mapred.TaskTracker",
+ "Hostname" : "ip-10-190-186-15.ec2.internal",
+ "Version" : "1.0.3.14, r",
+ "ConfigVersion" : "default",
+ "JobTrackerUrl" : "domu-12-31-39-14-ee-b3.compute-1.internal:50300",
+ "RpcPort" : 57448,
+ "HttpPort" : 50060,
+ "Healthy" : true,
+ "TasksInfoJson" : "{\"running\":0,\"failed\":0,\"commit_pending\":0}"
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=MetricsSystem,sub=Control",
+ "modelerType" : "org.apache.hadoop.metrics2.impl.MetricsSystemImpl"
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=RpcDetailedActivityForPort57448",
+ "modelerType" : "RpcDetailedActivityForPort57448",
+ "tag.context" : "rpcdetailed",
+ "tag.port" : "57448",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal"
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=MetricsSystem,sub=Stats",
+ "modelerType" : "MetricsSystem,sub=Stats",
+ "tag.context" : "metricssystem",
+ "num_sources" : 6,
+ "num_sinks" : 1,
+ "sink.ganglia.latency_num_ops" : 359,
+ "sink.ganglia.latency_avg_time" : 2.0,
+ "sink.ganglia.dropped" : 0,
+ "sink.ganglia.qsize" : 0,
+ "snapshot_num_ops" : 2519,
+ "snapshot_avg_time" : 0.0,
+ "snapshot_stdev_time" : 0.0,
+ "snapshot_imin_time" : 0.0,
+ "snapshot_imax_time" : 1.401298464324817E-45,
+ "snapshot_min_time" : 0.0,
+ "snapshot_max_time" : 8.0,
+ "publish_num_ops" : 359,
+ "publish_avg_time" : 0.0,
+ "publish_stdev_time" : 0.0,
+ "publish_imin_time" : 0.0,
+ "publish_imax_time" : 1.401298464324817E-45,
+ "publish_min_time" : 0.0,
+ "publish_max_time" : 1.0,
+ "dropped_pub_all" : 0
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=jvm",
+ "modelerType" : "jvm",
+ "tag.context" : "jvm",
+ "tag.processName" : "TaskTracker",
+ "tag.sessionId" : "",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "memNonHeapUsedM" : 20.945961,
+ "memNonHeapCommittedM" : 23.1875,
+ "memHeapUsedM" : 16.158371,
+ "memHeapCommittedM" : 105.0625,
+ "gcCount" : 12,
+ "gcTimeMillis" : 103,
+ "threadsNew" : 0,
+ "threadsRunnable" : 6,
+ "threadsBlocked" : 0,
+ "threadsWaiting" : 15,
+ "threadsTimedWaiting" : 7,
+ "threadsTerminated" : 0,
+ "logFatal" : 0,
+ "logError" : 0,
+ "logWarn" : 0,
+ "logInfo" : 3
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=RpcActivityForPort57448",
+ "modelerType" : "RpcActivityForPort57448",
+ "tag.context" : "rpc",
+ "tag.port" : "57448",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "rpcAuthenticationSuccesses" : 0,
+ "rpcAuthenticationFailures" : 0,
+ "rpcAuthorizationSuccesses" : 0,
+ "rpcAuthorizationFailures" : 0,
+ "ReceivedBytes" : 0,
+ "SentBytes" : 0,
+ "RpcQueueTime_num_ops" : 0,
+ "RpcQueueTime_avg_time" : 0.0,
+ "RpcProcessingTime_num_ops" : 0,
+ "RpcProcessingTime_avg_time" : 0.0,
+ "NumOpenConnections" : 0,
+ "callQueueLen" : 0
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=ShuffleServerMetrics",
+ "modelerType" : "ShuffleServerMetrics",
+ "tag.context" : "mapred",
+ "tag.sessionId" : "",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "shuffle_handler_busy_percent" : 0.0,
+ "shuffle_output_bytes" : 0,
+ "shuffle_failed_outputs" : 0,
+ "shuffle_success_outputs" : 0,
+ "shuffle_exceptions_caught" : 0
+ }, {
+ "name" : "Hadoop:service=TaskTracker,name=ugi",
+ "modelerType" : "ugi",
+ "tag.context" : "ugi",
+ "tag.hostName" : "ip-10-190-186-15.ec2.internal",
+ "loginSuccess_num_ops" : 0,
+ "loginSuccess_avg_time" : 0.0,
+ "loginFailure_num_ops" : 0,
+ "loginFailure_avg_time" : 0.0
+ } ]
+}