org.jclouds.scriptbuilder
Class InitScript

java.lang.Object
  extended by com.google.common.collect.ForwardingObject
      extended by org.jclouds.scriptbuilder.InitScript
All Implemented Interfaces:
AcceptsStatementVisitor, Statement

public class InitScript
extends com.google.common.collect.ForwardingObject
implements Statement, AcceptsStatementVisitor

Creates an init script file

Author:
Adrian Cole

Nested Class Summary
static class InitScript.Builder
           
 
Field Summary
protected  ScriptBuilder delegate
           
protected  Map<String,String> exports
           
protected  StatementList init
           
protected  String instanceHome
           
protected  String instanceName
           
protected  String logDir
           
protected  StatementList run
           
 
Constructor Summary
protected InitScript(String instanceName, String instanceHome, String logDir, Map<String,String> exports, StatementList init, StatementList run)
           
 
Method Summary
 void accept(StatementVisitor visitor)
           
static InitScript.Builder builder()
           
protected  ScriptBuilder delegate()
           
 boolean equals(Object that)
           
 Iterable<String> functionDependencies(OsFamily family)
           
 StatementList getInitStatement()
           
 String getInstanceHome()
          default /tmp/$INSTANCE_NAME
 String getInstanceName()
           
 String getLogDir()
          default $INSTANCE_HOME
 StatementList getRunStatement()
           
 int hashCode()
           
static ScriptBuilder makeInitScriptStatement(String instanceName, String instanceHome, String logDir, Map<String,String> exports, StatementList init, StatementList run)
           
 String render(OsFamily family)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

instanceName

protected final String instanceName

instanceHome

protected final String instanceHome

logDir

protected final String logDir

exports

protected final Map<String,String> exports

init

protected final StatementList init

run

protected final StatementList run

delegate

protected final ScriptBuilder delegate
Constructor Detail

InitScript

protected InitScript(String instanceName,
                     String instanceHome,
                     String logDir,
                     Map<String,String> exports,
                     StatementList init,
                     StatementList run)
Method Detail

builder

public static InitScript.Builder builder()

makeInitScriptStatement

public static ScriptBuilder makeInitScriptStatement(String instanceName,
                                                    String instanceHome,
                                                    String logDir,
                                                    Map<String,String> exports,
                                                    StatementList init,
                                                    StatementList run)

getInstanceName

public String getInstanceName()
Returns:
what will be bound to the INSTANCE_NAME variable, and uniquely identifies the process

getInstanceHome

public String getInstanceHome()
default /tmp/$INSTANCE_NAME

note

The parent directory should be set with unix sticky-bit or otherwise made available to all users. Otherwise, new instances by other users may fail due to not being able to create a directory. This is why the default is set to /tmp

Returns:
what will be bound to the INSTANCE_HOME variable, and represents the working directory of the instance

getLogDir

public String getLogDir()
default $INSTANCE_HOME

Returns:
what will be bound to the LOG_DIR variable, and represents where stdout and stderr.logs are written.

getInitStatement

public StatementList getInitStatement()
Returns:
statements that will be executed upon the init command

getRunStatement

public StatementList getRunStatement()
Returns:
statements that will be executed upon the run or start commands

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object that)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class com.google.common.collect.ForwardingObject

accept

public void accept(StatementVisitor visitor)
Specified by:
accept in interface AcceptsStatementVisitor

functionDependencies

public Iterable<String> functionDependencies(OsFamily family)
Specified by:
functionDependencies in interface Statement

render

public String render(OsFamily family)
Specified by:
render in interface Statement

delegate

protected ScriptBuilder delegate()
Specified by:
delegate in class com.google.common.collect.ForwardingObject


Copyright © 2009-2012 jclouds. All Rights Reserved.