org.apache.whirr.service
Class ClusterActionHandlerSupport

java.lang.Object
  extended by org.apache.whirr.service.ClusterActionHandler
      extended by org.apache.whirr.service.ClusterActionHandlerSupport
Direct Known Subclasses:
CassandraClusterActionHandler, ChefClusterActionHandler, ElasticSearchHandler, GangliaMetadClusterActionHandler, GangliaMonitorClusterActionHandler, HadoopClusterActionHandler, HamaClusterActionHandler, HBaseClusterActionHandler, MahoutClientClusterActionHandler, NoopClusterActionHandler, PuppetInstallClusterActionHandler, ZooKeeperClusterActionHandler

public abstract class ClusterActionHandlerSupport
extends ClusterActionHandler

This is a utility class to make it easier to implement ClusterActionHandler. For each 'before' and 'after' action type there is a corresponding method that implementations may override.


Field Summary
 
Fields inherited from class org.apache.whirr.service.ClusterActionHandler
BOOTSTRAP_ACTION, CONFIGURE_ACTION, DESTROY_ACTION
 
Constructor Summary
ClusterActionHandlerSupport()
           
 
Method Summary
static void addRunUrl(ClusterActionEvent event, String runUrl, String... args)
          A convenience method for adding a RunUrlStatement to a ClusterActionEvent.
static void addStatement(ClusterActionEvent event, org.jclouds.scriptbuilder.domain.Statement statement)
           
 void afterAction(ClusterActionEvent event)
          Called after the action has been performed.
protected  void afterBootstrap(ClusterActionEvent event)
           
protected  void afterConfigure(ClusterActionEvent event)
           
protected  void afterDestroy(ClusterActionEvent event)
           
protected  void afterOtherAction(ClusterActionEvent event)
           
 void beforeAction(ClusterActionEvent event)
          Called before the action is performed, giving the implementation an opportunity to specify scripts that should be run as a part of this action.
protected  void beforeBootstrap(ClusterActionEvent event)
           
protected  void beforeConfigure(ClusterActionEvent event)
           
protected  void beforeDestroy(ClusterActionEvent event)
           
protected  void beforeOtherAction(ClusterActionEvent event)
           
 String getCleanupFunction(org.apache.commons.configuration.Configuration config, String service, String defaultFunction)
          Get service cleanup function name from the configuration
protected  org.apache.commons.configuration.Configuration getConfiguration(ClusterSpec clusterSpec, org.apache.commons.configuration.Configuration defaults)
          Returns a composite configuration that is made up from the global configuration coming from the Whirr core with the service default properties.
protected  org.apache.commons.configuration.Configuration getConfiguration(ClusterSpec clusterSpec, String defaultsPropertiesFile)
           
 String getConfigureFunction(org.apache.commons.configuration.Configuration config, String service, String defaultFunction)
          Get service configure function name from the configuration
 String getFunctionName(org.apache.commons.configuration.Configuration config, String service, String functionName, String defaultFunction)
           
 String getInstallFunction(org.apache.commons.configuration.Configuration config, String service, String defaultFunction)
          Get service install function name from the configuration
 String getStartFunction(org.apache.commons.configuration.Configuration config, String service, String defaultFunction)
          Get service start function name from the configuration
 String getStopFunction(org.apache.commons.configuration.Configuration config, String service, String defaultFunction)
          Get service start function name from the configuration
static String prepareRemoteFileUrl(ClusterActionEvent event, String rawUrl)
          Prepare the file url for the remote machine.
 
Methods inherited from class org.apache.whirr.service.ClusterActionHandler
equals, getRole, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClusterActionHandlerSupport

public ClusterActionHandlerSupport()
Method Detail

beforeAction

public void beforeAction(ClusterActionEvent event)
                  throws IOException,
                         InterruptedException
Description copied from class: ClusterActionHandler
Called before the action is performed, giving the implementation an opportunity to specify scripts that should be run as a part of this action.

Overrides:
beforeAction in class ClusterActionHandler
Throws:
IOException
InterruptedException

