You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2013/03/19 16:56:13 UTC

svn commit: r1458360 [1/3] - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/api/resources/ ambari-server/src/main/java/org/apache/ambari/server/api/services/ ambari-server/src/main/java/org/apache/ambari/server/cont...

Author: tbeerbower
Date: Tue Mar 19 15:56:11 2013
New Revision: 1458360

URL: http://svn.apache.org/r1458360
Log:
AMBARI-1658 - Implement API/Service Provider for HDFS mirroring

Added:
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/FeedResourceDefinition.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/InstanceResourceDefinition.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinition.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/FeedService.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/InstanceService.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/TargetClusterService.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/FeedResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/InstanceResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/FeedResourceDefinitionTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/InstanceResourceDefinitionTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinitionTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/FeedServiceTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/InstanceServiceTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/TargetClusterServiceTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/FeedResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/InstanceResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestIvoryService.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/ClusterTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/FeedTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/InstanceTest.java
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
    incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json
    incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Mar 19 15:56:11 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1658. Implement API/Service Provider for HDFS mirroring. (tbeerbower)
+
  AMBARI-1599. Add ability to report actual configuration applied to a host. (ncole)
 
  AMBARI-1647. Integrate server and agent changes for upgrade on cluster. 

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/FeedResourceDefinition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/FeedResourceDefinition.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/FeedResourceDefinition.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/FeedResourceDefinition.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,55 @@
+/**
+ * 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.resources;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * DR feed resource definition.
+ */
+public class FeedResourceDefinition extends BaseResourceDefinition {
+
+  /**
+   * Constructor.
+   */
+  public FeedResourceDefinition() {
+    super(Resource.Type.DRFeed);
+  }
+
+  @Override
+  public String getPluralName() {
+    return "feeds";
+  }
+
+  @Override
+  public String getSingularName() {
+    return "feed";
+  }
+
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    Set<SubResourceDefinition> setChildren = new HashSet<SubResourceDefinition>();
+    setChildren.add(new SubResourceDefinition(Resource.Type.DRInstance));
+
+    return setChildren;
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/InstanceResourceDefinition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/InstanceResourceDefinition.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/InstanceResourceDefinition.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/InstanceResourceDefinition.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,52 @@
+/**
+ * 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.resources;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * DR instance resource definition.
+ */
+public class InstanceResourceDefinition extends BaseResourceDefinition {
+
+  /**
+   * Constructor.
+   */
+  public InstanceResourceDefinition() {
+    super(Resource.Type.DRInstance);
+  }
+
+  @Override
+  public String getPluralName() {
+    return "instances";
+  }
+
+  @Override
+  public String getSingularName() {
+    return "instance";
+  }
+
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    return Collections.emptySet();
+  }
+}

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java Tue Mar 19 15:56:11 2013
@@ -107,6 +107,18 @@ public class ResourceInstanceFactoryImpl
         resourceDefinition = new RepositoryResourceDefinition();
         break;
 
