|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
public interface ZXTMServletRequest
The ZXTMServletRequest interface is an extension to the standard ServletRequest class. In particular, it provides methods to allow the Servlet to alter the supplied request. The modified request can then be forwarded by ZXTM on to a backend node in order to generate a response. This means that Servlets in ZXTM do not have to be content generators, they can also modify the requests that other servers will use to generate a response. When ZXTM invokes a Servlet, the ServletRequest parameter can be safely cast into a ZXTMServletRequest. This will enable your Servlet to use the ZXTM extensions to the base Servlet API. For example, a typical Servlet can do the following:
public void service( ServletRequest req, ServletResponse res )
{
ZXTMServletRequest zreq = (ZXTMServletRequest)req;
ZXTMServletResponse zres = (ZXTMServletResponse)res;
// zreq and zres can now be used to access the extended ZXTM
// functionality
}
As well as the new methods exposed via this class and ZXTMServletResponse,
many of ZXTM's features are controllable via the Servlet attributes, which
can be queried and set with ServletRequest.getAttribute() and
ServletRequest.setAttribute(). These attributes provide similar functionality
to common TrafficScript functions, as shown below:
| Attribute name | Description | TrafficScript equivalent |
|---|---|---|
| args | Any arguments that were supplied to the Servlet with the TrafficScript java.run() function | |
| avoidnodes | A space-separated list of nodes that ZXTM should not use when choosing where to send this request | request.avoidNode() |
| bandwidth | Bandwidth class name | response.setBandwidthClass() |
| cache | 0 to disable caching, 1 to enable caching | http.cache.enable() |
| cachekey | Cache index hint | http.cache.setKey() |
| compress | 0 to disable compression, 1 to leave as default, 2 to force enable | http.compress.enable() |
| dstip | Destination IP address (IP that client connected to) | request.getLocalIP() |
| dstport | Port that the client connected to | request.getLocalPort() |
| idempotent | 0 to disable re-sending request, 1 to enable | request.setIdempotent() |
| logenabled | 0 to disable logging, 1 to enable | request.setLogEnabled() |
| node | Node used for this connection (read-only) | connection.getNode() |
| persistence | Get/set persistence class | connection.setPersistence() |
| persistencekey | Set additional persistence data | connection.setPersistenceKey() |
| persistencenode | Get/set node for NamedNode persistence | connection.setPersistenceNode() |
| pool | Get/set the pool to use for this request | pool.select() |
| proxy | Pick a specific host (name:port) to forward-proxy to | pool.select() |
| resendable | 1 if this request is resendable by a response rule | request.isResendable() |
| retries | Number of retries that this request has had | request.getRetries() |
| rule | Name of the current TrafficScript rule | rule.getName() |
| serverbandwidth | Server bandwidth class name | request.setBandwidthClass() |
| serverdstip | IP address of the node used for this request | response.getRemoteIP() |
| serverdstport | Port of the node used for this request | response.getRemotePort() |
| serversrcip | Local IP address used for connection to backend node | response.getLocalIP() |
| serversrcport | Local port used for connection to backend node | response.getLocalPort() |
| servertos | Type of Service flag for the server connection | request.setToS() |
| servicelevel | SLM class to use | connection.setServiceLevelClass() |
| srcip | IP address of the client | request.getRemoteIP() |
| srcport | Port of the client | request.getRemotePort() |
| ssl_sessionid | SSL session ID | ssl.sslSessionID() |
| SSL_PROTOCOL | SSL protocol | |
| ssl_ciphers | SSL cipher used | ssl.clientCipher() |
| ssl_cipher_size | SSL cipher size (bits) | ssl.clientCipher() |
| SSL_VERSION_INTERFACE | SSL library version | |
| tos | Type of Service flag for the client connection | response.setToS() |
| virtualserver | Name of the virtual server | connection.getVirtualServer() |
| Nested Class Summary | |
|---|---|
static class |
ZXTMServletRequest.DataType
|
| Method Summary | |
|---|---|
void |
emitEvent(String event,
String message)
This creates a custom event which can cause the alerting system to run an action. |
String |
geoGetCity(InetAddress ip)
Returns the city name of a given IPv4 address, or null if no information is available. |
String |
geoGetCity(String ip)
Returns the city name of a given IPv4 address, or null if no information is available. |
String |
geoGetCountry(InetAddress ip)
Returns the country name of a given IPv4 address, or null if no information is available. |
String |
geoGetCountry(String ip)
Returns the country name of a given IPv4 address, or null if no information is available. |
String |
geoGetCountryCode(String ip)
Returns the 2-character country code of a given IPv4 address, or null if no information is available. |
double |
geoGetDistanceKM(double[] coord1,
double[] coord2)
Returns the distance in kilometres between two points on the Earth's surface (given as lat-lon coordinate pairs). |
double |
geoGetDistanceKM(double lat1,
double lon1,
double lat2,
double lon2)
Returns the distance in kilometres between two points on the Earth's surface (given as lat-lon coordinates). |
double |
geoGetDistanceMiles(double[] coord1,
double[] coord2)
Returns the distance in miles between two points on the Earth's surface (given as lat-lon coordinate pairs). |
double |
geoGetDistanceMiles(double lat1,
double lon1,
double lat2,
double lon2)
Returns the distance in miles between two points on the Earth's surface (given as lat-lon coordinates). |
double |
geoGetIPDistanceKM(InetAddress ip1,
InetAddress ip2)
Returns the distance in kilometres between two IPv4 addresses, or -1 if either location can't be found. |
double |
geoGetIPDistanceKM(String ip1,
String ip2)
Returns the distance in kilometres between two IPv4 addresses, or -1 if either location can't be found. |
double |
geoGetIPDistanceMiles(InetAddress ip1,
InetAddress ip2)
Returns the distance in miles between two IPv4 addresses, or -1 if either location can't be found. |
double |
geoGetIPDistanceMiles(String ip1,
String ip2)
Returns the distance in miles between two IPv4 addresses, or -1 if either location can't be found. |
double[] |
geoGetLatLon(InetAddress ip)
Returns the latitude and longitude of a given IPv4 address, or null if no information is available. |
double[] |
geoGetLatLon(String ip)
Returns the latitude and longitude of a given IPv4 address, or null if no information is available. |
String |
geoGetRegion(InetAddress ip)
Returns the region name of a given IPv4 address, or null if no information is available. |
String |
geoGetRegion(String ip)
Returns the region name of a given IPv4 address, or null if no information is available. |
String |
geoGetRegionCode(InetAddress ip)
Returns the 2-character region code (in the US this is a state code) of a given IPv4 address, or null if no information is available. |
String |
geoGetRegionCode(String ip)
Returns the 2-character region code (in the US this is a state code) of a given IPv4 address, or null if no information is available. |
int |
getActiveNodes(String pool)
Returns the number of nodes that are alive in the named pool. |
String |
getConnectionData(String key)
Read connection-specific data that has been set by other servlets or TrafficScript rules. |
ZXTMServletRequest.DataType |
getConnectionDataType(String key)
Get the type of the connection-specific data that has been set by other servlets or TrafficScript rules. |
String |
getData(String key)
Read global data that has been set by other servlets or TrafficScript rules. |
ZXTMServletRequest.DataType |
getDataType(String key)
Get the type of the global data that has been set by other servlets or TrafficScript rules. |
ServletOutputStream |
getOutputStream()
Returns a ServletOutputStream suitable for writing binary data in the request. |
int |
getSLMConforming(String slm)
Returns the current percentage of requests that are meeting the specified Service Level Monitoring class' objectives. |
int |
getSLMThreshold(String slm)
Returns the percentage of requests that must meet the specified Service Level Monitoring class' objectives, for the class to be considered OK. |
PrintWriter |
getWriter()
Returns a PrintWriter object that can send character text to the server. |
void |
incrementCounter(int counter)
Increment a counter by 1, equivalent to TrafficScript's counter.increment() |
void |
incrementCounter(int counter,
int inc)
Increment a counter, equivalent to TrafficScript's counter.increment() |
boolean |
isSLMOK(String slm)
Checks if the specified Service Level Monitoring class is meeting its objectives. |
void |
setConnectionData(String key,
String value)
Set connection-specific data. |
void |
setConnectionData(String key,
String value,
ZXTMServletRequest.DataType type)
Set connection-specific data. |
void |
setData(String key,
String value)
Set global data. |
void |
setData(String key,
String value,
ZXTMServletRequest.DataType type)
Set global data. |
| Methods inherited from interface javax.servlet.ServletRequest |
|---|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding |
| Method Detail |
|---|
void emitEvent(String event,
String message)
throws InvalidParameterException
event - The event id which the alerting system will match against in
order to trigger an action.message - Detailed text explaining the event.
InvalidParameterException - The event id must contain only
alphanumeric characters and underscore.
String geoGetCity(InetAddress ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetCity(String ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetCountry(InetAddress ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetCountry(String ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetCountryCode(String ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
double geoGetDistanceKM(double[] coord1,
double[] coord2)
coord1 - Latitude and longitude pair for first point, as returned by @ref geoGetLatLon.coord2 - Latitude and longitude pair for second point, as returned by @ref geoGetLatLon.
double geoGetDistanceKM(double lat1,
double lon1,
double lat2,
double lon2)
lat1 - Latitude of first point.lon1 - Longitude of first point.lat2 - Latitude of second point.lon2 - Longitude of second point.
double geoGetDistanceMiles(double[] coord1,
double[] coord2)
coord1 - Latitude and longitude pair for first point, as returned by @ref geoGetLatLon.coord2 - Latitude and longitude pair for second point, as returned by @ref geoGetLatLon.
double geoGetDistanceMiles(double lat1,
double lon1,
double lat2,
double lon2)
lat1 - Latitude of first point.lon1 - Longitude of first point.lat2 - Latitude of second point.lon2 - Longitude of second point.
double geoGetIPDistanceKM(InetAddress ip1,
InetAddress ip2)
throws IOException,
InvalidParameterException
ip1 - An IPv4 address.ip2 - An IPv4 address.
IOException
InvalidParameterException
double geoGetIPDistanceKM(String ip1,
String ip2)
throws IOException,
InvalidParameterException
ip1 - An IPv4 address.ip2 - An IPv4 address.
IOException
InvalidParameterException
double geoGetIPDistanceMiles(InetAddress ip1,
InetAddress ip2)
throws IOException,
InvalidParameterException
ip1 - An IPv4 address.ip2 - An IPv4 address.
IOException
InvalidParameterException
double geoGetIPDistanceMiles(String ip1,
String ip2)
throws IOException,
InvalidParameterException
ip1 - An IPv4 address.ip2 - An IPv4 address.
IOException
InvalidParameterException
double[] geoGetLatLon(InetAddress ip)
throws IOException,
InvalidParameterException
ip - An IPv4 address.
IOException
InvalidParameterException
double[] geoGetLatLon(String ip)
throws IOException,
InvalidParameterException
ip - An IPv4 address.
IOException
InvalidParameterException
String geoGetRegion(InetAddress ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetRegion(String ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetRegionCode(InetAddress ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
String geoGetRegionCode(String ip)
throws InvalidParameterException,
IOException
ip - An IPv4 address.
InvalidParameterException
IOException
int getActiveNodes(String pool)
throws IOException
pool - the name of the pool to check
IOException - if an error occurs when communicating with ZXTM
String getConnectionData(String key)
throws IOException
key - the key to look up
IOException - if an error occurs when communicating with ZXTM
ZXTMServletRequest.DataType getConnectionDataType(String key)
throws IOException
IOException - if an error occurs when communicating with ZXTM
String getData(String key)
throws IOException
IOException - if an error occurs when communicating with ZXTM
ZXTMServletRequest.DataType getDataType(String key)
throws IOException
IOException - if an error occurs when communicating with ZXTM
ServletOutputStream getOutputStream()
throws IOException
IOException - if an error occurs when communicating with ZXTM
int getSLMConforming(String slm)
throws IOException
IOException - if an error occurs when communicating with ZXTM
int getSLMThreshold(String slm)
throws IOException
IOException - if an error occurs when communicating with ZXTM
PrintWriter getWriter()
throws IOException
IOException - if an error occurs when communicating with ZXTMvoid incrementCounter(int counter)
counter - the counter number to increment.
IOException - if an error occurs when communicating with ZXTM
void incrementCounter(int counter,
int inc)
counter - the counter numberinc - amount to increment the counter by.
IOException - if an error occurs when communicating with ZXTM
boolean isSLMOK(String slm)
throws IOException
IOException - if an error occurs when communicating with ZXTM
void setConnectionData(String key,
String value)
throws IOException
key - the key to index the data withvalue - the value to associate with the key
IOException - if an error occurs when communicating with ZXTM
void setConnectionData(String key,
String value,
ZXTMServletRequest.DataType type)
throws IOException
key - the key to index the data withvalue - the value to associate with the keytype - the type of the data being stored
IOException - if an error occurs when communicating with ZXTM
void setData(String key,
String value)
throws IOException
key - the key to index the data withvalue - the value to associate with the key
IOException - if an error occurs when communicating with ZXTM
void setData(String key,
String value,
ZXTMServletRequest.DataType type)
throws IOException
key - the key to index the data withvalue - the value to associate with the keytype - the type of the data being stored
IOException - if an error occurs when communicating with ZXTM
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||