admin@glassfish.java.net

Re: Extending GlassFish monitoring

From: Lloyd L Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Mon, 15 Oct 2007 15:42:57 -0700

Yamini,

1. Comments are almost non-existent.

2. Names like "MonitoringManager" imply some global scope. PWhat is
the intended usage? Why is it being added? Are you saying you are
trying to create a general purpose feature? It can't be a public
interface, so I don't get it. And it certainly deserves a LOT more
documentation if that is the intent.

3. How does AMX fit into this? New monitoring should be implemented
directly for AMX in my view, not on

4. Creating a HashTable to form an ObjectName (eg
getMonitoredObjectName) is perhaps the least efficient way to do it.
You might as well use String concatenation.

5. I don't understand why MonitoringManagerImpl does nothing. And
if it's a singleton, it should have a private constructor and be a
'final' class as well.

6. Yet another item into the kitchen sink that is AdminService. This
has been the pattern, but that doesn't mean the approach is good.

7.

Lloyd

On Oct 11, 2007, at 2:24 AM, Yamini K B wrote:

> Hi,
>
> (Sending this to wider audience on Siraj's suggestion)
>
> I've modified GlassFish administration to use pluggable feature
> factory to load a new monitoring manager. This monitoring manager
> can be used to define custom register/unregister methods for any
> new monitoring objects.
>
> SailFin monitoring support will be enabled using this feature.
>
> Please review and let me know your comments.
>
> Thanks & Regards,
> -Yamini
> ? admin-core/admin/src/java/com/sun/enterprise/admin/pluggable/
> MonitoringManager.java
> ? admin-core/admin/src/java/com/sun/enterprise/admin/pluggable/
> MonitoringManagerImpl.java
> Index: admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/DottedNameFactory.java
> ===================================================================
> RCS file: /cvs/glassfish/admin/monitor/src/java/com/sun/enterprise/
> admin/monitor/registry/spi/DottedNameFactory.java,v
> retrieving revision 1.4
> diff -u -r1.4 DottedNameFactory.java
> --- admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/DottedNameFactory.java 5 May 2007 05:24:19 -0000 1.4
> +++ admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/DottedNameFactory.java 11 Oct 2007 09:01:51 -0000
> @@ -68,7 +68,7 @@
> * @author Shreedhar Ganapathy<mailto:shreedhar.ganapathy_at_sun.com>
> * @revision $Revision: 1.4 $
> */
> -class DottedNameFactory {
> +public final class DottedNameFactory {
> private static final Logger logger = Logger.getLogger
> (AdminConstants.kLoggerName);
> private static final StringManager sm = StringManager.getManager
> (DottedNameFactory.class);
> private static String instanceName =null;
> @@ -379,4 +379,11 @@
> }
>
> // JVM1.5 related changes - END
> + public static String getDottedName(String name){
> + return getInstanceName() + DELIMITER + name;
> + }
> +
> + public static String getDottedName(String name, String type){
> + return getDottedName(type) + DELIMITER +
> DottedName.escapePart(name);
> + }
> }
> Index: admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/MonitoringObjectNames.java
> ===================================================================
> RCS file: /cvs/glassfish/admin/monitor/src/java/com/sun/enterprise/
> admin/monitor/registry/spi/MonitoringObjectNames.java,v
> retrieving revision 1.13
> diff -u -r1.13 MonitoringObjectNames.java
> --- admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/MonitoringObjectNames.java 5 May 2007 05:24:19 -0000 1.13
> +++ admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/MonitoringObjectNames.java 11 Oct 2007 09:01:51 -0000
> @@ -67,7 +67,7 @@
> * @since S1AS8.0
> * @version $Revision: 1.13 $
> */
> -final class MonitoringObjectNames {
> +public final class MonitoringObjectNames {
>
> private static final String SERVER_ID =
> ApplicationServer.getServerContext().getInstanceName();
> private static final Logger logger = Logger.getLogger
> (AdminConstants.kLoggerName);
> @@ -628,4 +628,17 @@
> return(formObjectName(t));
> }
> // JVM1.5 related changes - END
> +
> + public static ObjectName getMonitoredObjectName(String type) {
> + final Hashtable t = new Hashtable();
> + t.put("type", type);
> + return ( formObjectName(t) );
> + }
> +
> + public static ObjectName getMonitoredObjectName(String name,
> String type) {
> + final Hashtable t = new Hashtable();
> + t.put("type", type);
> + t.put("name", name);
> + return ( formObjectName(t) );
> + }
> }
> Index: admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/MonitoringRegistrationHelper.java
> ===================================================================
> RCS file: /cvs/glassfish/admin/monitor/src/java/com/sun/enterprise/
> admin/monitor/registry/spi/MonitoringRegistrationHelper.java,v
> retrieving revision 1.14
> diff -u -r1.14 MonitoringRegistrationHelper.java
> --- admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/MonitoringRegistrationHelper.java 5 May 2007 05:24:19
> -0000 1.14
> +++ admin/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/spi/MonitoringRegistrationHelper.java 11 Oct 2007 09:01:52
> -0000
> @@ -68,6 +68,11 @@
> import
> com.sun.enterprise.admin.monitor.registry.spi.reconfig.DynamicReconfig
> urator;
> import
> com.sun.enterprise.admin.monitor.registry.spi.reconfig.MonitoringConfi
> gChangeListener;
> import com.sun.enterprise.server.stats.JVMStatsImpl;
> +
> +import com.sun.enterprise.admin.server.core.AdminService;
> +//import com.sun.enterprise.server.ApplicationServer;
> +import com.sun.enterprise.admin.pluggable.MonitoringManager;
> +
> /**
> * Enables components to register their Stats implementation for
> monitoring.
> * This implementation provides a way for a JSR77 Managed
> Component's monitoring
> @@ -995,6 +1000,7 @@
> initializeJmsService();
> initializeJndi();
> //((StatsHolderImpl)rootStatsHolder).write();
> + initializeModuleMonitoring();
> }
>
> private void initializeRoot() {
> @@ -1864,4 +1870,11 @@
> public StatsHolder getRootStatsHolder() {
> return rootStatsHolder;
> }
> +
> + private void initializeModuleMonitoring() {
> + MonitoringManager mm = AdminService.getMonitoringFeature();
> +// MonitoringManager mm = ApplicationServer.getServerContext
> ().getPluggableFeatureFactory().getMonitoringManager();
> +
> + mm.registerAllStats(rootStatsHolder);
> + }
> }
> Index: admin-core/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/MonitoredObjectType.java
> ===================================================================
> RCS file: /cvs/glassfish/admin-core/monitor/src/java/com/sun/
> enterprise/admin/monitor/registry/MonitoredObjectType.java,v
> retrieving revision 1.4
> diff -u -r1.4 MonitoredObjectType.java
> --- admin-core/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/MonitoredObjectType.java 5 May 2007 05:25:46 -0000 1.4
> +++ admin-core/monitor/src/java/com/sun/enterprise/admin/monitor/
> registry/MonitoredObjectType.java 11 Oct 2007 09:01:55 -0000
> @@ -299,4 +299,8 @@
> MonitoredObjectType.HTTP_SERVICE,
> MonitoredObjectType.HTTP_LISTENER,
> MonitoredObjectType.VIRTUAL_SERVER};
> +
> + public static MonitoredObjectType newMonitoredObjectType
> (String name, boolean isSingleton ) {
> + return (new MonitoredObjectType(name, isSingleton));
> + }
> }
> Index: appserv-core/src/java/com/sun/enterprise/admin/server/core/
> AdminService.java
> ===================================================================
> RCS file: /cvs/glassfish/appserv-core/src/java/com/sun/enterprise/
> admin/server/core/AdminService.java,v
> retrieving revision 1.31.2.1
> diff -u -r1.31.2.1 AdminService.java
> --- appserv-core/src/java/com/sun/enterprise/admin/server/core/
> AdminService.java 24 Sep 2007 06:20:47 -0000 1.31.2.1
> +++ appserv-core/src/java/com/sun/enterprise/admin/server/core/
> AdminService.java 11 Oct 2007 09:02:14 -0000
> @@ -102,6 +102,9 @@
> //web service
> import com.sun.enterprise.webservice.WsUtil;
>
> +//monitoring manager
> +import com.sun.enterprise.admin.pluggable.MonitoringManager;
> +
> import com.sun.enterprise.admin.AdminContext;
> import com.sun.enterprise.admin.meta.MBeanRegistry;
> import com.sun.enterprise.admin.meta.MBeanRegistryFactory;
> @@ -199,6 +202,7 @@
>
> private final AutoDeployStarter autoDeployStarter = new
> AutoDeployStarter();
>
> + private static MonitoringManager mManager = null;
>
> /**
> * private constructor. AdminService instance should be
> initialized
> @@ -237,11 +241,15 @@
> if (ac instanceof AdminContextImpl) {
> ((AdminContextImpl)ac).setServerContext
> ((ServerContextImpl)sc);
> }
> + mManager = sc.getPluggableFeatureFactory
> ().getMonitoringManager();
> as.setAdminContext(ac);
> setAdminService(as);
> return as;
> }
>
> + public static MonitoringManager getMonitoringFeature() {
> + return mManager;
> + }
> /**
> * Instantiate admin service. This method verifies that
> specified type
> * is a known type and then creates an admin service object
> initialized
> Index: appserv-core/src/java/com/sun/enterprise/server/pluggable/
> PluggableFeatureFactory.java
> ===================================================================
> RCS file: /cvs/glassfish/appserv-core/src/java/com/sun/enterprise/
> server/pluggable/PluggableFeatureFactory.java,v
> retrieving revision 1.8.6.1
> diff -u -r1.8.6.1 PluggableFeatureFactory.java
> --- appserv-core/src/java/com/sun/enterprise/server/pluggable/
> PluggableFeatureFactory.java 24 Sep 2007 06:24:14 -0000 1.8.6.1
> +++ appserv-core/src/java/com/sun/enterprise/server/pluggable/
> PluggableFeatureFactory.java 11 Oct 2007 09:02:15 -0000
> @@ -46,6 +46,8 @@
> import com.sun.enterprise.server.ss.ASLazyKernel;
> import com.sun.enterprise.autotxrecovery.TransactionRecovery;
> import com.sun.enterprise.diagnostics.DiagnosticAgent;
> +
> +import com.sun.enterprise.admin.pluggable.MonitoringManager;
> /**
> * The interface to provide access to supported Pluggable
> Features. The
> * various editions of the product may provide varied
> implementation for
> @@ -162,4 +164,9 @@
> */
> public AdminExtensionFeature getAdminExtensionFeature();
>
> + /**
> + * Monitoring Extension Feature
> + */
> + public MonitoringManager getMonitoringManager();
> +
> }
> /*
> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
> *
> * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
> *
> * The contents of this file are subject to the terms of either the
> GNU
> * General Public License Version 2 only ("GPL") or the Common
> Development
> * and Distribution License("CDDL") (collectively, the "License").
> You
> * may not use this file except in compliance with the License. You
> can obtain
> * a copy of the License at https://glassfish.dev.java.net/public/
> CDDL+GPL.html
> * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
> the specific
> * language governing permissions and limitations under the License.
> *
> * When distributing the software, include this License Header
> Notice in each
> * file and include the License file at glassfish/bootstrap/legal/
> LICENSE.txt.
> * Sun designates this particular file as subject to the
> "Classpath" exception
> * as provided by Sun in the GPL Version 2 section of the License
> file that
> * accompanied this code. If applicable, add the following below
> the License
> * Header, with the fields enclosed by brackets [] replaced by your
> own
> * identifying information: "Portions Copyrighted [year]
> * [name of copyright owner]"
> *
> * Contributor(s):
> *
> * If you wish your version of this file to be governed by only the
> CDDL or
> * only the GPL Version 2, indicate your decision by adding
> "[Contributor]
> * elects to include this software in this distribution under the
> [CDDL or GPL
> * Version 2] license." If you don't indicate a single choice of
> license, a
> * recipient has the option to distribute your version of this file
> under
> * either the CDDL, the GPL Version 2 or to extend the choice of
> license to
> * its licensees as provided above. However, if you add GPL
> Version 2 code
> * and therefore, elected the GPL Version 2 license, then the
> option applies
> * only if the new code is made subject to such option by the
> copyright
> * holder.
> */
> package com.sun.enterprise.admin.pluggable;
>
> import com.sun.enterprise.admin.monitor.registry.StatsHolder;
> /**
> * Interface for adding monitoring extensions
> *
> */
> public interface MonitoringManager {
>
> /*
> * Implement this to register any stats implementation classes
> */
> public void registerAllStats(StatsHolder rootStatsHolder);
> }
> /*
> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
> *
> * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
> *
> * The contents of this file are subject to the terms of either the
> GNU
> * General Public License Version 2 only ("GPL") or the Common
> Development
> * and Distribution License("CDDL") (collectively, the "License").
> You
> * may not use this file except in compliance with the License. You
> can obtain
> * a copy of the License at https://glassfish.dev.java.net/public/
> CDDL+GPL.html
> * or glassfish/bootstrap/legal/LICENSE.txt. See the License for
> the specific
> * language governing permissions and limitations under the License.
> *
> * When distributing the software, include this License Header
> Notice in each
> * file and include the License file at glassfish/bootstrap/legal/
> LICENSE.txt.
> * Sun designates this particular file as subject to the
> "Classpath" exception
> * as provided by Sun in the GPL Version 2 section of the License
> file that
> * accompanied this code. If applicable, add the following below
> the License
> * Header, with the fields enclosed by brackets [] replaced by your
> own
> * identifying information: "Portions Copyrighted [year]
> * [name of copyright owner]"
> *
> * Contributor(s):
> *
> * If you wish your version of this file to be governed by only the
> CDDL or
> * only the GPL Version 2, indicate your decision by adding
> "[Contributor]
> * elects to include this software in this distribution under the
> [CDDL or GPL
> * Version 2] license." If you don't indicate a single choice of
> license, a
> * recipient has the option to distribute your version of this file
> under
> * either the CDDL, the GPL Version 2 or to extend the choice of
> license to
> * its licensees as provided above. However, if you add GPL
> Version 2 code
> * and therefore, elected the GPL Version 2 license, then the
> option applies
> * only if the new code is made subject to such option by the
> copyright
> * holder.
> */
> package com.sun.enterprise.admin.pluggable;
>
> import com.sun.enterprise.admin.monitor.registry.StatsHolder;
> /**
> * Default implementation for adding monitoring extensions
> *
> */
> public class MonitoringManagerImpl implements MonitoringManager {
>
> /*
> * Dummy implementation
> */
> public void registerAllStats(StatsHolder rootStatsHolder) {
> // no-op
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net

---
Lloyd L Chambers
lloyd.chambers_at_sun.com
Sun Microsystems, Inc