+      case DRFeed:
+        resourceDefinition = new FeedResourceDefinition();
+        break;
+
+      case DRTargetCluster:
+        resourceDefinition = new TargetClusterResourceDefinition();
+        break;
+
+      case DRInstance:
+        resourceDefinition = new InstanceResourceDefinition();
+        break;
+
       default:
         throw new IllegalArgumentException("Unsupported resource type: " + type);
     }

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinition.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinition.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinition.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,52 @@
+/**
+ * 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.resources;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * DR target cluster resource definition.
+ */
+public class TargetClusterResourceDefinition extends BaseResourceDefinition {
+
+  /**
+   * Constructor.
+   */
+  public TargetClusterResourceDefinition() {
+    super(Resource.Type.DRTargetCluster);
+  }
+
+  @Override
+  public String getPluralName() {
+    return "targets";
+  }
+
+  @Override
+  public String getSingularName() {
+    return "target";
+  }
+
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    return Collections.emptySet();
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/FeedService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/FeedService.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/FeedService.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/FeedService.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,151 @@
+/**
+ * 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.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
+
+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 java.util.Collections;
+
+/**
+ * DR feed service.
+ */
+@Path("/feeds/")
+public class FeedService extends BaseService {
+
+  /**
+   * Handles: GET /feeds/{feedName}
+   * Get a specific feed.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param feedName    feed id
+   * @return feed instance representation
+   */
+  @GET
+  @Path("{feedName}")
+  @Produces("text/plain")
+  public Response getFeed(@Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("feedName") String feedName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET, createFeedResource(feedName));
+  }
+
+  /**
+   * Handles: GET  /feeds
+   * Get all feeds.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @return feed collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getFeeds(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createFeedResource(null));
+  }
+
+  /**
+   * Handles: POST /feeds/{feedName}
+   * Create a specific feed.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param feedName feed id
+   * @return information regarding the created feed
+   */
+  @POST
+  @Path("{feedName}")
+  @Produces("text/plain")
+  public Response createFeed(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                                @PathParam("feedName") String feedName) {
+
+    return handleRequest(headers, body, ui, Request.Type.POST, createFeedResource(feedName));
+  }
+
+  /**
+   * Handles: PUT /feeds/{feedName}
+   * Update a specific feed.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param feedName feed id
+   * @return information regarding the updated feed
+   */
+  @PUT
+  @Path("{feedName}")
+  @Produces("text/plain")
+  public Response updateFeed(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                                @PathParam("feedName") String feedName) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT, createFeedResource(feedName));
+  }
+
+  /**
+   * Handles: DELETE /feeds/{feedName}
+   * Delete a specific feed.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param feedName feed id
+   * @return information regarding the deleted feed
+   */
+  @DELETE
+  @Path("{feedName}")
+  @Produces("text/plain")
+  public Response deleteFeed(@Context HttpHeaders headers, @Context UriInfo ui,
+                                @PathParam("feedName") String feedName) {
+
+    return handleRequest(headers, null, ui, Request.Type.DELETE, createFeedResource(feedName));
+  }
+
+  /**
+   * Get the instances sub-resource
+   *
+   * @param feedName feed id
+   * @return the instances service
+   */
+  @Path("{feedName}/instances")
+  public InstanceService getHostHandler(@PathParam("feedName") String feedName) {
+    return new InstanceService(feedName);
+  }
+
+  /**
+   * Create a feed resource instance.
+   *
+   * @param feedName feed name
+   *
+   * @return a feed resource instance
+   */
+  ResourceInstance createFeedResource(String feedName) {
+    return createResource(Resource.Type.DRFeed,
+        Collections.singletonMap(Resource.Type.DRFeed, feedName));
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/InstanceService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/InstanceService.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/InstanceService.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/InstanceService.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,184 @@
+/**
+ * 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 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.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Service responsible for instances resource requests.
+ */
+@Path("/instances/")
+public class InstanceService extends BaseService {
+
+  /**
+   * Parent feed id.
+   */
+  private String m_feedName;
+
+  /**
+   * Constructor.
+   */
+  public InstanceService() {
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param feedName feed id
+   */
+  public InstanceService(String feedName) {
+    m_feedName = feedName;
+  }
+
+  /**
+   * Handles GET /feeds/{feedID}/instances/{instanceID} and /instances/{instanceID}
+   * Get a specific instance.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param instanceID  instance id
+   *
+   * @return instance resource representation
+   */
+  @GET
+  @Path("{instanceID}")
+  @Produces("text/plain")
+  public Response getInstance(@Context HttpHeaders headers, @Context UriInfo ui,
+                          @PathParam("instanceID") String instanceID) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createInstanceResource(m_feedName, instanceID, ui));
+  }
+
+  /**
+   * Handles GET /feeds/{feedID}/instances and /instances
+   * Get all instances for a feed.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @return instance collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getInstances(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createInstanceResource(m_feedName, null, ui));
+  }
+
+  /**
+   * Handles POST /feeds/{feedID}/instances/{instanceID}
+   * Create a specific instance.
+   *
+   * @param body     http body
+   * @param headers  http headers
+   * @param ui       uri info
+   * @param instanceID instance id
+   *
+   * @return instance resource representation
+   */
+  @POST
+  @Path("{instanceID}")
+  @Produces("text/plain")
+  public Response createInstance(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("instanceID") String instanceID) {
+
+    return handleRequest(headers, body, ui, Request.Type.POST,
+        createInstanceResource(m_feedName, instanceID, ui));
+  }
+
+  /**
+   * Handles PUT /feeds/{feedID}/instances/{instanceID}
+   * Updates a specific instance.
+   *
+   * @param body     http body
+   * @param headers  http headers
+   * @param ui       uri info
+   * @param instanceID instance id
+   *
+   * @return information regarding updated instance
+   */
+  @PUT
+  @Path("{instanceID}")
+  @Produces("text/plain")
+  public Response updateInstance(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("instanceID") String instanceID) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT,
+        createInstanceResource(m_feedName, instanceID, ui));
+  }
+
+  /**
+   * Handles DELETE /feeds/{feedID}/instances/{instanceID}
+   * Deletes a specific instance.
+   *
+   * @param headers  http headers
+   * @param ui       uri info
+   * @param instanceID instance id
+   *
+   * @return instance resource representation
+   */
+  @DELETE
+  @Path("{instanceID}")
+  @Produces("text/plain")
+  public Response deleteInstance(@Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("instanceID") String instanceID) {
+
+    return handleRequest(headers, null, ui, Request.Type.DELETE,
+        createInstanceResource(m_feedName, instanceID, ui));
+  }
+
+  /**
+   * Create a service resource instance.
+   *
+   *
+   *
+   * @param feedName  feed
+   * @param instanceID     instance name
+   * @param ui           uri information
+   *
+   * @return a instance resource instance
+   */
+  ResourceInstance createInstanceResource(String feedName, String instanceID, UriInfo ui) {
+    boolean isAttached = ui.getRequestUri().toString().contains("/feeds/");
+
+    Map<Resource.Type,String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.DRInstance, instanceID);
+    if (isAttached) {
+      mapIds.put(Resource.Type.DRFeed, feedName);
+    }
+
+    return createResource(Resource.Type.DRInstance, mapIds);
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/TargetClusterService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/TargetClusterService.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/TargetClusterService.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/TargetClusterService.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,140 @@
+/**
+ * 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.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
+
+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 java.util.Collections;
+
+/**
+ * DR target cluster service.
+ */
+@Path("/targets/")
+public class TargetClusterService extends BaseService {
+
+  /**
+   * Handles: GET /targets/{targetName}
+   * Get a specific target.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param targetName    target id
+   * @return target instance representation
+   */
+  @GET
+  @Path("{targetName}")
+  @Produces("text/plain")
+  public Response getTargetCluster(@Context HttpHeaders headers, @Context UriInfo ui,
+                          @PathParam("targetName") String targetName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET, createTargetClusterResource(targetName));
+  }
+
+  /**
+   * Handles: GET  /targets
+   * Get all targets.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @return target collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getTargetClusters(@Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, null, ui, Request.Type.GET, createTargetClusterResource(null));
+  }
+
+  /**
+   * Handles: POST /targets/{targetName}
+   * Create a specific target.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param targetName target id
+   * @return information regarding the created target
+   */
+  @POST
+  @Path("{targetName}")
+  @Produces("text/plain")
+  public Response createTargetCluster(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("targetName") String targetName) {
+
+    return handleRequest(headers, body, ui, Request.Type.POST, createTargetClusterResource(targetName));
+  }
+
+  /**
+   * Handles: PUT /targets/{targetName}
+   * Update a specific target.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param targetName target id
+   * @return information regarding the updated target
+   */
+  @PUT
+  @Path("{targetName}")
+  @Produces("text/plain")
+  public Response updateTargetCluster(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("targetName") String targetName) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT, createTargetClusterResource(targetName));
+  }
+
+  /**
+   * Handles: DELETE /targets/{targetName}
+   * Delete a specific target.
+   *
+   * @param headers     http headers
+   * @param ui          uri info
+   * @param targetName target id
+   * @return information regarding the deleted target
+   */
+  @DELETE
+  @Path("{targetName}")
+  @Produces("text/plain")
+  public Response deleteTargetCluster(@Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("targetName") String targetName) {
+
+    return handleRequest(headers, null, ui, Request.Type.DELETE, createTargetClusterResource(targetName));
+  }
+
+  /**
+   * Create a target resource instance.
+   *
+   * @param targetName target name
+   *
+   * @return a target resource instance
+   */
+  ResourceInstance createTargetClusterResource(String targetName) {
+    return createResource(Resource.Type.DRTargetCluster,
+        Collections.singletonMap(Resource.Type.DRTargetCluster, targetName));
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Abstract resource provider implementation that maps to an Ambari management controller.
+ */
+public abstract class AbstractControllerResourceProvider extends AbstractResourceProvider {
+
+  /**
+   * The management controller to delegate to.
+   */
+  private final AmbariManagementController managementController;
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a  new resource provider for the given management controller.
+   *
+   * @param propertyIds          the property ids
+   * @param keyPropertyIds       the key property ids
+   * @param managementController the management controller
+   */
+  protected AbstractControllerResourceProvider(Set<String> propertyIds,
+                                               Map<Resource.Type, String> keyPropertyIds,
+                                               AmbariManagementController managementController) {
+    super(propertyIds, keyPropertyIds);
+    this.managementController = managementController;
+  }
+
+
+  // ----- accessors ---------------------------------------------------------
+
+  /**
+   * Get the associated management controller.
+   *
+   * @return the associated management controller
+   */
+  protected AmbariManagementController getManagementController() {
+    return managementController;
+  }
+
+
+  // ----- utility methods ---------------------------------------------------
+
+  /**
+   * 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,
+                                                     Set<String> propertyIds,
+                                                     Map<Resource.Type, String> keyPropertyIds,
+                                                     AmbariManagementController managementController) {
+    switch (type) {
+      case Cluster:
+        return new ClusterResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Service:
+        return new ServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Component:
+        return new ComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Host:
+        return new HostResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case HostComponent:
+        return new HostComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Configuration:
+        return new ConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Action:
+        return new ActionResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Request:
+        return new RequestResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Task:
+        return new TaskResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case User:
+        return new UserResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Stack:
+        return new StackResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case StackVersion:
+        return new StackVersionResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case StackService:
+        return new StackServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case StackServiceComponent:
+        return new StackServiceComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case StackConfiguration:
+        return new StackConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case OperatingSystem:
+        return new OperatingSystemResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Repository:
+        return new RepositoryResourceProvider(propertyIds, keyPropertyIds, managementController);
+      default:
+        throw new IllegalArgumentException("Unknown type " + type);
+    }
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProvider.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Abstract resource provider implementation that maps to an Ivory service.
+ */
+public abstract class AbstractDRResourceProvider extends AbstractResourceProvider {
+
+  /**
+   * The Ivory service.
+   */
+  private final IvoryService ivoryService;
+
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Create a  new resource provider for the given management controller.
+   *
+   * @param propertyIds    the property ids
+   * @param keyPropertyIds the key property ids
+   */
+  protected AbstractDRResourceProvider(Set<String> propertyIds,
+                                       Map<Resource.Type, String> keyPropertyIds,
+                                       IvoryService ivoryService) {
+    super(propertyIds, keyPropertyIds);
+    this.ivoryService = ivoryService;
+  }
+
+  // ----- accessors ---------------------------------------------------------
+
+  /**
+   * Get the associated service.
+   *
+   * @return the associated service
+   */
+  protected IvoryService getService() {
+    return ivoryService;
+  }
+
+  // ----- utility methods ---------------------------------------------------
+
+  /**
+   * Factory method for obtaining a resource provider based on a given Ivory service instance.
+   *
+   * @param type         the resource type
+   * @param propertyIds  the property ids
+   * @param service      the Ivory service
+   *
+   * @return a new resource provider
+   */
+  public static ResourceProvider getResourceProvider(Resource.Type type,
+                                                     Set<String> propertyIds,
+                                                     Map<Resource.Type, String> keyPropertyIds,
+                                                     IvoryService service) {
+    switch (type) {
+      case DRFeed:
+        return new FeedResourceProvider(service, propertyIds, keyPropertyIds);
+      case DRTargetCluster:
+        return new TargetClusterResourceProvider(service, propertyIds, keyPropertyIds);
+      case DRInstance:
+        return new InstanceResourceProvider(service, propertyIds, keyPropertyIds);
+      default:
+        throw new IllegalArgumentException("Unknown type " + type);
+    }
+  }
+}

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -29,7 +29,6 @@ import org.apache.ambari.server.AmbariEx
 import org.apache.ambari.server.DuplicateResourceException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ParentObjectNotFoundException;
-import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.ConfigurationRequest;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.predicate.BasePredicate;
@@ -45,11 +44,6 @@ import org.slf4j.LoggerFactory;
 public abstract class AbstractResourceProvider extends BaseProvider implements ResourceProvider, ObservableResourceProvider {
 
   /**
-   * The management controller to delegate to.
-   */
-  private final AmbariManagementController managementController;
-
-  /**
    * Key property mapping by resource type.
    */
   private final Map<Resource.Type, String> keyPropertyIds;
@@ -69,14 +63,11 @@ public abstract class AbstractResourcePr
    *
    * @param propertyIds           the property ids
    * @param keyPropertyIds        the key property ids
-   * @param managementController  the management controller
    */
   protected AbstractResourceProvider(Set<String> propertyIds,
-                                     Map<Resource.Type, String> keyPropertyIds,
-                                     AmbariManagementController managementController) {
+                                     Map<Resource.Type, String> keyPropertyIds) {
     super(propertyIds);
-    this.keyPropertyIds       = keyPropertyIds;
-    this.managementController = managementController;
+    this.keyPropertyIds = keyPropertyIds;
   }
 
 
@@ -103,18 +94,6 @@ public abstract class AbstractResourcePr
   }
 
 
-  // ----- accessors ---------------------------------------------------------
-
-  /**
-   * Get the associated management controller.
-   *
-   * @return the associated management controller
-   */
-  protected AmbariManagementController getManagementController() {
-    return managementController;
-  }
-
-
   // ----- utility methods ---------------------------------------------------
 
   /**
@@ -319,60 +298,6 @@ public abstract class AbstractResourcePr
   }
 
   /**
-   * 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,
-                                                     Set<String> propertyIds,
-                                                     Map<Resource.Type, String> keyPropertyIds,
-                                                     AmbariManagementController managementController) {
-    switch (type) {
-      case Cluster:
-        return new ClusterResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Service:
-        return new ServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Component:
-        return new ComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Host:
-        return new HostResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case HostComponent:
-        return new HostComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Configuration:
-        return new ConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Action:
-        return new ActionResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Request:
-        return new RequestResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Task:
-        return new TaskResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case User:
-        return new UserResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Stack:
-        return new StackResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case StackVersion:
-        return new StackVersionResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case StackService:
-        return new StackServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case StackServiceComponent:
-        return new StackServiceComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case StackConfiguration:
-        return new StackConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case OperatingSystem:
-        return new OperatingSystemResourceProvider(propertyIds, keyPropertyIds, managementController);
-      case Repository:
-        return new RepositoryResourceProvider(propertyIds, keyPropertyIds, managementController);
-      default:
-        throw new IllegalArgumentException("Unknown type " + type);
-    }
-  }
-
-  /**
    * Helper method to get a configuration request, if one exists.
    * @param parentCategory  the parent category name.  Checks for a property
    *    whose category is the parent and marked as a desired config.

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -34,7 +34,7 @@ import java.util.Set;
 /**
  * Resource provider for action resources.
  */
-class ActionResourceProvider extends AbstractResourceProvider {
+class ActionResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -44,7 +44,7 @@ import org.apache.ambari.server.controll
 /**
  * Resource provider for cluster resources.
  */
-class ClusterResourceProvider extends AbstractResourceProvider {
+class ClusterResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -34,7 +34,7 @@ import java.util.Set;
 /**
  * Resource provider for component resources.
  */
-class ComponentResourceProvider extends AbstractResourceProvider {
+class ComponentResourceProvider extends AbstractControllerResourceProvider {
 
 
   // ----- Property ID constants ---------------------------------------------

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -43,7 +43,7 @@ import java.util.Map.Entry;
 /**
  * Resource provider for configuration resources.
  */
-class ConfigurationResourceProvider extends AbstractResourceProvider {
+class ConfigurationResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java Tue Mar 19 15:56:11 2013
@@ -48,7 +48,7 @@ public class DefaultProviderModule exten
 
   @Override
   protected ResourceProvider createResourceProvider(Resource.Type type) {
-    return AbstractResourceProvider.getResourceProvider(type, PropertyHelper.getPropertyIds(type),
+    return AbstractControllerResourceProvider.getResourceProvider(type, PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type), managementController);
   }
 }

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/FeedResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/FeedResourceProvider.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/FeedResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/FeedResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,224 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.ivory.Feed;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * DR feed resource provider.
+ */
+public class FeedResourceProvider extends AbstractDRResourceProvider {
+
+  // ----- Property ID constants ---------------------------------------------
+
+  protected static final String FEED_NAME_PROPERTY_ID                = PropertyHelper.getPropertyId("Feed", "name");
+  protected static final String FEED_DESCRIPTION_PROPERTY_ID         = PropertyHelper.getPropertyId("Feed", "description");
+  protected static final String FEED_STATUS_PROPERTY_ID              = PropertyHelper.getPropertyId("Feed", "status");
+  protected static final String FEED_SCHEDULE_PROPERTY_ID            = PropertyHelper.getPropertyId("Feed", "schedule");
+  protected static final String FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("Feed", "sourceClusterName");
+  protected static final String FEED_TARGET_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("Feed", "targetClusterName");
+
+  private static Set<String> pkPropertyIds =
+      new HashSet<String>(Arrays.asList(new String[]{
+          FEED_NAME_PROPERTY_ID}));
+
+  /**
+   * Construct a provider.
+   *
+   * @param ivoryService    the ivory service
+   * @param propertyIds     the properties associated with this provider
+   * @param keyPropertyIds  the key property ids
+   */
+  public FeedResourceProvider(IvoryService ivoryService,
+                              Set<String> propertyIds,
+                              Map<Resource.Type, String> keyPropertyIds) {
+    super(propertyIds, keyPropertyIds, ivoryService);
+  }
+
+  @Override
+  public RequestStatus createResources(Request request)
+      throws SystemException, UnsupportedPropertyException,
+             ResourceAlreadyExistsException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    Set<Map<String, Object>> propertiesSet = request.getProperties();
+
+    for(Map<String, Object> propertyMap : propertiesSet) {
+      service.submitFeed(getFeed((String) propertyMap.get(FEED_NAME_PROPERTY_ID), propertyMap));
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  public Set<Resource> getResources(Request request, Predicate predicate)
+      throws SystemException, UnsupportedPropertyException,
+             NoSuchResourceException, NoSuchParentResourceException {
+
+    IvoryService  service      = getService();
+    List<String>  feedNames    = service.getFeedNames();
+    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
+    Set<Resource> resources    = new HashSet<Resource>();
+
+    for (String feedName : feedNames ) {
+
+      Feed feed = service.getFeed(feedName);
+
+      Resource resource = new ResourceImpl(Resource.Type.DRFeed);
+      setResourceProperty(resource, FEED_NAME_PROPERTY_ID,
+          feed.getName(), requestedIds);
+      setResourceProperty(resource, FEED_DESCRIPTION_PROPERTY_ID,
+          feed.getDescription(), requestedIds);
+      setResourceProperty(resource, FEED_STATUS_PROPERTY_ID,
+          feed.getStatus(), requestedIds);
+      setResourceProperty(resource, FEED_SCHEDULE_PROPERTY_ID,
+          feed.getSchedule(), requestedIds);
+      setResourceProperty(resource, FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID,
+          feed.getSourceClusterName(), requestedIds);
+      setResourceProperty(resource, FEED_TARGET_CLUSTER_NAME_PROPERTY_ID,
+          feed.getTargetClusterName(), requestedIds);
+
+      if (predicate == null || predicate.evaluate(resource)) {
+        resources.add(resource);
+      }
+    }
+    return resources;
+  }
+
+  @Override
+  public RequestStatus updateResources(Request request, Predicate predicate)
+      throws SystemException, UnsupportedPropertyException,
+             NoSuchResourceException, NoSuchParentResourceException {
+
+    Iterator<Map<String,Object>> iterator = request.getProperties().iterator();
+    if (iterator.hasNext()) {
+
+      Map<String, Object> propertyMap = iterator.next();
+
+      String desiredStatus = (String) propertyMap.get(FEED_STATUS_PROPERTY_ID);
+
+      // get all the feeds that pass the predicate check
+      Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);
+
+      // update all the matching feeds with the property values from the request
+      for (Resource resource : resources) {
+        IvoryService service = getService();
+        if (desiredStatus != null) {
+          String status   = (String) resource.getPropertyValue(FEED_STATUS_PROPERTY_ID);
+          String feedName = (String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID);
+
+          if (desiredStatus.equals("SCHEDULED")) {
+            service.scheduleFeed(feedName);
+          } else if (desiredStatus.equals("SUSPENDED")) {
+            service.suspendFeed(feedName);
+          } else if (status.equals("SUSPENDED") && desiredStatus.equals("RUNNING")) {
+            service.resumeFeed(feedName);
+          }
+        }
+        service.updateFeed(getFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID),
+            getUpdateMap(resource, propertyMap)));
+      }
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  public RequestStatus deleteResources(Predicate predicate)
+      throws SystemException, UnsupportedPropertyException,
+             NoSuchResourceException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    // get all the feeds that pass the predicate check
+    Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);
+
+    for (Resource resource : resources) {
+      // delete all the matching feeds with the property values from the request
+      service.deleteFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID));
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+
+  // ----- helper methods -----------------------------------------------------
+
+  /**
+   * Get a new feed object from the given name and map of properties.
+   *
+   * @param feedName     the feed name
+   * @param propertyMap  the properties
+   *
+   * @return a new feed
+   */
+  protected static Feed getFeed(String feedName, Map<String, Object> propertyMap) {
+    return new Feed(
+        feedName,
+        (String) propertyMap.get(FEED_DESCRIPTION_PROPERTY_ID),
+        (String) propertyMap.get(FEED_STATUS_PROPERTY_ID),
+        (String) propertyMap.get(FEED_SCHEDULE_PROPERTY_ID),
+        (String) propertyMap.get(FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID),
+        (String) propertyMap.get(FEED_TARGET_CLUSTER_NAME_PROPERTY_ID));
+  }
+
+  /**
+   * Get a property map for an update based on an existing feed resource updated with the
+   * given property map.
+   *
+   * @param resource     the resource
+   * @param propertyMap  the map of property updates
+   *
+   * @return the map of properies to use for the update
+   */
+  protected static Map<String, Object> getUpdateMap(Resource resource, Map<String, Object> propertyMap) {
+    Map<String, Object> updateMap = new HashMap<String, Object>();
+
+    updateMap.put(FEED_NAME_PROPERTY_ID, resource.getPropertyValue(FEED_NAME_PROPERTY_ID));
+    updateMap.put(FEED_DESCRIPTION_PROPERTY_ID, resource.getPropertyValue(FEED_DESCRIPTION_PROPERTY_ID));
+    updateMap.put(FEED_SCHEDULE_PROPERTY_ID, resource.getPropertyValue(FEED_SCHEDULE_PROPERTY_ID));
+    updateMap.put(FEED_STATUS_PROPERTY_ID, resource.getPropertyValue(FEED_STATUS_PROPERTY_ID));
+    updateMap.put(FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID, resource.getPropertyValue(FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID));
+    updateMap.put(FEED_TARGET_CLUSTER_NAME_PROPERTY_ID, resource.getPropertyValue(FEED_TARGET_CLUSTER_NAME_PROPERTY_ID));
+    updateMap.putAll(propertyMap);
+
+    return updateMap;
+  }
+
+}

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -35,7 +35,7 @@ import org.apache.ambari.server.Role;
 /**
  * Resource provider for host component resources.
  */
-class HostComponentResourceProvider extends AbstractResourceProvider {
+class HostComponentResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -42,7 +42,7 @@ import org.apache.ambari.server.controll
 /**
  * Resource provider for host resources.
  */
-class HostResourceProvider extends AbstractResourceProvider {
+class HostResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/InstanceResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/InstanceResourceProvider.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/InstanceResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/InstanceResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.ivory.Instance;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * DR instance resource provider.
+ */
+public class InstanceResourceProvider extends AbstractDRResourceProvider {
+
+  // ----- Property ID constants ---------------------------------------------
+
+  protected static final String INSTANCE_FEED_NAME_PROPERTY_ID  = PropertyHelper.getPropertyId("Instance", "feedName");
+  protected static final String INSTANCE_ID_PROPERTY_ID         = PropertyHelper.getPropertyId("Instance", "id");
+  protected static final String INSTANCE_STATUS_PROPERTY_ID     = PropertyHelper.getPropertyId("Instance", "status");
+  protected static final String INSTANCE_START_TIME_PROPERTY_ID = PropertyHelper.getPropertyId("Instance", "startTime");
+  protected static final String INSTANCE_END_TIME_PROPERTY_ID   = PropertyHelper.getPropertyId("Instance", "endTime");
+  protected static final String INSTANCE_DETAILS_PROPERTY_ID    = PropertyHelper.getPropertyId("Instance", "details");
+  protected static final String INSTANCE_LOG_PROPERTY_ID        = PropertyHelper.getPropertyId("Instance", "log");
+
+  private static Set<String> pkPropertyIds =
+      new HashSet<String>(Arrays.asList(new String[]{
+          INSTANCE_FEED_NAME_PROPERTY_ID,
+          INSTANCE_ID_PROPERTY_ID }));
+
+  /**
+   * Construct a provider.
+   *
+   * @param ivoryService    the ivory service
+   * @param propertyIds     the properties associated with this provider
+   * @param keyPropertyIds  the key property ids
+   */
+  public InstanceResourceProvider(IvoryService ivoryService,
+                                  Set<String> propertyIds,
+                                  Map<Resource.Type, String> keyPropertyIds) {
+    super(propertyIds, keyPropertyIds, ivoryService);
+  }
+
+  @Override
+  public RequestStatus createResources(Request request) throws SystemException,
+      UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException {
+    // we can't create instances directly
+    throw new UnsupportedOperationException("Not supported.");
+  }
+
+  @Override
+  public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException,
+      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+
+    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
+    Set<Resource> resources    = new HashSet<Resource>();
+    List<String>  feedNames    = new LinkedList<String>();
+
+    IvoryService service = getService();
+    if (predicate == null) {
+      feedNames = service.getFeedNames();
+    } else {
+      for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
+        String feedName = (String) propertyMap.get(INSTANCE_FEED_NAME_PROPERTY_ID);
+        if (feedName == null) {
+          // if any part of the predicate doesn't include feed name then we have to check them all
+          feedNames = service.getFeedNames();
+          break;
+        }
+        feedNames.add(feedName);
+      }
+    }
+
+    for (String feedName : feedNames) {
+      List<Instance> instances = service.getInstances(feedName);
+      for (Instance instance : instances) {
+        Resource resource = new ResourceImpl(Resource.Type.DRInstance);
+        setResourceProperty(resource, INSTANCE_FEED_NAME_PROPERTY_ID,
+            instance.getFeedName(), requestedIds);
+        setResourceProperty(resource, INSTANCE_ID_PROPERTY_ID,
+            instance.getId(), requestedIds);
+        setResourceProperty(resource, INSTANCE_STATUS_PROPERTY_ID,
+            instance.getStatus(), requestedIds);
+        setResourceProperty(resource, INSTANCE_START_TIME_PROPERTY_ID,
+            instance.getStartTime(), requestedIds);
+        setResourceProperty(resource, INSTANCE_END_TIME_PROPERTY_ID,
+            instance.getEndTime(), requestedIds);
+        setResourceProperty(resource, INSTANCE_DETAILS_PROPERTY_ID,
+            instance.getDetails(), requestedIds);
+        setResourceProperty(resource, INSTANCE_LOG_PROPERTY_ID,
+            instance.getLog(), requestedIds);
+
+        if (predicate == null || predicate.evaluate(resource)) {
+          resources.add(resource);
+        }
+      }
+    }
+    return resources;
+  }
+
+  @Override
+  public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException,
+      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    Iterator<Map<String,Object>> iterator = request.getProperties().iterator();
+    if (iterator.hasNext()) {
+
+      Map<String, Object> propertyMap = iterator.next();
+
+      String desiredStatus = (String) propertyMap.get(INSTANCE_STATUS_PROPERTY_ID);
+
+      if (desiredStatus != null) {
+        // get all the instances that pass the predicate check
+        Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);
+
+        // update all the matching instances with the property values from the request
+        for (Resource resource : resources) {
+          String status   = (String) resource.getPropertyValue(INSTANCE_STATUS_PROPERTY_ID);
+          String feedName = (String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID);
+          String id       = (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID);
+
+          if (desiredStatus.equals("SUSPENDED")) {
+            service.suspendInstance(feedName, id);
+          } else if (status.equals("SUSPENDED") && desiredStatus.equals("RUNNING")) {
+            service.resumeInstance(feedName, id);
+          }
+        }
+      }
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  public RequestStatus deleteResources(Predicate predicate) throws SystemException,
+      UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    // get all the instances that pass the predicate check
+    Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);
+
+    for (Resource resource : resources) {
+      // delete all the matching instances with the property values from the request
+      service.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID),
+          (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID));
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+
+  // ----- helper methods -----------------------------------------------------
+
+  protected static Instance getInstance(String feedName, String instanceId, Map<String, Object> propertyMap) {
+    return new Instance(
+        feedName,
+        instanceId,
+        (String) propertyMap.get(INSTANCE_STATUS_PROPERTY_ID),
+        (String) propertyMap.get(INSTANCE_START_TIME_PROPERTY_ID),
+        (String) propertyMap.get(INSTANCE_END_TIME_PROPERTY_ID),
+        (String) propertyMap.get(INSTANCE_DETAILS_PROPERTY_ID),
+        (String) propertyMap.get(INSTANCE_LOG_PROPERTY_ID));
+  }
+
+}

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -33,7 +33,7 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 
-public abstract class ReadOnlyResourceProvider extends AbstractResourceProvider {
+public abstract class ReadOnlyResourceProvider extends AbstractControllerResourceProvider {
 
   private static final String READ_ONLY_MSG = "Read-only resource";
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -40,7 +40,7 @@ import java.util.Set;
 /**
  * Resource provider for request resources.
  */
-class RequestResourceProvider extends AbstractResourceProvider {
+class RequestResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
   // Requests

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -34,7 +34,7 @@ import java.util.Set;
 /**
  * Resource provider for service resources.
  */
-class ServiceResourceProvider extends AbstractResourceProvider {
+class ServiceResourceProvider extends AbstractControllerResourceProvider {
 
 
   // ----- Property ID constants ---------------------------------------------

Added: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProvider.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProvider.java (added)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.ivory.Cluster;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * DR target cluster resource provider.
+ */
+public class TargetClusterResourceProvider extends AbstractDRResourceProvider {
+
+  // ----- Property ID constants ---------------------------------------------
+
+  protected static final String CLUSTER_NAME_PROPERTY_ID       = PropertyHelper.getPropertyId("Cluster", "name");
+  protected static final String CLUSTER_COLO_PROPERTY_ID       = PropertyHelper.getPropertyId("Cluster", "colo");
+  protected static final String CLUSTER_INTERFACES_PROPERTY_ID = PropertyHelper.getPropertyId("Cluster", "interfaces");
+  protected static final String CLUSTER_LOCATIONS_PROPERTY_ID  = PropertyHelper.getPropertyId("Cluster", "locations");
+  protected static final String CLUSTER_PROPERTIES_PROPERTY_ID = PropertyHelper.getPropertyId("Cluster", "properties");
+
+  private static Set<String> pkPropertyIds =
+      new HashSet<String>(Arrays.asList(new String[]{
+          CLUSTER_NAME_PROPERTY_ID }));
+
+  /**
+   * Construct a provider.
+   *
+   * @param ivoryService    the ivory service
+   * @param propertyIds     the properties associated with this provider
+   * @param keyPropertyIds  the key property ids
+   */
+  public TargetClusterResourceProvider(IvoryService ivoryService,
+                                       Set<String> propertyIds,
+                                       Map<Resource.Type, String> keyPropertyIds) {
+    super(propertyIds, keyPropertyIds, ivoryService);
+  }
+
+  @Override
+  public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    Set<Map<String, Object>> propertiesSet = request.getProperties();
+
+    for(Map<String, Object> propertyMap : propertiesSet) {
+      service.submitCluster(getCluster((String) propertyMap.get(CLUSTER_NAME_PROPERTY_ID), propertyMap));
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    IvoryService  service         = getService();
+    List<String>  clusterNames    = service.getClusterNames();
+    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
+    Set<Resource> resources    = new HashSet<Resource>();
+
+    for (String clusterName : clusterNames ) {
+
+      Cluster cluster = service.getCluster(clusterName);
+
+      Resource resource = new ResourceImpl(Resource.Type.DRTargetCluster);
+      setResourceProperty(resource, CLUSTER_NAME_PROPERTY_ID,
+          cluster.getName(), requestedIds);
+      setResourceProperty(resource, CLUSTER_COLO_PROPERTY_ID,
+          cluster.getColo(), requestedIds);
+      setResourceProperty(resource, CLUSTER_INTERFACES_PROPERTY_ID,
+          cluster.getInterfaces(), requestedIds);
+      setResourceProperty(resource, CLUSTER_LOCATIONS_PROPERTY_ID,
+          cluster.getLocations(), requestedIds);
+      setResourceProperty(resource, CLUSTER_PROPERTIES_PROPERTY_ID,
+          cluster.getProperties(), requestedIds);
+
+      if (predicate == null || predicate.evaluate(resource)) {
+        resources.add(resource);
+      }
+    }
+    return resources;
+  }
+
+  @Override
+  public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    Iterator<Map<String,Object>> iterator = request.getProperties().iterator();
+    if (iterator.hasNext()) {
+
+      Map<String, Object> propertyMap = iterator.next();
+
+      // get all the clusters that pass the predicate check
+      Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);
+
+      for (Resource resource : resources) {
+        // update all the matching clusters with the property values from the request
+        service.updateCluster(getCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID), propertyMap));
+      }
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  public RequestStatus deleteResources(Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    IvoryService service = getService();
+
+    // get all the clusters that pass the predicate check
+    Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate);
+
+    for (Resource resource : resources) {
+      // delete all the matching clusters with the property values from the request
+      service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID));
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+  // ----- helper methods -----------------------------------------------------
+
+  protected static Cluster getCluster(String clusterName, Map<String, Object> propertyMap) {
+    return new Cluster(
+        clusterName,
+        (String) propertyMap.get(CLUSTER_COLO_PROPERTY_ID),
+        (Set<String>) propertyMap.get(CLUSTER_INTERFACES_PROPERTY_ID),
+        (Set<String>) propertyMap.get(CLUSTER_LOCATIONS_PROPERTY_ID),
+        (Map<String, String>) propertyMap.get(CLUSTER_PROPERTIES_PROPERTY_ID));
+  }
+}

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -41,7 +41,7 @@ import java.util.Set;
 /**
  * Resource provider for task resources.
  */
-class TaskResourceProvider extends AbstractResourceProvider {
+class TaskResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java Tue Mar 19 15:56:11 2013
@@ -33,7 +33,7 @@ import java.util.Set;
 /**
  * Resource provider for user resources.
  */
-class UserResourceProvider extends AbstractResourceProvider {
+class UserResourceProvider extends AbstractControllerResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------