Wednesday, April 3, 2013

“Booting AMX” in GlassFish 3 with Groovy

In my previous blog post, I looked at using JMX as one of multiple methods supported by GlassFish 3 for its administration, monitoring, and management. In this blog post, I look in more detail at monitoring and managing GlassFish 3 via JMX and Groovy. I focus on local connection to GlassFish using the Attach API in this post, but I have covered remote JMX access of GlassFish in a previous post (see also Remote Glassfish V3.1 and the mystical JMX settings). The MBeans used for administration are generally the same in either case.

Because I’m using the Attach API in this post’s examples to connect to local Java processes that are started by me, I don’t need to specify the JMX remote connection propertiesjava.rmi.server.hostname,com.sun.management.jmxremote.port, and com.sun.management.jmxremote.ssl=false, and com.sun.management.jmxremote.authenticate) for remote access. The easiest way to find Java processes meeting the standard of being on the local machine and being processes that I started is via use of jps (pre-JDK 7 and JDK 7) or jcmd (JDK 7 only), which I show in the next two screen snapshots.

jpsShowsGlassFishProcessRunningWithPID_1584

jcmdShowsGlassFishProcessRunningWithPID_1584

As the above images indicate, GlassFish is running locally with PID (AKA Process ID or pid) 1584.To begin, I’m going to use Groovy to access the relevant MBeanServerConnection via the Attach API. This is done as shown in the following Groovy code (next two code listings) in which the method retrieveServerConnection(String) accepts the PID and returns the MBeanServerConnection for that Java process. That method uses another method in the code listing, retrieveUrlForPid(String, String), which uses the Attach API to provide a JMXServiceURL for the Java process.

retrieveServerConnection(String)

/** * Provide an MBeanServerConnection based on the provided process ID (pid). * * @param pid Process ID of Java process for which MBeanServerConnection is *    desired. * @return MBeanServerConnection connecting to Java process identified by pid. */def MBeanServerConnection retrieveServerConnection(String pid){   def connectorAddressStr = "com.sun.management.jmxremote.localConnectorAddress"   def jmxUrl = retrieveUrlForPid(pid, connectorAddressStr)   def jmxConnector = JMXConnectorFactory.connect(jmxUrl)   return jmxConnector.getMBeanServerConnection()}

retrieveUrlForPid(String, String)

