Browse Source

AMBARI-805. Add requestId tracking objects for management spi. (hitesh)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1393855 13f79535-47bb-0310-9956-ffa450edef68
Hitesh Shah 13 years ago
parent
commit
67ba63dfdb

+ 2 - 0
AMBARI-666-CHANGES.txt

@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-805. Add requestId tracking objects for management spi. (hitesh)
+
   AMBARI-803. FSM initial refactoring for eventual live/desired objects. (hitesh)
 
   AMBARI-802. Enhance Cluster Management pages. (yusaku)

+ 15 - 15
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java

@@ -31,16 +31,16 @@ public interface AmbariManagementController {
 
   // ----- Create -----------------------------------------------------------
 
-  public void createCluster(ClusterRequest request) throws AmbariException;
+  public TrackActionResponse createCluster(ClusterRequest request) throws AmbariException;
 
-  public void createServices(ServiceRequest request) throws AmbariException;
+  public TrackActionResponse createServices(ServiceRequest request) throws AmbariException;
 
-  public void createComponents(ServiceComponentRequest request)
+  public TrackActionResponse createComponents(ServiceComponentRequest request)
       throws AmbariException;
 
-  public void createHosts(HostRequest request) throws AmbariException;
+  public TrackActionResponse createHosts(HostRequest request) throws AmbariException;
 
-  public void createHostComponents(ServiceComponentHostRequest request)
+  public TrackActionResponse createHostComponents(ServiceComponentHostRequest request)
       throws AmbariException;
 
 
@@ -59,27 +59,27 @@ public interface AmbariManagementController {
 
   // ----- Update -----------------------------------------------------------
 
-  public void updateCluster(ClusterRequest request);
+  public TrackActionResponse updateCluster(ClusterRequest request);
 
-  public void updateServices(ServiceRequest request, Predicate predicate);
+  public TrackActionResponse updateServices(ServiceRequest request, Predicate predicate);
 
-  public void updateComponents(ServiceComponentRequest request, Predicate predicate);
+  public TrackActionResponse updateComponents(ServiceComponentRequest request, Predicate predicate);
 
-  public void updateHosts(HostRequest request, Predicate predicate);
+  public TrackActionResponse updateHosts(HostRequest request, Predicate predicate);
 
-  public void updateHostComponents(ServiceComponentHostRequest request, Predicate predicate);
+  public TrackActionResponse updateHostComponents(ServiceComponentHostRequest request, Predicate predicate);
 
 
   // ----- Delete -----------------------------------------------------------
 
-  public void deleteCluster(ClusterRequest request);
+  public TrackActionResponse deleteCluster(ClusterRequest request);
 
-  public void deleteServices(ServiceRequest request);
+  public TrackActionResponse deleteServices(ServiceRequest request);
 
-  public void deleteComponents(ServiceComponentRequest request);
+  public TrackActionResponse deleteComponents(ServiceComponentRequest request);
 
-  public void deleteHosts(HostRequest request);
+  public TrackActionResponse deleteHosts(HostRequest request);
 
 
-  public void deleteHostComponents(ServiceComponentHostRequest request);
+  public TrackActionResponse deleteHostComponents(ServiceComponentHostRequest request);
 }

+ 44 - 19
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -42,16 +42,18 @@ public class AmbariManagementControllerImpl implements
   }
   
   @Override
