Enhydra 5.1 API

com.lutris.multiServer
Class MultiServer

java.lang.Object
  |
  +--com.lutris.multiServer.MultiServer

public class MultiServer
extends java.lang.Object

A stand-alone server. It starts and stops services like the ServletContainer.

At startup time a configuration file is read, and it describes what services to start. After this config file is read, and the server is set up, no further action is taken by the server. The thread that ran through main() exits. The Services must create threads, and they are responsible for receiving requests from the outside world and processing them.

Normally one of the Servlets will be an administration application. This admin app knows about this class, and so it knows how to talk to the current ConnectionMethods and Servlets. It may change the server setup on the fly. For example, it can create and add a new ConnectionMethod. Or it could add a new channel to an already existing ConnectionMethod. Or register a new Servlet. Or add a logging filter to a channel. Or monitor performance.

This class implements main(). It is meant to be run as a java application. Do not instantiate this class. Use the static variables.

The main() function will initialize and configure the global logging facility. The facility name is "MultiServer", and you may use any of the level names defined in the Logger class. One set of level names listed in the MultiServer config file have their output directed to the server log file. Another set of level names have their output directed to stderr. Text written to any other level name not mentioned in the server config file will be ignored.
Any class running in this virtual machine may write to the MultiServer log file, using the following code:

 import com.lutris.logging.*;
 LogChannel logChan = Logger.getCentralLogger().getChannel("Multiserver");
 int level = logChan.getLevel("ERROR");
 logChan.write(level, "An error occured: ....");
 

Author:
Shawn McMurdo
, Andy John

Field Summary
static java.lang.String ACTIVATION_KEY
           
static java.lang.String ENTRAY_FILE
           
static java.lang.String LOG_CONF_FILE
           
static java.lang.String LOG_FILE
           
static java.lang.String LOG_TO_FILE
           
static java.lang.String LOG_TO_STDERR
           
static java.lang.String SERIAL_NUMBER
           
static java.lang.String SERVER
           
 
Method Summary
static long currentMemoryUsage(boolean forceGC)
          This method is used to get the current value of the amount of memory being used by the virtual machine.
static long getMaxMemoryUsage()
          This method if for getting the value that has been stored as highwater mark for memory usage by the virtual machine.
static Service getService(java.lang.String name)
          Get the named service.
static void main(java.lang.String[] argv)
          The entry point for the stand-alone server.
static void resetMaxMemoryUsage()
          This method is used to reset the maxMemoryUsage back to zero.
static void setMaxMemoryUsage(long used)
          This method is used for setting the highwater mark for the amount of memory that the virtual machine has used.
static void shutdown()
          Shut down the server.
static void stopAllServices()
          Stops all services and returns.
static java.lang.String writeConfigFile(java.lang.String filename)
          This function examines the current state of the server and writes it out to the same config file that was read when the server was started up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVER

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

LOG_FILE

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

LOG_TO_FILE

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

LOG_TO_STDERR

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

SERIAL_NUMBER

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

ACTIVATION_KEY

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

LOG_CONF_FILE

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

ENTRAY_FILE

public static final java.lang.String ENTRAY_FILE
Method Detail

main

public static void main(java.lang.String[] argv)
The entry point for the stand-alone server. If an argument is passed in, it is assumed to be the location of the server config file. If no arguments are passed in, the default filename "./MultiServer.config" is used.

Parameters:
argv - An array of input parameters. None are required.

stopAllServices

public static void stopAllServices()
Stops all services and returns.


shutdown

public static void shutdown()
Shut down the server. This function stops all services.


getService

public static Service getService(java.lang.String name)
Get the named service.

Returns:
the Service

writeConfigFile

public static java.lang.String writeConfigFile(java.lang.String filename)
This function examines the current state of the server and writes it out to the same config file that was read when the server was started up.

Parameters:
filename - The filename of the config file to write out. If null, the same file that was read at startup time will be rewritten.

getMaxMemoryUsage

public static long getMaxMemoryUsage()
This method if for getting the value that has been stored as highwater mark for memory usage by the virtual machine.


setMaxMemoryUsage

public static void setMaxMemoryUsage(long used)
This method is used for setting the highwater mark for the amount of memory that the virtual machine has used. The method does the appropriate checking to see if the value passed is greater than the current stored value.

Parameters:
used - The amount of memory that has been used.

resetMaxMemoryUsage

public static void resetMaxMemoryUsage()
This method is used to reset the maxMemoryUsage back to zero. This is so that new statistics can be gotten without restarting the application.


currentMemoryUsage

public static long currentMemoryUsage(boolean forceGC)
This method is used to get the current value of the amount of memory being used by the virtual machine.

Parameters:
forceGC - A boolean value to tell the method whether or not to run garbage collection before getting the memory statistics. WARNING!!! forcing garbage collection can cause a major performance impact.
Returns:
the current amount of memory being used by the virtual machine in bytes.

Enhydra 5.1 API