/** * Provide JMX URL for attaching to the provided process ID (pid). * * @param @pid Process ID for which JMX URL is needed to connect. * @param @connectorAddressStr String for connecting. * @return JMX URL to communicating with Java process identified by pid. */def JMXServiceURL retrieveUrlForPid(String pid, String connectorAddressStr){   // Attach to the target application's virtual machine   def vm = VirtualMachine.attach(pid)   // Obtain Connector Address   def connectorAddress =      vm.getAgentProperties().getProperty(connectorAddressStr)   // Load Agent if no connector address is available   if (connectorAddress == null)   {      def agent = vm.getSystemProperties().getProperty("java.home") +          File.separator + "lib" + File.separator + "management-agent.jar"      vm.loadAgent(agent)      // agent is started, get the connector address      connectorAddress =         vm.getAgentProperties().getProperty(connectorAddressStr)   }   return new JMXServiceURL(connectorAddress);}

With access to the MBeanServerConnection, I can start to do all types of useful things with Groovy and JMX to manage and monitor the a Java process. For example, the next code listing demonstrates how easy it is to now list the MBeans exposed by the Java process identified by a provided PID.

displayHostedMBeans(MBeanServerConnection)

/** * Display MBeans hosted on the provided MBeanServerConnection. * * @param mbeanServer MBeanServerConnection for which hosted MBeans are to be *    provided. */def displayHostedMBeans(MBeanServerConnection mbeanServer){   mbeanServer.queryNames(null, null).each   {      println it   }}

Running the above Groovy method against my running GlassFish instance with PID 1584 is demonstrated in the next screen snapshot.

groovyJmxDisplayHostedMBeansOutputOnGlassFishInstance

displayHostedMBeansAttributesAndOperations(MBeanServerConnection)

/** * Display MBeans hosted on provided MBean Server along with the attributes and * operations available on each MBean. */def displayHostedMBeansAttributesAndOperations(MBeanServerConnection mbeanServer){   mbeanServer.queryNames(null, null).each   { mbeanObjectName ->      def mbeanInfo = mbeanServer.getMBeanInfo(mbeanObjectName)      println mbeanObjectName      println "\tAttributes:"      mbeanInfo.attributes.each      { attribute ->         println "\t\t${attribute.type} ${attribute.name}"      }      println "\tOperations:"      mbeanInfo.operations.each      { operation ->         def operationStr = new StringBuilder();         operationStr << "\t\t" << operation.name << "("         operation.signature.each         { parameter ->            operationStr << parameter.type << " " << parameter.name << ", "         }         def operationString = operationStr.contains(",") ? operationStr.substring(0, operationStr.length()-2) : operationStr         println "${operationString})"      }      println ""   }}

groovyJmxDisplayHostedMBeansOperationsAttributesGlassFishJMX
The previously displayed screen snapshot shows the bootAMX operation available on the amx-support:type=boot-amx MBean. This needs to be run to make other GlassFish-provided AMX MBean available. The next snippet of Groovy code, a method I’ve named bootAmx(MBeanServerConnection), invokes this bootAMX operation to instruct GlassFish to expose significantly more details via its JMX interface.

bootAmx(MBeanServerConnection)

/** * "Boot AMX" on GlassFish. * * @param mbeanServer MBeanServerConnection to be used to invoke bootAMX *    operation. */def bootAmx(MBeanServerConnection mbeanServer){   def amxObjectName = new ObjectName("amx-support:type=boot-amx")   mbeanServer.invoke(amxObjectName, "bootAMX", null, null)}

When the simple Groovy just shown is run, GlassFish exposes significant more functionality via JMX. Now that I’ve “booted AMX,” I can rerun displayHostedMBeans(MBeanServerConnection) to see the new MBeans that are available. A portion of this is shown next in the screen snapshot and the small-font text below it contains the entire output.

groovyJmxDisplayHostedMBeansOutputOnGlassFishInstancePostBootAMX

amx:pp=/domain/configs/config[server-config]/network-config,type=transportsamx:pp=/domain/configs/config[default-config]/iiop-service,type=iiop-listener,name=orb-listener-1amx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=encryption.key.aliasamx:pp=/domain/resources/jdbc-connection-pool[DerbyPool],type=property,name=serverNameamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[http-listener-1]/http,type=file-cacheamx:pp=/domain/configs/config[server-config],type=mdb-containeramx:pp=/domain/configs/config[default-config],type=system-property,name=HTTP_LISTENER_PORTamx:pp=/domain/configs/config[server-config]/web-container/session-config/session-manager,type=store-propertiesamx:pp=/ext,type=config-toolsamx:pp=/domain/nodes,type=node,name=localhost-domain1amx:pp=/domain/servers/server[server],type=application-ref,name=__adminguiamx:pp=/domain/configs/config[default-config]/network-config/protocols,type=protocol,name=sec-admin-listeneramx:pp=/J2EEDomain/J2EEServer[server]/WebModule[__admingui],type=Servlet,name=DownloadServlet,j2eeType=Servlet,J2EEServer=server,WebModule=__admingui,J2EEApplication=nullamx:pp=/domain/configs/config[server-config]/network-config/transports,type=transport,name=tcpamx:pp=/domain/configs/config[default-config],type=system-property,name=OSGI_SHELL_TELNET_PORTamx:pp=/domain/configs/config[server-config],type=thread-poolsamx:pp=/domain/configs/config[server-config]/security-service,type=audit-module,name=defaultamx:pp=/domain/secure-admin,type=secure-admin-principal,name="CN=localhost-instance,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US"amx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=property,name=signature.key.aliasamx:pp=/,type=loggingjava.lang:type=MemoryPool,name=Code Cacheamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=encryption.key.aliasamx:pp=/domain/configs/config[default-config]/web-container,type=session-configamx:pp=/domain/configs/config[server-config]/security-service/auth-realm[file],type=property,name=fileamx:pp=/domain/configs/config[server-config]/iiop-service,type=iiop-listener,name=SSLamx:pp=/domain/configs/config[server-config]/security-service,type=message-security-config,name=SOAPamx:pp=/domain/configs/config[server-config]/iiop-service/iiop-listener[SSL_MUTUALAUTH],type=sslamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[http-listener-1],type=httpamx:pp=/domain/configs/config[default-config]/network-config,type=transportsamx:pp=/domain/configs/config[server-config]/http-service,type=virtual-server,name=serveramx:pp=/domain/configs/config[default-config]/web-container/session-config/session-manager,type=store-propertiesamx:pp=/domain/configs/config[default-config],type=ejb-containeramx:pp=/ext,type=system-statusamx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[admin-listener],type=httpamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=response-policyamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[HttpServlet]/provider-config[GFConsoleAuthModule],type=property,name=loginPageamx:pp=/domain/servers/server[server],type=resource-ref,name=jdbc/__TimerPooljava.lang:type=Memoryamx:pp=/mon/server-mon[server],type=compilation-system-mon,name=jvm/compilation-systemamx:pp=/domain/configs/config[server-config]/security-service,type=auth-realm,name=admin-realmamx:pp=/domain/configs/config[default-config]/log-service,type=module-log-levelsamx:pp=/mon/server-mon[server],type=server-runtime-monamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP],type=provider-config,name=XWS_ClientProvideramx:pp=/domain/configs/config[default-config]/web-container/session-config,type=session-manageramx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP],type=provider-config,name=XWS_ServerProvideramx:pp=/domain/configs/config[server-config]/thread-pools,type=thread-pool,name=http-thread-poolamx:pp=/domain/configs/config[default-config]/admin-service,type=property,name=adminConsoleDownloadLocationamx:pp=/domain/resources/jdbc-connection-pool[DerbyPool],type=property,name=connectionAttributesamx:pp=/domain/resources/jdbc-connection-pool[__TimerPool],type=property,name=connectionAttributesamx:pp=/domain/configs/config[default-config]/network-config/protocols,type=protocol,name=pu-protocolamx:pp=/domain/configs/config[server-config]/network-config,type=protocolsamx:pp=/ext,type=connector-runtime-api-provideramx:pp=/domain,type=resourcesjmxremote:type=jmx-connector-server,protocol=rmi_jrmp,name=systemamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[http-listener-2],type=sslamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[http-listener-2],type=httpamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=signature.key.aliasamx:pp=/,type=extamx:pp=/domain/configs/config[default-config]/monitoring-service,type=module-monitoring-levelsamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP],type=provider-config,name=ClientProvideramx:pp=/domain/configs/config[server-config]/security-service/message-security-config[HttpServlet]/provider-config[GFConsoleAuthModule],type=property,name=restAuthURLamx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[http-listener-1],type=httpamx:pp=/domain/configs/config[server-config]/jms-service,type=jms-host,name=default_JMS_hostamx:pp=/domain/configs/config[server-config]/web-container/session-config/session-manager,type=manager-propertiesamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=property,name=debugamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=debugamx:pp=/domain/configs/config[default-config]/network-config/network-listeners,type=network-listener,name=admin-listeneramx:pp=/domain/configs/config[default-config]/security-service/jacc-provider[default],type=property,name=repositoryamx:pp=/mon/server-mon[server],type=operating-system-mon,name=jvm/operating-systemamx:pp=/domain/configs/config[default-config]/security-service,type=audit-module,name=defaultjava.lang:type=MemoryPool,name=Survivor Spaceamx:pp=/domain/configs/config[default-config]/network-config,type=protocolsamx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[http-listener-2],type=sslamx:pp=/domain/configs/config[default-config]/thread-pools,type=thread-pool,name=http-thread-poolamx:pp=/J2EEDomain/J2EEServer[server]/WebModule[__admingui],type=Servlet,name=jsp,j2eeType=Servlet,J2EEServer=server,WebModule=__admingui,J2EEApplication=nullamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[pu-protocol],type=port-unificationamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=security.configamx:pp=/domain/configs/config[default-config],type=system-property,name=HTTP_SSL_LISTENER_PORTamx:pp=/domain/configs/config[default-config]/http-service,type=virtual-server,name=serveramx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=request-policyamx:pp=/domain/configs/config[server-config],type=iiop-serviceamx:pp=/domain/configs/config[default-config]/security-service,type=jacc-provider,name=defaultamx:pp=/domain/configs/config[default-config]/web-container/session-config/session-manager,type=manager-propertiesamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=request-policyamx:pp=/domain/configs/config[default-config]/security-service,type=auth-realm,name=certificatejava.nio:type=BufferPool,name=mappedjava.lang:type=Compilationamx:pp=/,type=runtimeamx:pp=/domain/configs/config[server-config]/monitoring-service,type=module-monitoring-levelsamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=dynamic.username.passwordamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=signature.key.aliasamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=encryption.key.aliasamx-support:type=amx-loader,name=configamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=dynamic.username.passwordamx:pp=/runtime,type=server-runtime,name=serveramx:pp=/domain/configs/config[server-config]/network-config/protocols,type=protocol,name=http-listener-1amx:pp=/domain,type=system-applicationsamx:pp=/domain/configs/config[server-config]/security-service,type=jacc-provider,name=defaultamx:pp=/J2EEDomain/J2EEServer[server]/JDBCResource[jdbc/__default]/JDBCDataSource[jdbc/__default],type=JDBCDriver,name=jdbc/__default,j2eeType=JDBCDriver,J2EEServer=server,JDBCResource=jdbc/__default,JDBCDataSource=jdbc/__defaultamx:pp=/domain/configs/config[server-config]/security-service/auth-realm[file],type=property,name=jaas-contextamx:pp=/domain/configs/config[server-config]/ejb-container,type=ejb-timer-serviceamx:pp=/domain/configs/config[default-config]/security-service,type=auth-realm,name=filejava.lang:type=Runtimeamx:pp=/J2EEDomain/J2EEServer[server]/WebModule[__admingui],type=Servlet,name=default,j2eeType=Servlet,J2EEServer=server,WebModule=__admingui,J2EEApplication=nullamx:pp=/domain/configs/config[default-config],type=web-containeramx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=debugamx:pp=/domain/system-applications/application[__admingui]/module[__admingui],type=engine,name=securityamx:pp=/domain/configs/config[server-config]/admin-service,type=jmx-connector,name=systemamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=response-policyamx:pp=/ext,type=realmsamx:pp=/,type=queryamx:pp=/domain/configs/config[default-config],type=thread-poolsamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[HttpServlet]/provider-config[GFConsoleAuthModule],type=property,name=loginErrorPageamx:pp=/domain/configs/config[server-config],type=connector-serviceamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=signature.key.aliasamx:pp=/domain/configs/config[default-config]/network-config,type=network-listenersamx:pp=/J2EEDomain/J2EEServer[server]/JDBCResource[jdbc/__TimerPool]/JDBCDataSource[jdbc/__TimerPool],type=JDBCDriver,name=jdbc/__TimerPool,j2eeType=JDBCDriver,J2EEServer=server,JDBCResource=jdbc/__TimerPool,JDBCDataSource=jdbc/__TimerPoolamx:pp=/domain/configs/config[default-config],type=system-property,name=JMS_PROVIDER_PORTamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=request-policyamx:pp=/domain/configs/config[default-config],type=availability-serviceamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[admin-http-redirect],type=http-redirectamx:pp=/,type=J2EEDomain,j2eeType=J2EEDomain,name=amxamx:pp=/domain/configs/config[default-config],type=system-property,name=IIOP_SSL_LISTENER_PORTamx:pp=/domain/configs/config[default-config]/iiop-service,type=iiop-listener,name=SSLamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=encryption.key.aliasamx:pp=/domain/configs/config[default-config]/network-config/transports,type=transport,name=tcpamx:pp=/domain/configs/config[default-config],type=system-property,name=JMX_SYSTEM_CONNECTOR_PORTamx:pp=/mon/server-mon[server],type=garbage-collector-mon,name=jvm/garbage-collectors/Copyamx:pp=/domain/configs/config[default-config]/http-service,type=virtual-server,name=__asadminamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=request-policyamx:pp=/,type=system-infoamx:pp=/domain/configs/config[default-config],type=group-management-serviceamx:pp=/domain/configs/config[default-config]/availability-service,type=web-container-availabilityamx:pp=/domain/configs/config[server-config]/group-management-service,type=failure-detectionamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=response-policyjava.lang:type=GarbageCollector,name=Copyamx:pp=/domain/configs/config[server-config],type=java-configamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP],type=provider-config,name=ServerProvideramx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[http-listener-2]/http,type=file-cacheamx:pp=/domain/configs/config[default-config],type=system-property,name=ASADMIN_LISTENER_PORTamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=request-policyamx:pp=/domain/configs/config[server-config]/network-config/protocols,type=protocol,name=http-listener-2amx:pp=/domain/configs/config[default-config]/jms-service,type=jms-host,name=default_JMS_hostamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=debugamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP],type=provider-config,name=ServerProvideramx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=signature.key.aliasamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=response-policyamx:pp=/domain/configs/config[server-config],type=web-containeramx:pp=/domain/configs/config[default-config]/security-service/auth-realm[admin-realm],type=property,name=jaas-contextjava.util.logging:type=Loggingamx:pp=/,type=toolsjava.lang:type=MemoryPool,name=Eden Spaceamx:pp=/domain/configs/config[default-config]/network-config/protocols,type=protocol,name=http-listener-2com.sun.management:type=HotSpotDiagnosticamx:pp=/domain/configs/config[default-config]/security-service,type=jacc-provider,name=simpleamx:pp=/domain/configs/config[default-config]/security-service,type=auth-realm,name=admin-realmamx:pp=/J2EEDomain/J2EEServer[server]/WebModule[__admingui],type=Servlet,name=FacesServlet,j2eeType=Servlet,J2EEServer=server,WebModule=__admingui,J2EEApplication=nullamx:pp=/domain/configs/config[server-config]/admin-service,type=property,name=adminConsoleContextRootamx:pp=/domain/configs/config[default-config],type=monitoring-serviceamx:pp=/domain/configs/config[server-config]/security-service,type=auth-realm,name=fileamx:pp=/domain/configs/config[server-config]/security-service/auth-realm[admin-realm],type=property,name=jaas-contextamx:pp=/domain/configs/config[server-config]/security-service/audit-module[default],type=property,name=auditOnamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=response-policyamx:pp=/domain/configs/config[default-config]/security-service/auth-realm[file],type=property,name=jaas-contextamx:pp=/domain/system-applications,type=application,name=__adminguiamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=security.configamx:pp=/domain/configs/config[default-config]/iiop-service/iiop-listener[SSL],type=sslamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=signature.key.aliasamx:pp=/domain/configs/config[default-config],type=connector-serviceamx:pp=/domain/configs/config[server-config],type=ejb-containeramx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=request-policyamx:pp=/mon/server-mon[server],type=garbage-collector-mon,name=jvm/garbage-collectors/MarkSweepCompactamx:pp=/domain/configs/config[default-config]/security-service/audit-module[default],type=property,name=auditOnamx:pp=/domain,type=secure-adminamx:pp=/domain/configs/config[default-config]/network-config/protocols,type=protocol,name=http-listener-1amx:pp=/,type=sampleamx:pp=/domain/configs/config[default-config]/group-management-service,type=failure-detectionamx:pp=/domain/configs/config[default-config]/network-config/network-listeners,type=network-listener,name=http-listener-1amx:pp=/domain/system-applications/application[__admingui],type=module,name=__adminguiamx:pp=/J2EEDomain/J2EEServer[server]/WebModule[__admingui],type=Servlet,name=ThemeServlet,j2eeType=Servlet,J2EEServer=server,WebModule=__admingui,J2EEApplication=nullamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=request-policyamx:pp=/domain/configs,type=config,name=default-configamx:pp=/domain/system-applications/application[__admingui]/module[__admingui],type=engine,name=webamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=dynamic.username.passwordamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=security.configjava.nio:type=BufferPool,name=directamx:pp=/domain/configs/config[server-config]/network-config/network-listeners,type=network-listener,name=http-listener-2amx:pp=/domain/configs/config[server-config]/iiop-service,type=orbamx:pp=/domain/configs/config[default-config],type=java-configamx:pp=/domain,type=property,name=administrative.domain.nameamx:pp=/domain,type=load-balancersamx:pp=/domain/resources/jdbc-connection-pool[__TimerPool],type=property,name=databaseNameamx:pp=/domain/resources,type=jdbc-connection-pool,name=DerbyPoolamx:pp=/domain/configs/config[default-config]/thread-pools,type=thread-pool,name=thread-pool-1amx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=property,name=encryption.key.aliasamx:pp=/domain/configs/config[default-config],type=diagnostic-serviceamx:pp=/domain/configs/config[default-config],type=security-serviceamx:pp=/domain/configs/config[default-config],type=system-property,name=IIOP_LISTENER_PORTamx:pp=/J2EEDomain/J2EEServer[server]/JDBCResource[jdbc/__TimerPool],type=JDBCDataSource,name=jdbc/__TimerPool,j2eeType=JDBCDataSource,J2EEServer=server,JDBCResource=jdbc/__TimerPoolamx:pp=/domain/resources/jdbc-connection-pool[DerbyPool],type=property,name=PortNumberamx:pp=/domain/configs/config[server-config],type=admin-serviceamx:pp=/domain/resources/jdbc-connection-pool[DerbyPool],type=property,name=DatabaseNameamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[admin-listener]/http,type=file-cacheamx:pp=/domain/configs/config[server-config]/web-container/session-config,type=session-managerjava.lang:type=MemoryPool,name=Tenured Genamx:pp=/domain/configs/config[server-config]/thread-pools,type=thread-pool,name=admin-thread-poolamx:pp=/domain/configs/config[server-config]/security-service,type=jacc-provider,name=simpleamx:pp=/domain/configs/config[server-config],type=monitoring-serviceamx:pp=/domain/configs/config[server-config]/security-service,type=property,name=default-digest-algorithmamx:pp=/domain/configs/config[default-config],type=network-configamx:pp=/,type=monamx:pp=/domain/configs/config[default-config],type=mdb-containeramx-support:type=boot-amxamx:pp=/domain/configs/config[default-config],type=transaction-serviceamx:pp=/J2EEDomain/J2EEServer[server],type=JDBCResource,name=jdbc/__default,j2eeType=JDBCResource,J2EEServer=serveramx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[admin-listener]/http,type=file-cacheamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[admin-listener],type=httpamx:pp=/domain,type=serversamx:pp=/domain/configs/config[default-config]/network-config/protocols,type=protocol,name=admin-http-redirectamx:pp=/domain/servers,type=server,name=serveramx:pp=/domain/configs/config[default-config]/availability-service,type=ejb-container-availabilityamx:pp=/domain/configs/config[server-config]/admin-service,type=property,name=ipsRootamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=response-policyamx:pp=/domain/configs/config[server-config]/iiop-service,type=iiop-listener,name=orb-listener-1java.lang:type=GarbageCollector,name=MarkSweepCompactamx:pp=/domain/configs/config[server-config]/admin-service,type=das-configamx:pp=/mon/server-mon[server],type=thread-system-mon,name=jvm/thread-systemamx:pp=/domain/resources,type=jdbc-resource,name=jdbc/__TimerPoolamx:pp=/J2EEDomain/J2EEServer[server]/JDBCResource[jdbc/__default],type=JDBCDataSource,name=jdbc/__default,j2eeType=JDBCDataSource,J2EEServer=server,JDBCResource=jdbc/__defaultamx:pp=/domain/configs/config[server-config]/security-service/jacc-provider[default],type=property,name=repositoryamx:pp=/domain/configs/config[server-config]/http-service,type=access-logjava.lang:type=ClassLoadingamx:pp=/domain/configs/config[server-config]/network-config/protocols,type=protocol,name=admin-listenerjava.lang:type=Threadingamx-support:type=amx-loader,name=j2eeamx:pp=/domain/configs/config[server-config]/security-service/auth-realm[admin-realm],type=property,name=fileamx:pp=/mon/server-mon[server],type=memory-mon,name=jvm/memoryamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=debugamx:pp=/domain/configs/config[default-config]/network-config/protocols,type=protocol,name=admin-listeneramx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=debugamx:pp=/domain/configs/config[server-config]/security-service,type=message-security-config,name=HttpServletamx:pp=/domain/configs/config[server-config]/web-container,type=session-configamx:pp=/domain/resources/jdbc-connection-pool[DerbyPool],type=property,name=Useramx:pp=/domain/configs/config[server-config]/thread-pools,type=thread-pool,name=thread-pool-1amx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=encryption.key.aliasamx:pp=/domain/configs/config[default-config]/http-service,type=access-logamx:pp=/mon,type=server-mon,name=serveramx:pp=/domain/servers/server[server],type=resource-ref,name=jdbc/__defaultamx:pp=/domain/configs/config[default-config],type=http-serviceamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=signature.key.aliasamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=property,name=dynamic.username.passwordamx:pp=/domain/resources/jdbc-connection-pool[DerbyPool],type=property,name=Passwordamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[pu-protocol]/port-unification,type=protocol-finder,name=admin-http-redirectamx:pp=/domain/configs/config[default-config]/security-service/auth-realm[file],type=property,name=fileamx:pp=/domain/configs/config[default-config]/security-service/auth-realm[admin-realm],type=property,name=fileamx:pp=/domain/configs/config[default-config]/iiop-service,type=orbamx:pp=/domain/configs/config[default-config]/admin-service,type=das-configamx:pp=/domain/configs,type=config,name=server-configamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[HttpServlet]/provider-config[GFConsoleAuthModule],type=request-policyamx:pp=/domain/configs/config[default-config],type=log-serviceamx:pp=/domain/configs/config[default-config]/iiop-service,type=iiop-listener,name=SSL_MUTUALAUTHamx:pp=/domain/configs/config[default-config],type=iiop-serviceamx:pp=/domain/configs/config[server-config]/iiop-service,type=iiop-listener,name=SSL_MUTUALAUTHamx:pp=/domain/configs/config[server-config]/security-service,type=auth-realm,name=certificateamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP],type=provider-config,name=ClientProvideramx:pp=/domain/configs/config[server-config],type=security-serviceamx:pp=/domain/configs/config[default-config]/security-service,type=message-security-config,name=SOAPamx:pp=/mon/server-mon[server],type=runtime-mon,name=jvm/runtimeamx:pp=/domain,type=lb-configsamx:pp=/J2EEDomain/J2EEServer[server],type=WebModule,name=__admingui,j2eeType=WebModule,J2EEServer=server,J2EEApplication=nulljava.lang:type=MemoryPool,name=Perm Genamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[HttpServlet],type=provider-config,name=GFConsoleAuthModuleamx:pp=/mon/server-mon[server],type=class-loading-system-mon,name=jvm/class-loading-systemjava.lang:type=MemoryManager,name=CodeCacheManageramx:pp=/domain/resources,type=jdbc-resource,name=jdbc/__defaultamx-support:type=mbean-trackeramx:pp=/domain/configs/config[server-config],type=network-configamx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[http-listener-2],type=httpamx:pp=/domain,type=configsamx:pp=/domain/configs/config[server-config]/http-service,type=virtual-server,name=__asadminamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP],type=provider-config,name=XWS_ClientProvideramx:pp=/domain/configs/config[default-config]/web-container/session-config,type=session-propertiesamx-support:type=amx-loader,name=startupamx:pp=/domain/configs/config[default-config],type=admin-serviceamx:pp=/domain/configs/config[default-config]/network-config/network-listeners,type=network-listener,name=http-listener-2amx:pp=/domain/configs/config[server-config],type=jms-serviceamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[sec-admin-listener]/http,type=file-cacheamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[sec-admin-listener],type=sslamx:pp=/domain,type=clustersamx:pp=/domain,type=nodesamx:pp=/domain/configs/config[default-config]/thread-pools,type=thread-pool,name=admin-thread-poolamx-support:type=AMXConfigLoaderamx:pp=/domain/configs/config[default-config]/ejb-container,type=ejb-timer-serviceamx:pp=/domain/configs/config[default-config]/iiop-service/iiop-listener[SSL_MUTUALAUTH],type=sslamx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[http-listener-2]/http,type=file-cacheamx:pp=/domain/resources,type=jdbc-connection-pool,name=__TimerPoolamx:pp=/domain/configs/config[default-config],type=jms-serviceamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=request-policyamx:pp=/domain/configs/config[server-config]/network-config/network-listeners,type=network-listener,name=admin-listeneramx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=property,name=debugamx:pp=/domain/configs/config[default-config],type=system-property,name=JAVA_DEBUGGER_PORTamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=property,name=encryption.key.aliasamx:pp=/domain/configs/config[server-config]/network-config,type=network-listenersamx:pp=/domain/secure-admin,type=secure-admin-principal,name="CN=localhost,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US"amx:pp=/domain/configs/config[server-config]/network-config/network-listeners,type=network-listener,name=http-listener-1amx:pp=/domain/configs/config[server-config]/web-container/session-config,type=session-propertiesamx:pp=/,type=bulk-accessamx:pp=/domain/configs/config[server-config],type=group-management-serviceamx:pp=/domain/configs/config[default-config],type=management-rulesamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ServerProvider],type=property,name=signature.key.aliasamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[XWS_ClientProvider],type=response-policyamx:pp=/domain/configs/config[default-config]/availability-service,type=jms-availabilityamx:pp=/domain/configs/config[default-config]/admin-service,type=jmx-connector,name=systemamx:pp=/domain/configs/config[default-config]/http-service/virtual-server[server],type=property,name=default-web-xmlamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=response-policyamx:pp=/domain/configs/config[server-config]/network-config/protocols/protocol[http-listener-1]/http,type=file-cacheamx:pp=/domain/configs/config[server-config]/admin-service,type=property,name=adminConsoleDownloadLocationamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[sec-admin-listener],type=httpamx:pp=/domain/configs/config[server-config],type=transaction-servicejava.lang:type=OperatingSystemamx:pp=/J2EEDomain/J2EEServer[server],type=JVM,j2eeType=JVM,J2EEServer=serveramx:pp=/,type=pathnamesamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=security.configamx-support:type=amx-loader,name=extamx:pp=/domain/configs/config[server-config]/security-service/message-security-config[SOAP],type=provider-config,name=XWS_ServerProvideramx:pp=/domain/configs/config[server-config]/security-service/message-security-config[HttpServlet]/provider-config[GFConsoleAuthModule],type=response-policyamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ServerProvider],type=property,name=debugamx:pp=/domain/configs/config[default-config]/network-config/protocols/protocol[pu-protocol]/port-unification,type=protocol-finder,name=http-finderamx:pp=/J2EEDomain/J2EEServer[server],type=JDBCResource,name=jdbc/__TimerPool,j2eeType=JDBCResource,J2EEServer=serveramx:pp=/domain/configs/config[server-config],type=http-serviceamx:pp=/,type=domainamx:pp=/domain/configs/config[default-config]/security-service/message-security-config[SOAP]/provider-config[ClientProvider],type=property,name=encryption.key.aliasamx:pp=/domain,type=applicationsamx:pp=/domain/configs/config[default-config],type=system-property,name=IIOP_SSL_MUTUALAUTH_PORTamx:pp=/domain/configs/config[server-config]/iiop-service/iiop-listener[SSL],type=sslamx:pp=/J2EEDomain,type=J2EEServer,name=server,j2eeType=J2EEServeramx:pp=,type=domain-rootJMImplementation:type=MBeanServerDelegate

As this image and the small-font text demonstrate, “booting AMX” has led to GlassFish exposing significant monitoring and management capabilities via JMX.

Conclusion

This post has demonstrated using Groovy to explore the standard JMX MBeans provided by the Java Platform as well as the AMX beans that GlassFish provides. The last Groovy code snippet invokes GlassFish’s “bootAMX” operation to unleash significantly more GlassFish JMX-based monitoring and managing capabilities. Although all of this could be accomplished with a GUI-based JMX client such as JConsole or JVisualVM, there are advantages at times to running things in scripts. Using Groovy as demonstrated in this post allows scripts to easily interact with GlassFish for administration.
 

Reference: “Booting AMX” in GlassFish 3 with Groovy from our JCG partner Dustin Marx at the Inspired by Actual Events blog.


Source : feedproxy[dot]google[dot]com

No comments:

Post a Comment