Groovy Documentation

org.linkedin.glu.agent.api
[Groovy] Interface Agent


interface Agent

Authors:
ypujante@linkedin.com


Property Summary
static java.lang.Object DEFAULT_TRANSITIONS

Default transitions for the state machine in the script (if the script does not provide its own)

static java.lang.Object SELF_UPGRADE_TRANSITIONS

 
Method Summary
boolean addTag(java.lang.String tag)

Adds a tag.

java.util.Set addTags(java.util.Collection tags)

Adds all the tags.

void clearError(java.lang.Object args)

Clears the error attached to the mountpoint.

java.lang.String executeAction(java.lang.Object args)

Executes the action on the software that was installed on the given mount point.

java.lang.Object executeActionAndWait(java.lang.Object args)

Shortcut for both actions.

boolean executeActionAndWaitForState(java.lang.Object args)

Shortcut for both actions.

java.lang.Object executeCall(java.lang.Object args)

Executes the call on the software that was installed on the given mount point.

java.lang.Object getFileContent(java.lang.Object args)

Returns the content of the file at the given location.

java.lang.Object getFullState(java.lang.Object args)

@param args.mountPoint the mount point of the script you want to get the (full) state

java.lang.Object getHostInfo()

@return information about the host

java.lang.Object getMountPoints()

@return a list of all mount points currently mounted in the agent

java.lang.Object getState(java.lang.Object args)

@param args.mountPoint the mount point of the script you want to get the state

java.util.Set getTags()

@return the set of all tags

int getTagsCount()

**************************************************************** Software management *****************************************************************

boolean hasAllTags(java.util.Collection tags)

@return true if the given tags are present (all of them)

boolean hasAnyTag(java.util.Collection tags)

@return true if at least one of them is present

boolean hasTag(java.lang.String tag)

@return true if the given tag is present

boolean hasTags()

@return true if there are no tags

void installScript(java.lang.Object args)

**************************************************************** Software management *****************************************************************

boolean interruptAction(java.lang.Object args)

Interrupts the action provided or the current one if neither action nor actionId is provided.

void kill(long pid, int signal)

Sends the signal to the process with the given pid

java.lang.Object ps()

Equivalent to the ps command on unix: returns information about all the processes running

boolean removeTag(java.lang.String tag)

Removes the provided tag.

java.util.Set removeTags(java.util.Collection tags)

Removes all the tags.

void setTags(java.util.Collection tags)

Allow you to set the exact set of tags you want.

void sync()

Resynchronizes the agent (to call in case the agent loose synchronization with zookeeper for example)

java.io.InputStream tailAgentLog(java.lang.Object args)

tails the agent log file

void uninstallScript(java.lang.Object args)

Removed a previously installed script.

java.lang.Object waitForAction(java.lang.Object args)

Waits for the action (previously scheduled in executeAction(Object)) to complete no longer than the timeout provided.

boolean waitForState(java.lang.Object args)

Waits for the script to be in the state

 

Property Detail

DEFAULT_TRANSITIONS

static java.lang.Object DEFAULT_TRANSITIONS
Default transitions for the state machine in the script (if the script does not provide its own)


SELF_UPGRADE_TRANSITIONS

static java.lang.Object SELF_UPGRADE_TRANSITIONS


 
Method Detail

addTag

boolean addTag(java.lang.String tag)
Adds a tag.
Returns:
true if the tag which was added was a new tag, otherwise false


addTags

java.util.Set addTags(java.util.Collection tags)
Adds all the tags.
Returns:
the set of tags that were added (empty set if they were all already present)


clearError

void clearError(java.lang.Object args)
Clears the error attached to the mountpoint.
throws:
NoSuchMountPointException when no mount point
Parameters:
args.mountPoint - same mount point provided during installScript(Object)


executeAction

java.lang.String executeAction(java.lang.Object args)
Executes the action on the software that was installed on the given mount point. Note that this method returns immediately and does not wait for the action to complete.
Parameters:
args.mountPoint - same mount point provided during installScript(Object)
args.action - the lifecycle method you want to execute
args.actionArgs - the arguments to provide the action
Returns:
a unique id referring to the action to be used in waitForAction(Object)


executeActionAndWait

java.lang.Object executeActionAndWait(java.lang.Object args)
Shortcut for both actions. Although it is a shortcut, there is a slight difference than issuing those 2 calls yourself: this one will never throw the NoSuchActionException
See Also:
executeAction(Object)
waitForAction(Object)


executeActionAndWaitForState

boolean executeActionAndWaitForState(java.lang.Object args)
Shortcut for both actions.
See Also:
executeAction(Object)
waitForState(Object)


executeCall

java.lang.Object executeCall(java.lang.Object args)
Executes the call on the software that was installed on the given mount point. Note that this method is a blocking call and will wait for the result of the call.
Parameters:
args.mountPoint - same mount point provided during installScript(Object)
args.call - the call you want to execute
args.callArgs - the arguments to provide the call
Returns:
whatever value the call returns


