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/11/07 09:13:24 UTC

svn commit: r1406489 [4/19] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/ ambari-agent/conf/ ambari-agent/conf/unix/ ambari-agent/src/main/puppet/manifestloader/ ambari-agent/src/main/puppet/modules/configgenerator/manifests/ ambari-agen...

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostComponentService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostComponentService.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostComponentService.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostComponentService.java Wed Nov  7 08:13:12 2012
@@ -84,7 +84,7 @@ public class HostComponentService extend
   }
 
   /**
-   * Handles PUT /clusters/{clusterID}/hosts/{hostID}/host_components/{hostComponentID}
+   * Handles POST /clusters/{clusterID}/hosts/{hostID}/host_components/{hostComponentID}
    * Create a specific host_component.
    *
    * @param body              http body
@@ -94,18 +94,18 @@ public class HostComponentService extend
    *
    * @return host_component resource representation
    */
-  @PUT
+  @POST
   @Path("{hostComponentName}")
   @Produces("text/plain")
   public Response createHostComponent(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                                    @PathParam("hostComponentName") String hostComponentName) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT,
+    return handleRequest(headers, body, ui, Request.Type.POST,
         createResourceDefinition(hostComponentName, m_clusterName, m_hostName));
   }
 
   /**
-   * Handles POST /clusters/{clusterID}/hosts/{hostID}/host_components/{hostComponentID}
+   * Handles PUT /clusters/{clusterID}/hosts/{hostID}/host_components/{hostComponentID}
    * Updates a specific host_component.
    *
    * @param body              http body
@@ -113,19 +113,37 @@ public class HostComponentService extend
    * @param ui                uri info
    * @param hostComponentName host_component id
    *
-   * @return host_component resource representation
+   * @return information regarding updated host_component
    */
-  @POST
+  @PUT
   @Path("{hostComponentName}")
   @Produces("text/plain")
   public Response updateHostComponent(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                                       @PathParam("hostComponentName") String hostComponentName) {
 
-    return handleRequest(headers, body, ui, Request.Type.POST,
+    return handleRequest(headers, body, ui, Request.Type.PUT,
         createResourceDefinition(hostComponentName, m_clusterName, m_hostName));
   }
 
   /**
+   * Handles PUT /clusters/{clusterID}/hosts/{hostID}/host_components
+   * Updates multiple host_component resources.
+   *
+   * @param body              http body
+   * @param headers           http headers
+   * @param ui                uri info
+   *
+   * @return information regarding updated host_component resources
+   */
+  @PUT
+  @Produces("text/plain")
+  public Response updateHostComponents(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT,
+        createResourceDefinition(null, m_clusterName, m_hostName));
+  }
+
+  /**
    * Handles DELETE /clusters/{clusterID}/hosts/{hostID}/host_components/{hostComponentID}
    * Delete a specific host_component.
    *

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java Wed Nov  7 08:13:12 2012
@@ -18,21 +18,38 @@
 
 package org.apache.ambari.server.api.services;
 
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
 import org.apache.ambari.server.api.resources.HostResourceDefinition;
 import org.apache.ambari.server.api.resources.ResourceDefinition;
 
-import javax.ws.rs.*;
-import javax.ws.rs.core.*;
-
 /**
  * Service responsible for hosts resource requests.
  */
+@Path("/hosts/")
 public class HostService extends BaseService {
 
   /**
    * Parent cluster id.
    */
   private String m_clusterName;
+  
+  /**
+   * Constructor.
+   */
+  public HostService() {
+    m_clusterName = null;
+  }
 
   /**
    * Constructor.
@@ -77,7 +94,7 @@ public class HostService extends BaseSer
   }
 
   /**
-   * Handles PUT /clusters/{clusterID}/hosts/{hostID}
+   * Handles POST /clusters/{clusterID}/hosts/{hostID}
    * Create a specific host.
    *
    * @param body     http body
@@ -87,19 +104,18 @@ public class HostService extends BaseSer
    *
    * @return host resource representation
    */
-
-  @PUT
+  @POST
   @Path("{hostName}")
   @Produces("text/plain")
   public Response createHost(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                           @PathParam("hostName") String hostName) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT,
+    return handleRequest(headers, body, ui, Request.Type.POST,
         createResourceDefinition(hostName, m_clusterName));
   }
 
   /**
-   * Handles POST /clusters/{clusterID}/hosts/{hostID}
+   * Handles PUT /clusters/{clusterID}/hosts/{hostID}
    * Updates a specific host.
    *
    * @param body     http body
@@ -107,19 +123,37 @@ public class HostService extends BaseSer
    * @param ui       uri info
    * @param hostName host id
    *
-   * @return host resource representation
+   * @return information regarding updated host
    */
