You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/10/16 18:55:06 UTC
svn commit: r1398884 [2/2] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-server/src/main/java/org/apache/ambari/server/api/query/
ambari-server/src/main/java/org/apache/ambari/server/api/resources/
ambari-server/src/main/java/org/apache/ambari/...
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ResourceProviderImplTest.java Tue Oct 16 16:55:05 2012
@@ -45,7 +45,6 @@ import static org.easymock.EasyMock.veri
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -75,10 +74,10 @@ public class ResourceProviderImplTest {
managementController);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<PropertyId, String>> propertySet = new LinkedHashSet<Map<PropertyId, String>>();
+ Set<Map<PropertyId, Object>> propertySet = new LinkedHashSet<Map<PropertyId, Object>>();
// Cluster 1: create a map of properties for the request
- Map<PropertyId, String> properties = new LinkedHashMap<PropertyId, String>();
+ Map<PropertyId, Object> properties = new LinkedHashMap<PropertyId, Object>();
// add the cluster name to the properties map
properties.put(ResourceProviderImpl.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -89,10 +88,10 @@ public class ResourceProviderImplTest {
propertySet.add(properties);
// Cluster 2: create a map of properties for the request
- properties = new LinkedHashMap<PropertyId, String>();
+ properties = new LinkedHashMap<PropertyId, Object>();
// add the cluster id to the properties map
- properties.put(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID, "99");
+ properties.put(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID, 99L);
// add the version to the properties map
properties.put(ResourceProviderImpl.CLUSTER_VERSION_PROPERTY_ID, "4.03");
@@ -154,8 +153,8 @@ public class ResourceProviderImplTest {
Assert.assertEquals(5, resources.size());
for (Resource resource : resources) {
- String id = resource.getPropertyValue(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID);
- String name = resource.getPropertyValue(ResourceProviderImpl.CLUSTER_NAME_PROPERTY_ID);
+ Long id = (Long) resource.getPropertyValue(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID);
+ String name = (String) resource.getPropertyValue(ResourceProviderImpl.CLUSTER_NAME_PROPERTY_ID);
Assert.assertEquals(name, "Cluster" + id);
}
@@ -164,15 +163,15 @@ public class ResourceProviderImplTest {
resources = provider.getResources(request, predicate);
Assert.assertEquals(1, resources.size());
- Assert.assertEquals("102", resources.iterator().next().getPropertyValue(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID));
+ Assert.assertEquals(102L, resources.iterator().next().getPropertyValue(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID));
Assert.assertEquals("Cluster102", resources.iterator().next().getPropertyValue(ResourceProviderImpl.CLUSTER_NAME_PROPERTY_ID));
// get cluster with id == 103
- predicate = new PredicateBuilder().property(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID).equals("103").toPredicate();
+ predicate = new PredicateBuilder().property(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID).equals(103L).toPredicate();
resources = provider.getResources(request, predicate);
Assert.assertEquals(1, resources.size());
- Assert.assertEquals("103", resources.iterator().next().getPropertyValue(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID));
+ Assert.assertEquals(103L, resources.iterator().next().getPropertyValue(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID));
Assert.assertEquals("Cluster103", resources.iterator().next().getPropertyValue(ResourceProviderImpl.CLUSTER_NAME_PROPERTY_ID));
// verify
@@ -203,7 +202,7 @@ public class ResourceProviderImplTest {
PropertyHelper.getKeyPropertyIds(type),
managementController);
- Map<PropertyId, String> properties = new LinkedHashMap<PropertyId, String>();
+ Map<PropertyId, Object> properties = new LinkedHashMap<PropertyId, Object>();
properties.put(ResourceProviderImpl.CLUSTER_VERSION_PROPERTY_ID, "4.02");
@@ -215,7 +214,7 @@ public class ResourceProviderImplTest {
provider.updateResources(request, predicate);
// update the cluster where id == 103
- predicate = new PredicateBuilder().property(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID).equals("103").toPredicate();
+ predicate = new PredicateBuilder().property(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID).equals(103L).toPredicate();
provider.updateResources(request, predicate);
// verify
@@ -251,7 +250,7 @@ public class ResourceProviderImplTest {
provider.deleteResources(predicate);
// delete the cluster where id == 103
- predicate = new PredicateBuilder().property(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID).equals("103").toPredicate();
+ predicate = new PredicateBuilder().property(ResourceProviderImpl.CLUSTER_ID_PROPERTY_ID).equals(103L).toPredicate();
provider.deleteResources(predicate);
// verify
@@ -278,10 +277,10 @@ public class ResourceProviderImplTest {
managementController);
// add the property map to a set for the request. add more maps for multiple creates
- Set<Map<PropertyId, String>> propertySet = new LinkedHashSet<Map<PropertyId, String>>();
+ Set<Map<PropertyId, Object>> propertySet = new LinkedHashSet<Map<PropertyId, Object>>();
// Service 1: create a map of properties for the request
- Map<PropertyId, String> properties = new LinkedHashMap<PropertyId, String>();
+ Map<PropertyId, Object> properties = new LinkedHashMap<PropertyId, Object>();
// add properties to the request map
properties.put(ResourceProviderImpl.SERVICE_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -348,9 +347,9 @@ public class ResourceProviderImplTest {
Assert.assertEquals(5, resources.size());
Set<String> names = new HashSet<String>();
for (Resource resource : resources) {
- String clusterName = resource.getPropertyValue(ResourceProviderImpl.SERVICE_CLUSTER_NAME_PROPERTY_ID);
+ String clusterName = (String) resource.getPropertyValue(ResourceProviderImpl.SERVICE_CLUSTER_NAME_PROPERTY_ID);
Assert.assertEquals("Cluster100", clusterName);
- names.add(resource.getPropertyValue(ResourceProviderImpl.SERVICE_SERVICE_NAME_PROPERTY_ID));
+ names.add((String) resource.getPropertyValue(ResourceProviderImpl.SERVICE_SERVICE_NAME_PROPERTY_ID));
}
// Make sure that all of the response objects got moved into resources
for (ServiceResponse serviceResponse : allResponse ) {
@@ -372,9 +371,9 @@ public class ResourceProviderImplTest {
Assert.assertEquals(3, resources.size());
names = new HashSet<String>();
for (Resource resource : resources) {
- String clusterName = resource.getPropertyValue(ResourceProviderImpl.SERVICE_CLUSTER_NAME_PROPERTY_ID);
+ String clusterName = (String) resource.getPropertyValue(ResourceProviderImpl.SERVICE_CLUSTER_NAME_PROPERTY_ID);
Assert.assertEquals("Cluster100", clusterName);
- names.add(resource.getPropertyValue(ResourceProviderImpl.SERVICE_SERVICE_NAME_PROPERTY_ID));
+ names.add((String) resource.getPropertyValue(ResourceProviderImpl.SERVICE_SERVICE_NAME_PROPERTY_ID));
}
// Make sure that all of the response objects got moved into resources
for (ServiceResponse serviceResponse : stateResponse ) {
@@ -405,7 +404,7 @@ public class ResourceProviderImplTest {
managementController);
// add the property map to a set for the request.
- Map<PropertyId, String> properties = new LinkedHashMap<PropertyId, String>();
+ Map<PropertyId, Object> properties = new LinkedHashMap<PropertyId, Object>();
properties.put(ResourceProviderImpl.SERVICE_SERVICE_STATE_PROPERTY_ID, "DEPLOYED");
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java Tue Oct 16 16:55:05 2012
@@ -60,9 +60,9 @@ public class JMXPropertyProviderTest {
Assert.assertEquals(propertyProvider.getSpec("ec2-50-17-129-192.compute-1.amazonaws.com:50070"), streamProvider.getLastSpec());
// see test/resources/hdfs_namenode_jmx.json for values
- Assert.assertEquals("1084287", resource.getPropertyValue(PropertyHelper.getPropertyId("ReceivedBytes", "rpc")));
- Assert.assertEquals("173", resource.getPropertyValue(PropertyHelper.getPropertyId("CreateFileOps", "dfs")));
- Assert.assertEquals("405.8686", resource.getPropertyValue(PropertyHelper.getPropertyId("memHeapUsedM", "jvm")));
+ Assert.assertEquals(1084287, resource.getPropertyValue(PropertyHelper.getPropertyId("ReceivedBytes", "rpc")));
+ Assert.assertEquals(173, resource.getPropertyValue(PropertyHelper.getPropertyId("CreateFileOps", "dfs")));
+ Assert.assertEquals(405.8686, resource.getPropertyValue(PropertyHelper.getPropertyId("memHeapUsedM", "jvm")));
// datanode
@@ -79,8 +79,8 @@ public class JMXPropertyProviderTest {
Assert.assertEquals(propertyProvider.getSpec("ec2-23-23-71-42.compute-1.amazonaws.com:50075"), streamProvider.getLastSpec());
// see test/resources/hdfs_datanode_jmx.json for values
- Assert.assertEquals("0", resource.getPropertyValue(PropertyHelper.getPropertyId("ReceivedBytes", "rpc")));
- Assert.assertEquals("16.870667", resource.getPropertyValue(PropertyHelper.getPropertyId("memHeapUsedM", "jvm")));
+ Assert.assertEquals(0, resource.getPropertyValue(PropertyHelper.getPropertyId("ReceivedBytes", "rpc")));
+ Assert.assertEquals(16.870667, resource.getPropertyValue(PropertyHelper.getPropertyId("memHeapUsedM", "jvm")));
// jobtracker
@@ -99,7 +99,7 @@ public class JMXPropertyProviderTest {
// see test/resources/mapreduce_jobtracker_jmx.json for values
// resource should now contain 3 properties... host name, component name, and jvm.threadsWaiting (from request)
Assert.assertEquals(3, PropertyHelper.getProperties(resource).size());
- Assert.assertEquals("59", resource.getPropertyValue(PropertyHelper.getPropertyId("threadsWaiting", "jvm")));
+ Assert.assertEquals(59, resource.getPropertyValue(PropertyHelper.getPropertyId("threadsWaiting", "jvm")));
Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("gcCount", "jvm")));
}
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java Tue Oct 16 16:55:05 2012
@@ -34,22 +34,22 @@ public class GreaterEqualsPredicateTest
public void testApply() {
Resource resource = new ResourceImpl(Resource.Type.HostComponent);
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- Predicate predicate = new GreaterEqualsPredicate(propertyId, Comparables.forInteger(10));
+ Predicate predicate = new GreaterEqualsPredicate(propertyId, 10);
- resource.setProperty(propertyId, "1");
+ resource.setProperty(propertyId, 1);
Assert.assertFalse(predicate.evaluate(resource));
- resource.setProperty(propertyId, "100");
+ resource.setProperty(propertyId, 100);
Assert.assertTrue(predicate.evaluate(resource));
- resource.setProperty(propertyId, "10");
+ resource.setProperty(propertyId, 10);
Assert.assertTrue(predicate.evaluate(resource));
}
@Test
public void testGetProperties() {
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- GreaterEqualsPredicate predicate = new GreaterEqualsPredicate(propertyId, Comparables.forInteger(10));
+ GreaterEqualsPredicate predicate = new GreaterEqualsPredicate(propertyId, 10);
Set<PropertyId> ids = predicate.getPropertyIds();
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java Tue Oct 16 16:55:05 2012
@@ -34,22 +34,22 @@ public class GreaterPredicateTest {
public void testApply() {
Resource resource = new ResourceImpl(Resource.Type.HostComponent);
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- Predicate predicate = new GreaterPredicate(propertyId, Comparables.forInteger(10));
+ Predicate predicate = new GreaterPredicate(propertyId, 10);
- resource.setProperty(propertyId, "1");
+ resource.setProperty(propertyId, 1);
Assert.assertFalse(predicate.evaluate(resource));
- resource.setProperty(propertyId, "100");
+ resource.setProperty(propertyId, 100);
Assert.assertTrue(predicate.evaluate(resource));
- resource.setProperty(propertyId, "10");
+ resource.setProperty(propertyId, 10);
Assert.assertFalse(predicate.evaluate(resource));
}
@Test
public void testGetProperties() {
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- GreaterPredicate predicate = new GreaterPredicate(propertyId, Comparables.forInteger(10));
+ GreaterPredicate predicate = new GreaterPredicate(propertyId, 10);
Set<PropertyId> ids = predicate.getPropertyIds();
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java Tue Oct 16 16:55:05 2012
@@ -34,22 +34,22 @@ public class LessEqualsPredicateTest {
public void testApply() {
Resource resource = new ResourceImpl(Resource.Type.HostComponent);
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- Predicate predicate = new LessEqualsPredicate(propertyId, Comparables.forInteger(10));
+ Predicate predicate = new LessEqualsPredicate(propertyId, 10);
- resource.setProperty(propertyId, "1");
+ resource.setProperty(propertyId, 1);
Assert.assertTrue(predicate.evaluate(resource));
- resource.setProperty(propertyId, "100");
+ resource.setProperty(propertyId, 100);
Assert.assertFalse(predicate.evaluate(resource));
- resource.setProperty(propertyId, "10");
+ resource.setProperty(propertyId, 10);
Assert.assertTrue(predicate.evaluate(resource));
}
@Test
public void testGetProperties() {
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- LessEqualsPredicate predicate = new LessEqualsPredicate(propertyId, Comparables.forInteger(10));
+ LessEqualsPredicate predicate = new LessEqualsPredicate(propertyId, 10);
Set<PropertyId> ids = predicate.getPropertyIds();
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java Tue Oct 16 16:55:05 2012
@@ -34,22 +34,22 @@ public class LessPredicateTest {
public void testApply() {
Resource resource = new ResourceImpl(Resource.Type.HostComponent);
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- Predicate predicate = new LessPredicate(propertyId, Comparables.forInteger(10));
+ Predicate predicate = new LessPredicate(propertyId, 10);
- resource.setProperty(propertyId, "1");
+ resource.setProperty(propertyId, 1);
Assert.assertTrue(predicate.evaluate(resource));
- resource.setProperty(propertyId, "100");
+ resource.setProperty(propertyId, 100);
Assert.assertFalse(predicate.evaluate(resource));
- resource.setProperty(propertyId, "10");
+ resource.setProperty(propertyId, 10);
Assert.assertFalse(predicate.evaluate(resource));
}
@Test
public void testGetProperties() {
PropertyIdImpl propertyId = new PropertyIdImpl("foo", "category1", false);
- LessPredicate predicate = new LessPredicate(propertyId, Comparables.forInteger(10));
+ LessPredicate predicate = new LessPredicate(propertyId, 1);
Set<PropertyId> ids = predicate.getPropertyIds();
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/ResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/ResourceImpl.java?rev=1398884&r1=1398883&r2=1398884&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/ResourceImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/ResourceImpl.java Tue Oct 16 16:55:05 2012
@@ -37,7 +37,7 @@ public class ResourceImpl implements Res
/**
* The map of categories/properties for this resources.
*/
- private final Map<String, Map<String, String>> categories = new HashMap<String, Map<String, String>>();
+ private final Map<String, Map<String, Object>> categories = new HashMap<String, Map<String, Object>>();
// ----- Constructors ------------------------------------------------------
@@ -60,18 +60,18 @@ public class ResourceImpl implements Res
}
@Override
- public Map<String, Map<String, String>> getCategories() {
+ public Map<String, Map<String, Object>> getCategories() {
return categories;
}
@Override
- public void setProperty(PropertyId id, String value) {
+ public void setProperty(PropertyId id, Object value) {
String category = id.getCategory();
- Map<String, String> properties = categories.get(category);
+ Map<String, Object> properties = categories.get(category);
if (properties == null) {
- properties = new HashMap<String, String>();
+ properties = new HashMap<String, Object>();
categories.put(category, properties);
}
@@ -79,29 +79,9 @@ public class ResourceImpl implements Res
}
@Override
- public void setProperty(PropertyId id, Integer value) {
- setProperty(id, value.toString());
- }
-
- @Override
- public void setProperty(PropertyId id, Float value) {
- setProperty(id, value.toString());
- }
-
- @Override
- public void setProperty(PropertyId id, Double value) {
- setProperty(id, value.toString());
- }
-
- @Override
- public void setProperty(PropertyId id, Long value) {
- setProperty(id, value.toString());
- }
-
- @Override
- public String getPropertyValue(PropertyId id) {
+ public Object getPropertyValue(PropertyId id) {
- Map<String, String> properties = categories.get(id.getCategory());
+ Map<String, Object> properties = categories.get(id.getCategory());
if (properties != null) {
return properties.get(id.getName());
@@ -117,8 +97,8 @@ public class ResourceImpl implements Res
StringBuilder sb = new StringBuilder();
sb.append("Resource : ").append(type).append("\n");
- for (Map.Entry<String, Map<String, String>> catEntry : categories.entrySet()) {
- for (Map.Entry<String, String> propEntry : catEntry.getValue().entrySet()) {
+ for (Map.Entry<String, Map<String, Object>> catEntry : categories.entrySet()) {
+ for (Map.Entry<String, Object> propEntry : catEntry.getValue().entrySet()) {
sb.append(" ").append(catEntry.getKey()).append(".").append(propEntry.getKey()).append(" : ").append(propEntry.getValue()).append("\n");
}
}