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;
}
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;
}
Aggregations