Browse Source

Revert "AMBARI-9652 AMS : Hosts metrics - "mem_shared" metrics array contains "null" (dsen)"

This reverts commit 58597876ef6893ef32a59f03be36c03e7dd7cb10.
Dmytro Sen 10 years ago
parent
commit
0ed6fd688f

+ 1 - 7
ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetric.java

@@ -19,10 +19,6 @@ package org.apache.hadoop.metrics2.sink.timeline;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.metrics2.sink.timeline.deserialize
-  .IgnoringNullsLinkedHashMap;
-import org.codehaus.jackson.map.annotate.JsonDeserialize;
-
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -43,9 +39,7 @@ public class TimelineMetric implements Comparable<TimelineMetric> {
   private long timestamp;
   private long startTime;
   private String type;
-
-  @JsonDeserialize(as = IgnoringNullsLinkedHashMap.class)
-  private Map<Long, Double> metricValues = new IgnoringNullsLinkedHashMap<Long, Double>();
+  private Map<Long, Double> metricValues = new TreeMap<Long, Double>();
 
   @XmlElement(name = "metricname")
   public String getMetricName() {

+ 0 - 34
ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/deserialize/IgnoringNullsLinkedHashMap.java

@@ -1,34 +0,0 @@
-/**
- * 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.hadoop.metrics2.sink.timeline.deserialize;
-
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-/**
- * This Map does not store neither null values. When null value is
- * inserted it is ignored.
- */
-public class IgnoringNullsLinkedHashMap<K, V> extends TreeMap<K, V> {
-  @Override
-  public V put(K key, V value) {
-    if (value == null) return null;
-
-    return super.put(key, value);
-  }
-}

+ 0 - 39
ambari-metrics/ambari-metrics-common/src/test/java/org/apache/hadoop/metrics2/sink/timeline/deserialize/IgnoringNullsLinkedHashMapTest.java

@@ -1,39 +0,0 @@
-/**
- * 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.hadoop.metrics2.sink.timeline.deserialize;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class IgnoringNullsLinkedHashMapTest {
-
-  @Test
-  public void testPut() throws Exception {
-    IgnoringNullsLinkedHashMap<Integer, String> map
-      = new IgnoringNullsLinkedHashMap<Integer, String>();
-
-    map.put(1, null);
-    map.put(2, "two");
-    map.put(3, null);
-    map.put(4, "four");
-    map.put(5, "five");
-
-    assertEquals(3,map.size());
-  }
-}

+ 3 - 2
ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebApp.java

@@ -25,6 +25,7 @@ import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.
 import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.TimelineStore;
 import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
 import org.apache.hadoop.yarn.webapp.WebApp;
+import org.apache.hadoop.yarn.webapp.YarnJacksonJaxbJsonProvider;
 import org.apache.hadoop.yarn.webapp.YarnWebParams;
 
 public class AHSWebApp extends WebApp implements YarnWebParams {
@@ -42,7 +43,7 @@ public class AHSWebApp extends WebApp implements YarnWebParams {
 
   @Override
   public void setup() {
-    bind(YarnAMSJacksonJaxbJsonProvider.class);
+    bind(YarnJacksonJaxbJsonProvider.class);
     bind(AHSWebServices.class);
     bind(TimelineWebServices.class);
     bind(GenericExceptionHandler.class);
@@ -59,4 +60,4 @@ public class AHSWebApp extends WebApp implements YarnWebParams {
       pajoin("/logs", NM_NODENAME, CONTAINER_ID, ENTITY_STRING, APP_OWNER,
         CONTAINER_LOG_TYPE), AHSController.class, "logs");
   }
-}
+}

+ 0 - 57
ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/YarnAMSJacksonJaxbJsonProvider.java

@@ -1,57 +0,0 @@
-/**
- * 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.hadoop.yarn.server.applicationhistoryservice.webapp;
-
-import com.google.inject.Singleton;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
-import org.codehaus.jackson.map.AnnotationIntrospector;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
-import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.ext.Provider;
-
-/**
- *
- */
-@Singleton
-@Provider
-@InterfaceStability.Unstable
-@InterfaceAudience.Private
-public class YarnAMSJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider {
-
-  public YarnAMSJacksonJaxbJsonProvider() {
-    super();
-  }
-
-  @Override
-  public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
-    ObjectMapper mapper = super.locateMapper(type, mediaType);
-    configObjectMapper(mapper);
-    return mapper;
-  }
-
-  public static void configObjectMapper(ObjectMapper mapper) {
-    mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
-  }
-
-}

+ 4 - 6
ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/TimelineMetric.java

@@ -17,15 +17,15 @@
  */
 package org.apache.hadoop.metrics2.sink.timeline;
 
-import org.apache.hadoop.metrics2.sink.timeline.deserialize
-  .IgnoringNullsLinkedHashMap;
-import org.codehaus.jackson.map.annotate.JsonDeserialize;
-
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import java.text.DecimalFormat;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 
 @XmlRootElement(name = "metric")
@@ -39,8 +39,6 @@ public class TimelineMetric implements Comparable<TimelineMetric> {
   private long timestamp;
   private long startTime;
   private String type;
-
-  @JsonDeserialize(as = IgnoringNullsLinkedHashMap.class)
   private Map<Long, Double> metricValues = new TreeMap<Long, Double>();
 
   @XmlElement(name = "metricname")

+ 0 - 35
ambari-server/src/main/java/org/apache/hadoop/metrics2/sink/timeline/deserialize/IgnoringNullsLinkedHashMap.java

@@ -1,35 +0,0 @@
- /**
- * 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.hadoop.metrics2.sink.timeline.deserialize;
-
-
- import java.util.LinkedHashMap;
-
- /**
- * This Map does not store neither null values. When null value is
- * inserted it is ignored.
- */
-public class IgnoringNullsLinkedHashMap<K, V> extends LinkedHashMap<K, V> {
-  @Override
-  public V put(K key, V value) {
-    if (value == null) return null;
-
-    return super.put(key, value);
-  }
-}