-
Notifications
You must be signed in to change notification settings - Fork 4
3.6 Shared load balancers
This section overviews shared load balancing features available in the SDK. Note that in all examples balancers
refers to the new ClcSdk().policyService()
variable.
To asynchronously create a load balancer, use the LoadBalancerConfig
command. To get the result of the operation, call waitUntilComplete().getResult()
.
loadBalancerService
.create(
new LoadBalancerConfig()
.name("Balancer2")
.description("Balancer2 description")
.status(LoadBalancerStatus.ENABLED)
.dataCenter(DataCenter.US_EAST_STERLING)
)
.waitUntilComplete()
.getResult()
To modify an existing balancer, use LoadBalancerConfig
. To get the result of the operation, call waitUntilComplete().getResult()
loadBalancerService
.update(
loadBalancer,
new LoadBalancerConfig()
.name("Modified name")
.description("Modified description ")
.status(LoadBalancerStatus.ENABLED)
)
.waitUntilComplete()
.getResult();
Balancers can be found by LoadBalancerFilter
usage, it is possible to find by data centers, name, ID, etc.
loadBalancerService.find(
new LoadBalancerFilter().nameContains("Balancer1")
);
loadBalancerService.findByRef(
LoadBalancer.refById(id, DataCenter.DE_FRANKFURT)
);
loadBalancerService.find(
new LoadBalancerFilter().dataCenters(DataCenter.DE_FRANKFURT)
);
You can delete a load balancer use LoadBalancerFilter
or reference on LoadBalancerPool
:
loadBalancerService.delete(
loadBalancerReference
);
loadBalancerService.delete(
new LoadBalancerFilter().nameContains("Balancer1")
);
To asynchronously create a balancer pool, use the LoadBalancerPoolConfig
command. To get the result of the operation, call waitUntilComplete().getResult()
.
loadBalancerPoolService
.create(
new LoadBalancerPoolConfig()
.port(80)
.method(LoadBalancerPoolMethod.ROUND_ROBIN)
.persistence(LoadBalancerPoolPersistence.STANDARD)
.loadBalancer(loadBalancerReference)
)
.waitUntilComplete()
.getResult();
To asynchronously modify an existing balancer pool, use LoadBalancerPoolConfig
command. To get the result of the operation, call waitUntilComplete().getResult()
.
loadBalancerPoolService
.update(
loadBalancerPool,
new LoadBalancerPoolConfig()
.method(LoadBalancerPoolMethod.LEAST_CONNECTION)
.persistence(LoadBalancerPoolPersistence.STICKY)
.loadBalancer(loadBalancerReference)
)
.waitUntilComplete()
.getResult();
You can find load balancer pools by various search criteria, such as balancer group, method, port, and persistence using LoadBalancerPoolFilter
.
loadBalancerPoolService.find(
new LoadBalancerPoolFilter().loadBalancers(loadBalancer)
);
loadBalancerPoolService.findByRef(loadBalancerPoolReference);
To delete balancer pools, use LoadBalancerPoolFilter
or reference on LoadBalancerPool
loadBalancerPoolService.delete(
loadBalancerPoolReference
);
loadBalancerPoolService.delete(
new LoadPoolBalancerFilter().nameContains("pool")
);
To modify load balancer nodes which belongs to certain load balancer pool, you need to pass pool reference and list of nodes metadata. For example:
loadBalancerNodeService
.update(loadBalancerPoolReference, nodeMetadataList)
.waitUntilComplete()
.getResult();
You can find balancer nodes by balancer pool, status, ipAddress, and privatePort.
loadBalancerNodeService.find(
new LoadBalancerNodeFilter().loadBalancerPools(loadBalancerPoolReference)
);
To delete all load balancer nodes which belongs to certain load balancer pool, you need to pass pool reference and empty list of nodes metadata:
loadBalancerNodeService
.update(loadBalancerPoolReference, new ArrayList<>())
.waitUntilComplete()
.getResult();
loadBalancerService
.create(
new LoadBalancerConfig()
.name(name)
.description(description)
.dataCenter(DataCenter.GB_PORTSMOUTH)
.pool(
new LoadBalancerPoolConfig()
.port(80)
.nodes(
new LoadBalancerNodeMetadata()
.ipAddress("66.155.18.22")
.privatePort(8088),
new LoadBalancerNodeMetadata()
.ipAddress("66.155.18.22")
.privatePort(8080)
),
new LoadBalancerPoolConfig()
.port(443)
.method(LoadBalancerPoolMethod.LEAST_CONNECTION)
.persistence(LoadBalancerPoolPersistence.STICKY)
)
)
.waitUntilComplete()
.getResult();
loadBalancerService
.update(
new LoadBalancerFilter().names(name),
new LoadBalancerConfig()
.name(name + " updated")
.description(description + " updated")
.dataCenter(DataCenter.GB_PORTSMOUTH)
.pool(
new LoadBalancerPoolConfig()
.port(80)
.nodes(
new LoadBalancerNodeMetadata()
.ipAddress("66.155.18.22")
.privatePort(8085)
)
)
)
.waitUntilComplete()
.getResult()
.get(0);
- [Getting Started] (./1.-Getting-started)
- User Guide - Basic Functions
- Server management
- Server actions
- Managing groups
- Group actions
- Searching templates
- Searching data centers
- Invoice statistics
- SDK configuration
- User Guide - Advanced Functions
- Configuring remote servers over SSH
- Defining a group hierarchy
- Billing statistics
- Server monitoring statistics
- Policies management
- Shared load balancers management
- User Guide - Framework adapters