Class JMXSummaryUtils
- java.lang.Object
-
- dk.netarkivet.monitor.webinterface.JMXSummaryUtils
-
public class JMXSummaryUtils extends java.lang.Object
Various utility methods and classes for the JMX Monitor page. and a bunch of JMX properties used by Monitor-JMXsummary.jsp.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JMXSummaryUtils.StarredRequest
This class encapsulates a HttpServletRequest, making non-existing parameters appear as "*" for wildcard (or "0" for the index parameter).
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
JMXApplicationInstIdProperty
JMX property for the application instance id.static java.lang.String
JMXApplicationNameProperty
JMX property for the application name.static java.lang.String
JMXArchiveReplicaNameProperty
JMX property for the replica name.static java.lang.String
JMXHarvestChannelProperty
JMX property for the harvest channel.static java.lang.String
JMXHttpportProperty
JMX property for the HTTP port.static java.lang.String
JMXIndexProperty
JMX property for the index.static java.lang.String
JMXMachineNameProperty
JMX property for the machine name.static java.lang.String
JMXPhysLocationProperty
JMX property for the physical location.static java.lang.String
JMXRemoveApplication
JMX property for remove application button.static java.lang.String[]
STARRABLE_PARAMETERS
JMX properties, which can set to star.static java.lang.String
STATUS_MONITOR_JMXSUMMARY
Status/Monitor-JMXsummary.jsp.
-
Constructor Summary
Constructors Constructor Description JMXSummaryUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
createJMXQuery(java.lang.String[] parameters, JMXSummaryUtils.StarredRequest starredRequest)
Build a JMX query string (ObjectName) from a request and a list of parameters to query for.static java.lang.String
generateLink(JMXSummaryUtils.StarredRequest request, java.lang.String setPart, java.lang.String setValue, java.lang.String linkText)
Generate an HTML link to the JMX summary page with one part of the URL parameters set to a specific value.static java.lang.String
generateMessage(java.lang.String logMessage, java.util.Locale l)
Make an HTML fragment that shows a log message preformatted.static java.lang.String
generateShowAllLink(JMXSummaryUtils.StarredRequest starredRequest, java.lang.String parameter, java.util.Locale l)
Generate HTML to show at the top of the table, containing a "show all" link if the parameter is currently restricted.static java.lang.String
generateShowColumn(JMXSummaryUtils.StarredRequest starredRequest, java.util.Locale l)
Creates the show links for showing columns again.static java.lang.String
generateShowLink(JMXSummaryUtils.StarredRequest starredRequest, java.lang.String parameter, java.util.Locale l)
Generate HTML to show at the top of the table, containing a "show all" and a "off" links if the parameter is currently restricted.static java.util.List<StatusEntry>
queryJMXFromRequest(java.lang.String[] parameters, JMXSummaryUtils.StarredRequest request, javax.servlet.jsp.PageContext context)
Get status entries from JMX based on a request and some parameters.static java.lang.String
reduceApplicationName(java.lang.String applicationName)
Reduce the class name of an application to the essentials.static void
RemoveApplication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.jsp.PageContext pageContext)
Remove an application.static boolean
showColumn(JMXSummaryUtils.StarredRequest starredRequest, java.lang.String parameter)
Tests if a parameter in the request is "-" (thus off).static void
unregisterJMXInstance(java.lang.String[] parameters, JMXSummaryUtils.StarredRequest request, javax.servlet.jsp.PageContext context)
Select zero or more beans from JMX and unregister these.
-
-
-
Field Detail
-
JMXRemoveApplication
public static final java.lang.String JMXRemoveApplication
JMX property for remove application button.- See Also:
- Constant Field Values
-
JMXPhysLocationProperty
public static final java.lang.String JMXPhysLocationProperty
JMX property for the physical location.- See Also:
- Constant Field Values
-
JMXMachineNameProperty
public static final java.lang.String JMXMachineNameProperty
JMX property for the machine name.- See Also:
- Constant Field Values
-
JMXApplicationNameProperty
public static final java.lang.String JMXApplicationNameProperty
JMX property for the application name.- See Also:
- Constant Field Values
-
JMXApplicationInstIdProperty
public static final java.lang.String JMXApplicationInstIdProperty
JMX property for the application instance id.- See Also:
- Constant Field Values
-
JMXHttpportProperty
public static final java.lang.String JMXHttpportProperty
JMX property for the HTTP port.- See Also:
- Constant Field Values
-
JMXHarvestChannelProperty
public static final java.lang.String JMXHarvestChannelProperty
JMX property for the harvest channel.- See Also:
- Constant Field Values
-
JMXArchiveReplicaNameProperty
public static final java.lang.String JMXArchiveReplicaNameProperty
JMX property for the replica name.- See Also:
- Constant Field Values
-
JMXIndexProperty
public static final java.lang.String JMXIndexProperty
JMX property for the index.- See Also:
- Constant Field Values
-
STARRABLE_PARAMETERS
public static final java.lang.String[] STARRABLE_PARAMETERS
JMX properties, which can set to star.
-
STATUS_MONITOR_JMXSUMMARY
public static final java.lang.String STATUS_MONITOR_JMXSUMMARY
Status/Monitor-JMXsummary.jsp.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JMXSummaryUtils
public JMXSummaryUtils()
-
-
Method Detail
-
reduceApplicationName
public static java.lang.String reduceApplicationName(java.lang.String applicationName) throws ArgumentNotValid
Reduce the class name of an application to the essentials.- Parameters:
applicationName
- The class name of the application, should not be null.- Returns:
- A reduced name suitable for user output.
- Throws:
ArgumentNotValid
- if argument isn't valid.
-
generateShowColumn
public static java.lang.String generateShowColumn(JMXSummaryUtils.StarredRequest starredRequest, java.util.Locale l) throws ArgumentNotValid
Creates the show links for showing columns again.Goes through all parameters to check if their column is active. If a column is not active, the link to showing a specific column again is generated.
- Parameters:
starredRequest
- A request to take parameters from, should be different from null.l
- For retrieving the correct words form the current language.- Returns:
- The link to show the parameter again.
- Throws:
ArgumentNotValid
- if argument isn't valid.
-
generateShowAllLink
public static java.lang.String generateShowAllLink(JMXSummaryUtils.StarredRequest starredRequest, java.lang.String parameter, java.util.Locale l) throws ArgumentNotValid
Generate HTML to show at the top of the table, containing a "show all" link if the parameter is currently restricted. This function is only used by JMXIndexProperty field, the other properties uses generateShowLing instead.- Parameters:
starredRequest
- A request to take parameters from, should not be null.parameter
- The parameter that, if not already unrestricted, should be unrestricted in the "show all" link, should not be null.l
- the current locale.- Returns:
- HTML to insert at the top of the JMX monitor table.
- Throws:
ArgumentNotValid
- if arguments isn't valid.
-
generateShowLink
public static java.lang.String generateShowLink(JMXSummaryUtils.StarredRequest starredRequest, java.lang.String parameter, java.util.Locale l) throws ArgumentNotValid
Generate HTML to show at the top of the table, containing a "show all" and a "off" links if the parameter is currently restricted.- Parameters:
starredRequest
- A request to take parameters from, should not be null.parameter
- The parameter that, if not already unrestricted, should be unrestricted in the "show all", should not be null.l
- the current locale.- Returns:
- HTML to insert at the top of the JMX monitor table.
- Throws:
ArgumentNotValid
- if arguments isn't valid.
-
showColumn
public static boolean showColumn(JMXSummaryUtils.StarredRequest starredRequest, java.lang.String parameter) throws ArgumentNotValid
Tests if a parameter in the request is "-" (thus off).- Parameters:
starredRequest
- A request to take parameters from, should not be null.parameter
- The parameter that should be tested.- Returns:
- Whether the parameter is set to "-".
- Throws:
ArgumentNotValid
- if argument isn't valid.
-
generateLink
public static java.lang.String generateLink(JMXSummaryUtils.StarredRequest request, java.lang.String setPart, java.lang.String setValue, java.lang.String linkText) throws ArgumentNotValid
Generate an HTML link to the JMX summary page with one part of the URL parameters set to a specific value.- Parameters:
request
- A request to draw other parameter values from, should not be null.setPart
- Which of the parameters to set.setValue
- The value to set that parameter to.linkText
- The HTML text that should go inside the link. Remember to escape HTML values if inserting a normal string.- Returns:
- A link to insert in the page, or an unlinked text, if setPart or setValue is null, or an empty string if linkText is null.
- Throws:
ArgumentNotValid
- if request is null.
-
queryJMXFromRequest
public static java.util.List<StatusEntry> queryJMXFromRequest(java.lang.String[] parameters, JMXSummaryUtils.StarredRequest request, javax.servlet.jsp.PageContext context) throws ArgumentNotValid, ForwardedToErrorPage
Get status entries from JMX based on a request and some parameters.- Parameters:
parameters
- The parameters to query JMX for, should not be null.request
- A request possibly containing values for some of the parameters, should not be null.context
- the current JSP context, should not be null.- Returns:
- Status entries for the MBeans that match the parameters.
- Throws:
ArgumentNotValid
- if the query is invalid (typically caused by invalid parameters).ForwardedToErrorPage
- if unable to create JMX-query.
-
unregisterJMXInstance
public static void unregisterJMXInstance(java.lang.String[] parameters, JMXSummaryUtils.StarredRequest request, javax.servlet.jsp.PageContext context) throws ArgumentNotValid
Select zero or more beans from JMX and unregister these.- Parameters:
parameters
- The parameters to query JMX for, should not be null.request
- A request possibly containing values for some of the parameters, which select zero or more beans.context
- the current JSP context, should not be null.- Throws:
ArgumentNotValid
- if arguments isn't valid.
-
createJMXQuery
public static java.lang.String createJMXQuery(java.lang.String[] parameters, JMXSummaryUtils.StarredRequest starredRequest) throws ArgumentNotValid
Build a JMX query string (ObjectName) from a request and a list of parameters to query for. This string is always a property pattern (wildcarded), even if all the values we define in the names are specified.- Parameters:
parameters
- The parameters to query for. These should make up the parts of the unique identification of an MBean.starredRequest
- A request containing current values for the given parameters.- Returns:
- A query, wildcarded for those parameters that are or missing in starredRequest.
- Throws:
ArgumentNotValid
- if one or all of the arguements are null.
-
generateMessage
public static java.lang.String generateMessage(java.lang.String logMessage, java.util.Locale l) throws ArgumentNotValid
Make an HTML fragment that shows a log message preformatted. If the log message is longer than NUMBER_OF_LOG_LINES lines, the rest are hidden and replaced with an internationalized link "More..." that will show the rest. Long loglines are split to length approximately monitor.preferredMaxJMXLogLength and then split again to ensure that no lines are wider than monitor.absoluteMaxJMXLogLength. However as the wrapping algorithm is not sophisticated it is better to split the lines in a meaningful way where they are generated.- Parameters:
logMessage
- The log message to present.l
- the current Locale.- Returns:
- An HTML fragment as defined above.
- Throws:
ArgumentNotValid
- if argument isn't valid.
-
RemoveApplication
public static void RemoveApplication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.jsp.PageContext pageContext) throws java.io.IOException, ArgumentNotValid
Remove an application. Used by Monitor-JMXsummary.jsp. Code has been moved from the jsp to here to avoid compile errors at runtime in correlation with the upgrade to java 1.8 and introduction of embedded tomcat to handle jsp pages. This was previously done via jetty 6.- Parameters:
request
- http request from selvletresponse
- http session for page context Harveststatus-running.jsppageContext
- http session for page context Harveststatus-running.jsp- Throws:
java.io.IOException
ArgumentNotValid
-
-