org.rhq.enterprise.agent
Class AgentUpdateThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.rhq.enterprise.agent.AgentUpdateThread
All Implemented Interfaces:
Runnable

public class AgentUpdateThread
extends Thread

This is a thread that will attempt to update the agent to the latest version. This will shutdown the currently running agent, so it is "destructive" in the sense that if successful, the VM this thread is running in will eventually die.

Author:
John Mazzitelli

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static boolean isUpdatingNow()
          This returns true if the agent is currently in the process of performing an update.
 void run()
           
static void updateAgentNow(AgentMain agent, boolean wait)
          This static method will immediately begin to update the agent.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

updateAgentNow

public static void updateAgentNow(AgentMain agent,
                                  boolean wait)
                           throws IllegalStateException
This static method will immediately begin to update the agent. Once you call this, there is no turning back - if all goes well, the currently running agent (and the VM its running in) will soon exit.

Parameters:
agent - the running agent that is to be updated
wait - if true, this will wait for the update thread to die. Note that if the agent update is successful, and you pass wait=true, this method will never return. It will only return if the update failed and the VM is still alive. Pass false if you want to fire-and-forget the agent update thread and return immediately.
Throws:
IllegalStateException - if the agent is already being updated
UnsupportedOperationException - if the agent is not allowed to update itself

isUpdatingNow

public static boolean isUpdatingNow()
This returns true if the agent is currently in the process of performing an update. When this returns true, it should be assumed the agent's VM will die shortly.

Returns:
true if an update thread is running and the update is being performed

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.