FileDocCategorySizeDatePackage
ClustersInfoManager.javaAPI DocGlassfish v2 API9646Fri May 04 22:35:04 BST 2007com.sun.enterprise.tools.upgrade.cluster

ClustersInfoManager

public class ClustersInfoManager extends Object
author
prakash

Fields Summary
private static ClustersInfoManager
clusterManager
private List
clusterInfoList
private com.sun.enterprise.util.i18n.StringManager
stringManager
private static Logger
logger
private Hashtable
iiopClustersMapping
private Hashtable
persistenceStoreMapping
private LBInfo
loadBalancerInfo
Constructors Summary
public ClustersInfoManager()
Creates a new instance of ClustersInfoManager

    
           
      
    
Methods Summary
public voidaddPersistenceStoreProperty(java.lang.String domainName, java.lang.String name, java.lang.String value)

        if(this.persistenceStoreMapping == null){
            persistenceStoreMapping = new Hashtable();
        }
        Properties propsList = (Properties)this.persistenceStoreMapping.get(domainName);
        if(propsList == null)
            propsList = new Properties();
        propsList.setProperty(name,value);
        this.persistenceStoreMapping.put(domainName,propsList);
    
public voidgatherClusterInfo(com.sun.enterprise.tools.upgrade.common.CommonInfoModel commonInfo)
Gathers cluster information when source domain is 8.x

        if(clusterInfoList == null)
            clusterInfoList = new ArrayList();
        clusterInfoList.clear();
        for(java.util.Iterator dItr = 
                commonInfo.getDomainMapping().keySet().iterator(); dItr.hasNext();){
            DomainInfo dInfo = (DomainInfo)commonInfo.getDomainMapping().get(dItr.next());
            String domainName = dInfo.getDomainName();
            String domainXmlFile = dInfo.getDomainPath() + File.separator +
                    UpgradeConstants.AS_CONFIG_DIRECTORY + File.separator + 
                    "domain.xml";
            //Build the clusterInfoList
            UpgradeUtils.getUpgradeUtils(commonInfo).updateClusterList(
                    domainXmlFile, domainName, clusterInfoList);
        }
    
public java.util.ListgetClusterInfoList()

        return this.clusterInfoList;
    
public static com.sun.enterprise.tools.upgrade.cluster.ClustersInfoManagergetClusterInfoManager()

        if(clusterManager == null)
            clusterManager = new ClustersInfoManager();
        return clusterManager;        
    
public IIOPClustergetIIOPCluster(java.lang.String domainName, java.lang.String clusterName)

        // If IIOPCluster for the domain not created, create one.
        // Domain name is the target domain name
        if(this.iiopClustersMapping == null)
            this.iiopClustersMapping = new Hashtable();
        List clList = (List)this.iiopClustersMapping.get(domainName);
        IIOPCluster iiopCluster = null;
        if((clList != null) && (!clList.isEmpty())){
            for(Iterator iIt = clList.iterator(); iIt.hasNext();){
                java.lang.Object iiopClusterObject = iIt.next();
                IIOPCluster iCluster = (IIOPCluster)iiopClusterObject;
                if(iCluster.getClusterName().equals(clusterName)){
                    iiopCluster = iCluster;
                    break;
                }
            }
        }else{
            clList = new ArrayList();
        }
        if(iiopCluster == null){
            iiopCluster = new IIOPCluster(clusterName);
            clList.add(iiopCluster);
            this.iiopClustersMapping.put(domainName,clList);
        }
        return iiopCluster;
    
public java.util.HashtablegetIIOPClustersMapping()

        return this.iiopClustersMapping;
    
public LBInfogetLoadBalancerInfo()

        return this.loadBalancerInfo;
    
public java.util.HashtablegetPersistenceStorePropertiesMapping()

        return this.persistenceStoreMapping;
    
public booleanisIIOPClusterExists(java.lang.String domainName, java.lang.String clusterName)

        if(this.iiopClustersMapping == null)
            return false;
        List clList = (List)this.iiopClustersMapping.get(domainName);
        if((clList == null) || (clList.isEmpty())){
            return false;
        }
        for(Iterator iIt = clList.iterator(); iIt.hasNext();){
            if(((IIOPCluster)iIt.next()).getClusterName().equals(clusterName)){
                return true;
            }
        }
        return false;
    
public static voidmain(java.lang.String[] args)

param
args the command line arguments

        List aList = new ArrayList();
        aList.add("c:\\temp\\clinstance.conf");
        aList.add("c:\\temp\\clinstance.conf");
        ClustersInfoManager cIM = ClustersInfoManager.getClusterInfoManager();
        cIM.processClinstanceConfFiles(aList);
        cIM.print();
        
    
public ClusterInfoparseClinstanceConfFile(java.lang.String fileName)

        return this.parseClinstanceConfFile(new File(fileName));
    
public ClusterInfoparseClinstanceConfFile(java.io.File file)

        if(!file.exists())
            throw new FileNotFoundException();
        ClusterInfo clInfo = new ClusterInfo();
        clInfo.parseClinstanceConfFile(file);
        return clInfo;
    
public voidprint()

        if(clusterInfoList != null){
            for(Iterator it = clusterInfoList.iterator(); it.hasNext();){
                ClusterInfo clInfo = (ClusterInfo)it.next();
                com.sun.enterprise.tools.upgrade.common.CommonInfoModel.getDefaultLogger().info("\n\n\n *****************");
                clInfo.print();                
            }
        }
    
public booleanprocessClinstanceConfFiles(java.util.List clinstanceConfFiles)

        if(clusterInfoList == null)
            clusterInfoList = new ArrayList();
        clusterInfoList.clear();
        for(Iterator it = clinstanceConfFiles.iterator(); it.hasNext();){
            try{
                clusterInfoList.add(this.parseClinstanceConfFile((String)it.next())); 
            }catch(FileNotFoundException fne){
                logger.severe(stringManager.getString("enterprise.tools.upgrade.clinstanceConfFileMissing"));
                System.exit(1);
                // if file is not found, that cluster is not added to the list.  Continue processing other cluster files
            }catch(Exception ex){
                logger.severe(stringManager.getString("enterprise.tools.upgrade.clinstanceConfFileProcessingException"));
                return false;
            }
        }
        return true;
    
public booleanprocessLoadBalancerFile(java.lang.String fileName)

        if(this.loadBalancerInfo == null)
            this.loadBalancerInfo = new LBInfo();
        if(! new File(fileName).exists())
            return false;
        return this.loadBalancerInfo.processLoadBalancerFile(fileName);