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/08 03:38:08 UTC
svn commit: r1395430 [9/13] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-agent/src/main/puppet/manifestloader/
ambari-agent/src/main/puppet/modules/configgenerator/manifests/
ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/ ambari-ag...
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java Mon Oct 8 01:37:59 2012
@@ -18,184 +18,151 @@
package org.apache.ambari.server.controller;
-import java.util.List;
import java.util.Map;
public class ServiceComponentHostResponse {
private String clusterName; // REF
-
- private List<PerServiceComponentHostResponse> hostComponents;
-
- public ServiceComponentHostResponse(String clusterName,
- List<PerServiceComponentHostResponse> hostComponents) {
+
+ private String serviceName;
+
+ private String componentName;
+
+ private String hostname;
+
+ // Config type -> version mapping
+ private Map<String, String> configVersions;
+
+ private String liveState;
+
+ private String stackVersion;
+
+ private String desiredState;
+
+ public ServiceComponentHostResponse(String clusterName, String serviceName,
+ String componentName, String hostname,
+ Map<String, String> configVersions, String liveState,
+ String stackVersion, String desiredState) {
super();
this.clusterName = clusterName;
- this.hostComponents = hostComponents;
+ this.serviceName = serviceName;
+ this.componentName = componentName;
+ this.hostname = hostname;
+ this.configVersions = configVersions;
+ this.liveState = liveState;
+ this.stackVersion = stackVersion;
+ this.desiredState = desiredState;
}
- public static class PerServiceComponentHostResponse {
-
- private String serviceName;
-
- private String componentName;
-
- private String hostname;
-
- // Config type -> version mapping
- private Map<String, String> configVersions;
-
- private String liveState;
-
- private String stackVersion;
-
- private String desiredState;
-
- public PerServiceComponentHostResponse(String serviceName,
- String componentName, String hostname,
- Map<String, String> configVersions, String liveState,
- String stackVersion, String desiredState) {
- super();
- this.serviceName = serviceName;
- this.componentName = componentName;
- this.hostname = hostname;
- this.configVersions = configVersions;
- this.liveState = liveState;
- this.stackVersion = stackVersion;
- this.desiredState = desiredState;
- }
-
- /**
- * @return the serviceName
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * @param serviceName the serviceName to set
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- /**
- * @return the componentName
- */
- public String getComponentName() {
- return componentName;
- }
-
- /**
- * @param componentName the componentName to set
- */
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
- /**
- * @return the hostname
- */
- public String getHostname() {
- return hostname;
- }
-
- /**
- * @param hostname the hostname to set
- */
- public void setHostname(String hostname) {
- this.hostname = hostname;
- }
-
- /**
- * @return the configVersions
- */
- public Map<String, String> getConfigVersions() {
- return configVersions;
- }
-
- /**
- * @param configVersions the configVersions to set
- */
- public void setConfigVersions(Map<String, String> configVersions) {
- this.configVersions = configVersions;
- }
-
- /**
- * @return the liveState
- */
- public String getLiveState() {
- return liveState;
- }
-
- /**
- * @param liveState the liveState to set
- */
- public void setLiveState(String liveState) {
- this.liveState = liveState;
- }
-
- /**
- * @return the stackVersion
- */
- public String getStackVersion() {
- return stackVersion;
- }
-
- /**
- * @param stackVersion the stackVersion to set
- */
- public void setStackVersion(String stackVersion) {
- this.stackVersion = stackVersion;
- }
-
- /**
- * @return the desiredState
- */
- public String getDesiredState() {
- return desiredState;
- }
-
- /**
- * @param desiredState the desiredState to set
- */
- public void setDesiredState(String desiredState) {
- this.desiredState = desiredState;
- }
-
+ /**
+ * @return the serviceName
+ */
+ public String getServiceName() {
+ return serviceName;
}
/**
- * @return the clusterName
+ * @param serviceName the serviceName to set
*/
- public String getClusterName() {
- return clusterName;
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
}
/**
- * @param clusterName the clusterName to set
+ * @return the componentName
*/
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
+ public String getComponentName() {
+ return componentName;
}
+ /**
+ * @param componentName the componentName to set
+ */
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+ /**
+ * @return the hostname
+ */
+ public String getHostname() {
+ return hostname;
+ }
/**
- * @return the hostComponents
+ * @param hostname the hostname to set
*/
- public List<PerServiceComponentHostResponse> getHostComponents() {
- return hostComponents;
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
}
+ /**
+ * @return the configVersions
+ */
+ public Map<String, String> getConfigVersions() {
+ return configVersions;
+ }
+ /**
+ * @param configVersions the configVersions to set
+ */
+ public void setConfigVersions(Map<String, String> configVersions) {
+ this.configVersions = configVersions;
+ }
/**
- * @param hostComponents the hostComponents to set
+ * @return the liveState
*/
- public void setHostComponents(
- List<PerServiceComponentHostResponse> hostComponents) {
- this.hostComponents = hostComponents;
+ public String getLiveState() {
+ return liveState;
}
+ /**
+ * @param liveState the liveState to set
+ */
+ public void setLiveState(String liveState) {
+ this.liveState = liveState;
+ }
+
+ /**
+ * @return the stackVersion
+ */
+ public String getStackVersion() {
+ return stackVersion;
+ }
+
+ /**
+ * @param stackVersion the stackVersion to set
+ */
+ public void setStackVersion(String stackVersion) {
+ this.stackVersion = stackVersion;
+ }
+
+ /**
+ * @return the desiredState
+ */
+ public String getDesiredState() {
+ return desiredState;
+ }
+
+ /**
+ * @param desiredState the desiredState to set
+ */
+ public void setDesiredState(String desiredState) {
+ this.desiredState = desiredState;
+ }
+
+ /**
+ * @return the clusterName
+ */
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ /**
+ * @param clusterName the clusterName to set
+ */
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java Mon Oct 8 01:37:59 2012
@@ -18,126 +18,99 @@
package org.apache.ambari.server.controller;
-import java.util.List;
import java.util.Map;
public class ServiceComponentRequest {
private String clusterName; // REF
-
- private List<PerServiceComponentRequest> components;
-
+
+ private String serviceName; // GET/CREATE/UPDATE/DELETE
+
+ private String componentName; // GET/CREATE/UPDATE/DELETE
+
+ // Config type -> version mapping
+ private Map<String, String> configVersions; // CREATE/UPDATE
+
+ private String desiredState; // CREATE/UPDATE
+
public ServiceComponentRequest(String clusterName,
- List<PerServiceComponentRequest> components) {
+ String serviceName, String componentName,
+ Map<String, String> configVersions, String desiredState) {
super();
this.clusterName = clusterName;
- this.components = components;
+ this.serviceName = serviceName;
+ this.componentName = componentName;
+ this.configVersions = configVersions;
+ this.desiredState = desiredState;
}
- public static class PerServiceComponentRequest {
+ /**
+ * @return the serviceName
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
- private String serviceName; // GET/CREATE/UPDATE/DELETE
-
- private String componentName; // GET/CREATE/UPDATE/DELETE
-
- // Config type -> version mapping
- private Map<String, String> configVersions; // CREATE/UPDATE
-
- private String desiredState; // CREATE/UPDATE
-
- public PerServiceComponentRequest(String serviceName, String componentName,
- Map<String, String> configVersions, String desiredState) {
- super();
- this.serviceName = serviceName;
- this.componentName = componentName;
- this.configVersions = configVersions;
- this.desiredState = desiredState;
- }
-
- /**
- * @return the serviceName
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * @param serviceName the serviceName to set
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- /**
- * @return the componentName
- */
- public String getComponentName() {
- return componentName;
- }
-
- /**
- * @param componentName the componentName to set
- */
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
- /**
- * @return the configVersions
- */
- public Map<String, String> getConfigVersions() {
- return configVersions;
- }
-
- /**
- * @param configVersions the configVersions to set
- */
- public void setConfigVersions(Map<String, String> configVersions) {
- this.configVersions = configVersions;
- }
-
- /**
- * @return the desiredState
- */
- public String getDesiredState() {
- return desiredState;
- }
-
- /**
- * @param desiredState the desiredState to set
- */
- public void setDesiredState(String desiredState) {
- this.desiredState = desiredState;
- }
-
+ /**
+ * @param serviceName the serviceName to set
+ */
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
}
/**
- * @return the clusterName
+ * @return the componentName
*/
- public String getClusterName() {
- return clusterName;
+ public String getComponentName() {
+ return componentName;
}
/**
- * @param clusterName the clusterName to set
+ * @param componentName the componentName to set
*/
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
}
/**
- * @return the components
+ * @return the configVersions
*/
- public List<PerServiceComponentRequest> getComponents() {
- return components;
+ public Map<String, String> getConfigVersions() {
+ return configVersions;
}
/**
- * @param components the components to set
+ * @param configVersions the configVersions to set
*/
- public void setComponents(List<PerServiceComponentRequest> components) {
- this.components = components;
+ public void setConfigVersions(Map<String, String> configVersions) {
+ this.configVersions = configVersions;
}
+ /**
+ * @return the desiredState
+ */
+ public String getDesiredState() {
+ return desiredState;
+ }
+
+ /**
+ * @param desiredState the desiredState to set
+ */
+ public void setDesiredState(String desiredState) {
+ this.desiredState = desiredState;
+ }
+
+ /**
+ * @return the clusterName
+ */
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ /**
+ * @param clusterName the clusterName to set
+ */
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java Mon Oct 8 01:37:59 2012
@@ -18,7 +18,6 @@
package org.apache.ambari.server.controller;
-import java.util.List;
import java.util.Map;
public class ServiceComponentResponse {
@@ -26,76 +25,66 @@ public class ServiceComponentResponse {
private Long clusterId; // REF
private String clusterName; // REF
-
- private List<PerServiceComponentResponse> components;
+
+ private String serviceName; // GET/CREATE/UPDATE/DELETE
+
+ private String componentName; // GET/CREATE/UPDATE/DELETE
+
+ // Config type -> version mapping
+ private Map<String, String> configVersions; // CREATE/UPDATE
+
public ServiceComponentResponse(Long clusterId, String clusterName,
- List<PerServiceComponentResponse> components) {
+ String serviceName,
+ String componentName, Map<String, String> configVersions) {
super();
this.clusterId = clusterId;
this.clusterName = clusterName;
- this.components = components;
+ this.serviceName = serviceName;
+ this.componentName = componentName;
+ this.configVersions = configVersions;
+ }
+
+ /**
+ * @return the serviceName
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ /**
+ * @param serviceName the serviceName to set
+ */
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ /**
+ * @return the componentName
+ */
+ public String getComponentName() {
+ return componentName;
+ }
+
+ /**
+ * @param componentName the componentName to set
+ */
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
}
- public static class PerServiceComponentResponse {
+ /**
+ * @return the configVersions
+ */
+ public Map<String, String> getConfigVersions() {
+ return configVersions;
+ }
- private String serviceName; // GET/CREATE/UPDATE/DELETE
-
- private String componentName; // GET/CREATE/UPDATE/DELETE
-
- // Config type -> version mapping
- private Map<String, String> configVersions; // CREATE/UPDATE
-
- public PerServiceComponentResponse(String serviceName,
- String componentName, Map<String, String> configVersions) {
- super();
- this.serviceName = serviceName;
- this.componentName = componentName;
- this.configVersions = configVersions;
- }
-
- /**
- * @return the serviceName
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * @param serviceName the serviceName to set
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- /**
- * @return the componentName
- */
- public String getComponentName() {
- return componentName;
- }
-
- /**
- * @param componentName the componentName to set
- */
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
- /**
- * @return the configVersions
- */
- public Map<String, String> getConfigVersions() {
- return configVersions;
- }
-
- /**
- * @param configVersions the configVersions to set
- */
- public void setConfigVersions(Map<String, String> configVersions) {
- this.configVersions = configVersions;
- }
-
+ /**
+ * @param configVersions the configVersions to set
+ */
+ public void setConfigVersions(Map<String, String> configVersions) {
+ this.configVersions = configVersions;
}
/**
@@ -125,19 +114,4 @@ public class ServiceComponentResponse {
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
-
- /**
- * @return the components
- */
- public List<PerServiceComponentResponse> getComponents() {
- return components;
- }
-
- /**
- * @param components the components to set
- */
- public void setComponents(List<PerServiceComponentResponse> components) {
- this.components = components;
- }
-
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java Mon Oct 8 01:37:59 2012
@@ -17,108 +17,81 @@
*/
package org.apache.ambari.server.controller;
-import java.util.List;
import java.util.Map;
public class ServiceRequest {
private String clusterName; // REF
- private List<PerServiceRequest> services;
+ private String serviceName; // GET/CREATE/UPDATE/DELETE
- public ServiceRequest(String clusterName, List<PerServiceRequest> services) {
+ // Config type -> version mapping
+ private Map<String, String> configVersions; // CREATE/UPDATE
+
+ private String desiredState; // CREATE/UPDATE
+
+ public ServiceRequest(String clusterName, String serviceName,
+ Map<String, String> configVersions, String desiredState) {
super();
this.clusterName = clusterName;
- this.services = services;
+ this.serviceName = serviceName;
+ this.configVersions = configVersions;
+ this.desiredState = desiredState;
}
- public static class PerServiceRequest {
+ /**
+ * @return the serviceName
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
- private String serviceName; // GET/CREATE/UPDATE/DELETE
-
- // Config type -> version mapping
- private Map<String, String> configVersions; // CREATE/UPDATE
-
- private String desiredState; // CREATE/UPDATE
-
- public PerServiceRequest(String serviceName,
- Map<String, String> configVersions, String desiredState) {
- super();
- this.serviceName = serviceName;
- this.configVersions = configVersions;
- this.desiredState = desiredState;
- }
-
- /**
- * @return the serviceName
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * @param serviceName the serviceName to set
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- /**
- * @return the configVersions
- */
- public Map<String, String> getConfigVersions() {
- return configVersions;
- }
-
- /**
- * @param configVersions the configVersions to set
- */
- public void setConfigVersions(Map<String, String> configVersions) {
- this.configVersions = configVersions;
- }
-
- /**
- * @return the desiredState
- */
- public String getDesiredState() {
- return desiredState;
- }
-
- /**
- * @param desiredState the desiredState to set
- */
- public void setDesiredState(String desiredState) {
- this.desiredState = desiredState;
- }
-
+ /**
+ * @param serviceName the serviceName to set
+ */
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
}
/**
- * @return the clusterName
+ * @return the configVersions
*/
- public String getClusterName() {
- return clusterName;
+ public Map<String, String> getConfigVersions() {
+ return configVersions;
}
/**
- * @param clusterName the clusterName to set
+ * @param configVersions the configVersions to set
*/
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
+ public void setConfigVersions(Map<String, String> configVersions) {
+ this.configVersions = configVersions;
}
/**
- * @return the services
+ * @return the desiredState
*/
- public List<PerServiceRequest> getServices() {
- return services;
+ public String getDesiredState() {
+ return desiredState;
}
/**
- * @param services the services to set
+ * @param desiredState the desiredState to set
*/
- public void setServices(List<PerServiceRequest> services) {
- this.services = services;
+ public void setDesiredState(String desiredState) {
+ this.desiredState = desiredState;
+ }
+
+ /**
+ * @return the clusterName
+ */
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ /**
+ * @param clusterName the clusterName to set
+ */
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
}
-
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java Mon Oct 8 01:37:59 2012
@@ -18,7 +18,6 @@
package org.apache.ambari.server.controller;
-import java.util.List;
import java.util.Map;
public class ServiceResponse {
@@ -27,75 +26,72 @@ public class ServiceResponse {
private String clusterName; // REF
- private List<PerServiceResponse> services;
-
+ private String serviceName;
+
+ private String currentStackVersion;
+
+ private String desiredStackVersion;
+
+ private String desiredState;
+
+ // Config type -> version mapping
+ private Map<String, String> configVersions; // CREATE/UPDATE
+
+
public ServiceResponse(Long clusterId, String clusterName,
- List<PerServiceResponse> services) {
+ String serviceName, String currentStackVersion,
+ Map<String, String> configVersions,
+ String desiredStackVersion, String desiredState) {
super();
this.clusterId = clusterId;
this.clusterName = clusterName;
- this.services = services;
+ this.serviceName = serviceName;
+ this.currentStackVersion = currentStackVersion;
+ this.configVersions = configVersions;
+ this.setDesiredStackVersion(desiredStackVersion);
+ this.setDesiredState(desiredState);
+ }
+
+ /**
+ * @return the serviceName
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ /**
+ * @param serviceName the serviceName to set
+ */
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ /**
+ * @return the currentStackVersion
+ */
+ public String getCurrentStackVersion() {
+ return currentStackVersion;
}
- public static class PerServiceResponse {
-
- private String serviceName;
-
- private String currentStackVersion;
-
- // Config type -> version mapping
- private Map<String, String> configVersions; // CREATE/UPDATE
-
- public PerServiceResponse(String serviceName, String currentStackVersion,
- Map<String, String> configVersions) {
- super();
- this.serviceName = serviceName;
- this.currentStackVersion = currentStackVersion;
- this.configVersions = configVersions;
- }
-
- /**
- * @return the serviceName
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * @param serviceName the serviceName to set
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- /**
- * @return the currentStackVersion
- */
- public String getCurrentStackVersion() {
- return currentStackVersion;
- }
-
- /**
- * @param currentStackVersion the currentStackVersion to set
- */
- public void setCurrentStackVersion(String currentStackVersion) {
- this.currentStackVersion = currentStackVersion;
- }
-
- /**
- * @return the configVersions
- */
- public Map<String, String> getConfigVersions() {
- return configVersions;
- }
-
- /**
- * @param configVersions the configVersions to set
- */
- public void setConfigVersions(Map<String, String> configVersions) {
- this.configVersions = configVersions;
- }
-
+ /**
+ * @param currentStackVersion the currentStackVersion to set
+ */
+ public void setCurrentStackVersion(String currentStackVersion) {
+ this.currentStackVersion = currentStackVersion;
+ }
+
+ /**
+ * @return the configVersions
+ */
+ public Map<String, String> getConfigVersions() {
+ return configVersions;
+ }
+
+ /**
+ * @param configVersions the configVersions to set
+ */
+ public void setConfigVersions(Map<String, String> configVersions) {
+ this.configVersions = configVersions;
}
/**
@@ -127,16 +123,30 @@ public class ServiceResponse {
}
/**
- * @return the services
+ * @return the desiredState
+ */
+ public String getDesiredState() {
+ return desiredState;
+ }
+
+ /**
+ * @param desiredState the desiredState to set
+ */
+ public void setDesiredState(String desiredState) {
+ this.desiredState = desiredState;
+ }
+
+ /**
+ * @return the desiredStackVersion
*/
- public List<PerServiceResponse> getServices() {
- return services;
+ public String getDesiredStackVersion() {
+ return desiredStackVersion;
}
/**
- * @param services the services to set
+ * @param desiredStackVersion the desiredStackVersion to set
*/
- public void setServices(List<PerServiceResponse> services) {
- this.services = services;
+ public void setDesiredStackVersion(String desiredStackVersion) {
+ this.desiredStackVersion = desiredStackVersion;
}
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionRequest.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionRequest.java Mon Oct 8 01:37:59 2012
@@ -19,7 +19,7 @@
package org.apache.ambari.server.controller;
public class TrackActionRequest {
-
+
private final Long requestId;
public TrackActionRequest(Long requestId) {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionResponse.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionResponse.java Mon Oct 8 01:37:59 2012
@@ -22,12 +22,12 @@ public class TrackActionResponse {
// Request ID for tracking async operations
private final Long requestId;
-
+
// TODO how are logs to be sent back?
private String logs;
// TODO stage specific information
-
+
public TrackActionResponse(Long requestId) {
super();
this.requestId = requestId;
@@ -53,6 +53,6 @@ public class TrackActionResponse {
public long getRequestId() {
return requestId;
}
-
-
+
+
}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/AndPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/AndPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/AndPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/AndPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,50 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Resource;
+
+
+/**
+ * Predicate which evaluates to true if all of the predicates in a predicate
+ * array evaluate to true.
+ */
+public class AndPredicate extends ArrayPredicate {
+
+ public AndPredicate(BasePredicate... predicates) {
+ super(predicates);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ Predicate[] predicates = getPredicates();
+ for (Predicate predicate : predicates) {
+ if (!predicate.evaluate(resource)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String getOperator() {
+ return "AND";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ArrayPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ArrayPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ArrayPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ArrayPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,83 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Predicate which evaluates an array of predicates.
+ */
+public abstract class ArrayPredicate implements BasePredicate {
+ private final BasePredicate[] predicates;
+ private final Set<PropertyId> propertyIds = new HashSet<PropertyId>();
+
+ public ArrayPredicate(BasePredicate... predicates) {
+ this.predicates = predicates;
+ for (BasePredicate predicate : predicates) {
+ propertyIds.addAll(predicate.getPropertyIds());
+ }
+ }
+
+ public BasePredicate[] getPredicates() {
+ return predicates;
+ }
+
+ @Override
+ public Set<PropertyId> getPropertyIds() {
+ return propertyIds;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ArrayPredicate)) return false;
+
+ ArrayPredicate that = (ArrayPredicate) o;
+
+ if (propertyIds != null ? !propertyIds.equals(that.propertyIds) : that.propertyIds != null) return false;
+
+ // don't care about array order
+ List<BasePredicate> listPredicates = Arrays.asList(predicates);
+ if (listPredicates.size() != that.predicates.length) return false;
+ for (BasePredicate predicate : predicates) {
+ if (!listPredicates.contains(predicate)) return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = predicates != null ? Arrays.hashCode(predicates) : 0;
+ result = 31 * result + (propertyIds != null ? propertyIds.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public void accept(PredicateVisitor visitor) {
+ visitor.acceptArrayPredicate(this);
+ }
+
+ public abstract String getOperator();
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/BasePredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/BasePredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/BasePredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/BasePredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,32 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.PropertyId;
+
+import java.util.Set;
+
+/**
+ * An extended predicate interface which allows for the retrieval of any
+ * associated property ids.
+ */
+public interface BasePredicate extends Predicate, PredicateVisitorAcceptor {
+ public Set<PropertyId> getPropertyIds();
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,66 @@
+/**
+ * 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;
+
+/**
+ *
+ */
+public class Comparables {
+
+ public static Comparable<String> forInteger(final Integer value) {
+
+ return new Comparable<String>() {
+ @Override
+ public int compareTo(String s) {
+ return value.compareTo(Integer.valueOf(s));
+ }
+ };
+ }
+
+ public static Comparable<String> forFloat(final Float value) {
+
+ return new Comparable<String>() {
+ @Override
+ public int compareTo(String s) {
+ return value.compareTo(Float.valueOf(s));
+ }
+ };
+ }
+
+ public static Comparable<String> forDouble(final Double value) {
+
+ return new Comparable<String>() {
+ @Override
+ public int compareTo(String s) {
+ return value.compareTo(Double.valueOf(s));
+ }
+ };
+ }
+
+ public static Comparable<String> forLong(final Long value) {
+
+ return new Comparable<String>() {
+ @Override
+ public int compareTo(String s) {
+ return value.compareTo(Long.valueOf(s));
+ }
+ };
+ }
+
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,66 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate that compares a given value to a {@link Resource} property.
+ */
+public abstract class ComparisonPredicate extends PropertyPredicate implements BasePredicate {
+ private final Comparable<String> value;
+
+ public ComparisonPredicate(PropertyId propertyId, Comparable<String> value) {
+ super(propertyId);
+ this.value = value;
+ }
+
+ public Comparable<String> getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ComparisonPredicate)) return false;
+ if (!super.equals(o)) return false;
+
+ ComparisonPredicate that = (ComparisonPredicate) o;
+
+ if (value != null ? !value.equals(that.value) : that.value != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + (value != null ? value.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public void accept(PredicateVisitor visitor) {
+ visitor.acceptComparisonPredicate(this);
+ }
+
+
+ public abstract String getOperator();
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,43 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate that checks equality of a given value to a {@link Resource} property.
+ */
+public class EqualsPredicate extends ComparisonPredicate {
+
+
+ public EqualsPredicate(PropertyId propertyId, Comparable<String> value) {
+ super(propertyId, value);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ return getValue().compareTo(resource.getPropertyValue(getPropertyId())) == 0;
+ }
+
+ @Override
+ public String getOperator() {
+ return "=";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,42 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate that checks if a given value is greater than or equal to a {@link Resource} property.
+ */
+public class GreaterEqualsPredicate extends ComparisonPredicate {
+
+ public GreaterEqualsPredicate(PropertyId propertyId, Comparable<String> value) {
+ super(propertyId, value);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ return getValue().compareTo(resource.getPropertyValue(getPropertyId())) <= 0;
+ }
+
+ @Override
+ public String getOperator() {
+ return ">=";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,41 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate that checks if a given value is greater than a {@link Resource} property.
+ */
+public class GreaterPredicate extends ComparisonPredicate {
+
+ public GreaterPredicate(PropertyId propertyId, Comparable<String> value) {
+ super(propertyId, value);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ return getValue().compareTo(resource.getPropertyValue(getPropertyId())) < 0;
+ }
+
+ @Override
+ public String getOperator() {
+ return ">";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,42 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
+
+
+/**
+ * Predicate that checks if a given value is less than or equal to a {@link Resource} property.
+ */
+public class LessEqualsPredicate extends ComparisonPredicate {
+
+ public LessEqualsPredicate(PropertyId propertyId, Comparable<String> value) {
+ super(propertyId, value);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ return getValue().compareTo(resource.getPropertyValue(getPropertyId())) >= 0;
+ }
+
+ @Override
+ public String getOperator() {
+ return "<=";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,41 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate that checks if a given value is less than a {@link Resource} property.
+ */
+public class LessPredicate extends ComparisonPredicate {
+
+ public LessPredicate(PropertyId propertyId, Comparable<String> value) {
+ super(propertyId, value);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ return getValue().compareTo(resource.getPropertyValue(getPropertyId())) > 0;
+ }
+
+ @Override
+ public String getOperator() {
+ return "<";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/NotPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/NotPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/NotPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/NotPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,40 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate that negates the evaluation of another predicate.
+ */
+public class NotPredicate extends UnaryPredicate {
+
+ public NotPredicate(BasePredicate predicate) {
+ super(predicate);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ return !getPredicate().evaluate(resource);
+ }
+
+ @Override
+ public String getOperator() {
+ return "NOT";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/OrPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/OrPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/OrPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/OrPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,47 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Predicate which evaluates to true if any of the predicates in a predicate
+ * array evaluate to true.
+ */
+public class OrPredicate extends ArrayPredicate {
+
+ public OrPredicate(BasePredicate... predicates) {
+ super(predicates);
+ }
+
+ @Override
+ public boolean evaluate(Resource resource) {
+ BasePredicate[] predicates = getPredicates();
+ for (BasePredicate predicate : predicates) {
+ if (predicate.evaluate(resource)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String getOperator() {
+ return "OR";
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,30 @@
+/**
+ * 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;
+
+/**
+ * A visitor of predicates.
+ */
+public interface PredicateVisitor {
+
+ public void acceptComparisonPredicate(ComparisonPredicate predicate);
+
+ public void acceptArrayPredicate(ArrayPredicate predicate);
+
+ public void acceptUnaryPredicate(UnaryPredicate predicate);
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,26 @@
+/**
+ * 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;
+
+/**
+ * An acceptor of predicate visitors.
+ */
+public interface PredicateVisitorAcceptor {
+
+ public void accept(PredicateVisitor visitor);
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,65 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * Predicate that is associated with a resource property.
+ */
+public abstract class PropertyPredicate implements BasePredicate {
+ private final PropertyId propertyId;
+
+ public PropertyPredicate(PropertyId propertyId) {
+ this.propertyId = propertyId;
+ }
+
+ @Override
+ public Set<PropertyId> getPropertyIds() {
+ return Collections.singleton(propertyId);
+ }
+
+ public PropertyId getPropertyId() {
+ return propertyId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof PropertyPredicate)) {
+ return false;
+ }
+
+ PropertyPredicate that = (PropertyPredicate) o;
+
+ return propertyId == null ? that.propertyId == null : propertyId.equals(that.propertyId);
+ }
+
+ @Override
+ public int hashCode() {
+ return propertyId != null ? propertyId.hashCode() : 0;
+ }
+}
+
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/UnaryPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/UnaryPredicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/UnaryPredicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/UnaryPredicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,49 @@
+/**
+ * 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 org.apache.ambari.server.controller.spi.PropertyId;
+
+import java.util.Set;
+
+/**
+ * Predicate that operates on one other predicate.
+ */
+public abstract class UnaryPredicate implements BasePredicate {
+ private final BasePredicate predicate;
+
+ public UnaryPredicate(BasePredicate predicate) {
+ this.predicate = predicate;
+ }
+
+ public BasePredicate getPredicate() {
+ return predicate;
+ }
+
+ @Override
+ public Set<PropertyId> getPropertyIds() {
+ return predicate.getPropertyIds();
+ }
+
+ @Override
+ public void accept(PredicateVisitor visitor) {
+ visitor.acceptUnaryPredicate(this);
+ }
+
+ public abstract String getOperator();
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,96 @@
+/**
+ * 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.spi;
+
+import org.apache.ambari.server.AmbariException;
+
+/**
+ * The cluster controller is the main access point for accessing resources
+ * from the backend sources. A cluster controller maintains a mapping of
+ * resource providers keyed by resource types.
+ */
+public interface ClusterController {
+
+ // ----- Monitoring ------------------------------------------------------
+
+ /**
+ * Get the resources of the given type filtered by the given request and
+ * predicate objects.
+ *
+ * @param type the type of the requested resources
+ * @param request the request object which defines the desired set of properties
+ * @param predicate the predicate object which filters which resources are returned
+ *
+ * @return an iterable object of the requested resources
+ *
+ * @throws AmbariException thrown if the resources cannot be obtained
+ */
+ public Iterable<Resource> getResources(Resource.Type type, Request request,
+ Predicate predicate) throws AmbariException;
+
+ /**
+ * Get the {@link Schema schema} for the given resource type. The schema
+ * for a given resource type describes the properties and categories provided
+ * by that type of resource.
+ *
+ * @param type the resource type
+ * @return the schema object for the given resource
+ */
+ public Schema getSchema(Resource.Type type);
+
+
+ // ----- Management -------------------------------------------------------
+
+ /**
+ * Create the resources defined by the properties in the given request object.
+ *
+ * @param type the type of the resources
+ * @param request the request object which defines the set of properties
+ * for the resources to be created
+ *
+ * @throws AmbariException thrown if the resources cannot be created
+ */
+ public void createResources(Resource.Type type, Request request) throws AmbariException;
+
+ /**
+ * Update the resources selected by the given predicate with the properties
+ * from the given request object.
+ *
+ * @param type the type of the resources
+ * @param request the request object which defines the set of properties
+ * for the resources to be updated
+ * @param predicate the predicate object which can be used to filter which
+ * resources are updated
+ *
+ * @throws AmbariException thrown if the resource cannot be updated
+ */
+ public void updateResources(Resource.Type type, Request request,
+ Predicate predicate) throws AmbariException;
+
+ /**
+ * Delete the resources selected by the given predicate.
+ *
+ * @param type the type of the resources
+ * @param predicate the predicate object which can be used to filter which
+ * resources are deleted
+ *
+ * @throws AmbariException thrown if the resource cannot be deleted
+ */
+ public void deleteResources(Resource.Type type,
+ Predicate predicate) throws AmbariException;
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Predicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Predicate.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Predicate.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Predicate.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,33 @@
+/**
+ * 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.spi;
+
+/**
+ * The predicate is used to filter the resources returned from the cluster
+ * controller. The predicate can examine a resource object and determine
+ * whether or not it should be included in the returned results.
+ */
+public interface Predicate {
+ /**
+ * Evaluate the predicate for the given resource.
+ *
+ * @param resource the resource to evaluate the predicate against
+ * @return the result of applying the predicate to the given resource
+ */
+ public boolean evaluate(Resource resource);
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyId.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyId.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyId.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyId.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.spi;
+
+/**
+ * The property id is used to uniquely identify a resource property. The
+ * property id is a composite of property name and category name as
+ * well as an indicator for temporal values.
+ */
+public interface PropertyId {
+
+ /**
+ * Get the property name.
+ *
+ * @return the property name
+ */
+ public String getName();
+
+ /**
+ * Get the category name.
+ *
+ * @return the category name
+ */
+ public String getCategory();
+
+ /**
+ * Indicates whether or not this property provides a temporal value.
+ *
+ * @return true if this property provides a temporal value.
+ */
+ public boolean isTemporal();
+
+ @Override
+ public int hashCode();
+
+ @Override
+ public boolean equals(Object o);
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.spi;
+
+import org.apache.ambari.server.AmbariException;
+
+import java.util.Set;
+
+/**
+ * The property provider is used to plug in various property sources into a
+ * resource provider. The property provider is able to populate, or partially
+ * populate a given resource object with property values.
+ */
+public interface PropertyProvider {
+
+ /**
+ * Populate the given set of resource with any properties that this property
+ * provider can provide and return a populated set of resources. The provider
+ * may drop resources from the original set if it determines that the don't
+ * meet the conditions of the predicate.
+ *
+ * @param resources the resources to be populated
+ * @param request the request object which defines the desired set of properties
+ * @param predicate the predicate object which filters which resources are returned
+ *
+ * @return the populated set of resources
+ *
+ * @throws AmbariException thrown if resources cannot be populated
+ */
+ public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate) throws AmbariException;
+
+ /**
+ * Get the set of property ids for the properties that this provider can provide.
+ *
+ * @return the set of property ids for the properties that this provider can provide
+ */
+ public Set<PropertyId> getPropertyIds();
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,88 @@
+/**
+ * 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.spi;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The request object carries the properties or property ids required to
+ * satisfy a resource request. The request object also contains any
+ * temporal (date range) information, if any, for each requested property.
+ */
+public interface Request {
+
+ /**
+ * Get the set of property ids being requested. Used for requests to get
+ * resources. An empty set signifies that all supported properties should
+ * be returned (i.e. select * ).
+ *
+ * @return the set of property ids being requested
+ */
+ public Set<PropertyId> getPropertyIds();
+
+ /**
+ * Get the set of maps of properties being requested. Used
+ * for requests to update or create resources. Each value
+ * in the set is a map of properties for a resource being
+ * created/updated. Each map contains property values keyed
+ * by property ids.
+ *
+ * @return the set of properties being requested
+ */
+ public Set<Map<PropertyId, Object>> getProperties();
+
+ /**
+ * Get the {@link TemporalInfo temporal information} for the given property
+ * id for this request, if any.
+ *
+ * @param id the property id
+ * @return the temporal information for the given property id; null if noe exists
+ */
+ public TemporalInfo getTemporalInfo(PropertyId id);
+
+ /**
+ * Temporal request information describing a range and increment of time.
+ */
+ public static interface TemporalInfo {
+
+ /**
+ * Get the start of the requested time range. The time is given in
+ * seconds since the Unix epoch.
+ *
+ * @return the start time in seconds
+ */
+ public long getStartTime();
+
+ /**
+ * Get the end of the requested time range. The time is given in
+ * seconds since the Unix epoch.
+ *
+ * @return the end time in seconds
+ */
+ public long getEndTime();
+
+ /**
+ * Get the requested time between each data point of the temporal
+ * data. The time is given in seconds.
+ *
+ * @return the step time in seconds
+ */
+ public long getStep();
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java Mon Oct 8 01:37:59 2012
@@ -0,0 +1,101 @@
+/**
+ * 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.spi;
+
+import java.util.Map;
+
+/**
+ * The resource object represents a requested resource. The resource
+ * contains a collection of values for the requested properties.
+ */
+public interface Resource {
+ /**
+ * Get the resource type.
+ *
+ * @return the resource type
+ */
+ public Type getType();
+
+ /**
+ * Get the map of categories contained by this resource. The map
+ * is keyed by the category name and contains maps of properties
+ * for each category.
+ *
+ * @return the map of categories
+ */
+ public Map<String, Map<String, String>> getCategories();
+
+ /**
+ * Set a string property value for the given property id on this resource.
+ *
+ * @param id the property id
+ * @param value the value
+ */
+ public void setProperty(PropertyId id, String value);
+
+ /**
+ * Set a integer property value for the given property id on this resource.
+ *
+ * @param id the property id
+ * @param value the value
+ */
+ public void setProperty(PropertyId id, Integer value);
+
+ /**
+ * Set a float property value for the given property id on this resource.
+ *
+ * @param id the property id
+ * @param value the value
+ */
+ public void setProperty(PropertyId id, Float value);
+
+ /**
+ * Set a double property value for the given property id on this resource.
+ *
+ * @param id the property id
+ * @param value the value
+ */
+ public void setProperty(PropertyId id, Double value);
+
+ /**
+ * Set a long property value for the given property id on this resource.
+ *
+ * @param id the property id
+ * @param value the value
+ */
+ public void setProperty(PropertyId id, Long value);
+
+ /**
+ * Get a property value for the given property id from this resource.
+ *
+ * @param id the property id
+ * @return the property value
+ */
+ public String getPropertyValue(PropertyId id);
+
+ /**
+ * Resource types.
+ */
+ public enum Type {
+ Cluster,
+ Service,
+ Host,
+ Component,
+ HostComponent
+ }
+}