You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/03/20 21:44:50 UTC

svn commit: r1459041 [14/18] - in /incubator/ambari/branches/branch-1.2: ./ ambari-agent/ ambari-agent/conf/unix/ ambari-agent/src/main/puppet/modules/hdp-ganglia/files/ ambari-agent/src/main/puppet/modules/hdp-ganglia/manifests/ ambari-agent/src/main/...

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,195 @@
+/**
+ * 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.AmbariManagementController;
+import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.TaskStatusResponse;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * TaskResourceProvider tests.
+ */
+public class TaskResourceProviderTest {
+  @Test
+  public void testCreateResources() throws Exception {
+    Resource.Type type = Resource.Type.Task;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+
+    // replay
+    replay(managementController, response);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    // add the property map to a set for the request.  add more maps for multiple creates
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    // add properties to the request map
+    properties.put(TaskResourceProvider.TASK_REQUEST_ID_PROPERTY_ID, 100);
+    properties.put(TaskResourceProvider.TASK_ID_PROPERTY_ID, 100);
+
+    propertySet.add(properties);
+
+    // create the request
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    try {
+      provider.createResources(request);
+      Assert.fail("Expected an UnsupportedOperationException");
+    } catch (UnsupportedOperationException e) {
+      // expected
+    }
+
+    // verify
+    verify(managementController, response);
+  }
+
+  @Test
+  public void testGetResources() throws Exception {
+    Resource.Type type = Resource.Type.Task;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+
+    Set<TaskStatusResponse> allResponse = new HashSet<TaskStatusResponse>();
+    allResponse.add(new TaskStatusResponse(100L, 100, 100L, "HostName100", "", "", "", 0, "", "", 0L, (short) 0));
+
+    // set expectations
+    expect(managementController.getTaskStatus(AbstractResourceProviderTest.Matcher.getTaskRequestSet(100L, 100L))).
+        andReturn(allResponse).once();
+
+    // replay
+    replay(managementController);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    Set<String> propertyIds = new HashSet<String>();
+
+    propertyIds.add(TaskResourceProvider.TASK_ID_PROPERTY_ID);
+    propertyIds.add(TaskResourceProvider.TASK_REQUEST_ID_PROPERTY_ID);
+
+    Predicate predicate = new PredicateBuilder().property(TaskResourceProvider.TASK_ID_PROPERTY_ID).equals("100").
+                          and().property(TaskResourceProvider.TASK_REQUEST_ID_PROPERTY_ID).equals("100").toPredicate();
+    Request request = PropertyHelper.getReadRequest(propertyIds);
+    Set<Resource> resources = provider.getResources(request, predicate);
+
+    Assert.assertEquals(1, resources.size());
+    for (Resource resource : resources) {
+      long taskId = (Long) resource.getPropertyValue(TaskResourceProvider.TASK_ID_PROPERTY_ID);
+      Assert.assertEquals(100L, taskId);
+    }
+
+    // verify
+    verify(managementController);
+  }
+
+  @Test
+  public void testUpdateResources() throws Exception {
+    Resource.Type type = Resource.Type.Task;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+
+    // replay
+    replay(managementController, response);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    // add the property map to a set for the request.
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    // create the request
+    Request request = PropertyHelper.getUpdateRequest(properties);
+
+    Predicate predicate = new PredicateBuilder().property(TaskResourceProvider.TASK_ID_PROPERTY_ID).equals("Task100").
+        toPredicate();
+
+    try {
+      provider.updateResources(request, predicate);
+      Assert.fail("Expected an UnsupportedOperationException");
+    } catch (UnsupportedOperationException e) {
+      // expected
+    }
+
+    // verify
+    verify(managementController, response);
+  }
+
+  @Test
+  public void testDeleteResources() throws Exception {
+    Resource.Type type = Resource.Type.Task;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+
+    // replay
+    replay(managementController);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    Predicate predicate = new PredicateBuilder().property(TaskResourceProvider.TASK_ID_PROPERTY_ID).equals("Task100").
+        toPredicate();
+    try {
+      provider.deleteResources(predicate);
+      Assert.fail("Expected an UnsupportedOperationException");
+    } catch (UnsupportedOperationException e) {
+      // expected
+    }
+
+    // verify
+    verify(managementController);
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,191 @@
+/**
+ * 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.AmbariManagementController;
+import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.UserRequest;
+import org.apache.ambari.server.controller.UserResponse;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * UserResourceProvider tests.
+ */
+public class UserResourceProviderTest {
+  @Test
+  public void testCreateResources() throws Exception {
+    Resource.Type type = Resource.Type.User;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+
+    managementController.createUsers(AbstractResourceProviderTest.Matcher.getUserRequestSet("User100"));
+
+    // replay
+    replay(managementController, response);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    // add the property map to a set for the request.  add more maps for multiple creates
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    // add properties to the request map
+    properties.put(UserResourceProvider.USER_USERNAME_PROPERTY_ID, "User100");
+
+    propertySet.add(properties);
+
+    // create the request
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    provider.createResources(request);
+
+    // verify
+    verify(managementController, response);
+  }
+
+  @Test
+  public void testGetResources() throws Exception {
+    Resource.Type type = Resource.Type.User;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+
+    Set<UserResponse> allResponse = new HashSet<UserResponse>();
+    allResponse.add(new UserResponse("User100", false));
+
+    // set expectations
+    expect(managementController.getUsers(AbstractResourceProviderTest.Matcher.getUserRequestSet("User100"))).
+        andReturn(allResponse).once();
+
+    // replay
+    replay(managementController);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    Set<String> propertyIds = new HashSet<String>();
+
+    propertyIds.add(UserResourceProvider.USER_USERNAME_PROPERTY_ID);
+    propertyIds.add(UserResourceProvider.USER_PASSWORD_PROPERTY_ID);
+
+    Predicate predicate = new PredicateBuilder().property(UserResourceProvider.USER_USERNAME_PROPERTY_ID).
+        equals("User100").toPredicate();
+    Request request = PropertyHelper.getReadRequest(propertyIds);
+    Set<Resource> resources = provider.getResources(request, predicate);
+
+    Assert.assertEquals(1, resources.size());
+    for (Resource resource : resources) {
+      String userName = (String) resource.getPropertyValue(UserResourceProvider.USER_USERNAME_PROPERTY_ID);
+      Assert.assertEquals("User100", userName);
+    }
+
+    // verify
+    verify(managementController);
+  }
+
+  @Test
+  public void testUpdateResources() throws Exception {
+    Resource.Type type = Resource.Type.User;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+
+    // set expectations
+    managementController.updateUsers(EasyMock.<Set<UserRequest>>anyObject());
+
+    // replay
+    replay(managementController, response);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    // add the property map to a set for the request.
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    properties.put(UserResourceProvider.USER_PASSWORD_PROPERTY_ID, "password");
+
+    // create the request
+    Request request = PropertyHelper.getUpdateRequest(properties);
+
+    Predicate  predicate = new PredicateBuilder().property(UserResourceProvider.USER_USERNAME_PROPERTY_ID).
+        equals("User100").toPredicate();
+    provider.updateResources(request, predicate);
+
+    // verify
+    verify(managementController, response);
+  }
+
+  @Test
+  public void testDeleteResources() throws Exception {
+    Resource.Type type = Resource.Type.User;
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+
+    // set expectations
+    managementController.deleteUsers(AbstractResourceProviderTest.Matcher.getUserRequestSet("User100"));
+
+    // replay
+    replay(managementController, response);
+
+    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+
+    Predicate predicate = new PredicateBuilder().property(UserResourceProvider.USER_USERNAME_PROPERTY_ID).
+        equals("User100").toPredicate();
+    provider.deleteResources(predicate);
+
+    // verify
+    verify(managementController, response);
+  }
+}

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java Wed Mar 20 20:44:43 2013
@@ -21,6 +21,7 @@ package org.apache.ambari.server.control
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.junit.Assert;
 import org.junit.Test;
@@ -29,6 +30,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+
 /**
  * JMX property provider tests.
  */
@@ -36,12 +38,10 @@ public class JMXPropertyProviderTest {
   protected static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "host_name");
   protected static final String HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "component_name");
 
-
   @Test
   public void testGetResources() throws Exception {
-
     TestStreamProvider  streamProvider = new TestStreamProvider();
-      TestJMXHostProvider hostProvider = new TestJMXHostProvider();
+    TestJMXHostProvider hostProvider = new TestJMXHostProvider(false);
 
     JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
         PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent),
@@ -59,7 +59,7 @@ public class JMXPropertyProviderTest {
 
     Assert.assertEquals(1, propertyProvider.populateResources(Collections.singleton(resource), request, null).size());
 
-    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-0e-34-e1.compute-1.internal:50070"), streamProvider.getLastSpec());
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-0e-34-e1.compute-1.internal", "50070"), streamProvider.getLastSpec());
 
     // see test/resources/hdfs_namenode_jmx.json for values
     Assert.assertEquals(13670605,  resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/rpc", "ReceivedBytes")));
@@ -81,7 +81,7 @@ public class JMXPropertyProviderTest {
 
     propertyProvider.populateResources(Collections.singleton(resource), request, null);
 
-    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal:50075"), streamProvider.getLastSpec());
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal", "50075"), streamProvider.getLastSpec());
 
     // see test/resources/hdfs_datanode_jmx.json for values
     Assert.assertEquals(856,  resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/rpc", "ReceivedBytes")));
@@ -104,19 +104,26 @@ public class JMXPropertyProviderTest {
     properties.add(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryUsed"));
     properties.add(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryMax"));
     properties.add(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryUsed"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/jobtracker", "jobs_submitted"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/jobtracker", "jobs_completed"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/jobtracker", "jobs_failed"));
+
     request = PropertyHelper.getReadRequest(properties);
 
     propertyProvider.populateResources(Collections.singleton(resource), request, null);
 
-    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal:50030"), streamProvider.getLastSpec());
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal", "50030"), streamProvider.getLastSpec());
 
     // see test/resources/mapreduce_jobtracker_jmx.json for values
-    Assert.assertEquals(7, PropertyHelper.getProperties(resource).size());
+    Assert.assertEquals(10, PropertyHelper.getProperties(resource).size());
     Assert.assertEquals(59, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "threadsWaiting")));
     Assert.assertEquals(1052770304, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryMax")));
     Assert.assertEquals(43580400, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryUsed")));
     Assert.assertEquals(136314880, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryMax")));
     Assert.assertEquals(29602888, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryUsed")));
+    Assert.assertEquals(2, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/jobtracker", "jobs_submitted")));
+    Assert.assertEquals(1, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/jobtracker", "jobs_completed")));
+    Assert.assertEquals(1, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/jobtracker", "jobs_failed")));
 
     Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "gcCount")));
 
@@ -132,17 +139,26 @@ public class JMXPropertyProviderTest {
     properties.add(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryUsed"));
     properties.add(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryMax"));
     properties.add(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryUsed"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_exceptions_caught"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_failed_outputs"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_output_bytes"));
+    properties.add(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_success_outputs"));
+
     request = PropertyHelper.getReadRequest(properties);
 
     propertyProvider.populateResources(Collections.singleton(resource), request, null);
 
-    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal:50060"), streamProvider.getLastSpec());
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal", "50060"), streamProvider.getLastSpec());
 
-    Assert.assertEquals(6, PropertyHelper.getProperties(resource).size());
+    Assert.assertEquals(10, PropertyHelper.getProperties(resource).size());
     Assert.assertEquals(954466304, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryMax")));
     Assert.assertEquals(18330984, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryUsed")));
     Assert.assertEquals(136314880, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryMax")));
     Assert.assertEquals(24235104, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryUsed")));
+    Assert.assertEquals(0, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_exceptions_caught")));
+    Assert.assertEquals(0, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_failed_outputs")));
+    Assert.assertEquals(1841, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_output_bytes")));
+    Assert.assertEquals(1, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/mapred/shuffleOutput", "shuffle_success_outputs")));
 
     Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "gcCount")));
 
@@ -163,7 +179,7 @@ public class JMXPropertyProviderTest {
 
     propertyProvider.populateResources(Collections.singleton(resource), request, null);
 
-    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal:60010"), streamProvider.getLastSpec());
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-14-ee-b3.compute-1.internal", "60010"), streamProvider.getLastSpec());
 
     Assert.assertEquals(7, PropertyHelper.getProperties(resource).size());
     Assert.assertEquals(1069416448, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryMax")));
@@ -175,10 +191,70 @@ public class JMXPropertyProviderTest {
     Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "gcCount")));
   }
 
+  @Test
+  public void testGetResourcesWithUnknownPort() throws Exception {
+    TestStreamProvider  streamProvider = new TestStreamProvider();
+    TestJMXHostProvider hostProvider = new TestJMXHostProvider(true);
+
+    JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
+        PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent),
+        streamProvider,
+        hostProvider, PropertyHelper.getPropertyId("HostRoles", "cluster_name"), PropertyHelper.getPropertyId("HostRoles", "host_name"), PropertyHelper.getPropertyId("HostRoles", "component_name"));
+
+    // namenode
+    Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+
+    resource.setProperty(HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "domu-12-31-39-0e-34-e1.compute-1.internal");
+    resource.setProperty(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "NAMENODE");
+
+    // request with an empty set should get all supported properties
+    Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
+
+    Assert.assertEquals(1, propertyProvider.populateResources(Collections.singleton(resource), request, null).size());
+
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-0e-34-e1.compute-1.internal", "50070"), streamProvider.getLastSpec());
+
+    // see test/resources/hdfs_namenode_jmx.json for values
+    Assert.assertEquals(13670605,  resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/rpc", "ReceivedBytes")));
+    Assert.assertEquals(28,      resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/dfs/namenode", "CreateFileOps")));
+    Assert.assertEquals(1006632960, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryMax")));
+    Assert.assertEquals(473433016, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "HeapMemoryUsed")));
+    Assert.assertEquals(136314880, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryMax")));
+    Assert.assertEquals(23634400, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/jvm", "NonHeapMemoryUsed")));
+  }
+
   private static class TestJMXHostProvider implements JMXHostProvider {
+    private final boolean unknownPort;
+
+    private TestJMXHostProvider(boolean unknownPort) {
+      this.unknownPort = unknownPort;
+    }
+
     @Override
     public String getHostName(String clusterName, String componentName) {
       return null;
     }
+
+    @Override
+    public String getPort(String clusterName, String componentName) throws
+      SystemException {
+
+      if (unknownPort) {
+        return null;
+      }
+      if (componentName.equals("NAMENODE"))
+        return "50070";
+      else if (componentName.equals("DATANODE"))
+        return "50075";
+      else if (componentName.equals("JOBTRACKER"))
+        return "50030";
+      else if (componentName.equals("TASKTRACKER"))
+        return "50060";
+      else if (componentName.equals("HBASE_MASTER"))
+        return "60010";
+      else
+        return null;
+    }
+
   }
 }

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicateTest.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicateTest.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicateTest.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,70 @@
+/**
+ * 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.predicate;
+
+import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tests for CategoryIsEmptyPredicate.
+ */
+public class CategoryIsEmptyPredicateTest {
+
+  @Test
+  public void testApply() {
+    Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+    String categoryId = PropertyHelper.getPropertyId("category1", null);
+    Predicate predicate = new CategoryIsEmptyPredicate(categoryId);
+
+    Assert.assertTrue(predicate.evaluate(resource));
+
+    resource.addCategory(categoryId);
+    Assert.assertTrue(predicate.evaluate(resource));
+
+    String propertyId = PropertyHelper.getPropertyId("category1", "bar");
+    resource.setProperty(propertyId, "value1");
+    Assert.assertFalse(predicate.evaluate(resource));
+  }
+
+  @Test
+  public void testApplyWithMap() {
+    Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+    String propertyId = PropertyHelper.getPropertyId("category1", "mapProperty");
+    Predicate predicate = new CategoryIsEmptyPredicate(propertyId);
+
+    Assert.assertTrue(predicate.evaluate(resource));
+
+    Map<String, String> mapProperty = new HashMap<String, String>();
+
+    resource.setProperty(propertyId, mapProperty);
+    Assert.assertTrue(predicate.evaluate(resource));
+
+    mapProperty.put("foo", "bar");
+
+    Assert.assertFalse(predicate.evaluate(resource));
+  }
+
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryPredicateTest.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryPredicateTest.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/CategoryPredicateTest.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,60 @@
+package org.apache.ambari.server.controller.predicate;
+
+import junit.framework.Assert;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Test;
+
+/**
+ * Tests for bas category predicate.
+ */
+public class CategoryPredicateTest {
+  @Test
+  public void testAccept() {
+    String propertyId = PropertyHelper.getPropertyId("category1", "foo");
+    TestCategoryPredicate predicate = new TestCategoryPredicate(propertyId);
+
+    TestPredicateVisitor visitor = new TestPredicateVisitor();
+    predicate.accept(visitor);
+
+    Assert.assertSame(predicate, visitor.visitedCategoryPredicate);
+  }
+
+  public static class TestCategoryPredicate extends CategoryPredicate {
+
+    public TestCategoryPredicate(String propertyId) {
+      super(propertyId);
+    }
+
+    @Override
+    public boolean evaluate(Resource resource) {
+      return false;
+    }
+  }
+
+  public static class TestPredicateVisitor implements PredicateVisitor {
+
+    CategoryPredicate visitedCategoryPredicate = null;
+
+    @Override
+    public void acceptComparisonPredicate(ComparisonPredicate predicate) {
+    }
+
+    @Override
+    public void acceptArrayPredicate(ArrayPredicate predicate) {
+    }
+
+    @Override
+    public void acceptUnaryPredicate(UnaryPredicate predicate) {
+    }
+
+    @Override
+    public void acceptAlwaysPredicate(AlwaysPredicate predicate) {
+    }
+
+    @Override
+    public void acceptCategoryPredicate(CategoryPredicate predicate) {
+      visitedCategoryPredicate = predicate;
+    }
+  }
+}

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java Wed Mar 20 20:44:43 2013
@@ -22,7 +22,7 @@ import org.apache.ambari.server.controll
 import org.junit.Test;
 
 /**
- *
+ *  Tests for predicate visitors.
  */
 public class PredicateVisitorTest {
 
@@ -56,6 +56,17 @@ public class PredicateVisitorTest {
     Assert.assertNull(visitor.visitedComparisonPredicate);
     Assert.assertNull(visitor.visitedArrayPredicate);
     Assert.assertSame(notPredicate, visitor.visitedUnaryPredicate);
+
+
+    CategoryPredicate categoryPredicate = new CategoryIsEmptyPredicate("cat1");
+
+    visitor = new TestPredicateVisitor();
+    categoryPredicate.accept(visitor);
+
+    Assert.assertNull(visitor.visitedComparisonPredicate);
+    Assert.assertNull(visitor.visitedArrayPredicate);
+    Assert.assertNull(visitor.visitedUnaryPredicate);
+    Assert.assertSame(categoryPredicate, visitor.visitedCategoryPredicate);
   }
 
   public static class TestPredicateVisitor implements PredicateVisitor {
@@ -64,6 +75,7 @@ public class PredicateVisitorTest {
     ArrayPredicate visitedArrayPredicate = null;
     UnaryPredicate visitedUnaryPredicate = null;
     AlwaysPredicate visitedAlwaysPredicate = null;
+    CategoryPredicate visitedCategoryPredicate = null;
 
     @Override
     public void acceptComparisonPredicate(ComparisonPredicate predicate) {
@@ -84,6 +96,10 @@ public class PredicateVisitorTest {
     public void acceptAlwaysPredicate(AlwaysPredicate predicate) {
       visitedAlwaysPredicate = predicate;
     }
-  }
 
+    @Override
+    public void acceptCategoryPredicate(CategoryPredicate predicate) {
+      visitedCategoryPredicate = predicate;
+    }
+  }
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/PropertyHelperTest.java Wed Mar 20 20:44:43 2013
@@ -17,159 +17,28 @@
  */
 package org.apache.ambari.server.controller.utilities;
 
-//import org.apache.ambari.server.controller.spi.Resource;
-//import org.codehaus.jackson.map.ObjectMapper;
-//import org.codehaus.jackson.type.TypeReference;
-//import org.junit.Ignore;
-//import org.junit.Test;
-//
-//import java.util.Collections;
-//import java.util.Map;
-//import java.util.TreeMap;
+import org.junit.Assert;
+import org.junit.Test;
+
 
 /**
- *
+ * Property helper tests.
  */
 public class PropertyHelperTest {
 
-//  private static final String JMX_PROPERTIES_FILE = "jmx_properties.json";
-//  private static final String GANGLIA_PROPERTIES_FILE = "ganglia_properties.json";
-//
-//  @Ignore
-//  @Test
-//  public void testGetGPropertyIds() throws Exception {
-//    ObjectMapper mapper = new ObjectMapper();
-//
-//    Map<Resource.Type, Map<String, Map<String, PropertyHelper.Metric>>> gangliaMetrics =
-//        mapper.readValue(ClassLoader.getSystemResourceAsStream(GANGLIA_PROPERTIES_FILE),
-//            new TypeReference<Map<Resource.Type, Map<String, Map<String, PropertyHelper.Metric>>>>() {});
-//
-//    Map<Resource.Type, Map<String, Map<String, PropertyHelper.Metric>>> jmxMetrics =
-//        mapper.readValue(ClassLoader.getSystemResourceAsStream(JMX_PROPERTIES_FILE),
-//            new TypeReference<Map<Resource.Type, Map<String, Map<String, PropertyHelper.Metric>>>>() {});
-//
-//    System.out.println("{\n");
-//
-//    for (Resource.Type type : Resource.Type.values()) {
-//
-//      Map<String, Map<String, PropertyHelper.Metric>> gMap = gangliaMetrics.get(type);
-//
-//      if (gMap == null) {
-//        continue;
-//      }
-//
-//      System.out.println("  \"" + type + "\":{\n");
-//
-//      Map<String, Map<String, PropertyHelper.Metric>> jMap = jmxMetrics.get(type);
-//
-//
-//      for (Map.Entry<String, Map<String, PropertyHelper.Metric>> entry: gMap.entrySet()) {
-//        String componentName = entry.getKey();
-//
-//        System.out.println("    \"" + componentName + "\":{\n");
-//
-//
-//          Map<String, PropertyHelper.Metric> gMetricMap = entry.getValue();
-//        Map<String, PropertyHelper.Metric> jMetricMap = jMap == null ?
-//            Collections.<String, PropertyHelper.Metric>emptyMap() : jMap.get(componentName);
-//
-//        Map<String, PropertyHelper.Metric> newGMetricMap = new TreeMap<String, PropertyHelper.Metric>();
-//
-//        for (Map.Entry<String, PropertyHelper.Metric> metricEntry : gMetricMap.entrySet()) {
-//
-//          String metricName = metricEntry.getKey();
-//          PropertyHelper.Metric gMetric = metricEntry.getValue();
-//          PropertyHelper.Metric jMetric = jMetricMap == null ? null : jMetricMap.get(metricName);
-//
-//          boolean jmxPointInTime = jMetric != null && jMetric.isPointInTime();
-//
-//          newGMetricMap.put(metricName, new PropertyHelper.Metric(gMetric.getMetric(),
-//              jmxPointInTime ? false : gMetric.isPointInTime(),
-//              gMetric.isTemporal()));
-//        }
-//
-//        for (Map.Entry<String, PropertyHelper.Metric> metricEntry : newGMetricMap.entrySet()) {
-//          String metricName = metricEntry.getKey();
-//          PropertyHelper.Metric gMetric = metricEntry.getValue();
-//
-//
-//          System.out.println("      \"" + metricName + "\":{\n" +
-//              "        \"metric\" : \"" + gMetric.getMetric() + "\",\n" +
-//              "        \"pointInTime\" : " + gMetric.isPointInTime() + ",\n" +
-//              "        \"temporal\" : " + gMetric.isTemporal() + "\n" +
-//              "      },");
-//
-//        }
-//
-//        System.out.println("    },\n");
-//      }
-//      System.out.println("  },\n");
-//    }
-//    System.out.println("},\n");
-//  }
-//
-//  @Ignore
-//  @Test
-//  public void testGetJPropertyIds() throws Exception {
-//    ObjectMapper mapper = new ObjectMapper();
-//
-//
-//    Map<Resource.Type, Map<String, Map<String, PropertyHelper.Metric>>> jmxMetrics =
-//        mapper.readValue(ClassLoader.getSystemResourceAsStream(JMX_PROPERTIES_FILE),
-//            new TypeReference<Map<Resource.Type, Map<String, Map<String, PropertyHelper.Metric>>>>() {});
-//
-//    System.out.println("{\n");
-//
-//    for (Resource.Type type : Resource.Type.values()) {
-//
-//      Map<String, Map<String, PropertyHelper.Metric>> jMap = jmxMetrics.get(type);
-//
-//      if (jMap == null) {
-//        continue;
-//      }
-//
-//      System.out.println("  \"" + type + "\":{\n");
-//
-//
-//      for (Map.Entry<String, Map<String, PropertyHelper.Metric>> entry: jMap.entrySet()) {
-//        String componentName = entry.getKey();
-//
-//        System.out.println("    \"" + componentName + "\":{\n");
-//
-//
-//        Map<String, PropertyHelper.Metric> jMetricMap = entry.getValue();
-//
-//        Map<String, PropertyHelper.Metric> newJMetricMap = new TreeMap<String, PropertyHelper.Metric>();
-//
-//        for (Map.Entry<String, PropertyHelper.Metric> metricEntry : jMetricMap.entrySet()) {
-//
-//          String metricName = metricEntry.getKey();
-//          PropertyHelper.Metric jMetric = metricEntry.getValue();
-//
-//
-//          newJMetricMap.put(metricName, new PropertyHelper.Metric(jMetric.getMetric(),
-//              jMetric.isPointInTime(),
-//              jMetric.isTemporal()));
-//        }
-//
-//        for (Map.Entry<String, PropertyHelper.Metric> metricEntry : newJMetricMap.entrySet()) {
-//          String metricName = metricEntry.getKey();
-//          PropertyHelper.Metric jMetric = metricEntry.getValue();
-//
-//
-//          System.out.println("      \"" + metricName + "\":{\n" +
-//              "        \"metric\" : \"" + jMetric.getMetric() + "\",\n" +
-//              "        \"pointInTime\" : " + jMetric.isPointInTime() + ",\n" +
-//              "        \"temporal\" : " + jMetric.isTemporal() + "\n" +
-//              "      },");
-//
-//        }
-//
-//        System.out.println("    },\n");
-//      }
-//      System.out.println("  },\n");
-//    }
-//    System.out.println("},\n");
-//  }
+  @Test
+  public void testGetPropertyId() {
+    Assert.assertEquals("foo", PropertyHelper.getPropertyId("", "foo"));
+    Assert.assertEquals("foo", PropertyHelper.getPropertyId(null, "foo"));
+    Assert.assertEquals("foo", PropertyHelper.getPropertyId(null, "foo/"));
+
+    Assert.assertEquals("cat", PropertyHelper.getPropertyId("cat", ""));
+    Assert.assertEquals("cat", PropertyHelper.getPropertyId("cat", null));
+    Assert.assertEquals("cat", PropertyHelper.getPropertyId("cat/", null));
+
+    Assert.assertEquals("cat/foo", PropertyHelper.getPropertyId("cat", "foo"));
+    Assert.assertEquals("cat/sub/foo", PropertyHelper.getPropertyId("cat/sub", "foo"));
+    Assert.assertEquals("cat/sub/foo", PropertyHelper.getPropertyId("cat/sub", "foo/"));
+  }
 }
 

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/test/resources/mapreduce_jobtracker_jmx.json Wed Mar 20 20:44:43 2013
@@ -377,7 +377,7 @@
     "reduces_launched" : 1,
     "reduces_completed" : 1,
     "reduces_failed" : 0,
-    "jobs_submitted" : 1,
+    "jobs_submitted" : 2,
     "jobs_completed" : 1,
     "waiting_maps" : 0,
     "waiting_reduces" : 0,
@@ -385,7 +385,7 @@
     "reserved_reduce_slots" : 0,
     "occupied_map_slots" : 0,
     "occupied_reduce_slots" : 0,
-    "jobs_failed" : 0,
+    "jobs_failed" : 1,
     "jobs_killed" : 0,
     "jobs_preparing" : 0,
     "jobs_running" : 0,
@@ -894,4 +894,4 @@
     "ImplementationVersion" : "1.6.0_31-b04",
     "ImplementationVendor" : "Sun Microsystems"
   } ]
-}
\ No newline at end of file
+}

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/app.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/app.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/app.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/app.js Wed Mar 20 20:44:43 2013
@@ -31,6 +31,12 @@ module.exports = Em.Application.create({
   isAdmin : function(){
     var user = this.db && this.db.getUser();
     return user ? user.admin : false;
+  }.property(),
+  /**
+   * return url prefix with number value of version of HDP stack
+   */
+  stackVersionURL:function(){
+    return '/stacks/HDP/version/' + App.defaultStackVersion.replace(/HDP-/g, '');
   }.property()
 });
 

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/application.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/application.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/application.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/application.js Wed Mar 20 20:44:43 2013
@@ -22,13 +22,17 @@ var App = require('app');
 App.ApplicationController = Em.Controller.extend({
 
   name: 'applicationController',
+
   clusterName: function () {
-    var name = App.router.get('clusterController.clusterName');
-    if (name) {
-      return name.capitalize();
-    }
-    return Em.I18n.t('installer.header');
+    return (App.router.get('clusterController.clusterName') || 'My Cluster').capitalize();
   }.property('App.router.clusterController.clusterName'),
+
+  clusterDisplayName: function () {
+    var name = this.get('clusterName');
+    var displayName = name.length > 13 ? name.substr(0, 10) + "..." : name;
+    return displayName.capitalize();
+  }.property('clusterName'),
+
   isClusterDataLoaded: function() {
     return App.router.get('clusterController.isLoaded');
   }.property('App.router.clusterController.isLoaded'),

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/cluster_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/cluster_controller.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/cluster_controller.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/cluster_controller.js Wed Mar 20 20:44:43 2013
@@ -152,7 +152,7 @@ App.ClusterController = Em.Controller.ex
       var nagiosSvc = svcs.findProperty("serviceName", "NAGIOS");
       return nagiosSvc != null;
     }
-  }.property('App.router.updateController.isUpdated'),
+  }.property('App.router.updateController.isUpdated', 'dataLoadList.services'),
 
   /**
    * Sorted list of alerts.
@@ -175,106 +175,85 @@ App.ClusterController = Em.Controller.ex
     });
     this.set('alerts', sortedArray);
   },
+  
+  /**
+   * Determination of Nagios presence is known only after App.Service is
+   * loaded from server. When that is done, no one tells alerts to load,
+   * due to which alerts are not loaded & shown till the next polling cycle.
+   * This method immediately loads alerts once Nagios presence is known.
+   */
+  isNagiosInstalledListener: function () {
+    var self = this;
+    self.loadAlerts(function () {
+      self.updateLoadStatus('alerts');
+    });
+  }.observes('isNagiosInstalled'),
 
   /**
-   * This method automatically loads alerts when Nagios URL
-   * changes. Once done it will trigger dataLoadList.alerts
-   * property, which will trigger the alerts property.
+   * Load alerts from server
+   * @param callback Slave function, should be called to fire delayed update.
+   * Look at <code>App.updater.run</code> for more information.
+   * Also used to set <code>dataLoadList.alerts</code> status during app loading
    */
-  loadAlerts:function () {
-    if(App.router.get('updateController.isUpdated')){
-      return;
-    }
-    var nagiosUrl = this.get('nagiosUrl');
-    if (nagiosUrl) {
-      var lastSlash = nagiosUrl.lastIndexOf('/');
-      if (lastSlash > -1) {
-        nagiosUrl = nagiosUrl.substring(0, lastSlash);
-      }
-      var dataUrl = this.getUrl('/data/alerts/alerts.json', '/host_components?HostRoles/component_name=NAGIOS_SERVER&fields=HostRoles/nagios_alerts');
+  loadAlerts:function (callback) {
+    if (this.get('isNagiosInstalled')) {
+      var dataUrl = this.getUrl('/data/alerts/alerts.json', '/host_components?fields=HostRoles/nagios_alerts&HostRoles/component_name=NAGIOS_SERVER');
+      var self = this;
       var ajaxOptions = {
         dataType:"json",
-        context:this,
-        complete:function (jqXHR, textStatus) {
-          this.updateLoadStatus('alerts');
-          this.updateAlerts();
+        complete:function () {
+          self.updateAlerts();
+          callback();
         },
         error: function(jqXHR, testStatus, error) {
-          // this.showMessage(Em.I18n.t('nagios.alerts.unavailable'));
           console.log('Nagios $.ajax() response:', error);
         }
       };
       App.HttpClient.get(dataUrl, App.alertsMapper, ajaxOptions);
     } else {
-      this.updateLoadStatus('alerts');
       console.log("No Nagios URL provided.")
+      callback();
     }
-  }.observes('nagiosUrl'),
+  },
 
   /**
-   * Show message in UI
+   * Send request to server to load components updated statuses
+   * @param callback Slave function, should be called to fire delayed update.
+   * Look at <code>App.updater.run</code> for more information
+   * @return {Boolean} Whether we have errors
    */
-  showMessage: function(message){
-    App.ModalPopup.show({
-      header: 'Message',
-      body: message,
-      onPrimary: function() {
-        this.hide();
-      },
-      secondary : null
-    });
-  },
-
-  statusTimeoutId: null,
-
-  loadUpdatedStatusDelayed: function(delay){
-    delay = delay || App.componentsUpdateInterval;
-    var self = this;
-
-    this.set('statusTimeoutId',
-      setTimeout(function(){
-        self.loadUpdatedStatus();
-      }, delay)
-    );
-  },
-
-  loadUpdatedStatus: function(){
-
-    var timeoutId = this.get('statusTimeoutId');
-    if(timeoutId){
-      clearTimeout(timeoutId);
-      this.set('statusTimeoutId', null);
-    }
-
-    if(!this.get('isWorking')){
-      return false;
-    }
+  loadUpdatedStatus: function(callback){
 
     if(!this.get('clusterName')){
-      this.loadUpdatedStatusDelayed(this.get('componentsUpdateInterval')/2, 'error:clusterName');
-      return;
+      callback();
+      return false;
     }
     
-    var servicesUrl = this.getUrl('/data/dashboard/services.json', '/services?fields=components/ServiceComponentInfo,components/host_components,components/host_components/HostRoles');
+    var servicesUrl = this.getUrl('/data/dashboard/services.json', '/services?fields=ServiceInfo,components/host_components/HostRoles/desired_state,components/host_components/HostRoles/state');
 
-    var self = this;
     App.HttpClient.get(servicesUrl, App.statusMapper, {
-      complete:function (jqXHR, textStatus) {
-        //console.log('Cluster Controller: Updated components statuses successfully!!!')
-        self.loadUpdatedStatusDelayed();
-      }
-    }, function(){
-      self.loadUpdatedStatusDelayed(null, 'error:response error');
+      complete: callback
     });
-
+    return true;
   },
-  startLoadUpdatedStatus: function(){
-    var self = this;
-    this.set('isWorking', true);
+
+  loadUpdatedStatusDelayed: function(delay){
     setTimeout(function(){
-      self.loadUpdatedStatus();
-    }, App.componentsUpdateInterval*2);
+      App.updater.immediateRun('loadUpdatedStatus');
+    }, delay);
   },
+
+  /**
+   * Start polling, when <code>isWorking</code> become true
+   */
+  startPolling: function(){
+    if(!this.get('isWorking')){
+      return false;
+    }
+    App.updater.run(this, 'loadUpdatedStatus', 'isWorking'); //update will not run it immediately
+    App.updater.run(this, 'loadAlerts', 'isWorking'); //update will not run it immediately
+    return true;
+  }.observes('isWorking'),
   /**
    *
    *  load all data and update load status
@@ -290,7 +269,7 @@ App.ClusterController = Em.Controller.ex
     }
 
     var clusterUrl = this.getUrl('/data/clusters/cluster.json', '?fields=Clusters');
-    var hostsUrl = this.getUrl('/data/hosts/hosts.json', '/hosts?fields=Hosts,host_components,metrics/cpu,metrics/disk,metrics/load,metrics/memory');
+    var hostsUrl = this.getUrl('/data/hosts/hosts.json', '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/disk_info,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one');
     var usersUrl = App.testMode ? '/data/users/users.json' : App.apiPrefix + '/users/?fields=*';
     var racksUrl = "/data/racks/racks.json";
 
@@ -330,6 +309,10 @@ App.ClusterController = Em.Controller.ex
       self.updateLoadStatus('services');
     }, true);
 
+    this.loadAlerts(function(){
+      self.updateLoadStatus('alerts');
+    });
+
   },
 
   clusterName:function () {

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/update_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/update_controller.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/update_controller.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/global/update_controller.js Wed Mar 20 20:44:43 2013
@@ -32,34 +32,26 @@ App.UpdateController = Em.Controller.ext
     return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url;
   },
 
+  /**
+   * Start polling, when <code>isWorking</code> become true
+   */
   updateAll:function(){
-    var timeIntervalId = this.get('timeIntervalId');
-    var self = this;
-    if(this.get('isWorking')){
-      if(timeIntervalId) return;
-      this.set('timeIntervalId', setInterval(function(){
-        self.updateAllWrapper();
-      }, App.contentUpdateInterval));
-    } else {
-      clearInterval(timeIntervalId);
-      this.set('timeIntervalId', null);
+    if(this.get('isWorking')) {
+      App.updater.run(this, 'updateHost', 'isWorking');
+      App.updater.run(this, 'updateServiceMetric', 'isWorking');
+      App.updater.run(this, 'graphsUpdate', 'isWorking');
     }
   }.observes('isWorking'),
 
-  updateAllWrapper: function() {
-    this.updateHost();
-    this.updateServiceMetric();
-    this.graphsUpdate();
-  },
-
-  updateHost:function(){
-      var hostsUrl = this.getUrl('/data/hosts/hosts.json', '/hosts?fields=Hosts,host_components,metrics/cpu,metrics/disk,metrics/load,metrics/memory');
+  updateHost:function(callback) {
+    var self = this;
+      var hostsUrl = this.getUrl('/data/hosts/hosts.json', '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/disk_info,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one');
       App.HttpClient.get(hostsUrl, App.hostsMapper, {
-        complete:function (jqXHR, textStatus) {}
+        complete: callback
       });
   },
   graphs: [],
-  graphsUpdate: function () {
+  graphsUpdate: function (callback) {
       var existedGraphs = [];
       this.get('graphs').forEach(function (_graph) {
         var view = Em.View.views[_graph.id];
@@ -73,12 +65,14 @@ App.UpdateController = Em.Controller.ext
           }
         }
       });
-      this.set('graphs', existedGraphs);
+    callback();
+    this.set('graphs', existedGraphs);
   },
-  
+
   /**
    * Updates the services information. 
-   * 
+   *
+   * @param callback
    * @param isInitialLoad  If true, only basic information is loaded.
    */
   updateServiceMetric: function (callback, isInitialLoad) {
@@ -90,9 +84,9 @@ App.UpdateController = Em.Controller.ext
     var callback = callback || function (jqXHR, textStatus) {
       self.set('isUpdated', true);
     };
-    App.HttpClient.get(servicesUrl, App.servicesMapper, {
-      complete: callback
-    });
+      App.HttpClient.get(servicesUrl, App.servicesMapper, {
+        complete: callback
+      });
   }
 
 

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/installer.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/installer.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/installer.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/installer.js Wed Mar 20 20:44:43 2013
@@ -404,7 +404,7 @@ App.InstallerController = App.WizardCont
 
   loadAdvancedConfig: function (serviceName) {
     var self = this;
-    var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' + serviceName + '.json' : App.apiPrefix + '/stacks/HDP/version/1.2.0/services/' + serviceName; // TODO: get this url from the stack selected by the user in Install Options page
+    var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' + serviceName + '.json' : App.apiPrefix + App.get('stackVersionURL') + '/services/' + serviceName; // TODO: get this url from the stack selected by the user in Install Options page
     var method = 'GET';
     var serviceComponents;
     $.ajax({

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main.js Wed Mar 20 20:44:43 2013
@@ -21,23 +21,6 @@ require('models/background_operation');
 
 App.MainController = Em.Controller.extend({
   name: 'mainController',
-  
-  clusterName: function () {
-    var name = App.router.get('clusterController.clusterName');
-    if (name) {
-      return name;
-    }
-    return 'My Cluster';
-  }.property('App.router.clusterController.clusterName'),
-  
-  clusterDisplayName: function () {
-    var name = App.router.get('clusterController.clusterName');
-    if (name) {
-      var displayName = name.length > 13 ? name.substr(0, 10) + "..." : name;
-      return displayName.capitalize();
-    }
-    return 'My Cluster';
-  }.property('App.router.clusterController.clusterName'),
 
   updateTitle: function(){
     var name = App.router.get('clusterController.clusterName');
@@ -63,11 +46,25 @@ App.MainController = Em.Controller.exten
   startPolling: function(){
     App.router.get('updateController').set('isWorking', true);
     App.router.get('backgroundOperationsController').set('isWorking', true);
-    App.router.get('clusterController').startLoadUpdatedStatus();
+    App.router.get('clusterController').set('isWorking', true);
   },
   stopPolling: function(){
     App.router.get('updateController').set('isWorking', false);
     App.router.get('backgroundOperationsController').set('isWorking', false);
     App.router.get('clusterController').set('isWorking', false);
-  }
+  },
+
+  reloadTimeOut: null,
+
+  pageReload: function () {
+
+    clearTimeout(this.get("reloadTimeOut"));
+
+    this.set('reloadTimeOut',
+        setTimeout(function () {
+          location.reload()
+        }, App.pageReloadTime)
+    );
+  }.observes("App.router.location.lastSetURL")
+
 })
\ No newline at end of file

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/authentication.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/authentication.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/authentication.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/authentication.js Wed Mar 20 20:44:43 2013
@@ -20,6 +20,10 @@ var App = require('app');
 
 App.MainAdminAuthenticationController = Em.Controller.extend({
   name:'mainAdminAuthenticationController',
+  /**
+   * save user form after editing
+   * @param event
+   */
   save:function (event) {
     var form = event.context;
     if (form.isValid()) {

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/user.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/user.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/user.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/admin/user.js Wed Mar 20 20:44:43 2013
@@ -20,6 +20,11 @@ var App = require('app');
 
 App.MainAdminUserController = Em.Controller.extend({
   name:'mainAdminUserController',
+
+  /**
+   * send request to the server to delete user if selected user is not current user
+   * @param event
+   */
   deleteRecord:function (event) {
     var self = this;
     if (event.context.get('userName') == App.get('router').getLoginName()) {
@@ -65,6 +70,14 @@ App.MainAdminUserController = Em.Control
       }
     });
   },
+
+  /**
+   * send request to the server and call callback function with true if request was success or false if request was failed
+   * @param url
+   * @param method
+   * @param postData
+   * @param callback
+   */
   sendCommandToServer : function(url, method, postData, callback){
     var url =  (App.testMode) ?
         '/data/wizard/deploy/poll_1.json' : //content is the same as ours

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/apps_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/apps_controller.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/apps_controller.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/apps_controller.js Wed Mar 20 20:44:43 2013
@@ -72,7 +72,6 @@ App.MainAppsController = Em.ArrayControl
    */
   iTotalDisplayRecordsObserver:function(){
     if(this.get("filterObject.allFilterActivated")){
-      //this.set("paginationObject.filteredDisplayRecords","-10");
       this.set("filterObject.allFilterActivated", false);
     }else{
       this.set("filterObject.filteredDisplayRecords",this.get("paginationObject.iTotalDisplayRecords"));
@@ -202,8 +201,8 @@ App.MainAppsController = Em.ArrayControl
         tmp.max = Math.floor((parseFloat(compareValue)+0.01)*1000);
         break;
         default:
-          tmp.min = Math.max(1024,Math.ceil((compareValue-0.05)*1024));
-          tmp.max = Math.min(1048575,Math.floor((compareValue+0.05)*1024));
+          tmp.min = Math.ceil((parseFloat(compareValue)-0.01)*1000);
+          tmp.max = Math.floor((parseFloat(compareValue)+0.01)*1000);
       }
       switch (compareChar) {
         case '<':
@@ -310,66 +309,28 @@ App.MainAppsController = Em.ArrayControl
       }
       return tmp;
     },
+
+    /**
+     * Create link for server request
+     * @return {String}
+     */
     createAppLink:function(){
       var link = "/jobhistory/datatable?";
 
-      if(this.sSearch_0){
-        link +=  "sSearch_0=" + this.sSearch_0 + "&";
-      }
-      if(this.sSearch_1){
-        link +=  "sSearch_1=" + this.sSearch_1 + "&";
-      }
-      if(this.sSearch_2 && this.sSearch_2 != "Any"){
-        link +=  "sSearch_2=" + this.sSearch_2 + "&";
-      }
-      if(this.sSearch_3){
-        link +=  "sSearch_3=" + this.sSearch_3 + "&";
-      }
-      if(this.minJobs){
-        link +=  "minJobs=" + this.minJobs + "&";
-      }
-      if(this.maxJobs){
-        link +=  "maxJobs=" + this.maxJobs + "&";
-      }
-      if(this.minInputBytes){
-        link +=  "minInputBytes=" + this.minInputBytes + "&";
-      }
-      if(this.maxInputBytes){
-        link +=  "maxInputBytes=" + this.maxInputBytes + "&";
-      }
-      if(this.minOutputBytes){
-        link +=  "minOutputBytes=" + this.minOutputBytes + "&";
-      }
-      if(this.maxOutputBytes){
-        link +=  "maxOutputBytes=" + this.maxOutputBytes + "&";
-      }
-      if(this.minDuration){
-        link +=  "minDuration=" + this.minDuration + "&";
-      }
-      if(this.maxDuration){
-        link +=  "maxDuration=" + this.maxDuration + "&";
-      }
-      if(this.minStartTime){
-        link +=  "minStartTime=" + this.minStartTime + "&";
-      }
-      if(this.maxStartTime){
-        link +=  "maxStartTime=" + this.maxStartTime + "&";
-      }
-      if(this.sSearch){
-        link +=  "sSearch=" + this.sSearch + "&";
-      }
-      if(this.iDisplayLength){
-        link +=  "iDisplayLength=" + this.iDisplayLength + "&";
-      }
-      if(this.iDisplayStart){
-        link +=  "iDisplayStart=" + this.iDisplayStart + "&";
-      }
-      if(this.iSortCol_0){
-        link +=  "iSortCol_0=" + this.iSortCol_0 + "&";
-      }
-      if(this.sSortDir_0){
-        link +=  "sSortDir_0=" + this.sSortDir_0 + "&";
-      }
+
+      var arr = [
+        "sSearch_0", "sSearch_1", "sSearch_2", "sSearch_3", "minJobs",
+        "maxJobs", "minInputBytes", "maxInputBytes", "minOutputBytes",
+        "maxOutputBytes", "minDuration", "maxDuration", "minStartTime",
+        "maxStartTime", "sSearch", "iDisplayLength", "iDisplayStart",
+        "iSortCol_0", "sSortDir_0"
+      ];
+
+      for (var n=0; n<arr.length;n++) {
+        if(this.get(arr[n])){
+          link += arr[n] + "=" + this.get(arr[n]) + "&";
+        }
+      };
 
       link = link.slice(0,link.length-1);
 
@@ -386,6 +347,25 @@ App.MainAppsController = Em.ArrayControl
     }
   }),
 
+  /**
+   * reset all filters in table
+   *
+   */
+  clearFilters: function () {
+    var obj=this.get("filterObject");
+    obj.set("sSearch_0","");
+    obj.set("sSearch_1","");
+    obj.set("sSearch_2","");
+    obj.set("sSearch_3","");
+    obj.set("runType","Any");
+    obj.set("jobs","");
+    obj.set("input","");
+    obj.set("output","");
+    obj.set("duration","");
+    obj.set("runDate","Any");
+  },
+
+
   runUrl : "/jobhistory/datatable",
   runTimeout : null,
 

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host.js Wed Mar 20 20:44:43 2013
@@ -25,6 +25,10 @@ App.MainHostController = Em.ArrayControl
   content: App.Host.find(),
   comeWithFilter: false,
 
+  alerts: function () {
+    return App.router.get('clusterController.alerts').filterProperty('isOk', false).filterProperty('ignoredForHosts', false);
+  }.property('App.router.clusterController.alerts.length'),
+
   /**
    * Components which will be shown in component filter
    */
@@ -47,6 +51,28 @@ App.MainHostController = Em.ArrayControl
   }.property('componentsForFilter'),
 
   /**
+   * Is true if alets filter is active
+   */
+  filteredByAlerts:false,
+
+  /**
+   * Is true if Hosts page was opened by clicking on alerts count badge
+   */
+  comeWithAlertsFilter: false,
+
+  /**
+   * Enable or disable filtering by alets
+   */
+  filterByAlerts: function () {
+    if (App.router.get('currentState.name') == 'index') {
+      this.set('filteredByAlerts', !this.get('filteredByAlerts'));
+    } else {
+      App.router.transitionTo('hosts.index');
+      this.set('comeWithAlertsFilter', true);
+    }
+  },
+
+  /**
    * Filter hosts by componentName of <code>component</code>
    * @param component App.HostComponent
    */
@@ -59,6 +85,10 @@ App.MainHostController = Em.ArrayControl
     this.set('comeWithFilter', true);
   },
 
+  /**
+   * On click callback for decommission button
+   * @param event
+   */
   decommissionButtonPopup:function () {
     var self = this;
     App.ModalPopup.show({
@@ -75,6 +105,11 @@ App.MainHostController = Em.ArrayControl
       }
     });
   },
+
+  /**
+   * On click callback for delete button
+   * @param event
+   */
   deleteButtonPopup:function () {
     var self = this;
     App.ModalPopup.show({
@@ -91,6 +126,42 @@ App.MainHostController = Em.ArrayControl
       }
     });
   },
+
+  showAlertsPopup: function (event) {
+    var host = event.context;
+    App.ModalPopup.show({
+      header: this.t('services.alerts.headingOfList'),
+      bodyClass: Ember.View.extend({
+        hostAlerts: function () {
+          var allAlerts = App.router.get('clusterController.alerts').filterProperty('ignoredForHosts', false);
+          if (host) {
+            return allAlerts.filterProperty('hostName', host.get('hostName'));
+          }
+          return 0;
+        }.property('App.router.clusterController.alerts'),
+
+        closePopup: function () {
+          this.get('parentView').hide();
+        },
+
+        templateName: require('templates/main/host/alerts_popup')
+      }),
+      primary: 'Close',
+      onPrimary: function() {
+        this.hide();
+      },
+      secondary : null,
+      didInsertElement: function () {
+        this.$().find('.modal-footer').addClass('align-center');
+        this.$().children('.modal').css({'margin-top': '-350px'});
+      }
+    });
+    event.stopPropagation();
+  },
+
+  /**
+   * remove selected hosts
+   */
   removeHosts:function () {
     var hosts = this.get('content');
     var selectedHosts = hosts.filterProperty('isChecked', true);
@@ -100,6 +171,10 @@ App.MainHostController = Em.ArrayControl
     this.get('fullContent').removeObjects(selectedHosts);
   },
 
+  /**
+   * remove hosts with id equal host_id
+   * @param host_id
+   */
   checkRemoved:function (host_id) {
     var hosts = this.get('content');
     var selectedHosts = hosts.filterProperty('id', host_id);

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/add_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/add_controller.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/add_controller.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/add_controller.js Wed Mar 20 20:44:43 2013
@@ -54,13 +54,26 @@ App.AddHostController = App.WizardContro
     isWizard: true
   }),
 
+  /**
+   * return new object extended from clusterStatusTemplate
+   * @return Object
+   */
   getCluster: function(){
     return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
   },
+
+  /**
+   * return new object extended from installOptionsTemplate
+   * @return Object
+   */
   getInstallOptions: function(){
     return jQuery.extend({}, this.get('installOptionsTemplate'));
   },
 
+  /**
+   * return empty hosts array
+   * @return Array
+   */
   getHosts: function(){
     return [];
   },
@@ -121,9 +134,12 @@ App.AddHostController = App.WizardContro
     console.log('addHostController:saveInstalledHosts: save hosts ', hostInfo);
   },
 
+  /**
+   * Load services data from server.
+   */
   loadServicesFromServer: function() {
     var displayOrderConfig = require('data/services');
-    var apiUrl = '/stacks/HDP/version/1.2.0';
+    var apiUrl = App.get('stackVersionURL');
     var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
     //
     apiService.forEach(function(item, index){
@@ -248,6 +264,7 @@ App.AddHostController = App.WizardContro
     console.log('addHostController.slaveComponentHosts: saved hosts', slaveComponentHosts);
     this.set('content.slaveComponentHosts', slaveComponentHosts);
   },
+
   /**
    * return slaveComponents bound to hosts
    * @return {Array}
@@ -317,6 +334,7 @@ App.AddHostController = App.WizardContro
 
     return result;
   },
+
   /**
    * Load master component hosts data for using in required step controllers
    */
@@ -399,6 +417,10 @@ App.AddHostController = App.WizardContro
     this.set('content.clients', clients);
     console.log("AddHostController.loadClients: loaded list ", clients);
   },
+
+  /**
+   * return true if cluster data is loaded and false otherwise
+   */
   dataLoading: function () {
     var dfd = $.Deferred();
     this.connectOutlet('loading');
@@ -410,6 +432,7 @@ App.AddHostController = App.WizardContro
     }, 50);
     return dfd.promise();
   },
+
   /**
    * Generate clients list for selected services and save it to model
    * @param stepController step4WizardController
@@ -462,16 +485,19 @@ App.AddHostController = App.WizardContro
     }
   },
 
+  /**
+   * load advanced configs for all selected services
+   */
   loadAdvancedConfigs: function () {
     this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName').forEach(function (_serviceName) {
       this.loadAdvancedConfig(_serviceName);
     }, this);
   },
+
   /**
-   * Generate serviceProperties save it to localdata
-   * called form stepController step6WizardController
+   * load advanced config for one service
+   * @param serviceName
    */
-
   loadAdvancedConfig: function (serviceName) {
     var self = this;
     var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' + serviceName + '.json' : App.apiPrefix + '/stacks/HDP/version/1.2.0/services/' + serviceName; // TODO: get this url from the stack selected by the user in Install Options page

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/details.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/details.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/details.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/host/details.js Wed Mar 20 20:44:43 2013
@@ -23,14 +23,26 @@ App.MainHostDetailsController = Em.Contr
   content: null,
   isFromHosts: false,
 
+  /**
+   * open dashboard page
+   */
   routeHome: function () {
     App.router.transitionTo('main.dashboard');
   },
+
+  /**
+   * open summary page of the selected service
+   * @param event
+   */
   routeToService: function(event){
     var service = event.context;
     App.router.transitionTo('main.services.service.summary',service);
   },
 
+  /**
+   * set new value to isFromHosts property
+   * @param isFromHosts new value
+   */
   setBack: function(isFromHosts){
     this.set('isFromHosts', isFromHosts);
   },
@@ -72,6 +84,10 @@ App.MainHostDetailsController = Em.Contr
     });
   },
 
+  /**
+   * send command to server to start selected host component
+   * @param event
+   */
   startComponent: function (event) {
     var self = this;
     App.ModalPopup.show({
@@ -124,6 +140,11 @@ App.MainHostDetailsController = Em.Contr
       }
     });
   },
+
+  /**
+   * send command to server to stop selected host component
+   * @param event
+   */
   stopComponent: function (event) {
     var self = this;
     App.ModalPopup.show({
@@ -176,6 +197,10 @@ App.MainHostDetailsController = Em.Contr
     });
   },
 
+  /**
+   * send command to server to run decommission on DATANODE
+   * @param event
+   */
   decommission: function(event){
     var self = this;
     var decommissionHostNames = this.get('view.decommissionDataNodeHostNames');
@@ -280,6 +305,10 @@ App.MainHostDetailsController = Em.Contr
     jQuery.ajax(configsAjax);
   },
 
+  /**
+   * send command to server to run recommission on DATANODE
+   * @param event
+   */
   recommission: function(event){
     var self = this;
     var decommissionHostNames = this.get('view.decommissionDataNodeHostNames');
@@ -354,6 +383,9 @@ App.MainHostDetailsController = Em.Contr
     })
   },
 
+  /**
+   * show confirmation popup to delete host
+   */
   deleteButtonPopup: function() {
     var self = this;
     App.ModalPopup.show({
@@ -370,6 +402,10 @@ App.MainHostDetailsController = Em.Contr
       }
     });
   },
+
+  /**
+   * remove host and open hosts page
+   */
   removeHost: function () {
     App.router.get('mainHostController').checkRemoved(this.get('content.id'));
     App.router.transitionTo('hosts');

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/add_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/add_controller.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/add_controller.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/add_controller.js Wed Mar 20 20:44:43 2013
@@ -54,6 +54,10 @@ App.AddServiceController = App.WizardCon
     isWizard: true
   }),
 
+  /**
+   * return new object extended from clusterStatusTemplate
+   * @return Object
+   */
   getCluster: function(){
     return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
   },
@@ -106,9 +110,12 @@ App.AddServiceController = App.WizardCon
     console.log('AddServiceController:saveInstalledHosts: save hosts ', hostInfo);
   },
 
+  /**
+   * Load services data from server.
+   */
   loadServicesFromServer: function() {
     var displayOrderConfig = require('data/services');
-    var apiUrl = '/stacks/HDP/version/1.2.0';
+    var apiUrl = App.get('stackVersionURL');
     var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
     //
     apiService.forEach(function(item, index){
@@ -279,6 +286,7 @@ App.AddServiceController = App.WizardCon
     console.log('addServiceController.slaveComponentHosts: saved hosts', slaveComponentHosts);
     this.set('content.slaveComponentHosts', slaveComponentHosts);
   },
+
   /**
    * return slaveComponents bound to hosts
    * @return {Array}
@@ -354,6 +362,7 @@ App.AddServiceController = App.WizardCon
 
     return result;
   },
+
   /**
    * Load master component hosts data for using in required step controllers
    */
@@ -436,6 +445,10 @@ App.AddServiceController = App.WizardCon
     this.set('content.clients', clients);
     console.log("AddServiceController.loadClients: loaded list ", clients);
   },
+
+  /**
+   * return true if cluster data is loaded and false otherwise
+   */
   dataLoading: function(){
     var dfd = $.Deferred();
     this.connectOutlet('loading');
@@ -451,6 +464,7 @@ App.AddServiceController = App.WizardCon
     }
     return dfd.promise();
   },
+
   /**
    * Generate clients list for selected services and save it to model
    * @param stepController step4WizardController
@@ -500,19 +514,22 @@ App.AddServiceController = App.WizardCon
     }
   },
 
+  /**
+   * load advanced configs for all selected services
+   */
   loadAdvancedConfigs: function () {
     App.db.getSelectedServiceNames().forEach(function (_serviceName) {
       this.loadAdvancedConfig(_serviceName);
     }, this);
   },
+
   /**
-   * Generate serviceProperties save it to localdata
-   * called form stepController step6WizardController
+   * load advanced config for one service
+   * @param serviceName
    */
-
   loadAdvancedConfig: function (serviceName) {
     var self = this;
-    var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' + serviceName + '.json' : App.apiPrefix + '/stacks/HDP/version/1.2.0/services/' + serviceName; // TODO: get this url from the stack selected by the user in Install Options page
+    var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' + serviceName + '.json' : App.apiPrefix + App.get('stackVersionURL') +'/services/' + serviceName; // TODO: get this url from the stack selected by the user in Install Options page
     var method = 'GET';
     $.ajax({
       type: method,

Modified: incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/info/configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/info/configs.js?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/info/configs.js (original)
+++ incubator/ambari/branches/branch-1.2/ambari-web/app/controllers/main/service/info/configs.js Wed Mar 20 20:44:43 2013
@@ -40,6 +40,9 @@ App.MainServiceInfoConfigsController = E
 
   slaveComponentGroups: null,
 
+  /**
+   * clear and set properties to default value
+   */
   clearStep: function () {
     this.set('dataIsLoaded', false);
     this.get('stepConfigs').clear();
@@ -339,7 +342,12 @@ App.MainServiceInfoConfigsController = E
     return serviceConfigs;
   },
 
-
+  /**
+   * return site config properties
+   * @param sitename
+   * @param tagname
+   * @return {Object}
+   */
   getSiteConfigProperties: function (sitename, tagname) {
     var self = this;
     var properties = {};
@@ -425,6 +433,9 @@ App.MainServiceInfoConfigsController = E
     }, this);
   },
 
+  /**
+   * open popup with appropriate message
+   */
   restartServicePopup: function (event) {
     var header;
     var message;
@@ -551,6 +562,10 @@ App.MainServiceInfoConfigsController = E
     return result;
   },
 
+  /**
+   * save new or change exist configs in global configs
+   * @param configs
+   */
   saveGlobalConfigs: function (configs) {
     var globalConfigs = this.get('globalConfigs');
     configs.filterProperty('id', 'puppet var').forEach(function (_config) {
@@ -568,6 +583,10 @@ App.MainServiceInfoConfigsController = E
     this.set('globalConfigs', globalConfigs);
   },
 
+  /**
+   * set hive hostnames in global configs
+   * @param globals
+   */
   setHiveHostName: function (globals) {
     if (globals.someProperty('name', 'hive_database')) {
       //TODO: Hive host depends on the type of db selected. Change puppet variable name if postgres is not the default db
@@ -586,12 +605,20 @@ App.MainServiceInfoConfigsController = E
     }
   },
 
+  /**
+   * save site configs
+   * @param configs
+   */
   saveSiteConfigs: function (configs) {
     var storedConfigs = configs.filterProperty('id', 'site property').filterProperty('value');
     var uiConfigs = this.loadUiSideConfigs();
     this.set('uiConfigs', storedConfigs.concat(uiConfigs));
   },
 
+  /**
+   * return configs from the UI side
+   * @return {Array}
+   */
   loadUiSideConfigs: function () {
     var uiConfig = [];
     var configs = this.get('configMapping').filterProperty('foreignKey', null);
@@ -618,10 +645,14 @@ App.MainServiceInfoConfigsController = E
     }, this);
     return uiConfig;
   },
+
   /**
-   * Set all site property that are derived from other puppet-variable
+   * return global config value
+   * @param templateName
+   * @param expression
+   * @param name
+   * @return {*}
    */
-
   getGlobConfigValue: function (templateName, expression, name) {
     var express = expression.match(/<(.*?)>/g);
     var value = expression;
@@ -724,6 +755,11 @@ App.MainServiceInfoConfigsController = E
       }, this);
     }
   },
+
+  /**
+   * try to create configuration and return true for success or false for failure
+   * @return {Boolean}
+   */
   createConfigurations: function () {
     var result = true;
     var serviceConfigTags = this.get('serviceConfigTags');
@@ -744,6 +780,10 @@ App.MainServiceInfoConfigsController = E
     return result;
   },
 
+  /**
+   * add newTagName property to each config in serviceConfigs
+   * @param serviceConfigs
+   */
   setNewTagNames: function (serviceConfigs) {
     var time = (new Date).getTime();
     serviceConfigs.forEach(function (_serviceConfigs) {
@@ -751,6 +791,11 @@ App.MainServiceInfoConfigsController = E
     }, this);
   },
 
+  /**
+   * send request to the server to create configs and return true for success and false for failure
+   * @param data
+   * @return {*}
+   */
   createConfigSite: function (data) {
     var result;
     var realData = data;
@@ -787,6 +832,11 @@ App.MainServiceInfoConfigsController = E
     return result;
   },
 
+  /**
+   * create global site object
+   * @param tagName
+   * @return {Object}
+   */
   createGlobalSiteObj: function (tagName) {
     var globalSiteProperties = {};
     this.get('globalConfigs').forEach(function (_globalSiteObj) {
@@ -804,6 +854,11 @@ App.MainServiceInfoConfigsController = E
     return {"type": "global", "tag": tagName, "properties": globalSiteProperties};
   },
 
+  /**
+   * create core site object
+   * @param tagName
+   * @return {Object}
+   */
   createCoreSiteObj: function (tagName) {
     var coreSiteObj = this.get('uiConfigs').filterProperty('filename', 'core-site.xml');
     var coreSiteProperties = {};
@@ -824,6 +879,12 @@ App.MainServiceInfoConfigsController = E
     return {"type": "core-site", "tag": tagName, "properties": coreSiteProperties};
   },
 
+  /**
+   * create site object
+   * @param siteName
+   * @param tagName
+   * @return {Object}
+   */
   createSiteObj: function (siteName, tagName) {
     var siteObj = this.get('uiConfigs').filterProperty('filename', siteName + '.xml');
     var siteProperties = {};
@@ -833,6 +894,11 @@ App.MainServiceInfoConfigsController = E
     return {"type": siteName, "tag": tagName, "properties": siteProperties};
   },
 
+  /**
+   * apply created configs to service and return true for success and false for failure
+   * @param serviceName
+   * @return {*}
+   */
   applyCreatedConfToService: function (serviceName) {
     var result;
     var clusterName = App.router.getClusterName();
@@ -867,6 +933,11 @@ App.MainServiceInfoConfigsController = E
     return result;
   },
 
+  /**
+   * return config for service
+   * @param serviceName
+   * @return {Object}
+   */
   getConfigForService: function (serviceName) {
     var data = {config: {}};
     this.get('serviceConfigTags').forEach(function (_serviceTag) {
@@ -883,6 +954,10 @@ App.MainServiceInfoConfigsController = E
     return data;
   },
 
+  /**
+   * return custom comfig
+   * @return {Object}
+   */
   setCustomConfigs: function () {
     var site = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).get('configs').filterProperty('id', 'conf-site');
     var siteProperties = [];
@@ -961,6 +1036,12 @@ App.MainServiceInfoConfigsController = E
     });
   },
 
+  /**
+   * return either specific url for request if testMode is false or testUrl
+   * @param testUrl
+   * @param url
+   * @return {*}
+   */
   getUrl: function (testUrl, url) {
     return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
   },