Package com.groiss.cluster
Class ClusterSupport
java.lang.Object
com.groiss.cluster.ClusterSupport
Cluster support functions accessible via HTTP requests.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Returns a list of addresses where logins may be performed.static HTMLPage
Shows information about the request and the session.static void
Displays details about a session in the Hazelcast subsystem.static void
Displays details about the state of the Hazelcast subsystem.static void
Gets the state of the current node suitable for health checks (e.g. via HAProxy).void
Determines the node which has the least workload based on the number of connected users and the performance factor of the node.static void
redirect
(HttpServletRequest req, HttpServletResponse res) Redirects the client to the node which has the least workload based on the number of connected users and the performance factor of the node.void
unbind
(HttpServletRequest req, HttpServletResponse res) Change the node.
-
Method Details
-
getNodeState
Gets the state of the current node suitable for health checks (e.g. via HAProxy).- Parameters:
req
- the requestres
- the response with one of the following states:HttpServletResponse.SC_OK
if the node is load balanced and logins are enabled (green)HttpServletResponse.SC_NOT_FOUND
if the node is load balanced, but logins are disabled without evicting sessions (blue)HttpServletResponse.SC_FORBIDDEN
else (red).
-
unbind
Change the node.Used in deployment scenarios behind a reverse proxy / loadbalancer.
Removes the current node routing cookie from the client and redirects it to the least loaded node.
- Parameters:
req
- the requestres
- the response; consists of an immediately expiring node cookie and calls document.location.replace withredirect(HttpServletRequest, HttpServletResponse)
- Throws:
Exception
-
getClientInfo
Shows information about the request and the session.- Parameters:
req
- the request- Returns:
- a Page containing information about
- the components of the request URL
- the remote address
- the node id
- the headers of the request
- the cookies in the request
- the parameters of the request
- the attributes of the request
- the session info
- attributes of the session
-
redirect
@EntryPoint public static void redirect(HttpServletRequest req, HttpServletResponse res) throws Exception Redirects the client to the node which has the least workload based on the number of connected users and the performance factor of the node.Used in deployment scenarios without a dedicated reverse proxy / loadbalancer.
- Parameters:
req
- the request; can have a parameternodeid
, then the redirect target is the specified node, irrespective of the current loadres
- the response; an HTML page which executes a "document.location.replace" call.- Throws:
Exception
-
getRedirectAddresses
@EntryPoint public void getRedirectAddresses(HttpServletRequest req, HttpServletResponse res) throws Exception Determines the node which has the least workload based on the number of connected users and the performance factor of the node. Sends back the URLs for RMI, HTTP and HTTPS for that node.Used in deployment scenarios without a dedicated reverse proxy / loadbalancer.
- Parameters:
req
- the requestres
- the response; atext/plain
page which consists of three lines denoting the RMI address, the HTTP address and the HTTPS address of the node- Throws:
Exception
-
getAllRedirectAddresses
@EntryPoint public void getAllRedirectAddresses(HttpServletRequest req, HttpServletResponse res) throws Exception Returns a list of addresses where logins may be performed.For each node that is considered to be alive, three URLs (RMI, HTTP and HTTPS) are returned. The nodes are sorted by their load; the least loaded node is the first one.
Used in deployment scenarios without a dedicated reverse proxy / loadbalancer.
- Parameters:
req
- the request; if it contains the parameterlocaladdress
, just the address of the current node will be returnedres
- the response; atext/plain
page which for each node consists of three lines denoting the RMI address, the HTTP address and the HTTPS address- Throws:
Exception
-
getHazelcastState
@EntryPoint public static void getHazelcastState(HttpServletRequest req, HttpServletResponse res) throws Exception Displays details about the state of the Hazelcast subsystem.The "view configuration" right is needed to call this function.
- Parameters:
req
- the request accepts the following parameters:showDetails=true
also displays details of all keys and their placement in partitions;showConfig=true
also displays the Hazelcast configuration
res
- the response, a text/plain status summary- Throws:
Exception
-
getHazelcastSessionInfo
@EntryPoint public static void getHazelcastSessionInfo(HttpServletRequest req, HttpServletResponse res) throws Exception Displays details about a session in the Hazelcast subsystem.The "view configuration" right is needed to call this function.
- Parameters:
req
- the request; if parametersessionid=<sessionid>
is given, the specified session is displayed; if the parameter is missing, the current session is displayedres
- a text/plain session status summary- Throws:
Exception
-