de.netseeker.ejoe
Class EJServer

java.lang.Object
  extended by de.netseeker.ejoe.EJServer

public class EJServer
extends java.lang.Object

This is the server component of EJOE. EJOE is a request object broker in it's natural meaning. You have to use this component if you want retrieve and send data from/to EJOE clients. EJOE offers basically three things for you:

  1. a multithreaded, high performance io server
  2. (de)serializing input of input objects send by clients and return objects provided by YOUR business logic
  3. a simple, clean and unique interface to integrate a object request broker into your application

Basic usage:

                       EJServer server = new EJServer( new EchoHandler() );
                       //to allow persistent client connections use
                       //server.enablePersistentConnections( true );
                       
                       //to use old style blocking IO instead of NIO use
                       //server.enableNonBlockingIO( false );
                       
                       server.start();
                       ...
                       server.stop();
 

Since:
0.3.0
Author:
netseeker aka Michael Manske

Constructor Summary
EJServer()
          Creates an instance of EJServer pre-configured with settings from the global ejserver.properties file.
EJServer(java.util.Properties properties)
          Creates an instance of EJServer pre-configured with settings from the given properties store
EJServer(ServerHandler handler)
          Creates an instance of the EJOE server component pre-configured whith a default value for the used port
EJServer(ServerHandler handler, int port)
          Creates an instance of the EJOE server component
EJServer(ServerHandler handler, java.lang.String bindAddr)
          Creates an instance of the EJOE server component pre-configured whith a default value for the used port
EJServer(ServerHandler handler, java.lang.String bindAddr, int port)
          Creates an instance of the EJOE server component
EJServer(java.lang.String pathToConfigFile)
          Creates an instance of EJServer pre-configured with settings from a global properties file.
 
