You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by om...@apache.org on 2011/09/23 01:19:25 UTC

svn commit: r1174448 - in /incubator/ambari/trunk: ./ controller/src/main/java/org/apache/ambari/components/

Author: omalley
Date: Thu Sep 22 23:19:24 2011
New Revision: 1174448

URL: http://svn.apache.org/viewvc?rev=1174448&view=rev
Log:
AMBARI-4. Created interface for component plugins. (omalley)

Added:
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ClusterContext.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/Installer.java
Modified:
    incubator/ambari/trunk/CHANGES.txt

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1174448&r1=1174447&r2=1174448&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Sep 22 23:19:24 2011
@@ -2,4 +2,6 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
-  AMBARI-1 Initial code import
+  AMBARI-4. Created interface for component plugins. (omalley)
+
+  AMBARI-1. Initial code import (omalley)

Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ClusterContext.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ClusterContext.java?rev=1174448&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ClusterContext.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ClusterContext.java Thu Sep 22 23:19:24 2011
@@ -0,0 +1,70 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.components;
+
+import org.apache.ambari.common.rest.entities.Blueprint;
+import org.apache.ambari.common.rest.entities.ClusterDefinition;
+
+public interface ClusterContext {
+
+  /**
+   * Get the cluster name.
+   * @return the name of the cluster
+   */
+  String getClusterName();
+  
+  /**
+   * Get all of the roles for this component that will be installed on this
+   * node.
+   * @return a list of all of the roles for this node
+   */
+  String[] getAllRoles();
+  
+  /**
+   * Get the list of all roles for this component that should be started 
+   * running on this node.
+   * @return the lists of roles that should be running
+   */
+  String[] getActiveRoles();
+  
+  /**
+   * Get the directory name for the directory that should contain the software.
+   * @return the full pathname of the directory
+   */
+  String getInstallDirectory();
+  
+  /**
+   * Get the directory name for the configuration directory.
+   * @return the full pathname for the directory
+   */
+  String getConfigDirectory();
+  
+  /**
+   * Get the definition for this cluster.
+   * @return the cluster definition
+   */
+  ClusterDefinition getClusterDefinition();
+  
+  /**
+   * Get the blueprint for this cluster.
+   * @return the cluster blueprint
+   */
+  Blueprint getBlueprint();
+  
+}

Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java?rev=1174448&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/ComponentPlugin.java Thu Sep 22 23:19:24 2011
@@ -0,0 +1,89 @@
+/**
+* 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.components;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.ambari.common.rest.entities.agent.Command;
+
+/**
+ * A plug in that defines how to manage each component.
+ * 
+ * All commands must be idempotent, so that if they are replayed, they
+ * work without failure.
+ */
+public abstract class ComponentPlugin {
+  
+  /**
+   * Get the roles for this component.
+   * @return the list of roles in the order that they should be started
+   * @throws IOException
+   */
+  public abstract String[] getRoles() throws IOException;
+  
+  /**
+   * Get the components that this one depends on.
+   * @return the list of components that must be installed for this one
+   * @throws IOException
+   */
+  public abstract String[] getRequiredComponents() throws IOException;
+  
+  /**
+   * Is this component a service (ie. runs servers)?
+   * @return true if it has running servers
+   * @throws IOException
+   */
+  public abstract boolean isService() throws IOException;
+  
+  /**
+   * Get the commands to write the configuration for this component.
+   * @param cluster the cluster that is being configured
+   * @return the list of commands to run on each node
+   * @throws IOException
+   */
+  public abstract List<Command> writeConfiguration(ClusterContext cluster
+                                                   ) throws IOException;
+  
+  /**
+   * Get the commands to finalize the installation on the machine.
+   * @param cluster the cluster that is being installed
+   * @return the list of commands to execute
+   * @throws IOException
+   */
+  public abstract List<Command> install(ClusterContext cluster
+                                        ) throws IOException;
+  
+  /**
+   * Get the commands start and stop the servers on this node.
+   * @param cluster the cluster that is being installed
+   * @return the list of commands to execute
+   * @throws IOException
+   */
+  public abstract List<Command> startStopServices(ClusterContext cluster
+                                                  ) throws IOException;
+  
+  /**
+   * Get the commands to run before the software is uninstalled.
+   * @param cluster the cluster that is being uninstalled
+   * @return the list of commands to execute
+   * @throws IOException
+   */
+  public abstract List<Command> uninstall(ClusterContext cluster
+                                          ) throws IOException;
+}

Added: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/Installer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/Installer.java?rev=1174448&view=auto
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/Installer.java (added)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/components/Installer.java Thu Sep 22 23:19:24 2011
@@ -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.components;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.ambari.common.rest.entities.agent.Command;
+
+/**
+ * The generic interface for component installers.
+ * Used for installing and removing cluster software deployments.
+ */
+public abstract class Installer {
+
+  /**
+   * Generate commands that will install the required software on
+   * each node in the cluster.
+   * @param cluster the information about the cluster.
+   * @return a list of commands for each node's agent to execute.
+   * @throws IOException
+   */
+  public abstract List<Command> install(ClusterContext cluster
+                                        ) throws IOException;
+  
+  /**
+   * Generate commands that will uninstall the software from each node in the
+   * cluster
+   * @param cluster the cluster definition to remove
+   * @return the commands for each node's agent to execute
+   * @throws IOException
+   */
+  public abstract List<Command> remove(ClusterContext cluster
+                                       ) throws IOException;
+  
+}