TimerAction
, java.lang.Runnable
public class ClusterNodesShuffler extends java.lang.Object implements java.lang.Runnable, TimerAction
final List<WSConfig> nodes = ...;
final UcsClusterProtocol ucsNProtocol =
new UcsClusterProtocolBuilder()
.build();
ucsNProtocol.setClientName("MyClientName");
ucsNProtocol.setClientApplicationType("MyAppType");
ClusterNodesShuffler shuffler = new ClusterNodesShuffler(ucsNProtocol, 2);
TimerActionTicket shufflerTimer = null;
try {
shuffler.setNodes(nodes);
ucsNProtocol.open();
shufflerTimer = TimerFactory.getTimer().schedule(3000, 3000, shuffler);
// do the business logic on the cluster protocol...
for (int i = 0; i < 200; i++) {
EventGetVersion resp = (EventGetVersion) ucsNProtocol.request(RequestGetVersion.create());
System.err.println("Resp from: " + resp.getEndpoint());
Thread.sleep(300);
}
} finally {
if (shufflerTimer != null) {
shufflerTimer.cancel();
shufflerTimer = null;
}
ucsNProtocol.close();
}
ClusterProtocol
Constructor | Description |
---|---|
ClusterNodesShuffler(ClusterProtocol protocol,
int activeNodes) |
Creates nodes shuffler for the given Cluster Protocol instance.
|
Modifier and Type | Method | Description |
---|---|---|
void |
onTimer() |
Performs single rotation of the selected cluster nodes.
|
void |
rotateNodes() |
Performs single rotation of the selected cluster nodes.
This operation is designed to be executed as periodical task Runnable .run()
or TimerAction .onTimer() , though, may be used directly
in case of application specific needs. |
void |
run() |
Performs single rotation of the selected cluster nodes.
|
protected void |
setActiveNodes() |
Combines "active nodes" list and passes it to the cluster protocol for appliance.
|
void |
setNodes(java.util.Collection<WSConfig> nodes) |
Sets the whole cluster nodes list for selections and rotations.
It shuffles given list, selects "active" nodes subset, and pushes it to the protocol for appliance. |
void |
setUseBackups(boolean useBackups) |
Enables or disables adding to the selected nodes other ones endpoints as backups.
|
public ClusterNodesShuffler(ClusterProtocol protocol, int activeNodes)
protocol
- the cluster protocol reference.activeNodes
- number of active cluster nodes to pass to the protocol.java.lang.IllegalArgumentException
- if given protocol reference is null
,
or number of active nodes is not a positive value.public void setUseBackups(boolean useBackups)
useBackups
- public void setNodes(java.util.Collection<WSConfig> nodes)
nodes
- the whole list of cluster nodes configurations.protected void setActiveNodes()
public void run()
run
in interface java.lang.Runnable
rotateNodes()
public void onTimer()
onTimer
in interface TimerAction
rotateNodes()
public void rotateNodes()
Runnable
.run()
or TimerAction
.onTimer()
, though, may be used directly
in case of application specific needs.Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 9.0.006.00
Copyright © 2006–2019 Genesys Telecommunications Laboratories, Inc. All rights reserved.