Method Summary
 void enableCompression(boolean enable)
          Enables or disables the usage of compressing/decompressing for outgoing/incoming data.
 void enableCompression(int compressionLevel)
          Enables the usage of compressing/decompressing for outgoing/incoming data with the given compression level.
 void enableHttpPackaging(boolean enable)
          Enables/disables support for http packaging.
 void enableNonBlockingIO(boolean enable)
          Enables/disables new style non-blocking IO for read and write operations.
 void enablePersistentConnections(boolean enable)
          Enables/disables support for persistents client connections.
 void enableRemoteClassLoading(boolean enable)
          Enables support for remote classloading
 void enableThreadPoolResizeControl(boolean enable)
          Enables/Disables automic, periodic control of the used worker pools.
 void enableThreadPoolResizeControl(boolean enable, long controlPeriod)
          This method works exactly as #enableThreadedProcessorUsage(boolean) but allows setting of a custom time period between control checks of the used worker pools.
 int getConnectionProcessors()
          Returns the number of Connection Processors used for delegating network IO operations to reader/writer workers
 EJServerConfigMBean getJMXConfigurationBean()
          Returns a JMX compliant bean to configure EJServer via JMX
 int getMaxReadProcessors()
          Returns the current amount of supported concurrent read processor threads.
 int getMaxWriteProcessors()
          Returns the current amount of supported concurrent write processor threads.
 IServerInfo getServerInfo()
           
 boolean hasCommpression()
          Returns whether compression has been enabled or not.
 boolean hasHttPackaging()
          Returns whether support for HTTP packaging has been enabled or not.
 boolean hasNonBlockingIO()
          Returns whether NIO has been enabled or not.
 boolean hasPersistentConnections()
          Returns whether support for persistent connections has been enabled or not.
 boolean isRunning()
          Indicates if this EJServer is running and ready to accept and process incoming connections
 void setConnectionProcessors(int count)
          Sets the number of Connection Processors to use for delegating network IO operations to reader/writer workers.
 void setMaxReadProcessors(int maxProcessors)
          Sets the amount of threads used for processing read operations on accepted connections.
 void setMaxWriteProcessors(int maxProcessors)
          Sets the amount of threads used for processing write operations.
 void start()
          (Re)Starts the main server as well as the class loader server (if it's configured)
 void stop()
          Stops the main server as well as the class loader server (if it's running)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EJServer

public EJServer(ServerHandler handler)
Creates an instance of the EJOE server component pre-configured whith a default value for the used port

Parameters:
handler - an implementation of de.netseeker.ejoe.ServerHandler

EJServer

public EJServer(ServerHandler handler,
                java.lang.String bindAddr)
Creates an instance of the EJOE server component pre-configured whith a default value for the used port

Parameters:
handler - an implementation of de.netseeker.ejoe.ServerHandler
bindAddr - the IP address identifying the network interface to which EJServer should bind itself

EJServer

public EJServer(ServerHandler handler,
                int port)
Creates an instance of the EJOE server component

Parameters:
handler - an implementation of de.netseeker.ejoe.ServerHandler
port - the port EJOE should listen to

EJServer

public EJServer(ServerHandler handler,
                java.lang.String bindAddr,
                int port)
Creates an instance of the EJOE server component

Parameters:
handler - an implementation of de.netseeker.ejoe.ServerHandler
bindAddr - the IP address identifying the network interface to which EJServer should bind itself
port - the port EJOE should listen to

EJServer

public EJServer()
Creates an instance of EJServer pre-configured with settings from the global ejserver.properties file. You MUST provide such an property file on the classpath to use this constructor.


EJServer

public EJServer(java.util.Properties properties)
Creates an instance of EJServer pre-configured with settings from the given properties store

Parameters:
properties - properties store containing EJServer settings

EJServer

public EJServer(java.lang.String pathToConfigFile)
Creates an instance of EJServer pre-configured with settings from a global properties file.

Parameters:
pathToConfigFile - path to the properties file
Method Detail

isRunning

public boolean isRunning()
Indicates if this EJServer is running and ready to accept and process incoming connections

Returns:
true if this EJServer is running and ready to accept and process incoming connections otherwise false

getMaxReadProcessors

public int getMaxReadProcessors()
Returns the current amount of supported concurrent read processor threads.

Returns:

setMaxReadProcessors

public void setMaxReadProcessors(int maxProcessors)
Sets the amount of threads used for processing read operations on accepted connections. This will indirectly control the amount of concurrently processed io read operations and adapter calls.

Parameters:
maxProcessors - new amount of threads used for processing accepted connections
See Also:
setMaxWriteProcessors(int)

getMaxWriteProcessors

public int getMaxWriteProcessors()
Returns the current amount of supported concurrent write processor threads.

Returns:

setMaxWriteProcessors

public void setMaxWriteProcessors(int maxProcessors)
Sets the amount of threads used for processing write operations. This will directly control the amount of concurrently processed io socket write operations.

Parameters:
maxProcessors - new amount of threads used for processing io socket write operations
See Also:
setMaxReadProcessors(int)

enableThreadPoolResizeControl

public void enableThreadPoolResizeControl(boolean enable)
Enables/Disables automic, periodic control of the used worker pools. If enabled the worker pools will be checked regulary and shrinked or increased if neccessary. The control ensures that the pool sizes will never extend the size of maxReadProcessors/maxWriteProcessors.

Parameters:
enable -
See Also:
enableThreadPoolResizeControl(boolean, long)

enableThreadPoolResizeControl

public void enableThreadPoolResizeControl(boolean enable,
                                          long controlPeriod)
This method works exactly as #enableThreadedProcessorUsage(boolean) but allows setting of a custom time period between control checks of the used worker pools.

Parameters:
enable -
controlPeriod - period between control checks in milliseconds
See Also:
enableThreadPoolResizeControl(boolean)

hasCommpression

public boolean hasCommpression()
Returns whether compression has been enabled or not.

Returns:

enableCompression

public void enableCompression(boolean enable)
Enables or disables the usage of compressing/decompressing for outgoing/incoming data. Enabling compression *can* result in signifcantly better throughput especially when using a text based SerializeAdapter in confunction with large data objects.

See Also:
SerializeAdapter

enableCompression

public void enableCompression(int compressionLevel)
Enables the usage of compressing/decompressing for outgoing/incoming data with the given compression level. Enabling compression *can* result in signifcantly better throughput especially when using a text based SerializeAdapter in confunction with large data objects.

Parameters:
compressionLevel - the level of compression to use, must be in range of 0-9
See Also:
SerializeAdapter

hasNonBlockingIO

public boolean hasNonBlockingIO()
Returns whether NIO has been enabled or not.

Returns:

enableNonBlockingIO

public void enableNonBlockingIO(boolean enable)
Enables/disables new style non-blocking IO for read and write operations. Sometimes this can be significantly faster than using blocking io. Be aware that connection acception as well as EJOES internal connection handshaking will use NIO anyway to ensure high latency.


hasPersistentConnections

public boolean hasPersistentConnections()
Returns whether support for persistent connections has been enabled or not.

Returns:

enablePersistentConnections

public void enablePersistentConnections(boolean enable)
Enables/disables support for persistents client connections. Usage of persistent connections is more performant in most cases because the client doesn't need to open a new connection on each request. The drawback of persistent connections can be a higher server load because the server may have to handle a lot of "idle" client connections.

Parameters:
enable -

enableHttpPackaging

public void enableHttpPackaging(boolean enable)
Enables/disables support for http packaging.

Parameters:
enable -

hasHttPackaging

public boolean hasHttPackaging()
Returns whether support for HTTP packaging has been enabled or not.

Returns:

getConnectionProcessors

public int getConnectionProcessors()
Returns the number of Connection Processors used for delegating network IO operations to reader/writer workers

Returns:
the number of used Connection Processors

setConnectionProcessors

public void setConnectionProcessors(int count)
Sets the number of Connection Processors to use for delegating network IO operations to reader/writer workers. It is strongly recommended to use the number of physically available processor units.

Parameters:
count - the number of Connection Processors to use

enableRemoteClassLoading

public void enableRemoteClassLoading(boolean enable)
Enables support for remote classloading

Parameters:
enable -

getJMXConfigurationBean

public EJServerConfigMBean getJMXConfigurationBean()
Returns a JMX compliant bean to configure EJServer via JMX

Returns:

getServerInfo

public IServerInfo getServerInfo()
Returns:

start

public void start()
           throws java.io.IOException
(Re)Starts the main server as well as the class loader server (if it's configured)

Throws:
java.io.IOException

stop

public void stop()
Stops the main server as well as the class loader server (if it's running)



Copyright © 2005-2007 netseeker. All Rights Reserved.