getFileContent

java.lang.Object getFileContent(java.lang.Object args)
Returns the content of the file at the given location. If the file is a directory then returns ls() (Map) otherwise returns tail() (InputStream)
params:
args.location which file to read the content
params:
args.maxLine the number of lines maximum to read
params:
args.maxSize the maximum size to read


getFullState

java.lang.Object getFullState(java.lang.Object args)
Parameters:
args.mountPoint - the mount point of the script you want to get the (full) state
Returns:
the full state of the mountpoint ([scriptDefinition: [...], scriptState: [...]]. Ex: [scriptDefinition:[initParameters:[:], parent:/, mountPoint:/container/i001, scriptFactory:[location:file:/tmp/TomcatServerWithWarsScript.groovy, class:org.linkedin.glu.agent.impl.script.FromLocationScriptFactory]], scriptState:[stateMachine:[currentState:installed], script:[:]]]
See Also:
StateManager#getFullState()#getFullState()


getHostInfo

java.lang.Object getHostInfo()
Returns:
information about the host


getMountPoints

java.lang.Object getMountPoints()
Returns:
a list of all mount points currently mounted in the agent


getState

java.lang.Object getState(java.lang.Object args)
throws:
NoSuchMountPointException when no mount point
Parameters:
args.mountPoint - the mount point of the script you want to get the state
Returns:
the state of the script (currentState/transitionState/error)
See Also:
StateManager#getState()#getState()


getTags

java.util.Set getTags()
Returns:
the set of all tags


getTagsCount

int getTagsCount()
***************************************************************** Software management ******************************************************************


hasAllTags

boolean hasAllTags(java.util.Collection tags)
Returns:
true if the given tags are present (all of them)


hasAnyTag

boolean hasAnyTag(java.util.Collection tags)
Returns:
true if at least one of them is present


hasTag

boolean hasTag(java.lang.String tag)
Returns:
true if the given tag is present


hasTags

boolean hasTags()
Returns:
true if there are no tags


installScript

void installScript(java.lang.Object args)
***************************************************************** Software management ******************************************************************


interruptAction

boolean interruptAction(java.lang.Object args)
Interrupts the action provided or the current one if neither action nor actionId is provided. If you provide one, you should provide only one of action or actionId.
Parameters:
args.mountPoint - same mount point provided during installScript(Object)
args.action - the lifecycle method you want to interrupt
args.actionId - the id of the action to interrupt
Returns:
true if the action was interrupted properly or false if there was no such action or already completed


kill

void kill(long pid, int signal)
Sends the signal to the process with the given pid


ps

java.lang.Object ps()
Equivalent to the ps command on unix: returns information about all the processes running
Returns:
a map where the key is the pid and the value is a map with the following entries when applicable:
  • env
  • args
  • cpu
  • credName
  • exe
  • fd
  • mem
  • modules
  • state
  • time


removeTag

boolean removeTag(java.lang.String tag)
Removes the provided tag.
Returns:
true if the tag was removed or false if the tag was not present in the first place


removeTags

java.util.Set removeTags(java.util.Collection tags)
Removes all the tags.
Returns:
the set of tags that were not present (empty set if they were all already present)


setTags

void setTags(java.util.Collection tags)
Allow you to set the exact set of tags you want. Equivalent to calling (in an atomic fashion)
 removeTags(getTags())
 addTags(tags)
 
Parameters:
tags - tags to set


sync

void sync()
Resynchronizes the agent (to call in case the agent loose synchronization with zookeeper for example)


tailAgentLog

java.io.InputStream tailAgentLog(java.lang.Object args)
tails the agent log file
params:
args.log which log to tail (optional, default to glu-agent.out)
params:
args.maxLine the number of lines maximum to read
params:
args.maxSize the maximum size to read


uninstallScript

void uninstallScript(java.lang.Object args)
Removed a previously installed script. Note that the lifecyle must be ended first otherwise an exception will be thrown.
Parameters:
args.mountPoint - same mount point provided during installScript(Object)
args.force - set to true if you want to force uninstalling the script regardless of its state


waitForAction

java.lang.Object waitForAction(java.lang.Object args)
Waits for the action (previously scheduled in executeAction(Object)) to complete no longer than the timeout provided. Note that due to the nature of the call it is possible that this method throws a NoSuchActionException in some cases:
throws:
NoSuchActionException if the action cannot be found
throws:
TimeOutException if the action cannot be completed in the given amount of time
Parameters:
args.mountPoint - the mount point of the script you want to wait for
args.actionId - the id of the action to wait for
args.timeout - if not null, the amount of time to wait maximum
Returns:
the value of the execution


waitForState

boolean waitForState(java.lang.Object args)
Waits for the script to be in the state
throws:
NoSuchMountPointException when no mount point
Parameters:
args.mountPoint - the mount point of the script you want to wait for
args.state - the desired state to wait for
args.timeout - if not null, the amount of time to wait maximum
Returns:
true if the state was reached within the timeout, false otherwise


 

Groovy Documentation