-  @POST
+  @PUT
   @Path("{hostName}")
   @Produces("text/plain")
   public Response updateHost(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                           @PathParam("hostName") String hostName) {
 
-    return handleRequest(headers, body, ui, Request.Type.POST,
+    return handleRequest(headers, body, ui, Request.Type.PUT,
         createResourceDefinition(hostName, m_clusterName));
   }
 
   /**
+   * Handles PUT /clusters/{clusterID}/hosts
+   * Updates multiple hosts.
+   *
+   * @param body     http body
+   * @param headers  http headers
+   * @param ui       uri info
+   *
+   * @return information regarding updated host
+   */
+  @PUT
+  @Produces("text/plain")
+  public Response updateHosts(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT,
+        createResourceDefinition(null, m_clusterName));
+  }
+
+  /**
    * Handles DELETE /clusters/{clusterID}/hosts/{hostID}
    * Deletes a specific host.
    *

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueImpl.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueImpl.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueImpl.java Wed Nov  7 08:13:12 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.api.services;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.WebApplicationException;
+
+import org.mortbay.jetty.Response;
+
+import com.google.inject.Singleton;
+
+@Singleton
+public class PersistKeyValueImpl {
+  Map<String, String> keyvalues = new HashMap<String, String>();
+  
+  public synchronized String getValue(String key) {
+    if (keyvalues.containsKey(key)) {
+      return keyvalues.get(key);
+    }
+    throw new WebApplicationException(Response.SC_NOT_FOUND);
+  }
+  
+  public synchronized void put(String key, String value) {
+    keyvalues.put(key, value);
+  }
+  
+  public synchronized Map<String, String> getAllKeyValues() {
+    Map<String, String> clone = new HashMap<String, String>(keyvalues);
+    return keyvalues;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueService.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueService.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueService.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,87 @@
+/**
+ * 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.api.services;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBException;
+
+import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
+import org.apache.ambari.server.utils.StageUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+
+import com.google.inject.Inject;
+
+@Path("/persist/")
+public class PersistKeyValueService {
+  private static PersistKeyValueImpl persistKeyVal;
+  private static Log LOG = LogFactory.getLog(PersistKeyValueService.class);
+
+  @Inject
+  public static void init(PersistKeyValueImpl instance) {
+    persistKeyVal = instance;
+  }
+
+  @POST
+  @Produces("text/plain")
+  public Response update(String keyValues,
+      @Context HttpServletRequest req)
+      throws WebApplicationException, InvalidStateTransitionException,
+      JsonGenerationException, JsonMappingException, JAXBException, IOException {
+    LOG.info("Received message from UI " + keyValues);
+    Map<String, String> keyValuesMap = StageUtils.fromJson(keyValues, Map.class);
+    /* Call into the heartbeat handler */
+
+    for (Map.Entry<String, String> keyValue: keyValuesMap.entrySet()) {
+      persistKeyVal.put(keyValue.getKey(), keyValue.getValue());
+    }
+    return Response.status(Response.Status.ACCEPTED).build();
+  }
+  
+  @GET
+  @Produces("text/plain")
+  @Path("{keyName}")
+  public String getKey( @PathParam("keyName") String keyName) {
+    LOG.info("Looking for keyName " + keyName);
+    return persistKeyVal.getValue(keyName);
+  }
+  
+  @GET
+  @Produces("text/plain")
+  public String getAllKeyValues() throws JsonGenerationException,
+    JsonMappingException, JAXBException, IOException {
+    Map<String, String> ret = persistKeyVal.getAllKeyValues();
+    String stringRet = StageUtils.jaxbToString(ret);
+    LOG.info("Returning " + stringRet);
+    return stringRet;
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistenceManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistenceManager.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistenceManager.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistenceManager.java Wed Nov  7 08:13:12 2012
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.api.services;
 
 import org.apache.ambari.server.api.resources.ResourceDefinition;
+import org.apache.ambari.server.controller.spi.RequestStatus;
 
 /**
  * Persistence manager which is responsible for persisting a resource state to the back end.
@@ -30,6 +31,8 @@ public interface PersistenceManager {
    *
    * @param resource  the resource to persist
    *
+   * @return the request state.
+   *
    */
-  public void persist(ResourceDefinition resource);
+  public RequestStatus persist(ResourceDefinition resource);
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java Wed Nov  7 08:13:12 2012
@@ -37,8 +37,8 @@ public interface Request {
    */
   public enum Type {
     GET,
-    PUT,
     POST,
+    PUT,
     DELETE
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java Wed Nov  7 08:13:12 2012
@@ -63,6 +63,11 @@ public class RequestImpl implements Requ
   private Type m_Type;
 
   /**
+   * Predicate operators.
+   */
+  private Pattern m_pattern = Pattern.compile("!=|>=|<=|=|>|<");
+
+  /**
    * Associated resource definition
    */
   private ResourceDefinition m_resourceDefinition;
@@ -116,19 +121,13 @@ public class RequestImpl implements Requ
 
     if (qsBegin == -1) return null;
 
-    Pattern pattern = Pattern.compile("!=|>=|<=|=|>|<");
-    String qs = uri.substring(qsBegin + 1);
-    String[] tokens = qs.split("&");
+    String[] tokens = uri.substring(qsBegin + 1).split("&");
 
     Set<Predicate> setPredicates = new HashSet<Predicate>();
     for (String outerToken : tokens) {
-      Matcher m = pattern.matcher(outerToken);
-      m.find();
-      String field = outerToken.substring(0, m.start());
-      if (! field.equals("fields")) {
-        int tokEnd = m.end();
-        String value = outerToken.substring(tokEnd);
-        setPredicates.add(createPredicate(field, m.group(), value));
+      if (outerToken != null &&  !outerToken.startsWith("fields")) {
+        setPredicates.add(outerToken.contains("|") ?
+            handleOrPredicate(outerToken) : createPredicate(outerToken));
       }
     }
 
@@ -206,15 +205,17 @@ public class RequestImpl implements Requ
 
   @Override
   public ResultPostProcessor getResultPostProcessor() {
-    return new ResultPostProcessorImpl(this);
+    //todo: Need to reconsider post processor creation and association with a resource type.
+    //todo: mutating operations return request resources which aren't children of all resources.
+    return getRequestType() == Type.GET ? new ResultPostProcessorImpl(this) : new NullPostProcessor();
   }
 
   @Override
   public PersistenceManager getPersistenceManager() {
     switch (getRequestType()) {
-      case PUT:
-        return new CreatePersistenceManager();
       case POST:
+        return new CreatePersistenceManager();
+      case PUT:
         return new UpdatePersistenceManager();
       case DELETE:
         return new DeletePersistenceManager();
@@ -225,8 +226,14 @@ public class RequestImpl implements Requ
     }
   }
 
-  private Predicate createPredicate(String field, String operator, String value) {
-    PropertyId propertyId = PropertyHelper.getPropertyId(field);
+  private Predicate createPredicate(String token) {
+
+    Matcher m = m_pattern.matcher(token);
+    m.find();
+
+    PropertyId propertyId = PropertyHelper.getPropertyId(token.substring(0, m.start()));
+    String     value      = token.substring(m.end());
+    String     operator   = m.group();
 
     if (operator.equals("=")) {
       return new EqualsPredicate(propertyId, value);
@@ -245,7 +252,24 @@ public class RequestImpl implements Requ
     }
   }
 
+  private Predicate handleOrPredicate(String predicate) {
+    Set<Predicate> setPredicates = new HashSet<Predicate>();
+    String[] tokens = predicate.split("\\|");
+    for (String tok : tokens) {
+      setPredicates.add(createPredicate(tok));
+    }
+
+    return new OrPredicate(setPredicates.toArray(new BasePredicate[setPredicates.size()]));
+  }
+
   private  RequestBodyParser getHttpBodyParser() {
     return new JsonPropertyParser();
   }
+
+  private class NullPostProcessor implements ResultPostProcessor {
+    @Override
+    public void process(Result result) {
+      //no-op
+    }
+  }
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,109 @@
+/**
+ * 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.api.services;
+
+
+import org.apache.ambari.server.api.resources.RequestResourceDefinition;
+import org.apache.ambari.server.api.resources.ResourceDefinition;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+
+/**
+ * Service responsible for request resource requests.
+ */
+public class RequestService extends BaseService {
+  /**
+   * Parent cluster name.
+   */
+  private String m_clusterName;
+
+
+  /**
+   * Constructor.
+   *
+   * @param clusterName cluster id
+   */
+  public RequestService(String clusterName) {
+    m_clusterName = clusterName;
+  }
+
+  /**
+   * Handles URL: /clusters/{clusterID}/requests/{requestID}
+   * Get a specific request.
+   *
+   * @param headers    http headers
+   * @param ui         uri info
+   * @param requestId  request id
+   *
+   * @return request resource representation
+   */
+  @GET
+  @Path("{requestId}")
+  @Produces("text/plain")
+  public Response getRequest(@Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("requestId") String requestId) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createResourceDefinition(requestId, m_clusterName));
+  }
+
+  /**
+   * Handles URL: /clusters/{clusterId}/requests
+   * Get all requests for a cluster.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   *
+   * @return request collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getRequests(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createResourceDefinition(null, m_clusterName));
+  }
+
+  /**
+   * Gets the tasks sub-resource.
+   */
+  @Path("{requestId}/tasks")
+  public TaskService getTaskHandler(@PathParam("requestId") String requestId) {
+    return new TaskService(m_clusterName, requestId);
+  }
+
+  /**
+   * Create a request resource definition.
+   *
+   * @param requestId    request id
+   * @param clusterName  cluster name
+   *
+   * @return a request resource definition
+   */
+  ResourceDefinition createResourceDefinition(String requestId, String clusterName) {
+    return new RequestResourceDefinition(requestId, clusterName);
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResponseFactory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResponseFactory.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResponseFactory.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResponseFactory.java Wed Nov  7 08:13:12 2012
@@ -27,11 +27,25 @@ public class ResponseFactory {
   /**
    * Create a response from a provided result.
    *
-   * @param result  the result to wrap
+   * @param requestType  request type
+   * @param result       the result to wrap
+   * @param synchronous  if the request has been handled synchronously
    *
    * @return a new jax-rs Response instance for the provided result
    */
-  public Response createResponse(Object result) {
-    return Response.ok(result).build();
+  public Response createResponse(Request.Type requestType, Object result, boolean synchronous) {
+
+    int status = 200;
+
+    if (synchronous) {
+      if (requestType == Request.Type.POST) {
+        //todo: for now not providing a url for create
+        status = 201;
+      }
+    } else {
+      status = 202;
+    }
+
+    return Response.status(status).entity(result).build();
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Result.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Result.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Result.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Result.java Wed Nov  7 08:13:12 2012
@@ -32,4 +32,12 @@ public interface Result {
    * @return the results of the request a a Tree structure
    */
   public TreeNode<Resource> getResultTree();
+
+  /**
+   * Determine whether the request was handle synchronously.
+   * If the request is synchronous, all work was completed prior to returning.
+   *
+   * @return true if the request was synchronous, false if it was asynchronous
+   */
+  public boolean isSynchronous();
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResultImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResultImpl.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResultImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ResultImpl.java Wed Nov  7 08:13:12 2012
@@ -30,14 +30,27 @@ import org.apache.ambari.server.api.util
 public class ResultImpl implements Result {
 
   /**
+   * Whether the request was handled synchronously.
+   */
+  private boolean m_synchronous;
+
+  /**
    * Tree structure which holds the results
    */
   private TreeNode<Resource> m_tree = new TreeNodeImpl<Resource>(null, null, null);
 
+  public ResultImpl(boolean synchronous) {
+    m_synchronous = synchronous;
+  }
 
   @Override
   public TreeNode<Resource> getResultTree() {
     return m_tree;
   }
+
+  @Override
+  public boolean isSynchronous() {
+    return m_synchronous;
+  }
 }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java Wed Nov  7 08:13:12 2012
@@ -77,7 +77,7 @@ public class ServiceService extends Base
   }
 
   /**
-   * Handles: PUT /clusters/{clusterId}/services/{serviceId}
+   * Handles: POST /clusters/{clusterId}/services/{serviceId}
    * Create a specific service.
    *
    * @param body        http body
@@ -86,18 +86,35 @@ public class ServiceService extends Base
    * @param serviceName service id
    * @return information regarding the created service
    */
-  @PUT
+  @POST
   @Path("{serviceName}")
   @Produces("text/plain")
   public Response createService(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("serviceName") String serviceName) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT,
+    return handleRequest(headers, body, ui, Request.Type.POST,
         createResourceDefinition(serviceName, m_clusterName));
   }
 
   /**
-   * Handles: POST /clusters/{clusterId}/services/{serviceId}
+   * Handles: POST /clusters/{clusterId}/services
+   * Create multiple services.
+   *
+   * @param body        http body
+   * @param headers     http headers
+   * @param ui          uri info
+   * @return information regarding the created services
+   */
+  @POST
+  @Produces("text/plain")
+  public Response createServices(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+
+    return handleRequest(headers, body, ui, Request.Type.POST,
+        createResourceDefinition(null, m_clusterName));
+  }
+
+  /**
+   * Handles: PUT /clusters/{clusterId}/services/{serviceId}
    * Update a specific service.
    *
    * @param body        http body
@@ -106,13 +123,29 @@ public class ServiceService extends Base
    * @param serviceName service id
    * @return information regarding the updated service
    */
-  @POST
+  @PUT
   @Path("{serviceName}")
   @Produces("text/plain")
   public Response updateService(String body, @Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("serviceName") String serviceName) {
 
-    return handleRequest(headers, body, ui, Request.Type.POST, createResourceDefinition(serviceName, m_clusterName));
+    return handleRequest(headers, body, ui, Request.Type.PUT, createResourceDefinition(serviceName, m_clusterName));
+  }
+
+  /**
+   * Handles: PUT /clusters/{clusterId}/services
+   * Update multiple services.
+   *
+   * @param body        http body
+   * @param headers     http headers
+   * @param ui          uri info
+   * @return information regarding the updated service
+   */
+  @PUT
+  @Produces("text/plain")
+  public Response updateServices(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT, createResourceDefinition(null, m_clusterName));
   }
 
   /**
@@ -144,12 +177,24 @@ public class ServiceService extends Base
 
     return new ComponentService(m_clusterName, serviceName);
   }
+  
+  /**
+   * Get the components sub-resource.
+   *
+   * @param serviceName service id
+   * @return the action service
+   */
+  @Path("{serviceName}/actions")
+  public ActionService getActionHandler(@PathParam("serviceName") String serviceName) {
+    return new ActionService(m_clusterName, serviceName);
+  }
 
   /**
    * Create a service resource definition.
    *
-   * @param serviceName host name
-   * @param clusterName cluster name
+   * @param serviceName  service name
+   * @param clusterName  cluster name
+   *
    * @return a service resource definition
    */
   ResourceDefinition createResourceDefinition(String serviceName, String clusterName) {

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/TaskService.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,106 @@
+/**
+ * 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.api.services;
+
+import org.apache.ambari.server.api.resources.ResourceDefinition;
+import org.apache.ambari.server.api.resources.TaskResourceDefinition;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+/**
+ * Service responsible for task resource requests.
+ */
+public class TaskService extends BaseService {
+  /**
+   * Parent cluster id.
+   */
+  private String m_clusterName;
+
+  /**
+   * Parent request id.
+   */
+  private String m_requestId;
+
+  /**
+   * Constructor.
+   *
+   * @param clusterName  cluster id
+   * @param requestId    request id
+   */
+  public TaskService(String clusterName, String requestId) {
+    m_clusterName = clusterName;
+    m_requestId = requestId;
+  }
+
+  /**
+   * Handles GET: /clusters/{clusterID}/requests/{requestID}/tasks/{taskID}
+   * Get a specific task.
+   *
+   * @param headers  http headers
+   * @param ui       uri info
+   * @param taskId   component id
+   *
+   * @return a task resource representation
+   */
+  @GET
+  @Path("{taskId}")
+  @Produces("text/plain")
+  public Response getTask(@Context HttpHeaders headers, @Context UriInfo ui,
+                          @PathParam("taskId") String taskId) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createResourceDefinition(taskId, m_clusterName, m_requestId));
+  }
+
+  /**
+   * Handles GET: /clusters/{clusterID}/requests/{requestID}/tasks
+   * Get all tasks for a request.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   *
+   * @return task collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getComponents(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createResourceDefinition(null, m_clusterName, m_requestId));
+  }
+
+  /**
+   * Create a task resource definition.
+   *
+   * @param clusterName  cluster name
+   * @param requestId    request id
+   * @param taskId       task id
+   *
+   * @return a task resource definition
+   */
+  ResourceDefinition createResourceDefinition(String clusterName, String requestId, String taskId) {
+    return new TaskResourceDefinition(clusterName, requestId, taskId);
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/UpdatePersistenceManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/UpdatePersistenceManager.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/UpdatePersistenceManager.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/UpdatePersistenceManager.java Wed Nov  7 08:13:12 2012
@@ -21,6 +21,7 @@ package org.apache.ambari.server.api.ser
 
 import org.apache.ambari.server.api.resources.ResourceDefinition;
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.spi.RequestStatus;
 
 
 /**
@@ -28,10 +29,10 @@ import org.apache.ambari.server.AmbariEx
  */
 public class UpdatePersistenceManager extends BasePersistenceManager {
   @Override
-  public void persist(ResourceDefinition resource) {
+  public RequestStatus persist(ResourceDefinition resource) {
     try {
-      getClusterController().updateResources(resource.getType(), createControllerRequest(resource.getProperties()),
-          resource.getQuery().getInternalPredicate());
+      return getClusterController().updateResources(resource.getType(), createControllerRequest(
+          resource.getProperties()), resource.getQuery().getInternalPredicate());
     } catch (AmbariException e) {
       //todo: handle exception
       throw new RuntimeException("Update of resource failed: " + e, e);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java Wed Nov  7 08:13:12 2012
@@ -32,7 +32,6 @@ import java.util.Map;
  * JSON parser which parses a JSON string into a map of properties and values.
  */
 public class JsonPropertyParser implements RequestBodyParser {
-  //todo: change value type to String when it is supported in back end
   private Map<PropertyId, String> m_properties = new HashMap<PropertyId, String>();
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BootStrapImpl.java Wed Nov  7 08:13:12 2012
@@ -132,14 +132,14 @@ public class BootStrapImpl {
     }
 
     private String createHostString(List<String> list) {
-      String ret = "";
+      StringBuilder ret = new StringBuilder();
       if (list == null) {
-        return ret;
+        return "";
       }
       for (String host: list) {
-        ret = ret + host + ",";
+        ret.append(host).append(",");
       }
-      return ret;
+      return ret.toString();
     }
 
     /** Create request id dir for each bootstrap call **/
@@ -201,11 +201,11 @@ public class BootStrapImpl {
           StringWriter writer_1 = new StringWriter();
           IOUtils.copy(process.getInputStream(), writer_1);
           String outMesg = writer_1.toString();
-          if (outMesg == null)  outMesg = "";
+          //if (outMesg == null)  outMesg = "";
           StringWriter writer_2 = new StringWriter();
           IOUtils.copy(process.getErrorStream(), writer_2);
           String errMesg = writer_2.toString();
-          if (errMesg == null)  errMesg = "";
+          //if (errMesg == null)  errMesg = "";
           scriptlog = outMesg + "\n" + errMesg;
           if (exitCode != 0) {
             stat = BSStat.ERROR;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java Wed Nov  7 08:13:12 2012
@@ -59,13 +59,13 @@ public class SshHostInfo {
   }
 
   public String hostListAsString() {
-    String ret = "";
+    StringBuilder ret = new StringBuilder();
     if (this.hosts == null) {
       return "";
     }
     for (String host : this.hosts) {
-      ret = ret + host + ":";
+      ret.append(host).append(":");
     }
-    return ret;
+    return ret.toString();
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java Wed Nov  7 08:13:12 2012
@@ -45,6 +45,7 @@ public class Configuration {
 
   public static final String CONFIG_FILE = "ambari.properties";
   public static final String BOOTSTRAP_DIR = "bootstrap.dir";
+  public static final String API_AUTHENTICATE = "api.authenticate";
   public static final String BOOTSTRAP_SCRIPT = "bootstrap.script";
   public static final String SRVR_KSTR_DIR_KEY = "security.server.keys_dir";
   public static final String SRVR_CRT_NAME_KEY = "security.server.cert_name";
@@ -78,8 +79,11 @@ public class Configuration {
       "authorization.ldap.managerPassword";
   public static final String LDAP_USERNAME_ATTRIBUTE_KEY =
       "authorization.ldap.usernameAttribute";
-  public static final String LDAP_USER_DEFAULT_ROLE_KEY =
-      "authorization.ldap.userDefaultRole";
+
+  public static final String USER_ROLE_NAME_KEY =
+      "authorization.userRoleName";
+  public static final String ADMIN_ROLE_NAME_KEY =
+      "authorization.adminRoleName";
 
   public static final String PERSISTENCE_IN_MEMORY_KEY =
       "server.persistence.inMemory";
@@ -96,7 +100,8 @@ public class Configuration {
 
   private static final String CLIENT_SECURITY_DEFAULT = "local";
 
-  private static final String LDAP_USER_DEFAULT_ROLE_DEFAULT = "user";
+  private static final String USER_ROLE_NAME_DEFAULT = "user";
+  private static final String ADMIN_ROLE_NAME_DEFAULT = "admin";
   private static final String LDAP_BIND_ANONYMOUSLY_DEFAULT = "true";
 
   //TODO For embedded server only - should be removed later
@@ -146,10 +151,10 @@ public class Configuration {
         PASSPHRASE_ENV_KEY, PASSPHRASE_ENV_DEFAULT));
     configsMap.put(PASSPHRASE_KEY, System.getenv(configsMap.get(
         PASSPHRASE_ENV_KEY)));
-    configsMap.put(CLIENT_SECURITY_KEY, properties.getProperty(
-        CLIENT_SECURITY_KEY, CLIENT_SECURITY_DEFAULT));
-    configsMap.put(LDAP_USER_DEFAULT_ROLE_KEY, properties.getProperty(
-        LDAP_USER_DEFAULT_ROLE_KEY, LDAP_USER_DEFAULT_ROLE_DEFAULT));
+    configsMap.put(USER_ROLE_NAME_KEY, properties.getProperty(
+        USER_ROLE_NAME_KEY, USER_ROLE_NAME_DEFAULT));
+    configsMap.put(ADMIN_ROLE_NAME_KEY, properties.getProperty(
+        ADMIN_ROLE_NAME_KEY, ADMIN_ROLE_NAME_DEFAULT));
     configsMap.put(RESOURCES_DIR_KEY, properties.getProperty(
         RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT));
     configsMap.put(SRVR_CRT_PASS_LEN_KEY, properties.getProperty(
@@ -253,9 +258,17 @@ public class Configuration {
    */
   public String getMetadataPath() {
     return properties.getProperty(METADETA_DIR_PATH);
-//    return "src/main/resources/stacks";
   }
 
+  /**
+   * Check to see if the API should be authenticated or not
+   * @return false if not, true if the authentication is enabled.
+   */
+  public boolean getApiAuthentication() {
+    return ("true".equals(properties.getProperty(API_AUTHENTICATE, "false")));
+  }
+  
+  
   public PersistenceType getPersistenceType() {
     String value = properties.getProperty(PERSISTENCE_IN_MEMORY_KEY, PERSISTENCE_IN_MEMORY_DEFAULT);
     if ("true".equalsIgnoreCase(value)) {

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller;
+
+import java.util.Map;
+
+public class ActionRequest {
+  private String clusterName; 
+
+  private String serviceName;
+  
+  private String actionName; //for CREATE only
+
+  private Map<String, String> parameters; //for CREATE only
+
+  public ActionRequest(String clusterName, String serviceName,
+      String actionName, Map<String, String> params) {
+    this.clusterName = clusterName;
+    this.serviceName = serviceName;
+    this.actionName = actionName;
+    this.parameters = params;
+  }
+
+  public String getClusterName() {
+    return clusterName;
+  }
+
+  public void setClusterName(String clusterName) {
+    this.clusterName = clusterName;
+  }
+
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  public String getActionName() {
+    return actionName;
+  }
+
+  public void setActionName(String actionName) {
+    this.actionName = actionName;
+  }
+
+  public Map<String, String> getParameters() {
+    return parameters;
+  }
+
+  public void setParameters(Map<String, String> parameters) {
+    this.parameters = parameters;
+  }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,51 @@
+/**
+ * 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;
+
+
+public class ActionResponse {
+  private String clusterName; 
+
+  private String serviceName;
+  
+  private String actionName;
+
+  public String getClusterName() {
+    return clusterName;
+  }
+
+  public void setClusterName(String clusterName) {
+    this.clusterName = clusterName;
+  }
+
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  public String getActionName() {
+    return actionName;
+  }
+
+  public void setActionName(String actionName) {
+    this.actionName = actionName;
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java Wed Nov  7 08:13:12 2012
@@ -45,7 +45,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the service cannot be created
    */
-  public void createServices(Set<ServiceRequest> request)
+  public void createServices(Set<ServiceRequest> requests)
       throws AmbariException;
 
   /**
@@ -55,7 +55,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the component cannot be created
    */
-  public void createComponents(Set<ServiceComponentRequest> request)
+  public void createComponents(Set<ServiceComponentRequest> requests)
       throws AmbariException;
 
   /**
@@ -65,7 +65,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the host cannot be created
    */
-  public void createHosts(Set<HostRequest> request)
+  public void createHosts(Set<HostRequest> requests)
       throws AmbariException;
 
   /**
@@ -76,83 +76,74 @@ public interface AmbariManagementControl
    * @throws AmbariException thrown if the host component cannot be created
    */
   public void createHostComponents(
-      Set<ServiceComponentHostRequest> request) throws AmbariException;
+      Set<ServiceComponentHostRequest> requests) throws AmbariException;
 
   /**
    * Creates a configuration.
    *
    * @param request the request object which defines the configuration.
    *
-   * @return a track action response
-   *
    * @throws AmbariException when the configuration cannot be created.
    */
-  public TrackActionResponse createConfiguration(ConfigurationRequest request) throws AmbariException;
+  public void createConfiguration(ConfigurationRequest request)
+      throws AmbariException;
 
 
   // ----- Read -------------------------------------------------------------
 
   /**
-   * Get the clusters identified by the given request object.
+   * Get the clusters identified by the given request objects.
    *
-   * @param request  the request object which identifies the clusters to be returned
+   * @param requests  the request objects which identify the clusters to be returned
    *
    * @return a set of cluster responses
    *
    * @throws AmbariException thrown if the resource cannot be read
    */
-  public Set<ClusterResponse> getClusters(ClusterRequest request)
-      throws AmbariException;
   public Set<ClusterResponse> getClusters(Set<ClusterRequest> requests)
       throws AmbariException;
 
   /**
-   * Get the services identified by the given request object.
+   * Get the services identified by the given request objects.
    *
-   * @param request  the request object which identifies the services
+   * @param requests  the request objects which identify the services
    * to be returned
    *
    * @return a set of service responses
    *
    * @throws AmbariException thrown if the resource cannot be read
    */
-  public Set<ServiceResponse> getServices(ServiceRequest request)
-      throws AmbariException;
   public Set<ServiceResponse> getServices(Set<ServiceRequest> requests)
       throws AmbariException;
 
   /**
-   * Get the components identified by the given request object.
+   * Get the components identified by the given request objects.
    *
-   * @param request  the request object which identifies the components to be returned
+   * @param requests  the request objects which identify the components to be returned
    *
    * @return a set of component responses
    *
    * @throws AmbariException thrown if the resource cannot be read
    */
   public Set<ServiceComponentResponse> getComponents(
-      ServiceComponentRequest request) throws AmbariException;
-  public Set<ServiceComponentResponse> getComponents(
       Set<ServiceComponentRequest> requests) throws AmbariException;
 
   /**
-   * Get the hosts identified by the given request object.
+   * Get the hosts identified by the given request objects.
    *
-   * @param request  the request object which identifies the hosts to be returned
+   * @param requests  the request objects which identify the hosts to be returned
    *
    * @return a set of host responses
    *
    * @throws AmbariException thrown if the resource cannot be read
    */
-  public Set<HostResponse> getHosts(HostRequest request)
-      throws AmbariException;
   public Set<HostResponse> getHosts(Set<HostRequest> requests)
       throws AmbariException;
 
   /**
-   * Get the host components identified by the given request object.
+   * Get the host components identified by the given request objects.
    *
-   * @param request  the request object which identifies the host components
+   * @param requests  the request objects which identify the host components
    * to be returned
    *
    * @return a set of host component responses
@@ -160,24 +151,44 @@ public interface AmbariManagementControl
    * @throws AmbariException thrown if the resource cannot be read
    */
   public Set<ServiceComponentHostResponse> getHostComponents(
-      ServiceComponentHostRequest request) throws AmbariException;
-  public Set<ServiceComponentHostResponse> getHostComponents(
       Set<ServiceComponentHostRequest> requests) throws AmbariException;
 
   /**
-   * Gets the configurations identified by the given request object.
+   * Gets the configurations identified by the given request objects.
    *
-   * @param request   the request object
+   * @param requests   the request objects
    *
    * @return  a set of configuration responses
    *
    * @throws AmbariException if the configurations could not be read
    */
   public Set<ConfigurationResponse> getConfigurations(
-      ConfigurationRequest request) throws AmbariException;
-  public Set<ConfigurationResponse> getConfigurations(
       Set<ConfigurationRequest> requests) throws AmbariException;
 
+  /**
+   * Gets the request status identified by the given request object.
+   *
+   * @param request   the request object
+   *
+   * @return  a set of request status responses
+   *
+   * @throws AmbariException if the request status could not be read
+   */
+  public Set<RequestStatusResponse> getRequestStatus(RequestStatusRequest request)
+      throws AmbariException;
+
+  /**
+   * Gets the task status identified by the given request objects.
+   *
+   * @param requests   the request objects
+   *
+   * @return  a set of task status responses
+   *
+   * @throws AmbariException if the configurations could not be read
+   */
+  public Set<TaskStatusResponse> getTaskStatus(Set<TaskStatusRequest> requests)
+      throws AmbariException;
+
 
   // ----- Update -----------------------------------------------------------
 
@@ -192,7 +203,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public TrackActionResponse updateCluster(ClusterRequest request)
+  public RequestStatusResponse updateCluster(ClusterRequest request)
       throws AmbariException;
 
   /**
@@ -206,7 +217,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public TrackActionResponse updateServices(Set<ServiceRequest> request)
+  public RequestStatusResponse updateServices(Set<ServiceRequest> requests)
       throws AmbariException;
 
   /**
@@ -220,8 +231,8 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public TrackActionResponse updateComponents(
-      Set<ServiceComponentRequest> request) throws AmbariException;
+  public RequestStatusResponse updateComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException;
 
   /**
    * Update the host identified by the given request object with the
@@ -232,7 +243,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public void updateHosts(Set<HostRequest> request)
+  public void updateHosts(Set<HostRequest> requests)
       throws AmbariException;
 
   /**
@@ -246,8 +257,8 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public TrackActionResponse updateHostComponents(
-      Set<ServiceComponentHostRequest> request) throws AmbariException;
+  public RequestStatusResponse updateHostComponents(
+      Set<ServiceComponentHostRequest> requests) throws AmbariException;
 
 
   // ----- Delete -----------------------------------------------------------
@@ -257,8 +268,6 @@ public interface AmbariManagementControl
    *
    * @param request  the request object which identifies which cluster to delete
    *
-   * @return a track action response
-   *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
   public void deleteCluster(ClusterRequest request) throws AmbariException;
@@ -266,26 +275,26 @@ public interface AmbariManagementControl
   /**
    * Delete the service identified by the given request object.
    *
-   * @return a track action response
-   *
    * @param requests  the request object which identifies which service to delete
    *
+   * @return a track action response
+   *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
-  public TrackActionResponse deleteServices(Set<ServiceRequest> request)
+  public RequestStatusResponse deleteServices(Set<ServiceRequest> requests)
       throws AmbariException;
 
   /**
    * Delete the component identified by the given request object.
    *
-   * @return a track action response
-   *
    * @param requests  the request object which identifies which component to delete
    *
+   * @return a track action response
+   *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
-  public TrackActionResponse deleteComponents(
-      Set<ServiceComponentRequest> request) throws AmbariException;
+  public RequestStatusResponse deleteComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException;
 
   /**
    * Delete the host identified by the given request object.
@@ -296,7 +305,7 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
-  public void deleteHosts(Set<HostRequest> request)
+  public void deleteHosts(Set<HostRequest> requests)
       throws AmbariException;
 
   /**
@@ -308,12 +317,12 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
-  public TrackActionResponse deleteHostComponents(
-      Set<ServiceComponentHostRequest> request) throws AmbariException;
+  public RequestStatusResponse deleteHostComponents(
+      Set<ServiceComponentHostRequest> requests) throws AmbariException;
 
-  public TrackActionResponse createOperations(Set<OperationRequest> request)
+  public RequestStatusResponse createActions(Set<ActionRequest> request)
       throws AmbariException;
 
-  public void getOperations(Set<OperationRequest> request)
+  public Set<ActionResponse> getActions(Set<ActionRequest> request)
       throws AmbariException;
 }