FileDocCategorySizeDatePackage
ClusteredServerConfigTest.javaAPI DocGlassfish v2 API7027Fri May 04 22:23:54 BST 2007com.sun.enterprise.management.config

ClusteredServerConfigTest

public final class ClusteredServerConfigTest extends com.sun.enterprise.management.AMXTestBase implements com.sun.enterprise.management.ClusterSupportRequired

Fields Summary
Constructors Summary
public ClusteredServerConfigTest()

    
Methods Summary
public com.sun.appserv.management.config.ClusteredServerConfigcreateClusteredServer(java.lang.String serverName, java.lang.String nodeAgentName, int basePort)

	    final DomainConfig      domainConfig    = getDomainConfig();
	    
	    if ( domainConfig.getClusteredServerConfigMap().get( serverName ) != null )
	    {
	        domainConfig.removeClusteredServerConfig( serverName );
	    }
	    else if ( domainConfig.getStandaloneServerConfigMap().get( serverName ) != null )
	    {
	        domainConfig.removeStandaloneServerConfig( serverName );
	    }
	    
	    final ClusterConfig clusterConfig   =
	        ClusterConfigTest.ensureDefaultInstance( domainConfig );
	    
	    if ( domainConfig.getClusteredServerConfigMap().get( serverName ) != null )
	    {
	        domainConfig.removeClusteredServerConfig( serverName );
	        assert domainConfig.getClusteredServerConfigMap().get( serverName ) == null;
	    }
	    
	    final ConfigSetup   setup   = new ConfigSetup( getDomainRoot() );
	    final Map<String,String>    options = new HashMap<String,String>();
	    setup.setupServerPorts( options, basePort );
	    
	    final ClusteredServerConfig csc  =
	        domainConfig.createClusteredServerConfig( serverName,
	                    clusterConfig.getName(),
	                    nodeAgentName,
	                    options );
	    sanityCheck( csc );
	    
	    return csc;
	
private voidsanityCheck(com.sun.appserv.management.config.ClusteredServerConfig csc)

        assert XTypes.CLUSTERED_SERVER_CONFIG.equals( csc.getJ2EEType() );
        
        final String configName    = csc.getReferencedConfigName();
        final String nodeAgentName = csc.getReferencedNodeAgentName();
        
        final Map<String,DeployedItemRefConfig>	deployedItems   =
            csc.getDeployedItemRefConfigMap();
            
            
        final Map<String,ResourceRefConfig>	resources   =
            csc.getResourceRefConfigMap();
        
        final String lbWeight   = csc.getLBWeight();
        csc.setLBWeight( lbWeight );
    
public voidtestCreateRemove()

	    final DomainConfig  domainConfig    = getDomainConfig();
	    final NodeAgentConfig   nodeAgentConfig = getDASNodeAgentConfig();
	    
	    if ( nodeAgentConfig == null )
	    {
	        warning( "SKIPPING ClusteredServerConfigTest.testCreateRemove: " +
	            "no DAS Node Agent has been specified; use " +
	                PropertyKeys.DAS_NODE_AGENT_NAME );
	    }
	    else
	    {
	        final int NUM   = 5;
	        final String    baseName    = "ClusteredServerConfigTest";
	        
	        verifyRefContainers();
	        
	        final ClusteredServerConfig[]   servers = new ClusteredServerConfig[ NUM ];
	        for( int i = 0; i < NUM; ++i )
	        {
	            final int   basePort    = 11000 + i * 10;
	            servers[ i ]    = createClusteredServer( baseName + "-" + i,
	                                nodeAgentConfig.getName(),
	                                basePort );
	            printVerbose( "Created ClusteredServerConfig: " + servers[ i ].getName() );
	            assert XTypes.CLUSTERED_SERVER_CONFIG.equals( servers[ i ].getJ2EEType() );
	            
	            verifyRefContainers();
	        }
	        
	        for( int i = 0; i < NUM; ++i )
	        {
	            final String name   = servers[ i ].getName();
    	        domainConfig.removeClusteredServerConfig( name );
	            printVerbose( "Removed ClusteredServerConfig: " + name );
	        }
    	    
	    }
	
private voidverifyRefContainers()

	    final Set<String>   j2eeTypes   =
	        GSetUtil.newUnmodifiableStringSet(
	            XTypes.DEPLOYED_ITEM_REF_CONFIG, XTypes.RESOURCE_REF_CONFIG );
	    
	    final Set<RefConfig>    refs    = getQueryMgr().queryJ2EETypesSet( j2eeTypes );
	    
	    for( final RefConfig ref : refs )
	    {
	        assert ref.getContainer() != null :
	            "MBean " + Util.getObjectName( ref ) + " return null from getContainer()";
	    }