use of org.glassfish.loadbalancer.config.LoadBalancer in project Payara by payara.
the class ApplyHttpLbChanges method process.
public void process() throws Exception {
ConnectionManager _connectionManager = null;
LoadBalancer lb = LbConfigHelper.getLoadBalancer(domain, lbName);
String lbHost = lb.getDeviceHost();
String lbPort = lb.getDevicePort();
String lbProxyHost = null;
String lbProxyPort = null;
Property lbProxyHostProperty = lb.getProperty(SSL_PROXY_HOST_PROPERTY);
if (lbProxyHostProperty != null) {
lbProxyHost = lbProxyHostProperty.getValue();
Property lbProxyPortProperty = lb.getProperty(SSL_PROXY_PORT_PROPERTY);
if (lbProxyPortProperty != null) {
lbProxyPort = lbProxyPortProperty.getValue();
}
}
boolean isSec = true;
Property isSecProperty = lb.getProperty(IS_SECURE_PROPERTY);
if (isSecProperty != null) {
isSec = Boolean.getBoolean(isSecProperty.getValue());
}
_connectionManager = new ConnectionManager(lbHost, lbPort, lbProxyHost, lbProxyPort, lbName, isSec);
if (ping != null && Boolean.valueOf(ping).booleanValue()) {
ping(_connectionManager);
} else {
publish(_connectionManager, domain, lb.getLbConfigName());
}
}
use of org.glassfish.loadbalancer.config.LoadBalancer in project Payara by payara.
the class CreateHTTPLoadBalancerCommand method addLoadBalancer.
private void addLoadBalancer(final String lbConfigName) {
LoadBalancers loadBalancers = domain.getExtensionByType(LoadBalancers.class);
// create load-balancers parent element if it does not exist
if (loadBalancers == null) {
Transaction transaction = new Transaction();
try {
ConfigBeanProxy domainProxy = transaction.enroll(domain);
loadBalancers = domainProxy.createChild(LoadBalancers.class);
((Domain) domainProxy).getExtensions().add(loadBalancers);
transaction.commit();
} catch (TransactionFailure ex) {
transaction.rollback();
String msg = localStrings.getLocalString("FailedToUpdateLB", "Failed to update load-balancers");
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(msg);
return;
} catch (RetryableException ex) {
transaction.rollback();
String msg = localStrings.getLocalString("FailedToUpdateLB", "Failed to update load-balancers");
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(msg);
return;
}
}
try {
ConfigSupport.apply(new SingleConfigCode<LoadBalancers>() {
@Override
public Object run(LoadBalancers param) throws PropertyVetoException, TransactionFailure {
LoadBalancer lb = param.createChild(LoadBalancer.class);
lb.setDeviceHost(devicehost);
lb.setDevicePort(deviceport);
lb.setLbConfigName(lbConfigName);
lb.setName(load_balancer_name);
// add properties
if (properties != null) {
for (Object propname : properties.keySet()) {
Property newprop = lb.createChild(Property.class);
newprop.setName((String) propname);
newprop.setValue(properties.getProperty((String) propname));
lb.getProperty().add(newprop);
}
}
if (sslproxyhost != null) {
Property newprop = lb.createChild(Property.class);
newprop.setName("ssl-proxy-host");
newprop.setValue(sslproxyhost);
lb.getProperty().add(newprop);
}
if (sslproxyport != null) {
Property newprop = lb.createChild(Property.class);
newprop.setName("ssl-proxy-port");
newprop.setValue(sslproxyport);
lb.getProperty().add(newprop);
}
param.getLoadBalancer().add(lb);
return Boolean.TRUE;
}
}, loadBalancers);
} catch (TransactionFailure ex) {
String msg = localStrings.getLocalString("FailedToUpdateLB", "Failed to update load-balancers");
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(msg);
return;
}
}
Aggregations