com.sun.jini.phoenix
Class Activation

java.lang.Object
  extended by com.sun.jini.phoenix.Activation
All Implemented Interfaces:
Serializable

 class Activation
extends Object
implements Serializable

Phoenix main class.

Since:
2.0
Author:
Sun Microsystems, Inc.

Nested Class Summary
(package private)  class Activation.ActivatorImpl
           
private static class Activation.ActLogHandler
          Handler for the log that knows how to take the initial snapshot and apply an update (a LogRecord) to the current state.
private  class Activation.GroupEntry
          Container for group information: group's descriptor, group's instantiator, flag to indicate pending group creation, and table of the group's active objects.
private static class Activation.LogGroupIncarnation
          Log record for an active group incarnation
private static class Activation.LogRecord
          Abstract class for all log records.
private static class Activation.LogRegisterGroup
          Log record for registering a group.
private static class Activation.LogRegisterObject
          Log record for registering an object.
private static class Activation.LogUnregisterGroup
          Log record for unregistering a group.
private static class Activation.LogUnregisterObject
          Log record for unregistering an object.
private static class Activation.LogUpdateDesc
          Log record for updating an activation desc
private static class Activation.LogUpdateGroupDesc
          Log record for unregistering a group.
(package private)  class Activation.MonitorImpl
           
private  class Activation.ObjectEntry
           
(package private)  class Activation.RegistryImpl
          A read-only registry containing a single entry for the system.
private  class Activation.Shutdown
          Thread to shutdown phoenix.
private  class Activation.ShutdownHook
          Thread to destroy children in the event of abnormal termination.
(package private)  class Activation.SystemImpl
           
 
Field Summary
private  Activator activator
          ActivatorImpl instance
private  Exporter activatorExporter
          exporter for activator
private  Activator activatorStub
          stub for activator
private  String[] command
          the default java command for groups
private  int groupCounter
          counter for numbering groups
private  MarshalledObject groupData
          MarshalledObject(ActivationGroupData) or null
private  String groupLocation
          Location of ActivationGroupImpl or null
private  ProxyPreparer groupPreparer
          preparer for ActivationInstantiators
private  int groupSemaphore
          number of simultaneous group exec's
private  Map groupTable
          maps group id to its GroupEntry groups
private  long groupTimeout
          timeout on wait for child process to be created or destroyed
private  Map idTable
          maps activation id uid to its respective group id
private  ReliableLog log
          persistent store
private static Logger logger
           
private  LoginContext login
          login context
private static Object logLock
           
private  ActivationMonitor monitor
          MonitorImpl instance
private  Exporter monitorExporter
          exporter for monitor
private  ActivationMonitor monitorStub
          stub for monitor
private  int numUpdates
          number of log updates since last log snapshot
private  GroupOutputHandler outputHandler
           
private static String PHOENIX
           
private static int PHOENIX_PORT
           
private  Registry registry
          RegistryImpl instance
private  Exporter registryExporter
          exporter for registry
private  Registry registryStub
          stub for registry
private static ResourceBundle resources
           
private static long serialVersionUID
           
private  Thread shutdownHook
          Runtime shutdown hook
private  boolean shuttingDown
          true if shutdown has been called
private  int snapshotInterval
          take log snapshot after this many updates
private  PhoenixStarter starter
          Non-null if phoenix was started by the service starter
private  ActivationSystem system
          SystemImpl instance
private  Exporter systemExporter
          exporter for system
private  ActivationSystem systemStub
          stub for system
private  long unexportTimeout
          timeout on wait for unexport to succeed
private  long unexportWait
          timeout on wait between unexport attempts
 
Constructor Summary
private Activation()
          Create an uninitialized instance of Activation that can be populated with log data.
 
Method Summary
private  String[] activationArgs(ActivationGroupDesc desc)
           
private  void addLogRecord(Activation.LogRecord rec)
          Adds a record to the activation log.
private static void bomb(String error)
           
private static void bomb(String res, String val)
           
private  void checkShutdown()
          If shutting down, throw an ActivationException.
(package private)  ActivationSystem getActivationSystemProxy()
          Returns the ActivationSystem proxy (used by the PhoenixStarter).
private  ActivationID getAID(UID uid)
           