-  public void createCluster(ClusterRequest request) throws AmbariException {
+  public TrackActionResponse createCluster(ClusterRequest request) throws AmbariException {
     if (request.getClusterName() == null
         || request.getClusterName().isEmpty()) {
       // TODO throw error
     }
     clusters.addCluster(request.getClusterName());
+    // TODO
+    return null;
   }
 
   @Override
-  public void createServices(ServiceRequest request) throws AmbariException {
+  public TrackActionResponse createServices(ServiceRequest request) throws AmbariException {
     if (request.getClusterName() == null
         || request.getClusterName().isEmpty()) {
       // TODO throw error
@@ -66,23 +68,30 @@ public class AmbariManagementControllerImpl implements
       
       // TODO take action based on desired state
     }
+    // TODO
+    return null;
   }
 
   @Override
-  public void createComponents(
+  public TrackActionResponse createComponents(
       ServiceComponentRequest request) throws AmbariException {
     // TODO Auto-generated method stub
+    return null;
   }
 
   @Override
-  public void createHosts(HostRequest request) throws AmbariException {
+  public TrackActionResponse createHosts(HostRequest request) throws AmbariException {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void createHostComponents(
+  public TrackActionResponse createHostComponents(
       ServiceComponentHostRequest request) throws AmbariException {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
@@ -119,60 +128,76 @@ public class AmbariManagementControllerImpl implements
   }
 
   @Override
-  public void updateCluster(ClusterRequest request) {
+  public TrackActionResponse updateCluster(ClusterRequest request) {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void updateServices(ServiceRequest request,
+  public TrackActionResponse updateServices(ServiceRequest request,
       Predicate predicate) {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void updateComponents(
+  public TrackActionResponse updateComponents(
       ServiceComponentRequest request, Predicate predicate) {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void updateHosts(HostRequest request, Predicate predicate) {
+  public TrackActionResponse updateHosts(HostRequest request, Predicate predicate) {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void updateHostComponents(
+  public TrackActionResponse updateHostComponents(
       ServiceComponentHostRequest request, Predicate predicate) {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void deleteCluster(ClusterRequest request) {
+  public TrackActionResponse deleteCluster(ClusterRequest request) {
     // TODO Auto-generated method stub
+    // TODO
+    return null;
   }
 
   @Override
-  public void deleteServices(ServiceRequest request) {
+  public TrackActionResponse deleteServices(ServiceRequest request) {
     // TODO Auto-generated method stub
-
+    // TODO
+    return null;
   }
 
   @Override
-  public void deleteComponents(ServiceComponentRequest request) {
+  public TrackActionResponse deleteComponents(ServiceComponentRequest request) {
     // TODO Auto-generated method stub
-
+    // TODO
+    return null;
   }
 
   @Override
-  public void deleteHosts(HostRequest request) {
+  public TrackActionResponse deleteHosts(HostRequest request) {
     // TODO Auto-generated method stub
-
+    // TODO
+    return null;
   }
 
   @Override
-  public void deleteHostComponents(ServiceComponentHostRequest request) {
+  public TrackActionResponse deleteHostComponents(ServiceComponentHostRequest request) {
     // TODO Auto-generated method stub
-
+    // TODO
+    return null;
   }
 
 }

+ 37 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionRequest.java

@@ -0,0 +1,37 @@
+/**
+ * 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 TrackActionRequest {
+  
+  private final Long requestId;
+
+  public TrackActionRequest(Long requestId) {
+    super();
+    this.requestId = requestId;
+  }
+
+  /**
+   * @return the requestId
+   */
+  public Long getRequestId() {
+    return requestId;
+  }
+
+}

+ 58 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/TrackActionResponse.java

@@ -0,0 +1,58 @@
+/**
+ * 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 TrackActionResponse {
+
+  // Request ID for tracking async operations
+  private final Long requestId;
+  
+  // TODO how are logs to be sent back?
+  private String logs;
+
+  // TODO stage specific information
+  
+  public TrackActionResponse(Long requestId) {
+    super();
+    this.requestId = requestId;
+  }
+
+  /**
+   * @return the logs
+   */
+  public String getLogs() {
+    return logs;
+  }
+
+  /**
+   * @param logs the logs to set
+   */
+  public void setLogs(String logs) {
+    this.logs = logs;
+  }
+
+  /**
+   * @return the requestId
+   */
+  public long getRequestId() {
+    return requestId;
+  }
+  
+  
+}