afterAction

public void afterAction(ClusterActionEvent event)
                 throws IOException,
                        InterruptedException
Description copied from class: ClusterActionHandler
Called after the action has been performed.

Overrides:
afterAction in class ClusterActionHandler
Throws:
IOException
InterruptedException

beforeBootstrap

protected void beforeBootstrap(ClusterActionEvent event)
                        throws IOException,
                               InterruptedException
Throws:
IOException
InterruptedException

beforeConfigure

protected void beforeConfigure(ClusterActionEvent event)
                        throws IOException,
                               InterruptedException
Throws:
IOException
InterruptedException

beforeDestroy

protected void beforeDestroy(ClusterActionEvent event)
                      throws IOException,
                             InterruptedException
Throws:
IOException
InterruptedException

beforeOtherAction

protected void beforeOtherAction(ClusterActionEvent event)
                          throws IOException,
                                 InterruptedException
Throws:
IOException
InterruptedException

afterBootstrap

protected void afterBootstrap(ClusterActionEvent event)
                       throws IOException,
                              InterruptedException
Throws:
IOException
InterruptedException

afterConfigure

protected void afterConfigure(ClusterActionEvent event)
                       throws IOException,
                              InterruptedException
Throws:
IOException
InterruptedException

afterDestroy

protected void afterDestroy(ClusterActionEvent event)
                     throws IOException,
                            InterruptedException
Throws:
IOException
InterruptedException

afterOtherAction

protected void afterOtherAction(ClusterActionEvent event)
                         throws IOException,
                                InterruptedException
Throws:
IOException
InterruptedException

getConfiguration

protected org.apache.commons.configuration.Configuration getConfiguration(ClusterSpec clusterSpec,
                                                                          org.apache.commons.configuration.Configuration defaults)
Returns a composite configuration that is made up from the global configuration coming from the Whirr core with the service default properties.

Parameters:
clusterSpec - The cluster specification instance.
Returns:
The composite configuration.

getConfiguration

protected org.apache.commons.configuration.Configuration getConfiguration(ClusterSpec clusterSpec,
                                                                          String defaultsPropertiesFile)
                                                                   throws IOException
Throws:
IOException

addRunUrl

public static void addRunUrl(ClusterActionEvent event,
                             String runUrl,
                             String... args)
                      throws IOException
A convenience method for adding a RunUrlStatement to a ClusterActionEvent.

Throws:
IOException

addStatement

public static void addStatement(ClusterActionEvent event,
                                org.jclouds.scriptbuilder.domain.Statement statement)

prepareRemoteFileUrl

public static String prepareRemoteFileUrl(ClusterActionEvent event,
                                          String rawUrl)
                                   throws IOException
Prepare the file url for the remote machine. For public urls this function does nothing. For local urls it uploads the files to a temporary blob cache and adds download statement.

Parameters:
rawUrl - raw url as provided in the configuration file
Returns:
an URL visible to the install / configure scripts
Throws:
IOException

getStartFunction

public String getStartFunction(org.apache.commons.configuration.Configuration config,
                               String service,
                               String defaultFunction)
Get service start function name from the configuration


getStopFunction

public String getStopFunction(org.apache.commons.configuration.Configuration config,
                              String service,
                              String defaultFunction)
Get service start function name from the configuration


getInstallFunction

public String getInstallFunction(org.apache.commons.configuration.Configuration config,
                                 String service,
                                 String defaultFunction)
Get service install function name from the configuration


getConfigureFunction

public String getConfigureFunction(org.apache.commons.configuration.Configuration config,
                                   String service,
                                   String defaultFunction)
Get service configure function name from the configuration


getCleanupFunction

public String getCleanupFunction(org.apache.commons.configuration.Configuration config,
                                 String service,
                                 String defaultFunction)
Get service cleanup function name from the configuration


getFunctionName

public String getFunctionName(org.apache.commons.configuration.Configuration config,
                              String service,
                              String functionName,
                              String defaultFunction)


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.