com.metamatrix.platform.vm.controller
Class VMController

java.lang.Object
  extended by com.metamatrix.platform.vm.controller.VMController
All Implemented Interfaces:
VMControllerInterface
Direct Known Subclasses:
SocketVMController

public abstract class VMController
extends java.lang.Object
implements VMControllerInterface

This class is used to start up and bind VM's to the naming server. The following command will startup a standalone vm with no services.

   java com.metamatrix.framework.vm.controller.VMController  false log.txt
 
The following command will startup a vm and start services as defined in the deployment model. The vmName must exist in the property service.

   java com.metamatrix.framework.vm.controller.VMController vmName true log.txt
 


Field Summary
protected  ClientServiceRegistry clientServices
           
static int DEFAULT_STARTER_MAX_THREADS
           
static int DEFAULT_STARTER_TIMETOLIVE
           
protected  Host host
           
protected  VMControllerID id
           
protected  ClusteredRegistryState registry
           
static java.lang.String SERVICE_MONITOR_INTERVAL
          Interval to check the state of services (ms)
static java.lang.String STARTER_MAX_THREADS
           
static java.lang.String STARTER_TIMETOLIVE
          Time-to-live for threads used to start services (ms)
protected  java.lang.String vmName
           
 
Constructor Summary
VMController(Host host, java.lang.String vmName, VMControllerID vmId, ClusteredRegistryState registry, ServerEvents serverEvents, MessageBus bus, HostManagement hostManagement)
          Create a new instance of VMController.
 
Method Summary
 void checkService(ServiceID serviceID)
          Check a service, and updates the state in some cases.
protected  void doStopVM(boolean now, boolean shutdown)
           
protected static void doUsage()
           
 void dumpThreads()
          Prints thread information to a log file.
 byte[] exportLogs()
          Export the server logs to a byte[].
 java.net.InetAddress getAddress()
          Get the address of the host this VM is running on.
 Host getConfigHost()
           
 LogConfiguration getCurrentLogConfiguration()
          Return current log configuration for this vm.
 VMControllerID getID()
          Get the ID for this controller.
 java.lang.String getName()
          Get the name for this controller.
abstract  WorkerPoolStats getProcessPoolStats()
           
protected  java.util.Properties getProperties()
           
abstract  SocketListenerStats getSocketListenerStats()
           
 java.util.Date getStartTime()
          Get the time the VM was initialized.
 VMStatistics getVMStatistics()
          Return information about VM.
 boolean isShuttingDown()
          Returns true if system is being shutdown.
protected  boolean isStarted()
          Return TRUE if the system's services are started; i.e.
protected  void logMessage(java.lang.String s)
           
 void ping()
          Method called from registries to determine if VMController is alive.
 void runGC()
          Run GC on vm.
 void setCurrentLogConfiguration(LogConfiguration logConfiguration)
          Set the current log configuration for this vm.
 void shutdown()
          Shut down all services waiting for work to complete.
 void shutdownNow()
          Shut down all services without waiting for work to complete.
 void shutdownService(ServiceID serviceID)
          Shut down service waiting for work to complete.
 void shutdownServiceNow(ServiceID serviceID)
          Shut down service without waiting for work to complete.
 void startDeployedService(ServiceComponentDefnID id)
          Start the service identified by the ServiceComponentID If synch is true then wait for service to start before returning.
 void startService(ServiceID serviceID)
          Start a previously stopped service
 void startVM()
          Starts the VM by invoking all the deployed services
 void stopAllServices()
          Kill services
 void stopAllServicesNow()
          Kill services now!!!
 void stopService(ServiceID id)
          Kill service once work is complete
 void stopServiceNow(ServiceID id)
          Kill service now!!!
 void stopVM()
          Kill all services (waiting for work to complete) and then kill the vm.
 void stopVMNow()
          Kill all services now, do not wait for work to complete, do not collect $200
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STARTER_MAX_THREADS

public static final java.lang.String STARTER_MAX_THREADS
See Also:
Constant Field Values

STARTER_TIMETOLIVE

public static final java.lang.String STARTER_TIMETOLIVE
Time-to-live for threads used to start services (ms)

See Also:
Constant Field Values

SERVICE_MONITOR_INTERVAL

public static final java.lang.String SERVICE_MONITOR_INTERVAL
Interval to check the state of services (ms)

See Also:
Constant Field Values

DEFAULT_STARTER_MAX_THREADS

public static final int DEFAULT_STARTER_MAX_THREADS
See Also:
Constant Field Values

DEFAULT_STARTER_TIMETOLIVE

public static final int DEFAULT_STARTER_TIMETOLIVE
See Also:
Constant Field Values

host

protected Host host

vmName

protected java.lang.String vmName

id

protected VMControllerID id

registry

protected ClusteredRegistryState registry

clientServices

protected ClientServiceRegistry clientServices
Constructor Detail

VMController

public VMController(Host host,
                    java.lang.String vmName,
                    VMControllerID vmId,
                    ClusteredRegistryState registry,
                    ServerEvents serverEvents,
                    MessageBus bus,
                    HostManagement hostManagement)
             throws java.lang.Exception
Create a new instance of VMController.

Parameters:
vmName - Name of VM
startDeployedServices - If true all services that are deployed to this vm are started.
standalone - If true indicates that VMController is running in its own vm.
Throws:
java.lang.Exception - if an error occurs initializing vmController
Method Detail

logMessage

protected void logMessage(java.lang.String s)

doUsage

protected static void doUsage()

getID

public VMControllerID getID()
Description copied from interface: VMControllerInterface
Get the ID for this controller.

