Get the state of the cluster


You want to get the list of agents connected to the cluster.


Call the getAgentInfo() method on the ClusterJobScheduler to retrieve the list of agents currently connected to the coordinator.

package stkscalabilitysdk.howto;

import java.util.List;

import agi.parallel.client.ClusterJobScheduler;
import agi.parallel.infrastructure.AgentSnapshot;

public class GetCoordinatorSnapshot {
    public static void main(String[] args) {
        ClusterJobScheduler scheduler = new ClusterJobScheduler("localhost");
        try {
            List<AgentSnapshot> agents = scheduler.getAgentInfo();
            for (int i = 0; i < agents.size(); i++) {
                System.out.println(String.format("Agent #%s, MachineName=%s, HostCount=%s, Activity=%s", i + 1, agents.get(i).getMachineName(), agents.get(i).getCapacity(), agents.get(i).getActivity()));
        } finally {

         * The output of the application should resemble:
         * Agent #1, MachineName=AgentComputerName1, HostCount=12, Activity=Idle
         * Agent #2, MachineName=AgentComputerName2, HostCount=8, Activity=Idle
         * Agent #3, MachineName=AgentComputerName3, HostCount=8, Activity=Idle
         * Agent #4, MachineName=AgentComputerName4, HostCount=8, Activity=Idle

Getting the list of agents is useful when checking to make sure the coordinator is in a certain state before submitting tasks. Another use for getting the list of agents is to display the information for monitoring purposes.

See Also

Other Resources

STK Scalability 1.4 API for Java