Search in sources :

Example 6 with ClusterRef

use of com.sun.enterprise.config.serverbeans.ClusterRef in project Payara by payara.

the class LoadbalancerReaderImpl method getClustersDataFromLBConfig.

public ClusterReader[] getClustersDataFromLBConfig() throws LbReaderException {
    List<Ref> serverOrClusters = _lbConfig.getClusterRefOrServerRef();
    ClusterReader[] cls = new ClusterReader[serverOrClusters.size()];
    Iterator<Ref> iter = serverOrClusters.iterator();
    int i = 0;
    while (iter.hasNext()) {
        Ref ref = iter.next();
        if (ref instanceof ServerRef) {
            cls[i++] = new StandAloneClusterReaderImpl(_domain, _appRegistry, (ServerRef) ref);
        } else if (ref instanceof ClusterRef) {
            cls[i++] = new ClusterReaderImpl(_domain, _appRegistry, (ClusterRef) ref);
        } else {
            String msg = LbLogUtil.getStringManager().getString("UnableToDetermineType", ref.getRef());
            throw new LbReaderException(msg);
        }
    }
    return cls;
}
Also used : ClusterRef(com.sun.enterprise.config.serverbeans.ClusterRef) Ref(com.sun.enterprise.config.serverbeans.Ref) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef) ClusterReader(org.glassfish.loadbalancer.admin.cli.reader.api.ClusterReader) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef) ClusterRef(com.sun.enterprise.config.serverbeans.ClusterRef) LbReaderException(org.glassfish.loadbalancer.admin.cli.reader.api.LbReaderException)

Example 7 with ClusterRef

use of com.sun.enterprise.config.serverbeans.ClusterRef in project Payara by payara.

the class CreateHTTPHealthCheckerCommand method matchLbConfigToTarget.

/**
 * Returns an array of LbConfigs that has a reference to the target
 * server or cluster. If there are no references found for the
 * target or the arguments are null, this method returns null.
 *
 * @param  lbConfigs  array of existing LbConfigs in the system
 * @param  target     name of server or cluster
 *
 * @return array of LbConfigs that has a ref to the target server
 */
private List<LbConfig> matchLbConfigToTarget(List<LbConfig> lbConfigs, String target) {
    List<LbConfig> list = null;
    // bad target
    if (target == null) {
        String msg = localStrings.getLocalString("Nulltarget", "Null target");
        logger.warning(msg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return null;
    }
    // system has lb configs defined
    if (!lbConfigs.isEmpty()) {
        list = new ArrayList<LbConfig>();
        for (int i = 0; i < lbConfigs.size(); i++) {
            // target is a cluster
            if (tgt.isCluster(target)) {
                ClusterRef cRef = lbConfigs.get(i).getRefByRef(ClusterRef.class, target);
                // this lb config has a reference to the target cluster
                if (cRef != null) {
                    list.add(lbConfigs.get(i));
                }
            // target is a server
            } else if (domain.isServer(target)) {
                ServerRef sRef = lbConfigs.get(i).getRefByRef(ServerRef.class, target);
                // this lb config has a reference to the target server
                if (sRef != null) {
                    list.add(lbConfigs.get(i));
                }
            }
        }
    }
    return list;
}
Also used : LbConfig(org.glassfish.loadbalancer.config.LbConfig) ClusterRef(com.sun.enterprise.config.serverbeans.ClusterRef) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef)

Aggregations

ClusterRef (com.sun.enterprise.config.serverbeans.ClusterRef)7 ServerRef (com.sun.enterprise.config.serverbeans.ServerRef)6 LbConfig (org.glassfish.loadbalancer.config.LbConfig)4 Cluster (com.sun.enterprise.config.serverbeans.Cluster)1 HealthChecker (com.sun.enterprise.config.serverbeans.HealthChecker)1 Ref (com.sun.enterprise.config.serverbeans.Ref)1 PropertyVetoException (java.beans.PropertyVetoException)1 List (java.util.List)1 ActionReport (org.glassfish.api.ActionReport)1 ClusterReader (org.glassfish.loadbalancer.admin.cli.reader.api.ClusterReader)1 LbReaderException (org.glassfish.loadbalancer.admin.cli.reader.api.LbReaderException)1 LbConfigs (org.glassfish.loadbalancer.config.LbConfigs)1