com.googlecode.jmxtrans.util
Class JmxUtils

java.lang.Object
  extended by com.googlecode.jmxtrans.util.JmxUtils

public class JmxUtils
extends java.lang.Object

The worker code.

Author:
jon

Nested Class Summary
static class JmxUtils.ProcessQueryThread
          Executes either a getAttribute or getAttributes query.
static class JmxUtils.ProcessServerThread
          Executes either a getAttribute or getAttributes query.
 
Constructor Summary
JmxUtils()
           
 
Method Summary
static java.lang.String cleanupStr(java.lang.String name)
          Replaces all .
static void execute(com.googlecode.jmxtrans.model.JmxProcess process)
          Either invokes the servers multithreaded (max threads == jmxProcess.getMultiThreaded()) or invokes them one at a time.
static java.lang.String getConcatedTypeNameValues(java.util.List<java.lang.String> typeNames, java.lang.String typeNameStr)
          Given a typeName string, get the first match from the typeNames setting.
static java.lang.String getConcatedTypeNameValues(com.googlecode.jmxtrans.model.Query query, java.util.List<java.lang.String> typeNames, java.lang.String typeName)
          Given a typeName string, get the first match from the typeNames setting.
static java.util.Map<java.lang.String,org.apache.commons.pool.KeyedObjectPool> getDefaultPoolMap()
          Helper method which returns a default PoolMap.
static java.util.Map<java.lang.String,java.lang.String[]> getEnvironment(com.googlecode.jmxtrans.model.Server server)
          Generates the proper username/password environment for JMX connections.
static com.googlecode.jmxtrans.model.JmxProcess getJmxProcess(java.io.File file)
          Uses jackson to load json configuration from a File into a full object tree representation of that json.
static java.lang.String getKeyString(com.googlecode.jmxtrans.model.Query query, com.googlecode.jmxtrans.model.Result result, java.util.Map.Entry<java.lang.String,java.lang.Object> values, java.util.List<java.lang.String> typeNames, java.lang.String rootPrefix)
           
static java.lang.String getKeyString2(com.googlecode.jmxtrans.model.Query query, com.googlecode.jmxtrans.model.Result result, java.util.Map.Entry<java.lang.String,java.lang.Object> values, java.util.List<java.lang.String> typeNames, java.lang.String rootPrefix)
           
static javax.management.remote.JMXConnector getServerConnection(com.googlecode.jmxtrans.model.Server server)
          Helper method for connecting to a Server.
static java.util.Map<java.lang.String,java.lang.String> getWebLogicEnvironment(com.googlecode.jmxtrans.model.Server server)
          Generates the proper username/password environment for JMX connections.
static boolean isNumeric(java.lang.Object value)
          Useful for figuring out if an Object is a number.
static boolean isNumeric(java.lang.String str)
           Checks if the String contains only unicode digits.
static void mergeServerLists(java.util.List<com.googlecode.jmxtrans.model.Server> existing, java.util.List<com.googlecode.jmxtrans.model.Server> adding)
          Merges two lists of servers (and their queries).
static void prettyPrintJson(com.googlecode.jmxtrans.model.JmxProcess process)
          Utility function good for testing things.
static void printJson(com.googlecode.jmxtrans.model.JmxProcess process)
          Utility function good for testing things.
static void processQueriesForServer(javax.management.MBeanServerConnection mbeanServer, com.googlecode.jmxtrans.model.Server server)
          Either invokes the queries multithreaded (max threads == server.getMultiThreaded()) or invokes them one at a time.
static void processQuery(javax.management.MBeanServerConnection mbeanServer, com.googlecode.jmxtrans.model.Query query)
          Responsible for processing individual Queries.
static void processServer(com.googlecode.jmxtrans.model.Server server, javax.management.remote.JMXConnector conn)
          Does the work for processing a Server object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmxUtils

public JmxUtils()
Method Detail

mergeServerLists

public static void mergeServerLists(java.util.List<com.googlecode.jmxtrans.model.Server> existing,
                                    java.util.List<com.googlecode.jmxtrans.model.Server> adding)
Merges two lists of servers (and their queries). Based on the equality of both sets of objects. Public for testing purposes.


processQueriesForServer

public static void processQueriesForServer(javax.management.MBeanServerConnection mbeanServer,
                                           com.googlecode.jmxtrans.model.Server server)
                                    throws java.lang.Exception
Either invokes the queries multithreaded (max threads == server.getMultiThreaded()) or invokes them one at a time.

Throws:
java.lang.Exception

processQuery

public static void processQuery(javax.management.MBeanServerConnection mbeanServer,
                                com.googlecode.jmxtrans.model.Query query)
                         throws java.lang.Exception
Responsible for processing individual Queries.

Throws:
java.lang.Exception

getServerConnection

