FileDocCategorySizeDatePackage
ClusterInfo.javaAPI DocGlassfish v2 API6415Fri May 04 22:35:02 BST 2007com.sun.enterprise.tools.upgrade.cluster

ClusterInfo

public class ClusterInfo extends Object
author
prakash

Fields Summary
private String
clusterName
private List
clusteredInstanceList
private String
domainName
private static Logger
log
Constructors Summary
public ClusterInfo()


     
    
Methods Summary
private ClusteredInstancecreateNewInstance(java.lang.String instanceName)

        ClusteredInstance clInstance = new ClusteredInstance(instanceName);
        clusteredInstanceList.add(clInstance);
        return clInstance;
    
public java.lang.StringgetClusterName()

        return this.clusterName;
    
public java.util.ListgetClusteredInstanceList()

        return this.clusteredInstanceList;
    
public java.lang.StringgetDomainName()

        if(this.domainName == null){
            ClusteredInstance clInstance = this.getMasterInstance();
            if((clInstance == null) && (this.clusteredInstanceList.size() > 0)){
                clInstance = (ClusteredInstance)this.clusteredInstanceList.get(0);
            }
            this.domainName = clInstance.getDomain();
            return clInstance.getDomain();
        }
        return this.domainName;
    
public ClusteredInstancegetMasterInstance()

        ClusteredInstance clInstance = null; 
        for(Iterator it = this.clusteredInstanceList.iterator(); it.hasNext();){
            clInstance = (ClusteredInstance)it.next();
            if(clInstance.isMaster())
                return clInstance;
        }
        return null;
    
public voidparseClinstanceConfFile(java.io.File file)

        if(clusteredInstanceList == null){
            clusteredInstanceList = new ArrayList();
        }
        clusteredInstanceList.clear();
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        String line = null;
        ClusteredInstance clInstance = null;            
        while((line = reader.readLine()) != null){
            if(line.trim().startsWith("#")){
                // Comment line.  pass on
                continue;
            }
            if(line.trim().startsWith("instancename")){
                String instanceName = line.substring("instancename".length()).trim();
                clInstance = createNewInstance(instanceName);
                continue;
            } 
            if(clInstance != null)
                clInstance.extractDataFromLine(line);
        }
    
public voidprint()

        if(clusteredInstanceList != null){
            for(Iterator it = clusteredInstanceList.iterator(); it.hasNext();){
                ClusteredInstance clInst = (ClusteredInstance)it.next();
                log.info(clInst.getInstanceName());
                log.info(clInst.getUser());
                log.info(clInst.getHost());
                log.info(clInst.getPort());
                log.info(clInst.getDomain());
                log.info(clInst.getInstancePort());
                log.info(String.valueOf(clInst.isMaster()));
                log.info("\n");
            }
        }
    
public voidsetClusterName(java.lang.String clName)

        this.clusterName = clName;
    
public voidsetDomainName(java.lang.String dName)

        this.domainName = dName;
    
public voidupdateClusteredInstanceList(java.lang.String domainXMLFile, java.lang.String domainName, java.lang.String clName, com.sun.enterprise.tools.upgrade.common.UpgradeUtils upgradeUtils)
Builds ClusteredInstance list with domain name and respective cluster name.

        if(clusteredInstanceList == null) {
            clusteredInstanceList = new ArrayList();
        }
        clusteredInstanceList.clear();		
        upgradeUtils.updateClusteredInstanceList(domainXMLFile,
            domainName, clName, clusteredInstanceList);