incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1395430 [2/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...
Date Mon, 08 Oct 2012 01:38:08 GMT
Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/Heartbeat.py Mon Oct  8 01:37:59 2012
@@ -39,17 +39,19 @@ class Heartbeat:
     timestamp = int(time.time()*1000)
     queueResult = self.actionQueue.result()
     installedRoleStates = serverStatus.build()
+    
     nodeStatus = { "status" : "HEALTHY",
                    "cause" : "NONE"}
     
     heartbeat = { 'responseId'        : int(id),
                   'timestamp'         : timestamp,
                   'hostname'          : socket.gethostname(),
-                 # 'reports'           : self.reports,
                  # 'componentStatus'   : self.componentStatus,
                   'nodeStatus'        : nodeStatus
                 }
-  
+    if len(queueResult) != 0:
+      heartbeat['reports'] = queueResult
+      pass
     
     return heartbeat
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py Mon Oct  8 01:37:59 2012
@@ -119,7 +119,7 @@ class CertificateManager():
     response = f.read()
     f.close()
     data = json.loads(response)
-    logger.info("Sign response from Server: \n" + pprint.pformat(data))
+    logger.debug("Sign response from Server: \n" + pprint.pformat(data))
     result=data['result']
     if result == 'OK':
       agentCrtContent=data['signedCa']

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/shell.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/shell.py?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/shell.py (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/shell.py Mon Oct  8 01:37:59 2012
@@ -88,18 +88,19 @@ class shellRunner:
     code = 0
     cmd = " "
     cmd = cmd.join(script)
-    p = subprocess.Popen(cmd, preexec_fn=changeUid, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
+    p = subprocess.Popen(cmd, preexec_fn=changeUid, stdout=subprocess.PIPE, 
+                         stderr=subprocess.PIPE, shell=True, close_fds=True)
     out, err = p.communicate()
     code = p.wait()
     logger.debug("Exitcode for %s is %d" % (cmd,code))
     return {'exitCode': code, 'output': out, 'error': err}
 
   # dispatch action types
-  def runAction(self, clusterId, component, role, user, command, cleanUpCommand, result):
+  def runAction(self, clusterId, component, role, 
+                user, command, cleanUpCommand, result):
     oldDir = os.getcwd()
     #TODO: handle this better. Don't like that it is doing a chdir for the main process
     os.chdir(self.getWorkDir(clusterId, role))
-    oldUid = os.getuid()
     try:
       if user is not None:
         user=getpwnam(user)[2]
@@ -107,7 +108,8 @@ class shellRunner:
         user = oldUid
       threadLocal.uid = user
     except Exception:
-      logger.warn("%s %s %s can not switch user for RUN_ACTION." % (clusterId, component, role))
+      logger.warn("%s %s %s can not switch user for RUN_ACTION." 
+                  % (clusterId, component, role))
     code = 0
     cmd = sys.executable
     tempfilename = tempfile.mktemp()
@@ -116,7 +118,8 @@ class shellRunner:
     tmp.close()
     cmd = "%s %s %s" % (cmd, tempfilename, " ".join(command['param']))
     commandResult = {}
-    p = subprocess.Popen(cmd, preexec_fn=changeUid, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
+    p = subprocess.Popen(cmd, preexec_fn=changeUid, stdout=subprocess.PIPE,
+                          stderr=subprocess.PIPE, shell=True, close_fds=True)
     out, err = p.communicate()
     code = p.wait()
     if code != 0:
@@ -134,7 +137,8 @@ class shellRunner:
       cmd = "%s %s %s" % (cmd, tempfilename, " ".join(cleanUpCommand['param']))
       cleanUpCode = 0
       cleanUpResult = {}
-      p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
+      p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                            shell=True, close_fds=True)
       out, err = p.communicate()
       cleanUpCode = p.wait()
       if cleanUpCode != 0:
@@ -147,17 +151,20 @@ class shellRunner:
     try:
       os.chdir(oldDir)
     except Exception:
-      logger.warn("%s %s %s can not restore environment for RUN_ACTION." % (clusterId, component, role))
+      logger.warn("%s %s %s can not restore environment for RUN_ACTION."
+                   % (clusterId, component, role))
     return result
 
   # Start a process and presist its state
-  def startProcess(self, clusterId, clusterDefinitionRevision, component, role, script, user, result):
+  def startProcess(self, clusterId, clusterDefinitionRevision, component,
+                    role, script, user, result):
     global serverTracker
     oldDir = os.getcwd()
     try:
       os.chdir(self.getWorkDir(clusterId,role))
     except Exception:
-      logger.warn("%s %s %s can not switch dir for START_ACTION." % (clusterId, component, role))
+      logger.warn("%s %s %s can not switch dir for START_ACTION."
+                   % (clusterId, component, role))
     oldUid = os.getuid()
     try:
       if user is not None:
@@ -166,10 +173,12 @@ class shellRunner:
         user = os.getuid()
       threadLocal.uid = user
     except Exception:
-      logger.warn("%s %s %s can not switch user for START_ACTION." % (clusterId, component, role))
+      logger.warn("%s %s %s can not switch user for START_ACTION." 
+                  % (clusterId, component, role))
     code = 0
     commandResult = {}
-    process = self.getServerKey(clusterId,clusterDefinitionRevision,component,role)
+    process = self.getServerKey(clusterId,clusterDefinitionRevision,
+                                component,role)
     if not process in serverTracker:
       try:
         plauncher = processlauncher(script,user)
@@ -177,7 +186,8 @@ class shellRunner:
         plauncher.blockUntilProcessCreation()
       except Exception:
         traceback.print_exc()
-        logger.warn("Can not launch process for %s %s %s" % (clusterId, component, role))
+        logger.warn("Can not launch process for %s %s %s" 
+                    % (clusterId, component, role))
         code = -1
       serverTracker[process] = plauncher
       commandResult['exitCode'] = code 
@@ -185,16 +195,19 @@ class shellRunner:
     try:
       os.chdir(oldDir)
     except Exception:
-      logger.warn("%s %s %s can not restore environment for START_ACTION." % (clusterId, component, role))
+      logger.warn("%s %s %s can not restore environment for START_ACTION." \
+                   % (clusterId, component, role))
     return result
 
   # Stop a process and remove presisted state
   def stopProcess(self, processKey):
     global serverTracker
     keyFragments = processKey.split('/')
-    process = self.getServerKey(keyFragments[0],keyFragments[1],keyFragments[2],keyFragments[3])
+    process = self.getServerKey(keyFragments[0],keyFragments[1],
+                                keyFragments[2],keyFragments[3])
     if process in serverTracker:
-      logger.info ("Sending %s with PID %d the SIGTERM signal" % (process,serverTracker[process].getpid()))
+      logger.info ("Sending %s with PID %d the SIGTERM signal"
+                    % (process,serverTracker[process].getpid()))
       killprocessgrp(serverTracker[process].getpid())
       del serverTracker[process]
 
@@ -227,10 +240,13 @@ class processlauncher(threading.Thread):
       tmp.write(self.script['script'])
       tmp.close()
       threadLocal.uid = self.uid
-      self.cmd = "%s %s %s" % (pythoncmd, tempfilename, " ".join(self.script['param']))
+      self.cmd = "%s %s %s" % (pythoncmd, tempfilename,
+                                " ".join(self.script['param']))
       logger.info("Launching %s as uid %d" % (self.cmd,self.uid) )
-      p = subprocess.Popen(self.cmd, preexec_fn=self.changeUidAndSetSid, stdout=subprocess.PIPE, 
-                           stderr=subprocess.PIPE, shell=True, close_fds=True)
+      p = subprocess.Popen(self.cmd,
+                            preexec_fn=self.changeUidAndSetSid, 
+                            stdout=subprocess.PIPE, 
+                            stderr=subprocess.PIPE, shell=True, close_fds=True)
       logger.info("Launched %s; PID %d" % (self.cmd,p.pid))
       self.serverpid = p.pid
       self.out, self.err = p.communicate()
@@ -253,7 +269,8 @@ class processlauncher(threading.Thread):
       time.sleep(1)
       logger.info("Waiting for process %s to start" % self.cmd)
       if sleepCount > 10:
-        logger.warn("Couldn't start process %s even after %d seconds" % (self.cmd,sleepCount))
+        logger.warn("Couldn't start process %s even after %d seconds"
+                     % (self.cmd,sleepCount))
         os._exit(1)
     return self.serverpid
 

Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/imports.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/imports.txt?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/imports.txt (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/imports.txt Mon Oct  8 01:37:59 2012
@@ -0,0 +1,12 @@
+import "/etc/puppet/agent/modules/hdp/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-hadoop/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-hbase/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-zookeeper/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-oozie/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-pig/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-sqoop/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-templeton/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-hive/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-hcat/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-mysql/manifests/*.pp"
+import "/etc/puppet/agent/modules/hdp-monitor-webserver/manifests/*.pp"

Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/manifestGenerator.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/manifestGenerator.py?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/manifestGenerator.py (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/manifestGenerator/manifestGenerator.py Mon Oct  8 01:37:59 2012
@@ -0,0 +1,98 @@
+import json
+
+def generateManifest(inputJsonStr):
+#reading json
+  parsedJson = json.loads(inputJsonStr)
+  hostname = parsedJson['hostname']
+  clusterHostInfo = parsedJson['clusterHostInfo']
+  params = parsedJson['params']
+  configurations = parsedJson['configurations']
+  hostAttributes = parsedJson['hostAttributes']
+  roles = parsedJson['roles']
+  
+#writing manifest
+  manifest = open('site.pp', 'w')
+
+  #writing imports from external static file
+  writeImports(manifest)
+  
+  #writing nodes
+  writeNodes(manifest, clusterHostInfo)
+  
+  #writing params from map
+  writeParams(manifest, params)
+  
+  #writing config maps
+  writeConfigurations(manifest, configurations)
+
+  #cycle here - writing host attributes
+  writeHostAttributes(manifest, hostAttributes)
+
+  #writing task definitions 
+  writeTasks(manifest, roles)
+     
+  manifest.close()
+    
+  
+  #read static imports from file and write them to manifest
+  def writeImports(outputFile, inputFileName='imports.txt'):
+    inputFile = open(inputFileName, 'r')
+    
+    for line in inputFile:
+      outputFile.write(line)
+      
+    inputFile.close()
+
+  #write nodes
+  def writeNodes(outputFile, clusterHostInfo):
+    for node in clusterHostInfo.iterkeys():
+      outputFile.write('$' + node + '= ['
+    
+      coma = ''
+      for host in node:
+        outputFile.write(coma + '\'' + host + '\'')
+        coma = ', '
+
+      outputFile.write(']\n'
+
+  #write params
+  def writeParams(outputFile, params):
+    for param in params.iterkeys():
+      outputFile.write('$' +  param + '="' + params[param] + '"\n')
+
+  #write host attributes
+  def writeHostAttributes(outputFile, hostAttributes):
+    outputFile.write('$hostAttributes={\n')
+  
+    coma = ''
+    for attribute in hostAttributes.iterkeys():
+      outputFile.write(coma + '"' +  attribute + '" => "{' + hostAttributes[attribute] + '"}')
+      coma = ',\n'
+
+    outputFile.write('}\n')
+
+  #write configurations
+  def writeConfigurations(outputFile, configs):
+    outputFile.write('$configuration =  {\n'
+  
+    for configName in configs.iterkeys():
+      outputFile.write('$' + configName + '=> {\n')
+      config = configs[configName]
+      
+      coma = ''
+      for configParam in config.iterkeys():
+        outputFile.write(coma + '"' + configParam + '" => "' + config[configParam] + '"')
+        coma = ',\n'
+
+      outputFile.write('\n}\n')
+      
+    outputFile.write('\n}\n'
+
+  #write node tasks
+  def writeTasks(outputFile, tasks):
+    for task in tasks :
+      nodename = task['role']
+      command = task['roleCommand']
+      taskParams = task['params']
+    #TODO: write node task to file
+      
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/pom.xml?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/pom.xml Mon Oct  8 01:37:59 2012
@@ -30,6 +30,11 @@
     </profiles>
   <dependencies>
     <dependency>
+      <groupId>org.apache.ambari</groupId>
+      <artifactId>ambari-server</artifactId>
+      <version>1.0.3-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-mapper-asl</artifactId>
       <version>1.9.2</version>
@@ -62,17 +67,14 @@
     <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-core-asl</artifactId>
-      <version>1.9.2</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-jaxrs</artifactId>
-      <version>1.9.2</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-xc</artifactId>
-      <version>1.9.7</version>
     </dependency>
     <dependency>
       <groupId>asm</groupId>
@@ -99,5 +101,10 @@
       <groupId>com.sun.grizzly</groupId>
       <artifactId>grizzly-comet-webserver</artifactId>
     </dependency>
+    <dependency>
+      <groupId>com.google.inject</groupId>
+      <artifactId>guice</artifactId>
+      <version>3.0</version>
+    </dependency>
   </dependencies>
 </project>

Added: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ProviderModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ProviderModule.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ProviderModule.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ProviderModule.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.api.controller;
+
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+
+
+/**
+ *
+ */
+public interface ProviderModule {
+  public ResourceProvider getResourceProvider(Resource.Type type);
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ganglia/GangliaPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ganglia/GangliaPropertyProvider.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ganglia/GangliaPropertyProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/ganglia/GangliaPropertyProvider.java Mon Oct  8 01:37:59 2012
@@ -19,11 +19,11 @@
 package org.apache.ambari.api.controller.ganglia;
 
 import org.apache.ambari.api.controller.internal.PropertyIdImpl;
-import org.apache.ambari.api.controller.spi.Predicate;
-import org.apache.ambari.api.controller.spi.PropertyId;
-import org.apache.ambari.api.controller.spi.PropertyProvider;
-import org.apache.ambari.api.controller.spi.Request;
-import org.apache.ambari.api.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.api.controller.utilities.PredicateHelper;
 
 import java.util.HashMap;

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ClusterControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ClusterControllerImpl.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ClusterControllerImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ClusterControllerImpl.java Mon Oct  8 01:37:59 2012
@@ -15,17 +15,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.ambari.api.controller.internal;
 
-import org.apache.ambari.api.controller.spi.ClusterController;
-import org.apache.ambari.api.controller.spi.Predicate;
-import org.apache.ambari.api.controller.spi.PropertyProvider;
-import org.apache.ambari.api.controller.spi.Request;
-import org.apache.ambari.api.controller.spi.Resource;
-import org.apache.ambari.api.controller.spi.ResourceProvider;
-import org.apache.ambari.api.controller.spi.Schema;
+import org.apache.ambari.api.controller.ProviderModule;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.spi.ClusterController;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.spi.Schema;
 
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -36,16 +40,32 @@ import java.util.Set;
  */
 public class ClusterControllerImpl implements ClusterController {
 
-  private final Map<Resource.Type, Schema> schemas;
+  /**
+   * Module of providers for this controller.
+   */
+  private final ProviderModule providerModule;
+
+  /**
+   * Map of resource providers keyed by resource type.
+   */
+  private final Map<Resource.Type, ResourceProvider> resourceProviders;
+
 
-  public ClusterControllerImpl(Map<Resource.Type, Schema> schemas) {
-    this.schemas = schemas;
+  // ----- Constructors ------------------------------------------------------
+
+  public ClusterControllerImpl(ProviderModule providerModule) {
+    this.providerModule = providerModule;
+    this.resourceProviders = getResourceSchemas();
   }
 
+
+  // ----- ClusterController -------------------------------------------------
+
   @Override
-  public Iterable<Resource> getResources(Resource.Type type, Request request, Predicate predicate) {
-    ResourceProvider provider = schemas.get(type).getResourceProvider();
-    Set<Resource> resources = null;
+  public Iterable<Resource> getResources(Resource.Type type, Request request, Predicate predicate)
+      throws AmbariException{
+    ResourceProvider provider = resourceProviders.get(type);
+    Set<Resource> resources;
 
     if (provider == null) {
       resources = Collections.emptySet();
@@ -58,49 +78,134 @@ public class ClusterControllerImpl imple
 
   @Override
   public Schema getSchema(Resource.Type type) {
-    return schemas.get(type);
+    return resourceProviders.get(type).getSchema();
+  }
+
+  @Override
+  public void createResources(Resource.Type type, Request request) throws AmbariException {
+    ResourceProvider provider = resourceProviders.get(type);
+    if (provider != null) {
+      provider.createResources(request);
+    }
   }
 
+  @Override
+  public void updateResources(Resource.Type type, Request request, Predicate predicate) throws AmbariException {
+    ResourceProvider provider = resourceProviders.get(type);
+    if (provider != null) {
+      provider.updateResources(request, predicate);
+    }
+  }
+
+  @Override
+  public void deleteResources(Resource.Type type, Predicate predicate) throws AmbariException {
+    ResourceProvider provider = resourceProviders.get(type);
+    if (provider != null) {
+      provider.deleteResources(predicate);
+    }
+  }
+
+
+  // ----- helper methods ----------------------------------------------------
+
   private Set<Resource> populateResources(Resource.Type type,
                                           Set<Resource> resources,
                                           Request request,
-                                          Predicate predicate) {
+                                          Predicate predicate) throws AmbariException{
     Set<Resource> keepers = resources;
 
-    for (PropertyProvider propertyProvider : schemas.get(type).getPropertyProviders()) {
+    for (PropertyProvider propertyProvider : resourceProviders.get(type).getPropertyProviders()) {
       //TODO : only call the provider if it provides properties that we need ...
       keepers = propertyProvider.populateResources(keepers, request, predicate);
     }
     return keepers;
   }
 
+  private Map<Resource.Type, ResourceProvider> getResourceSchemas() {
+    Map<Resource.Type, ResourceProvider> resourceProviders = new HashMap<Resource.Type, ResourceProvider>();
+
+    resourceProviders.put(Resource.Type.Cluster, providerModule.getResourceProvider(Resource.Type.Cluster));
+    resourceProviders.put(Resource.Type.Service, providerModule.getResourceProvider(Resource.Type.Service));
+    resourceProviders.put(Resource.Type.Host, providerModule.getResourceProvider(Resource.Type.Host));
+    resourceProviders.put(Resource.Type.Component, providerModule.getResourceProvider(Resource.Type.Component));
+    resourceProviders.put(Resource.Type.HostComponent, providerModule.getResourceProvider(Resource.Type.HostComponent));
+
+    return resourceProviders;
+  }
+
+
+  // ----- ResourceIterable inner class --------------------------------------
+
   private static class ResourceIterable implements Iterable<Resource> {
+
+    /**
+     * The resources to iterate over.
+     */
     private final Set<Resource> resources;
+
+    /**
+     * The predicate used to filter the set.
+     */
     private final Predicate predicate;
 
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a ResourceIterable.
+     *
+     * @param resources  the set of resources to iterate over
+     * @param predicate  the predicate used to filter the set of resources
+     */
     private ResourceIterable(Set<Resource> resources, Predicate predicate) {
       this.resources = resources;
       this.predicate = predicate;
     }
 
+    // ----- Iterable --------------------------------------------------------
+
     @Override
     public Iterator<Resource> iterator() {
       return new ResourceIterator(resources, predicate);
     }
   }
 
+
+  // ----- ResourceIterator inner class --------------------------------------
+
   private static class ResourceIterator implements Iterator<Resource> {
 
+    /**
+     * The underlying iterator.
+     */
     private final Iterator<Resource> iterator;
+
+    /**
+     * The predicate used to filter the resource being iterated over.
+     */
     private final Predicate predicate;
+
+    /**
+     * The next resource.
+     */
     private Resource nextResource;
 
+
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a new ResourceIterator.
+     *
+     * @param resources  the set of resources to iterate over
+     * @param predicate  the predicate used to filter the set of resources
+     */
     private ResourceIterator(Set<Resource> resources, Predicate predicate) {
-      this.iterator = resources.iterator();
-      this.predicate = predicate;
+      this.iterator     = resources.iterator();
+      this.predicate    = predicate;
       this.nextResource = getNextResource();
     }
 
+    // ----- Iterator --------------------------------------------------------
+
     @Override
     public boolean hasNext() {
       return nextResource != null;
@@ -123,6 +228,13 @@ public class ClusterControllerImpl imple
       throw new UnsupportedOperationException("Remove not supported.");
     }
 
+    // ----- helper methods --------------------------------------------------
+
+    /**
+     * Get the next resource.
+     *
+     * @return the next resource.
+     */
     private Resource getNextResource() {
       while (iterator.hasNext()) {
         Resource next = iterator.next();

Added: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/DefaultProviderModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/DefaultProviderModule.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/DefaultProviderModule.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/DefaultProviderModule.java Mon Oct  8 01:37:59 2012
@@ -0,0 +1,48 @@
+/**
+ * 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.api.controller.internal;
+
+import org.apache.ambari.api.controller.ProviderModule;
+import org.apache.ambari.api.controller.utilities.Properties;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.AmbariManagementControllerImpl;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ *
+ */
+public class DefaultProviderModule implements ProviderModule {
+
+  private static final List<PropertyProvider> PROPERTY_PROVIDERS =
+      new LinkedList<PropertyProvider>();
+
+  @Override
+  public ResourceProvider getResourceProvider(Resource.Type type) {
+    AmbariManagementController managementController =
+        new AmbariManagementControllerImpl(null, null);
+    return ResourceProviderImpl.getResourceProvider(type,
+        PROPERTY_PROVIDERS, Properties.getPropertyIds(type, "DB"),
+        Properties.getKeyPropertyIds(type), managementController);
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyIdImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyIdImpl.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyIdImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyIdImpl.java Mon Oct  8 01:37:59 2012
@@ -18,26 +18,52 @@
 
 package org.apache.ambari.api.controller.internal;
 
-import org.apache.ambari.api.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.PropertyId;
 
 /**
- *
+ * Simple PropertyId implementation.
  */
 public class PropertyIdImpl implements PropertyId {
+  /**
+   * The property name.
+   */
   private String name;
+
+  /**
+   * The category name.
+   */
   private String category;
+
+  /**
+   * Indicates whether or not this property is temporal.
+   */
   private boolean temporal;
 
-  public PropertyIdImpl() {
 
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a property id.  Required for JSON serialization.
+   */
+  public PropertyIdImpl() {
   }
 
+  /**
+   * Create a property id.
+   *
+   * @param name      the property name.
+   * @param category  the property category.
+   * @param temporal  a temporal indicator
+   */
   public PropertyIdImpl(String name, String category, boolean temporal) {
-    this.name = name;
+    this.name     = name;
     this.category = category;
     this.temporal = temporal;
   }
 
+
+  // ----- PropertyId --------------------------------------------------------
+
   public String getName() {
     return name;
   }
@@ -50,17 +76,27 @@ public class PropertyIdImpl implements P
     return temporal;
   }
 
+
+  // ----- Object overrides --------------------------------------------------
+
   @Override
   public int hashCode() {
-    return name.hashCode() + (category == null ? 0 : category.hashCode()) + (temporal ? 1 : 0);
+    return name.hashCode() +
+        (category == null ? 0 : category.hashCode()) +
+        (temporal ? 1 : 0);
   }
 
   @Override
   public boolean equals(Object o) {
 
-    if (!(o instanceof PropertyIdImpl)) {
+    if (this == o) {
+      return true;
+    }
+
+    if (!(o.getClass().equals(PropertyIdImpl.class))) {
       return false;
     }
+
     PropertyIdImpl that = (PropertyIdImpl) o;
 
     return this.name.equals(that.getName()) &&
@@ -68,21 +104,18 @@ public class PropertyIdImpl implements P
         this.isTemporal() == that.isTemporal();
   }
 
+  @Override
+  public String toString() {
+    return "PropertyId[" + category + ", " + name + "]";
+  }
+
+
+  // ----- helper methods ----------------------------------------------------
+
   private static boolean equals(Object o1, Object o2) {
     if (o1 == null) {
       return o2 == null;
     }
-
-    if (o2 == null) {
-      return o1 == null;
-    }
-
-    return o1.equals(o2);
-  }
-
-
-  @Override
-  public String toString() {
-    return "PropertyId[" + category + ", " + name + "]";
+    return o2 != null && o1.equals(o2);
   }
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyPredicateVisitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyPredicateVisitor.java?rev=1395430&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyPredicateVisitor.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/PropertyPredicateVisitor.java Mon Oct  8 01:37:59 2012
@@ -0,0 +1,62 @@
+/**
+ * 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.api.controller.internal;
+
+import org.apache.ambari.server.controller.predicate.ArrayPredicate;
+import org.apache.ambari.server.controller.predicate.ComparisonPredicate;
+import org.apache.ambari.server.controller.predicate.PredicateVisitor;
+import org.apache.ambari.server.controller.predicate.UnaryPredicate;
+import org.apache.ambari.server.controller.spi.PropertyId;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Predicate visitor for extracting property values from the PropertyPredicates of a predicate graph.
+ */
+public class PropertyPredicateVisitor implements PredicateVisitor {
+  private final Map<PropertyId, Object> properties = new HashMap<PropertyId, Object>();
+
+  @Override
+  public void acceptComparisonPredicate(ComparisonPredicate predicate) {
+    properties.put(predicate.getPropertyId(), predicate.getValue());
+  }
+
+  @Override
+  public void acceptArrayPredicate(ArrayPredicate predicate) {
+    //Do nothing
+  }
+
+  @Override
+  public void acceptUnaryPredicate(UnaryPredicate predicate) {
+    //Do nothing
+  }
+
+
+  // ----- accessors ---------------------------------------------------------
+
+  /**
+   * Get the properties.
+   *
+   * @return the properties
+   */
+  public Map<PropertyId, Object> getProperties() {
+    return properties;
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/RequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/RequestImpl.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/RequestImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/RequestImpl.java Mon Oct  8 01:37:59 2012
@@ -18,8 +18,8 @@
 
 package org.apache.ambari.api.controller.internal;
 
-import org.apache.ambari.api.controller.spi.PropertyId;
-import org.apache.ambari.api.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Request;
 
 import java.util.Collections;
 import java.util.HashSet;
@@ -31,21 +31,47 @@ import java.util.Set;
  */
 public class RequestImpl implements Request {
 
+  /**
+   * The property ids associated with this request.  Used for requests that
+   * get resource values.
+   */
   private final Set<PropertyId> propertyIds;
-  private final Set<Map<PropertyId, String>> properties;
 
-  public RequestImpl(Set<PropertyId> propertyIds, Set<Map<PropertyId, String>> properties) {
-    this.propertyIds = propertyIds == null ? Collections.unmodifiableSet(new HashSet<PropertyId>()) : Collections.unmodifiableSet(propertyIds);
-    this.properties = properties == null ? Collections.unmodifiableSet(new HashSet<Map<PropertyId, String>>()) : Collections.unmodifiableSet(properties);
+  /**
+   * The properties associated with this request.  Used for requests that create
+   * resources or update resource values.
+   */
+  private final Set<Map<PropertyId, Object>> properties;
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a request.
+   *
+   * @param propertyIds  the property ids associated with the request; may be null
+   * @param properties   the properties associated with the request; may be null
+   */
+  public RequestImpl(Set<PropertyId> propertyIds, Set<Map<PropertyId, Object>> properties) {
+    this.propertyIds = propertyIds == null ?
+        Collections.unmodifiableSet(new HashSet<PropertyId>()) :
+        Collections.unmodifiableSet(propertyIds);
+
+    this.properties = properties == null ?
+        Collections.unmodifiableSet(new HashSet<Map<PropertyId, Object>>()) :
+        Collections.unmodifiableSet(properties);
   }
 
+
+  // ----- Request -----------------------------------------------------------
+
   @Override
   public Set<PropertyId> getPropertyIds() {
     return propertyIds;
   }
 
   @Override
-  public Set<Map<PropertyId, String>> getProperties() {
+  public Set<Map<PropertyId, Object>> getProperties() {
     return properties;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceImpl.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceImpl.java Mon Oct  8 01:37:59 2012
@@ -18,23 +18,42 @@
 
 package org.apache.ambari.api.controller.internal;
 
-import org.apache.ambari.api.controller.spi.PropertyId;
-import org.apache.ambari.api.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.Resource;
 
 import java.util.HashMap;
 import java.util.Map;
 
 /**
- * Default resource implementation.
+ * Simple resource implementation.
  */
 public class ResourceImpl implements Resource {
+
+  /**
+   * The resource type.
+   */
   private final Type type;
+
+  /**
+   * The map of categories/properties for this resource.
+   */
   private final Map<String, Map<String, String>> categories = new HashMap<String, Map<String, String>>();
 
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a resource of the given type.
+   *
+   * @param type  the resource type
+   */
   public ResourceImpl(Type type) {
     this.type = type;
   }
 
+
+  // ----- Resource ----------------------------------------------------------
+
   @Override
   public Type getType() {
     return type;
@@ -90,6 +109,9 @@ public class ResourceImpl implements Res
     return null;
   }
 
+
+  // ----- Object overrides --------------------------------------------------
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceProviderImpl.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceProviderImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/ResourceProviderImpl.java Mon Oct  8 01:37:59 2012
@@ -18,201 +18,646 @@
 
 package org.apache.ambari.api.controller.internal;
 
-import org.apache.ambari.api.controller.spi.ManagementController;
-import org.apache.ambari.api.controller.spi.Predicate;
-import org.apache.ambari.api.controller.spi.PropertyId;
-import org.apache.ambari.api.controller.spi.Request;
-import org.apache.ambari.api.controller.spi.Resource;
-import org.apache.ambari.api.controller.spi.ResourceProvider;
+import org.apache.ambari.api.controller.utilities.PredicateHelper;
+import org.apache.ambari.api.controller.utilities.Properties;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.ClusterRequest;
+import org.apache.ambari.server.controller.ClusterResponse;
+import org.apache.ambari.server.controller.HostRequest;
+import org.apache.ambari.server.controller.HostResponse;
+import org.apache.ambari.server.controller.ServiceComponentHostRequest;
+import org.apache.ambari.server.controller.ServiceComponentHostResponse;
+import org.apache.ambari.server.controller.ServiceComponentRequest;
+import org.apache.ambari.server.controller.ServiceComponentResponse;
+import org.apache.ambari.server.controller.ServiceRequest;
+import org.apache.ambari.server.controller.ServiceResponse;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.spi.Schema;
 
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
+ * Basic resource provider implementation that maps to a management controller.
  */
 public abstract class ResourceProviderImpl implements ResourceProvider {
 
-  protected final Set<PropertyId> propertyIds;
-
-  private final ManagementController managementController;
-
-  private ResourceProviderImpl(Set<PropertyId> propertyIds, ManagementController managementController) {
-    this.propertyIds = propertyIds;
+  /**
+   * The list of property providers for this provider's resource type.
+   */
+  private final List<PropertyProvider> propertyProviders;
+
+  /**
+   * The set of property ids supported by this resource provider.
+   */
+  private final Set<PropertyId> propertyIds;
+
+  /**
+   * The management controller to delegate to.
+   */
+  private final AmbariManagementController managementController;
+
+  /**
+   * The schema for this provider's resource type.
+   */
+  private final Schema schema;
+
+
+  // ----- Property ID constants ---------------------------------------------
+
+  // Clusters
+  private static final PropertyId CLUSTER_ID_PROPERTY_ID      = Properties.getPropertyId("cluster_id", "Clusters");
+  private static final PropertyId CLUSTER_NAME_PROPERTY_ID    = Properties.getPropertyId("cluster_name", "Clusters");
+  private static final PropertyId CLUSTER_VERSION_PROPERTY_ID = Properties.getPropertyId("version", "Clusters");
+  // Services
+  private static final PropertyId SERVICE_CLUSTER_NAME_PROPERTY_ID  = Properties.getPropertyId("cluster_name", "ServiceInfo");
+  private static final PropertyId SERVICE_SERVICE_NAME_PROPERTY_ID  = Properties.getPropertyId("service_name", "ServiceInfo");
+  private static final PropertyId SERVICE_SERVICE_STATE_PROPERTY_ID = Properties.getPropertyId("state", "ServiceInfo");
+  // Components
+  private static final PropertyId COMPONENT_CLUSTER_NAME_PROPERTY_ID   = Properties.getPropertyId("cluster_name", "ServiceComponentInfo");
+  private static final PropertyId COMPONENT_SERVICE_NAME_PROPERTY_ID   = Properties.getPropertyId("service_name", "ServiceComponentInfo");
+  private static final PropertyId COMPONENT_COMPONENT_NAME_PROPERTY_ID = Properties.getPropertyId("service_name", "ServiceComponentInfo");
+  private static final PropertyId COMPONENT_STATE_PROPERTY_ID          = Properties.getPropertyId("state", "ServiceComponentInfo");
+  // Hosts
+  private static final PropertyId HOST_CLUSTER_NAME_PROPERTY_ID = Properties.getPropertyId("cluster_name", "Hosts");
+  private static final PropertyId HOST_NAME_PROPERTY_ID         = Properties.getPropertyId("host_name", "Hosts");
+  private static final PropertyId HOST_IP_PROPERTY_ID           = Properties.getPropertyId("ip", "Hosts");
+  private static final PropertyId HOST_TOTAL_MEM_PROPERTY_ID    = Properties.getPropertyId("total_mem", "Hosts");
+  private static final PropertyId HOST_CPU_COUNT_PROPERTY_ID    = Properties.getPropertyId("cpu_count", "Hosts");
+  private static final PropertyId HOST_OS_ARCH_PROPERTY_ID      = Properties.getPropertyId("os_arch", "Hosts");
+  private static final PropertyId HOST_OS_TYPE_PROPERTY_ID      = Properties.getPropertyId("os_type", "Hosts");
+  // Host Components
+  private static final PropertyId HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID   = Properties.getPropertyId("cluster_name", "HostRoles");
+  private static final PropertyId HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID   = Properties.getPropertyId("service_name", "HostRoles");
+  private static final PropertyId HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = Properties.getPropertyId("service_name", "HostRoles");
+  private static final PropertyId HOST_COMPONENT_HOST_NAME_PROPERTY_ID      = Properties.getPropertyId("host_name", "HostRoles");
+  private static final PropertyId HOST_COMPONENT_STATE_PROPERTY_ID          = Properties.getPropertyId("state", "HostRoles");
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a  new resource provider for the given management controller.
+   *
+   * @param propertyIds           the property ids
+   * @param managementController  the management controller
+   */
+  private ResourceProviderImpl(List<PropertyProvider> propertyProviders,
+                               Set<PropertyId> propertyIds,
+                               Map<Resource.Type, PropertyId> keyPropertyIds,
+                               AmbariManagementController managementController) {
+    this.propertyProviders    = propertyProviders;
+    this.propertyIds          = propertyIds;
     this.managementController = managementController;
+    this.schema               = new SchemaImpl(this, keyPropertyIds);
   }
 
+
+  // ----- ResourceProvider --------------------------------------------------
+
   @Override
   public Set<PropertyId> getPropertyIds() {
     return propertyIds;
   }
 
-  public ManagementController getManagementController() {
+  @Override
+  public List<PropertyProvider> getPropertyProviders() {
+    return propertyProviders;
+  }
+
+  @Override
+  public Schema getSchema() {
+    return schema;
+  }
+
+
+  // ----- accessors ---------------------------------------------------------
+
+  /**
+   * Get the associated management controller.
+   *
+   * @return the associated management controller
+   */
+  public AmbariManagementController getManagementController() {
     return managementController;
   }
 
-  public static ResourceProvider getResourceProvider(Resource.Type type, Set<PropertyId> propertyIds, ManagementController managementController)  {
 
+  // ----- utility methods ---------------------------------------------------
+
+  /**
+   * Get a map of property values from a given predicate.
+   *
+   * @param predicate  the predicate
+   *
+   * @return the map of properties
+   */
+  private static Map<PropertyId, Object> getProperties(Predicate predicate) {
+    PropertyPredicateVisitor visitor = new PropertyPredicateVisitor();
+    PredicateHelper.visit(predicate, visitor);
+    return visitor.getProperties();
+  }
+
+  /**
+   * Transfer property values from one map to another for the given list of property ids.
+   *
+   * @param to           the target map
+   * @param from         the source map
+   * @param propertyIds  the list of property ids
+   */
+  private static void setProperties(Map<PropertyId, Object> to, Map<PropertyId, Object> from, PropertyId ... propertyIds) {
+    for (PropertyId propertyId : propertyIds) {
+      if (from.containsKey(propertyId)) {
+        to.put(propertyId, from.get(propertyId));
+      }
+    }
+  }
+
+  /**
+   * Set a string property value on the given resource for the given id and value.
+   * Make sure that the id is in the given set of requested ids.
+   *
+   * @param resource      the resource
+   * @param propertyId    the property id
+   * @param value         the value to set
+   * @param requestedIds  the requested set of property ids
+   */
+  private static void setResourceProperty(Resource resource, PropertyId propertyId, String value, Set<PropertyId> requestedIds) {
+    if (requestedIds.contains(propertyId)) {
+      resource.setProperty(propertyId, value);
+    }
+  }
+
+  /**
+   * Set a long property value on the given resource for the given id and value.
+   * Make sure that the id is in the given set of requested ids.
+   *
+   * @param resource      the resource
+   * @param propertyId    the property id
+   * @param value         the value to set
+   * @param requestedIds  the requested set of property ids
+   */
+  private static void setResourceProperty(Resource resource, PropertyId propertyId, Long value, Set<PropertyId> requestedIds) {
+    if (requestedIds.contains(propertyId)) {
+      resource.setProperty(propertyId, value);
+    }
+  }
+
+  /**
+   * Set a integer property value on the given resource for the given id and value.
+   * Make sure that the id is in the given set of requested ids.
+   *
+   * @param resource      the resource
+   * @param propertyId    the property id
+   * @param value         the value to set
+   * @param requestedIds  the requested set of property ids
+   */
+  private static void setResourceProperty(Resource resource, PropertyId propertyId, Integer value, Set<PropertyId> requestedIds) {
+    if (requestedIds.contains(propertyId)) {
+      resource.setProperty(propertyId, value);
+    }
+  }
+
+  /**
+   * Factory method for obtaining a resource provider based on a given type and management controller.
+   *
+   * @param type                  the resource type
+   * @param propertyIds           the property ids
+   * @param managementController  the management controller
+   *
+   * @return a new resource provider
+   */
+  public static ResourceProvider getResourceProvider(Resource.Type type,
+                                                     List<PropertyProvider> propertyProviders,
+                                                     Set<PropertyId> propertyIds,
+                                                     Map<Resource.Type, PropertyId> keyPropertyIds,
+                                                     AmbariManagementController managementController) {
     switch (type) {
       case Cluster:
-        return new ClusterResourceProvider(propertyIds, managementController);
+        return new ClusterResourceProvider(propertyProviders, propertyIds, keyPropertyIds, managementController);
       case Service:
-        return new ServiceResourceProvider(propertyIds, managementController);
+        return new ServiceResourceProvider(propertyProviders, propertyIds, keyPropertyIds, managementController);
       case Component:
-        return new ComponentResourceProvider(propertyIds, managementController);
+        return new ComponentResourceProvider(propertyProviders, propertyIds, keyPropertyIds, managementController);
       case Host:
-        return new HostResourceProvider(propertyIds, managementController);
+        return new HostResourceProvider(propertyProviders, propertyIds, keyPropertyIds, managementController);
       case HostComponent:
-        return new HostComponentResourceProvider(propertyIds, managementController);
+        return new HostComponentResourceProvider(propertyProviders, propertyIds, keyPropertyIds, managementController);
     }
     throw new IllegalArgumentException("Unknown type " + type);
   }
 
-  protected Request getRequest(Request request) {
-    Set<PropertyId> propertyIds = new HashSet<PropertyId>(request.getPropertyIds());
-    if (propertyIds.size() == 0) {
-      request = new RequestImpl(this.propertyIds, null);
-    }
-    return request;
-  }
+
+  // ------ ClusterResourceProvider inner class ------------------------------
 
   private static class ClusterResourceProvider extends ResourceProviderImpl{
 
-    private ClusterResourceProvider(Set<PropertyId> propertyIds, ManagementController managementController) {
-      super(propertyIds, managementController);
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param managementController  the management controller
+     */
+    private ClusterResourceProvider(List<PropertyProvider> propertyProviders, Set<PropertyId> propertyIds, Map<Resource.Type, PropertyId> keyPropertyIds, AmbariManagementController managementController) {
+      super(propertyProviders, propertyIds, keyPropertyIds, managementController);
     }
 
+// ----- ResourceProvider ------------------------------------------------
+
     @Override
-    public void createResources(Request request) {
-      getManagementController().createClusters(request);
+    public void createResources(Request request) throws AmbariException {
+
+      for (Map<PropertyId, Object> properties : request.getProperties()) {
+        getManagementController().createCluster(getRequest(properties));
+      }
     }
 
     @Override
-    public Set<Resource> getResources(Request request, Predicate predicate) {
-      request = getRequest(request);
-      return getManagementController().getClusters(request, predicate);
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId> requestedIds   = request.getPropertyIds();
+      ClusterRequest  clusterRequest = getRequest(getProperties(predicate));
+
+      Set<ClusterResponse> responses = getManagementController().getClusters(clusterRequest);
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (ClusterResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Cluster);
+        setResourceProperty(resource, CLUSTER_ID_PROPERTY_ID, response.getClusterId(), requestedIds);
+        setResourceProperty(resource, CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+      }
+      return resources;
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) {
-      getManagementController().updateClusters(request, predicate);
+    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+      // get the cluster request properties from the given request
+      Map<PropertyId, Object> properties = request.getProperties().iterator().next();
+      // get the id for the cluster request from the predicate
+      setProperties(properties, getProperties(predicate), CLUSTER_ID_PROPERTY_ID);
+
+      ClusterRequest clusterRequest = getRequest(properties);
+      getManagementController().updateCluster(clusterRequest);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) {
-      getManagementController().deleteClusters(predicate);
+    public void deleteResources(Predicate predicate) throws AmbariException {
+      ClusterRequest clusterRequest = getRequest(getProperties(predicate));
+      getManagementController().deleteCluster(clusterRequest);
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    /**
+     * Get a cluster request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the cluster request object
+     */
+    private ClusterRequest getRequest(Map<PropertyId, Object> properties) {
+
+      return new ClusterRequest(
+          (Long) properties.get(CLUSTER_ID_PROPERTY_ID),
+          (String) properties.get(CLUSTER_NAME_PROPERTY_ID),
+          (String) properties.get(CLUSTER_VERSION_PROPERTY_ID),
+          null);  // TODO : host names
     }
   }
 
+  // ------ ServiceResourceProvider inner class ------------------------------
+
   private static class ServiceResourceProvider extends ResourceProviderImpl{
 
-    private ServiceResourceProvider(Set<PropertyId> propertyIds, ManagementController managementController) {
-      super(propertyIds, managementController);
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param managementController  the management controller
+     */
+    private ServiceResourceProvider(List<PropertyProvider> propertyProviders, Set<PropertyId> propertyIds, Map<Resource.Type, PropertyId> keyPropertyIds, AmbariManagementController managementController) {
+      super(propertyProviders, propertyIds, keyPropertyIds, managementController);
     }
 
+    // ----- ResourceProvider ------------------------------------------------
+
     @Override
-    public void createResources(Request request) {
-      getManagementController().createServices(request);
+    public void createResources(Request request) throws AmbariException {
+      for (Map<PropertyId, Object> properties : request.getProperties()) {
+        getManagementController().createService(getRequest(properties));
+      }
     }
 
     @Override
-    public Set<Resource> getResources(Request request, Predicate predicate) {
-      request = getRequest(request);
-      return getManagementController().getServices(request, predicate);
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId> requestedIds   = request.getPropertyIds();
+      ServiceRequest  serviceRequest = getRequest(getProperties(predicate));
+
+      Set<ServiceResponse> responses = getManagementController().getServices(serviceRequest);
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (ServiceResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Service);
+//        setResourceProperty(resource, SERVICE_CLUSTER_ID_PROPERTY_ID, response.getClusterId(), requestedIds);
+        setResourceProperty(resource, SERVICE_CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+        setResourceProperty(resource, SERVICE_SERVICE_NAME_PROPERTY_ID, response.getServiceName(), requestedIds);
+//        setResourceProperty(resource, SERVICE_VERSION_PROPERTY_ID, response.getCurrentStackVersion(), requestedIds);
+      }
+      return resources;
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) {
-      getManagementController().updateServices(request, predicate);
+    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+      // get the service request properties from the given request
+      Map<PropertyId, Object> properties = request.getProperties().iterator().next();
+      // get the pk for the service request from the predicate
+      setProperties(properties, getProperties(predicate),
+          SERVICE_CLUSTER_NAME_PROPERTY_ID, SERVICE_SERVICE_NAME_PROPERTY_ID);
+
+      ServiceRequest serviceRequest = getRequest(properties);
+      getManagementController().updateService(serviceRequest);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) {
-      getManagementController().deleteServices(predicate);
+    public void deleteResources(Predicate predicate) throws AmbariException {
+      ServiceRequest serviceRequest = getRequest(getProperties(predicate));
+      getManagementController().deleteService(serviceRequest);
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    /**
+     * Get a service request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the service request object
+     */
+    private ServiceRequest getRequest(Map<PropertyId, Object> properties) {
+      return new ServiceRequest(
+          (String) properties.get(SERVICE_CLUSTER_NAME_PROPERTY_ID),
+          (String) properties.get(SERVICE_SERVICE_NAME_PROPERTY_ID),
+          null,
+          (String) properties.get(SERVICE_SERVICE_STATE_PROPERTY_ID));
     }
   }
 
+  // ------ ComponentResourceProvider inner class ----------------------------
+
   private static class ComponentResourceProvider extends ResourceProviderImpl{
 
-    private ComponentResourceProvider(Set<PropertyId> propertyIds, ManagementController managementController) {
-      super(propertyIds, managementController);
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param managementController  the management controller
+     */
+    private ComponentResourceProvider(List<PropertyProvider> propertyProviders, Set<PropertyId> propertyIds, Map<Resource.Type, PropertyId> keyPropertyIds, AmbariManagementController managementController) {
+      super(propertyProviders, propertyIds, keyPropertyIds, managementController);
     }
 
+    // ----- ResourceProvider ------------------------------------------------
+
     @Override
-    public void createResources(Request request) {
-      getManagementController().createComponents(request);
+    public void createResources(Request request) throws AmbariException {
+      for (Map<PropertyId, Object> properties : request.getProperties()) {
+        getManagementController().createComponent(getRequest(properties));
+      }
     }
 
     @Override
-    public Set<Resource> getResources(Request request, Predicate predicate) {
-      request = getRequest(request);
-      return getManagementController().getComponents(request, predicate);
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId>          requestedIds            = request.getPropertyIds();
+      ServiceComponentRequest  serviceComponentRequest = getRequest(getProperties(predicate));
+
+      Set<ServiceComponentResponse> responses = getManagementController().getComponents(serviceComponentRequest);
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (ServiceComponentResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Component);
+//        setResourceProperty(resource, COMPONENT_CLUSTER_ID_PROPERTY_ID, response.getClusterId(), requestedIds);
+        setResourceProperty(resource, COMPONENT_CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+        setResourceProperty(resource, COMPONENT_SERVICE_NAME_PROPERTY_ID, response.getServiceName(), requestedIds);
+        setResourceProperty(resource, COMPONENT_COMPONENT_NAME_PROPERTY_ID, response.getComponentName(), requestedIds);
+//        setResourceProperty(resource, COMPONENT_VERSION_PROPERTY_ID, response.getCurrentStackVersion(), requestedIds);
+      }
+      return resources;
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) {
-      getManagementController().updateComponents(request, predicate);
+    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+      // get the component request properties from the given request
+      Map<PropertyId, Object> properties = request.getProperties().iterator().next();
+      // get the pk for the service request from the predicate
+      setProperties(properties, getProperties(predicate),
+          COMPONENT_CLUSTER_NAME_PROPERTY_ID, COMPONENT_SERVICE_NAME_PROPERTY_ID, COMPONENT_COMPONENT_NAME_PROPERTY_ID);
+
+      ServiceComponentRequest serviceComponentRequest = getRequest(properties);
+      getManagementController().updateComponent(serviceComponentRequest);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) {
-      getManagementController().deleteComponents(predicate);
+    public void deleteResources(Predicate predicate) throws AmbariException {
+      ServiceComponentRequest serviceComponentRequest = getRequest(getProperties(predicate));
+      getManagementController().deleteComponent(serviceComponentRequest);
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    /**
+     * Get a component request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the component request object
+     */
+    private ServiceComponentRequest getRequest(Map<PropertyId, Object> properties) {
+      return new ServiceComponentRequest(
+          (String) properties.get(COMPONENT_CLUSTER_NAME_PROPERTY_ID),
+          (String) properties.get(COMPONENT_SERVICE_NAME_PROPERTY_ID),
+          (String) properties.get(COMPONENT_COMPONENT_NAME_PROPERTY_ID),
+          null,
+          (String) properties.get(COMPONENT_STATE_PROPERTY_ID));
     }
   }
 
+  // ------ HostResourceProvider inner class ---------------------------------
+
   private static class HostResourceProvider extends ResourceProviderImpl{
 
-    private HostResourceProvider(Set<PropertyId> propertyIds, ManagementController managementController) {
-      super(propertyIds, managementController);
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param managementController  the management controller
+     */
+    private HostResourceProvider(List<PropertyProvider> propertyProviders, Set<PropertyId> propertyIds, Map<Resource.Type, PropertyId> keyPropertyIds, AmbariManagementController managementController) {
+      super(propertyProviders, propertyIds, keyPropertyIds, managementController);
     }
 
+    // ----- ResourceProvider ------------------------------------------------
+
     @Override
-    public void createResources(Request request) {
-      getManagementController().createHosts(request);
+    public void createResources(Request request) throws AmbariException {
+      for (Map<PropertyId, Object> properties : request.getProperties()) {
+        getManagementController().createHost(getRequest(properties));
+      }
     }
 
     @Override
-    public Set<Resource> getResources(Request request, Predicate predicate) {
-      request = getRequest(request);
-      return getManagementController().getHosts(request, predicate);
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId> requestedIds = request.getPropertyIds();
+      HostRequest     hostRequest  = getRequest(getProperties(predicate));
+
+      Set<HostResponse> responses = getManagementController().getHosts(hostRequest);
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (HostResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Host);
+        // TODO : more than one cluster
+//        setResourceProperty(resource, HOST_CLUSTER_NAME_PROPERTY_ID, response.getClusterNames(), requestedIds);
+        setResourceProperty(resource, HOST_NAME_PROPERTY_ID, response.getHostname(), requestedIds);
+        setResourceProperty(resource, HOST_IP_PROPERTY_ID, response.getIpv4(), requestedIds);
+        setResourceProperty(resource, HOST_TOTAL_MEM_PROPERTY_ID, response.getTotalMemBytes(), requestedIds);
+        setResourceProperty(resource, HOST_CPU_COUNT_PROPERTY_ID, response.getCpuCount(), requestedIds);
+        setResourceProperty(resource, HOST_OS_ARCH_PROPERTY_ID, response.getOsArch(), requestedIds);
+        setResourceProperty(resource, HOST_OS_TYPE_PROPERTY_ID, response.getOsType(), requestedIds);
+        // TODO ...
+      }
+      return resources;
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) {
-      getManagementController().updateHosts(request, predicate);
+    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+      // get the host request properties from the given request
+      Map<PropertyId, Object> properties = request.getProperties().iterator().next();
+      // get the pk for the service request from the predicate
+      setProperties(properties, getProperties(predicate), HOST_CLUSTER_NAME_PROPERTY_ID);
+
+      HostRequest hostRequest = getRequest(properties);
+      getManagementController().updateHost(hostRequest);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) {
-      getManagementController().deleteHosts(predicate);
+    public void deleteResources(Predicate predicate) throws AmbariException {
+      HostRequest hostRequest = getRequest(getProperties(predicate));
+      getManagementController().deleteHost(hostRequest);
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    /**
+     * Get a component request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the component request object
+     */
+    private HostRequest getRequest(Map<PropertyId, Object> properties) {
+      return new HostRequest(
+          (String) properties.get(HOST_NAME_PROPERTY_ID),
+          // TODO : more than one cluster
+          Collections.singletonList((String) properties.get(HOST_CLUSTER_NAME_PROPERTY_ID)),
+          null);
     }
   }
 
+  // ------ HostComponentResourceProvider inner class ------------------------
+
   private static class HostComponentResourceProvider extends ResourceProviderImpl{
 
-    private HostComponentResourceProvider(Set<PropertyId> propertyIds, ManagementController managementController) {
-      super(propertyIds, managementController);
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param managementController  the management controller
+     */
+    private HostComponentResourceProvider(List<PropertyProvider> propertyProviders, Set<PropertyId> propertyIds, Map<Resource.Type, PropertyId> keyPropertyIds, AmbariManagementController managementController) {
+      super(propertyProviders, propertyIds, keyPropertyIds, managementController);
     }
 
+    // ----- ResourceProvider ------------------------------------------------
+
     @Override
-    public void createResources(Request request) {
-      getManagementController().createHostComponents(request);
+    public void createResources(Request request) throws AmbariException {
+      for (Map<PropertyId, Object> properties : request.getProperties()) {
+        getManagementController().createHostComponent(getRequest(properties));
+      }
     }
 
     @Override
-    public Set<Resource> getResources(Request request, Predicate predicate) {
-      request = getRequest(request);
-      return getManagementController().getHostComponents(request, predicate);
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId>             requestedIds         = request.getPropertyIds();
+      ServiceComponentHostRequest hostComponentRequest = getRequest(getProperties(predicate));
+
+      Set<ServiceComponentHostResponse> responses = getManagementController().getHostComponents(hostComponentRequest);
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (ServiceComponentHostResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+        setResourceProperty(resource, HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+        setResourceProperty(resource, HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID, response.getServiceName(), requestedIds);
+        setResourceProperty(resource, HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, response.getComponentName(), requestedIds);
+        setResourceProperty(resource, HOST_COMPONENT_HOST_NAME_PROPERTY_ID, response.getHostname(), requestedIds);
+        setResourceProperty(resource, HOST_COMPONENT_STATE_PROPERTY_ID, response.getLiveState(), requestedIds);
+      }
+      return resources;
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) {
-      getManagementController().updateHostComponents(request, predicate);
+    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+      // get the host request properties from the given request
+      Map<PropertyId, Object> properties = request.getProperties().iterator().next();
+      // get the pk for the service request from the predicate
+      setProperties(properties, getProperties(predicate),
+          HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID,
+          HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
+
+      ServiceComponentHostRequest hostComponentRequest = getRequest(properties);
+      getManagementController().updateHostComponent(hostComponentRequest);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) {
-      getManagementController().deleteHostComponents(predicate);
+    public void deleteResources(Predicate predicate) throws AmbariException {
+      ServiceComponentHostRequest clusterRequest = getRequest(getProperties(predicate));
+      getManagementController().deleteHostComponent(clusterRequest);
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    /**
+     * Get a component request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the component request object
+     */
+    private ServiceComponentHostRequest getRequest(Map<PropertyId, Object> properties) {
+      return new ServiceComponentHostRequest(
+          (String) properties.get(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID),
+          (String) properties.get(HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID),
+          (String) properties.get(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID),
+          (String) properties.get(HOST_COMPONENT_HOST_NAME_PROPERTY_ID),
+          null,
+          (String) properties.get(HOST_COMPONENT_STATE_PROPERTY_ID));
     }
   }
 }
-

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/SchemaImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/SchemaImpl.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/SchemaImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/internal/SchemaImpl.java Mon Oct  8 01:37:59 2012
@@ -18,11 +18,11 @@
 
 package org.apache.ambari.api.controller.internal;
 
-import org.apache.ambari.api.controller.spi.PropertyId;
-import org.apache.ambari.api.controller.spi.PropertyProvider;
-import org.apache.ambari.api.controller.spi.Resource;
-import org.apache.ambari.api.controller.spi.ResourceProvider;
-import org.apache.ambari.api.controller.spi.Schema;
+import org.apache.ambari.server.controller.spi.PropertyId;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.spi.Schema;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -31,21 +31,43 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * Default schema implementation.
+ * Simple schema implementation.
  */
 public class SchemaImpl implements Schema {
+  /**
+   * The associated resource provider.
+   */
   private final ResourceProvider resourceProvider;
+
+  /**
+   * The list of associated property providers.
+   */
   private final List<PropertyProvider> propertyProviders;
+
+  /**
+   * Key property mapping by resource type.
+   */
   private final Map<Resource.Type, PropertyId> keyPropertyIds;
 
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a new schema for the given providers.
+   *
+   * @param resourceProvider   the resource provider
+   * @param keyPropertyIds     the key property mapping
+   */
   public SchemaImpl(ResourceProvider resourceProvider,
-                    List<PropertyProvider> propertyProviders,
                     Map<Resource.Type, PropertyId> keyPropertyIds) {
     this.resourceProvider = resourceProvider;
-    this.propertyProviders = propertyProviders;
+    this.propertyProviders = resourceProvider.getPropertyProviders();
     this.keyPropertyIds = keyPropertyIds;
   }
 
+
+  // ----- Schema ------------------------------------------------------------
+
   @Override
   public PropertyId getKeyPropertyId(Resource.Type type) {
     return keyPropertyIds.get(type);
@@ -67,17 +89,10 @@ public class SchemaImpl implements Schem
     return categories;
   }
 
-  @Override
-  public ResourceProvider getResourceProvider() {
-    return resourceProvider;
-  }
 
-  @Override
-  public List<PropertyProvider> getPropertyProviders() {
-    return propertyProviders;
-  }
+  // ----- helper methods ----------------------------------------------------
 
-  public Set<PropertyId> getPropertyIds() {
+  private Set<PropertyId> getPropertyIds() {
     Set<PropertyId> propertyIds = new HashSet<PropertyId>(resourceProvider.getPropertyIds());
     for (PropertyProvider propertyProvider : propertyProviders) {
       propertyIds.addAll(propertyProvider.getPropertyIds());

Modified: incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/jdbc/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/jdbc/ConnectionFactory.java?rev=1395430&r1=1395429&r2=1395430&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/jdbc/ConnectionFactory.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-api/src/main/java/org/apache/ambari/api/controller/jdbc/ConnectionFactory.java Mon Oct  8 01:37:59 2012
@@ -22,8 +22,15 @@ import java.sql.Connection;
 import java.sql.SQLException;
 
 /**
- *
+ * Simple JDBC connection factory interface.
  */
 public interface ConnectionFactory {
+  /**
+   * Get a connection.
+   *
+   * @return the connection
+   *
+   * @throws SQLException thrown if the connection cannot be obtained
+   */
   public Connection getConnection() throws SQLException;
 }



Mime
View raw message