private static Configuration getConfig(String[] configOptions, PhoenixStarter starter)
          Return a configuration for the specified options.
private static String getDefaultGroupLocation()
           
private static Exporter getExporter(Configuration config, String name, Exporter defaultExporter)
          Return the exporter with the specified name from the specified configuration.
private  Activation.GroupEntry getGroupEntry(ActivationGroupID id)
          Returns the group entry for the group id.
private  Activation.GroupEntry getGroupEntry(UID uid)
          Returns the group entry for the object's id.
private  ActivationGroupID getGroupID(UID uid)
          Returns the groupID for a given id of an object in the group.
private static int getInt(Configuration config, String name, int defValue)
          Return an int configuration entry.
private static ProxyPreparer getPreparer(Configuration config, String name)
          Return a ProxyPreparer configuration entry.
(package private) static String getTextResource(String key)
          Retrieves text resources from the locale-specific properties file.
private static UID getUID(ActivationID id)
           
private  void init(ReliableLog log, LoginContext login, Configuration config, String[] configOptions, PhoenixStarter starter)
           
static void main(String[] args)
          Starts phoenix.
(package private) static Activation main(String[] configOptions, boolean stop, PhoenixStarter starter)
          Starts phoenix and returns a reference to the recovered Activation instance.
private  String Pstartgroup()
          Acquire the group semaphore and return a group name.
private static void shutdown(Configuration config)
          Shut down an activation system daemon, using the specified configuration location to obtain the host and port of the daemon's registry, the client constraints for the remote call, and the permissions to grant to the system proxy.
private  void snapshot()
           
private static void usage()
           
private  void Vstartgroup()
          Release the group semaphore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

PHOENIX

private static final String PHOENIX
See Also:
Constant Field Values

resources

private static ResourceBundle resources

logger

private static Logger logger

PHOENIX_PORT

private static final int PHOENIX_PORT
See Also:
Constant Field Values

logLock

private static final Object logLock

idTable

private Map idTable
maps activation id uid to its respective group id


groupTable

private Map groupTable
maps group id to its GroupEntry groups


login

private transient LoginContext login
login context


groupSemaphore

private transient int groupSemaphore
number of simultaneous group exec's


groupCounter

private transient int groupCounter
counter for numbering groups


log

private transient ReliableLog log
persistent store


numUpdates

private transient int numUpdates
number of log updates since last log snapshot


snapshotInterval

private transient int snapshotInterval
take log snapshot after this many updates


command

private transient String[] command
the default java command for groups


groupTimeout

private transient long groupTimeout
timeout on wait for child process to be created or destroyed


unexportTimeout

private transient long unexportTimeout
timeout on wait for unexport to succeed


unexportWait

private transient long unexportWait
timeout on wait between unexport attempts


activator

private transient Activator activator
ActivatorImpl instance


activatorExporter

private transient Exporter activatorExporter
exporter for activator


activatorStub

private transient Activator activatorStub
stub for activator


system

private transient ActivationSystem system
SystemImpl instance


systemExporter

private transient Exporter systemExporter
exporter for system


systemStub

private transient ActivationSystem systemStub
stub for system


monitor

private transient ActivationMonitor monitor
MonitorImpl instance


monitorExporter

private transient Exporter monitorExporter
exporter for monitor


monitorStub

private transient ActivationMonitor monitorStub
stub for monitor


registry

private transient Registry registry
RegistryImpl instance


registryExporter

private transient Exporter registryExporter
exporter for registry


registryStub

private transient Registry registryStub
stub for registry


groupData

private transient MarshalledObject groupData
MarshalledObject(ActivationGroupData) or null


groupLocation

private transient String groupLocation
Location of ActivationGroupImpl or null


groupPreparer

private transient ProxyPreparer groupPreparer
preparer for ActivationInstantiators


outputHandler

private transient GroupOutputHandler outputHandler

shuttingDown

private volatile boolean shuttingDown
true if shutdown has been called


shutdownHook

private transient Thread shutdownHook
Runtime shutdown hook


starter

private transient PhoenixStarter starter
Non-null if phoenix was started by the service starter

Constructor Detail

Activation

