FileDocCategorySizeDatePackage
SystemInfoImpl.javaAPI DocGlassfish v2 API7411Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

SystemInfoImpl

public final class SystemInfoImpl extends AMXImplBase implements com.sun.appserv.management.base.SystemInfo

Fields Summary
private final MBeanServer
mServer
private BootUtil
mBootUtil
public static final String
NAME_PROP_VALUE
private final Map
mFeatures
private static long
LAST_REFRESH
private static final String[]
FEATURE_NAMES
Constructors Summary
public SystemInfoImpl(MBeanServer server, BootUtil bootUtil)

		super( );
		
		mServer			= server;
		mBootUtil		= bootUtil;
		
		mFeatures	= new HashMap<String,Boolean>();
		
		final boolean	supportsClusters	= supportsClusters( );
		
		mFeatures.put( CLUSTERS_FEATURE, Boolean.valueOf( supportsClusters ));
		mFeatures.put( MULTIPLE_SERVERS_FEATURE, Boolean.valueOf( supportsClusters ));
		mFeatures.put( RUNNING_IN_DAS_FEATURE, Boolean.valueOf( isRunningInDomainAdminServer() ) );
	
Methods Summary
private void_refresh()

        checkHADBAvailable();
    
private voidcheckHADBAvailable()

        final boolean   available   = mServer.isRegistered(
            com.sun.enterprise.admin.common.ObjectNames.getHADBConfigObjectName() );
        mFeatures.put( HADB_CONFIG_FEATURE, Boolean.valueOf( available ) );
    
public java.lang.String[]getFeatureNames()

	
		 
	
	
		return( (String[])FEATURE_NAMES.clone() );
	
public final java.lang.StringgetGroup()

		return( AMX.GROUP_UTILITY );
	
private javax.management.ObjectNamegetOldServersMBeanObjectName()
Get the ObjectName of the "type=servers" MBean, which only exists in the DAS.

		// if we find the old "servers" MBean, it should only be running in the DAS.
		final ObjectName	pattern		=
				Util.newObjectName( "com.sun.appserv", "category=config,type=servers" );
		final Set<ObjectName> serversSet	= JMXUtil.queryNames( mServer, pattern, null );
		
		final ObjectName	objectName	= serversSet.size() == 0 ? 
					null : (ObjectName)GSetUtil.getSingleton( serversSet );
					
		return( objectName );
	
public java.util.MapgetPerformanceMillis()
Return a Map keyed by an arbitrary String denoting some feature. The value is the time in milliseconds. Code should not rely on the keys as they are subject to changes, additions, or removal at any time, except as otherwise documented. Even documented items should be used only for informational purposes, such as assessing performance.

return
Map

        // ensure that we return a copy which is a HashMap, not some other variant of Map
        final HashMap<String,Long>  result = new HashMap<String,Long>();
        
        result.putAll( SystemInfoData.getInstance().getPerformanceMillis() );
        
        return result;
    
private booleanisRunningInDomainAdminServer()

		return( getOldServersMBeanObjectName() != null );
	
private voidrefresh()

          
    
    
        final long REFRESH_MILLIS   = 5 * 1000; // 5 seconds
        final long elapsed   = System.currentTimeMillis() - LAST_REFRESH;
        if ( elapsed > REFRESH_MILLIS )
        {
            _refresh();
        }
    
private final booleansupportsClusters()

	
		  
	 
	
		final ObjectName	serversObjectName	= getOldServersMBeanObjectName();
		
		boolean	supportsClusters	= false;
		if ( serversObjectName != null )
		{
			// see if the 'servers' MBean supports listing unclustered instances
			try
			{
				final MBeanInfo				info	= mServer.getMBeanInfo( serversObjectName );
				
				final String	operationName	= "listUnclusteredServerInstancesAsString";
				final Set	operations	= JMXUtil.findInfoByName( info.getOperations(), operationName );
				supportsClusters	= operations.size() != 0;
				
			}
			catch( JMException e )
			{
				// should never happen...
				throw new RuntimeException( "problem with 'servers' MBean: " + serversObjectName, e );
			}
		}
		else
		{
			// presumably, we're in another instance, which implies multiple instances.
			// assume this also means clustering is possible
			supportsClusters	= true;
		}
		
		return( supportsClusters );
	
public booleansupportsFeature(java.lang.String key)

		boolean	supports	= false;
		
		Boolean	result	= mFeatures.get( key );
		if ( result == null )
		{
			result	= Boolean.FALSE;
		}
		
		return( result.booleanValue() );