ePages 6.11.0 - DE_EPAGES/WebInterface/API/ApplicationServer.pm

Package DE_EPAGES::WebInterface::API::ApplicationServer

The application server is a server process that implements the business loging of the epages application. The process waits for incoming requests from the message center and distributes them to the appropriate modules, aka. servlets for further processing.
This module encapsulates the communication protocol between the web adapter and the applictaion server. It uses the MessageCenter module to communicate the status of the process and to exchange cache hints with other application servers.

Example
my $AppServer = DE_EPAGES::WebInterface::API::ApplicationServer->new(
    Address     => '213.232.211.243',  Port   => 10048,
    MCAddress   => '213.232.211.243',  MCPort => 10042,
    MaxRequest  => 5000,
    BindAddress => inet_ntoa( INADDR_ANY )
);
$AppServer->run;
@EXPORT_OK
GetAppServer
TestSocket
ProcessRequest

Functions

GetAppServer
TestSocket
address
currentRequest
currentResponse
currentServlet
enterMonitorMode
flushOutput
messageCenter
monitor
monitorThread
new
port
requestNo
run
serverSocket
serverVariables
sockets
webadapter

GetAppServer

Returns the application server object that handles the current request. Returns undef if the application no application server is running.

Syntax
$AppServer = GetAppServer();
Return
$AppServer (object)
the applcation server object

TestSocket

Checks connection to socket.

Syntax
TestSocket($Host, $Port, $Timeout, $Tries);
Input
$Host (string)
host name or IP address
$Port (integer)
port
$Timeout (integer)
connection timeout in seconds (optional)
$Tries (integer)
number of connection tries (optional)

address

Returns the application server IP address.

Syntax
$Address = $AppServer->address;
Return
$Address (string)
ip address

currentRequest

Returns the currently processed request.

Syntax
$Request = $AppServer->currentRequest;
Return
$Request (object)
request object, see HTTP::Request

currentResponse

Returns the response object for the currently processed request.

Syntax
$Request = $AppServer->currentResponse;
Return
$Request (object)
response object, see HTTP::Response

currentServlet

Returns the currently processed servlet.

Syntax
$Request = $AppServer->currentServlet;
Return
$Servlet (object)
servlet object

enterMonitorMode

Sets the application server into monitor mode which means that the application server will send no further output and the progress can be monitored.

Syntax
$AppServer->enterMonitorMode;

flushOutput

Sends the buffered response data immediately to the client.

Syntax
$AppServer->flushOutput;

messageCenter

Returns the message center.

Syntax
$MessageCenter = $AppServer->messageCenter;
Return
$MessageCenter (object)
message center object, see also DE_EPAGES::WebInterface::API::MessageCenter

monitor

Returns the current monitor object.

Syntax
$Monitor = $AppServer->monitor;
Return
$Monitor (object)
monitor

monitorThread

Returns the current monitor thread object (not the thread it self).

Syntax
$MonitorThread = $AppServer->monitorThread;
Return
$MonitorThread (object)
monitor interface

new

Creates a new application server object.

Syntax
$AppServer = DE_EPAGES::WebInterface::API::ApplicationServer->new( %Options );
Example
my $AppServer = DE_EPAGES::WebInterface::API::ApplicationServer->new(
Address     => '213.232.211.243',  Port   => 10048,
MCAddress   => '213.232.211.243',  MCPort => 10042,
MaxRequest  => 5000,
MaxUptime   => 3600,
MaxMemory   => 150,
BindAddress => inet_ntoa( INADDR_ANY )
);
Input
%Options (hash)
some named parameters
  • Address - IP address of the application server
  • Port - port number where the application server listens for requests
  • MCAddress - message center ip address
  • MCPort - message center port number
  • MaxRequest - maximum number of requests handled by the application server (default: 10000)
  • MaxUptime - maximum runtime of the application server in seconds (default: undef=unlimited)
  • MaxMemory - maximum memory size of the application server in MBytes (default: undef=unlimited)
  • FreeRequestPeriod - period time in seconds when the AS contacts the MC (default: 5)
  • BindAddress - ip address used to listen for requests
    (in case of multiple network interfaces)
  • WebAdapter - web adapter object to receive the request
  • MonitorThread - monitor thread
Return
$AppServer (object)
the applcation server object

port

Returns the application server port number.

Syntax
$Port = $AppServer->port;
Return
$Port (int)
port number

requestNo

Returns the current request counter.

Syntax
$Counter = $AppServer->requestNo;
Return
$Counter (int)
the request counter value

run

Waits for incoming requests from the web adapter, distributes them to request handlers and sends the response back to the web apapter. This loop continues until the number of MaxRequest is reached or a 'shutdown' request is received.

Syntax
$AppServer->run;

serverSocket

Returns the server socket that are used to wait for incoming requests from the web adapter.

Syntax
$Socket = $AppServer->serverSocket;
Return
$Socket (object)
an IO::Socket object

serverVariables

Returns a hash of server variables that correspond to the CGI interface. The values are only valid for the current request.

Syntax
$hVars = $AppServer->serverVariables;
Return
$hVars (hash ref)
server variables

sockets

Returns the selector of sockets that are used by the application server. These sockets include the server socket that is used to wait for incoming requests and client sockets that are used for the actual data transfer between application server and web adapter.

Syntax
$hSockets = $AppServer->sockets;
Return
$hSockets (object)
an IO::Select object

webadapter

Returns the the webadapter interface object.

Syntax
$WebAdapter = $AppServer->webadapter;
Return
$WebAdapter (object)
web adapter