Specified by:
getID in interface VMControllerInterface

startVM

public void startVM()
Description copied from interface: VMControllerInterface
Starts the VM by invoking all the deployed services

Specified by:
startVM in interface VMControllerInterface

startService

public void startService(ServiceID serviceID)
Description copied from interface: VMControllerInterface
Start a previously stopped service

Specified by:
startService in interface VMControllerInterface

startDeployedService

public void startDeployedService(ServiceComponentDefnID id)
Description copied from interface: VMControllerInterface
Start the service identified by the ServiceComponentID If synch is true then wait for service to start before returning. Any exceptions will then be thrown to the caller. If synch is false then start service asynchronously.

Specified by:
startDeployedService in interface VMControllerInterface

stopVM

public void stopVM()
Kill all services (waiting for work to complete) and then kill the vm.

Specified by:
stopVM in interface VMControllerInterface

doStopVM

protected void doStopVM(boolean now,
                        boolean shutdown)

stopVMNow

public void stopVMNow()
Kill all services now, do not wait for work to complete, do not collect $200

Specified by:
stopVMNow in interface VMControllerInterface

stopService

public void stopService(ServiceID id)
Kill service once work is complete

Specified by:
stopService in interface VMControllerInterface

stopServiceNow

public void stopServiceNow(ServiceID id)
Kill service now!!!

Specified by:
stopServiceNow in interface VMControllerInterface

stopAllServicesNow

public void stopAllServicesNow()
                        throws MultipleException
Kill services now!!!

Specified by:
stopAllServicesNow in interface VMControllerInterface
Throws:
MultipleException

stopAllServices

public void stopAllServices()
                     throws MultipleException
Kill services

Specified by:
stopAllServices in interface VMControllerInterface
Throws:
MultipleException

shutdown

public void shutdown()
Shut down all services waiting for work to complete. Essential services will also be shutdown.

Specified by:
shutdown in interface VMControllerInterface

shutdownNow

public void shutdownNow()
Shut down all services without waiting for work to complete. Essential services will also be shutdown.

Specified by:
shutdownNow in interface VMControllerInterface

shutdownService

public void shutdownService(ServiceID serviceID)
Description copied from interface: VMControllerInterface
Shut down service waiting for work to complete. Essential services will also be shutdown.

Specified by:
shutdownService in interface VMControllerInterface

shutdownServiceNow

public void shutdownServiceNow(ServiceID serviceID)
Shut down service without waiting for work to complete. Essential services will also be shutdown.

Specified by:
shutdownServiceNow in interface VMControllerInterface

getCurrentLogConfiguration

public LogConfiguration getCurrentLogConfiguration()
Return current log configuration for this vm.

Specified by:
getCurrentLogConfiguration in interface VMControllerInterface

setCurrentLogConfiguration

public void setCurrentLogConfiguration(LogConfiguration logConfiguration)
Set the current log configuration for this vm.

Specified by:
setCurrentLogConfiguration in interface VMControllerInterface

getStartTime

public java.util.Date getStartTime()
Get the time the VM was initialized.

Specified by:
getStartTime in interface VMControllerInterface

getConfigHost

public Host getConfigHost()

ping

public void ping()
Method called from registries to determine if VMController is alive.

Specified by:
ping in interface VMControllerInterface

isShuttingDown

public boolean isShuttingDown()
Description copied from interface: VMControllerInterface
Returns true if system is being shutdown.

Specified by:
isShuttingDown in interface VMControllerInterface

getVMStatistics

public VMStatistics getVMStatistics()
Return information about VM. totalMemory, freeMemory, threadCount

Specified by:
getVMStatistics in interface VMControllerInterface

dumpThreads

public void dumpThreads()
Prints thread information to a log file. Does not include the stacktrace - that is not available in 1.4.

Specified by:
dumpThreads in interface VMControllerInterface

runGC

public void runGC()
Run GC on vm.

Specified by:
runGC in interface VMControllerInterface

exportLogs

public byte[] exportLogs()
Description copied from interface: VMControllerInterface
Export the server logs to a byte[]. The bytes contain the contents of a .zip file containing the logs. This will export all logs on the host that contains this VMController.

Specified by:
exportLogs in interface VMControllerInterface
Returns:
the logs, as a byte[].
Since:
4.3
See Also:
VMControllerInterface.exportLogs()

getSocketListenerStats

public abstract SocketListenerStats getSocketListenerStats()

getProcessPoolStats

public abstract WorkerPoolStats getProcessPoolStats()

checkService

public void checkService(ServiceID serviceID)
Check a service, and updates the state in some cases. Catches any ServiceExceptions, so that the caller doesn't have to deal with them.

Specified by:
checkService in interface VMControllerInterface
Parameters:
serviceID - Identifies service to be stopped

getProperties

protected java.util.Properties getProperties()

isStarted

protected boolean isStarted()
Return TRUE if the system's services are started; i.e. at least one of every essential services in a product is running. Authorization, Configuration, Membership and Session services are considered to be essential.

Parameters:
callerSessionID - ID of the caller's current session.
Returns:
Boolean - TRUE if system is started, FALSE if not.
Throws:
MetaMatrixComponentException - if an error occurred in communicating with a component.

getAddress

public java.net.InetAddress getAddress()
Description copied from interface: VMControllerInterface
Get the address of the host this VM is running on.

Specified by:
getAddress in interface VMControllerInterface

getName

public java.lang.String getName()
Description copied from interface: VMControllerInterface
Get the name for this controller.

Specified by:
getName in interface VMControllerInterface


Copyright © 2009. All Rights Reserved.