public static javax.management.remote.JMXConnector getServerConnection(com.googlecode.jmxtrans.model.Server server)
                                                                throws java.lang.Exception
Helper method for connecting to a Server. You need to close the resulting connection.

Throws:
java.lang.Exception

getWebLogicEnvironment

public static java.util.Map<java.lang.String,java.lang.String> getWebLogicEnvironment(com.googlecode.jmxtrans.model.Server server)
Generates the proper username/password environment for JMX connections.


getEnvironment

public static java.util.Map<java.lang.String,java.lang.String[]> getEnvironment(com.googlecode.jmxtrans.model.Server server)
Generates the proper username/password environment for JMX connections.


execute

public static void execute(com.googlecode.jmxtrans.model.JmxProcess process)
                    throws java.lang.Exception
Either invokes the servers multithreaded (max threads == jmxProcess.getMultiThreaded()) or invokes them one at a time.

Throws:
java.lang.Exception

processServer

public static void processServer(com.googlecode.jmxtrans.model.Server server,
                                 javax.management.remote.JMXConnector conn)
                          throws java.lang.Exception
Does the work for processing a Server object.

Throws:
java.lang.Exception

printJson

public static void printJson(com.googlecode.jmxtrans.model.JmxProcess process)
                      throws java.lang.Exception
Utility function good for testing things. Prints out the json tree of the JmxProcess.

Throws:
java.lang.Exception

prettyPrintJson

public static void prettyPrintJson(com.googlecode.jmxtrans.model.JmxProcess process)
                            throws java.lang.Exception
Utility function good for testing things. Prints out the json tree of the JmxProcess.

Throws:
java.lang.Exception

getJmxProcess

public static com.googlecode.jmxtrans.model.JmxProcess getJmxProcess(java.io.File file)
                                                              throws org.codehaus.jackson.JsonParseException,
                                                                     org.codehaus.jackson.map.JsonMappingException,
                                                                     java.io.IOException
Uses jackson to load json configuration from a File into a full object tree representation of that json.

Throws:
org.codehaus.jackson.JsonParseException
org.codehaus.jackson.map.JsonMappingException
java.io.IOException

isNumeric

public static boolean isNumeric(java.lang.Object value)
Useful for figuring out if an Object is a number.


isNumeric

public static boolean isNumeric(java.lang.String str)

Checks if the String contains only unicode digits. A decimal point is a digit and returns true.

null will return false. An empty String ("") will return true.

 StringUtils.isNumeric(null)   = false
 StringUtils.isNumeric("")     = true
 StringUtils.isNumeric("  ")   = false
 StringUtils.isNumeric("123")  = true
 StringUtils.isNumeric("12 3") = false
 StringUtils.isNumeric("ab2c") = false
 StringUtils.isNumeric("12-3") = false
 StringUtils.isNumeric("12.3") = true
 

Parameters:
str - the String to check, may be null
Returns:
true if only contains digits, and is non-null

getDefaultPoolMap

public static java.util.Map<java.lang.String,org.apache.commons.pool.KeyedObjectPool> getDefaultPoolMap()
Helper method which returns a default PoolMap. TODO: allow for more configuration options?


getKeyString

public static java.lang.String getKeyString(com.googlecode.jmxtrans.model.Query query,
                                            com.googlecode.jmxtrans.model.Result result,
                                            java.util.Map.Entry<java.lang.String,java.lang.Object> values,
                                            java.util.List<java.lang.String> typeNames,
                                            java.lang.String rootPrefix)

getKeyString2

public static java.lang.String getKeyString2(com.googlecode.jmxtrans.model.Query query,
                                             com.googlecode.jmxtrans.model.Result result,
                                             java.util.Map.Entry<java.lang.String,java.lang.Object> values,
                                             java.util.List<java.lang.String> typeNames,
                                             java.lang.String rootPrefix)

cleanupStr

public static java.lang.String cleanupStr(java.lang.String name)
Replaces all . with _ and removes all spaces and double/single quotes.


getConcatedTypeNameValues

public static java.lang.String getConcatedTypeNameValues(java.util.List<java.lang.String> typeNames,
                                                         java.lang.String typeNameStr)
Given a typeName string, get the first match from the typeNames setting. In other words, suppose you have: typeName=name=PS Eden Space,type=MemoryPool If you addTypeName("name"), then it'll retrieve 'PS Eden Space' from the string


getConcatedTypeNameValues

public static java.lang.String getConcatedTypeNameValues(com.googlecode.jmxtrans.model.Query query,
                                                         java.util.List<java.lang.String> typeNames,
                                                         java.lang.String typeName)
Given a typeName string, get the first match from the typeNames setting. In other words, suppose you have: typeName=name=PS Eden Space,type=MemoryPool If you addTypeName("name"), then it'll retrieve 'PS Eden Space' from the string



Copyright © 2013 Red Hat. All Rights Reserved.