private Activation()
Create an uninitialized instance of Activation that can be populated with log data. This is only called when the initial snapshot is taken during the first incarnation of phoenix.

Method Detail

init

private void init(ReliableLog log,
                  LoginContext login,
                  Configuration config,
                  String[] configOptions,
                  PhoenixStarter starter)
           throws Exception
Throws:
Exception

getDefaultGroupLocation

private static String getDefaultGroupLocation()

getConfig

private static Configuration getConfig(String[] configOptions,
                                       PhoenixStarter starter)
                                throws ConfigurationException
Return a configuration for the specified options.

Throws:
ConfigurationException

getInt

private static int getInt(Configuration config,
                          String name,
                          int defValue)
                   throws ConfigurationException
Return an int configuration entry.

Throws:
ConfigurationException

getExporter

private static Exporter getExporter(Configuration config,
                                    String name,
                                    Exporter defaultExporter)
                             throws ConfigurationException
Return the exporter with the specified name from the specified configuration.

Throws:
ConfigurationException

getPreparer

private static ProxyPreparer getPreparer(Configuration config,
                                         String name)
                                  throws ConfigurationException
Return a ProxyPreparer configuration entry.

Throws:
ConfigurationException

checkShutdown

private void checkShutdown()
                    throws ActivationException
If shutting down, throw an ActivationException.

Throws:
ActivationException

getAID

private ActivationID getAID(UID uid)

getUID

private static UID getUID(ActivationID id)
                   throws UnknownObjectException
Throws:
UnknownObjectException

getGroupID

private ActivationGroupID getGroupID(UID uid)
                              throws UnknownObjectException
Returns the groupID for a given id of an object in the group. Throws UnknownObjectException if the object is not registered.

Throws:
UnknownObjectException

getGroupEntry

private Activation.GroupEntry getGroupEntry(ActivationGroupID id)
                                     throws UnknownGroupException
Returns the group entry for the group id. Throws UnknownGroupException if the group is not registered.

Throws:
UnknownGroupException

getGroupEntry

private Activation.GroupEntry getGroupEntry(UID uid)
                                     throws UnknownObjectException
Returns the group entry for the object's id. Throws UnknownObjectException if the object is not registered.

Throws:
UnknownObjectException

activationArgs

private String[] activationArgs(ActivationGroupDesc desc)

addLogRecord

private void addLogRecord(Activation.LogRecord rec)
                   throws ActivationException
Adds a record to the activation log. If the number of updates passes a predetermined threshold, record a snapshot before adding the record to the log.

Throws:
ActivationException

snapshot

private void snapshot()
               throws ActivationException
Throws:
ActivationException

usage

private static void usage()

bomb

private static void bomb(String error)

bomb

private static void bomb(String res,
                         String val)

main

public static void main(String[] args)
Starts phoenix. See the package documentation for details.

Parameters:
args - command line options

getActivationSystemProxy

ActivationSystem getActivationSystemProxy()
Returns the ActivationSystem proxy (used by the PhoenixStarter).


main

static Activation main(String[] configOptions,
                       boolean stop,
                       PhoenixStarter starter)
                throws Exception
Starts phoenix and returns a reference to the recovered Activation instance.

Parameters:
configOptions - the configuration options for the configuration
stop - if true, initiates shutdown of the activation system on the "registryHost" and "registryPort" obtained from the configuration
starter - the PhoenixStarter instance, or null
Throws:
Exception

shutdown

private static void shutdown(Configuration config)
                      throws Exception
Shut down an activation system daemon, using the specified configuration location to obtain the host and port of the daemon's registry, the client constraints for the remote call, and the permissions to grant to the system proxy.

Throws:
Exception

getTextResource

static String getTextResource(String key)
Retrieves text resources from the locale-specific properties file.


Pstartgroup

private String Pstartgroup()
                    throws ActivationException
Acquire the group semaphore and return a group name. Each Pstartgroup must be followed by a Vstartgroup. The calling thread will wait until there are fewer than N other threads holding the group semaphore. The calling thread will then acquire the semaphore and return.

Throws:
ActivationException

Vstartgroup

private void Vstartgroup()
Release the group semaphore. Every P operation must be followed by a V operation. This may cause another thread to wake up and return from its P operation.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.