Class SlurmNodeDiscovery
java.lang.Object
com.scivicslab.pojoactor.core.distributed.discovery.SlurmNodeDiscovery
- All Implemented Interfaces:
NodeDiscovery
Node discovery implementation for Slurm workload manager.
This implementation reads Slurm environment variables to discover nodes in the cluster:
SLURM_JOB_NODELIST- List of nodes allocated to the jobSLURM_PROCID- Process rank (0-based index)SLURM_NTASKS- Total number of tasks
Usage Example
#!/bin/bash
#SBATCH --nodes=10
#SBATCH --ntasks-per-node=1
srun java -jar myapp.jar --port=8080
public static void main(String[] args) {
NodeDiscovery discovery = new SlurmNodeDiscovery();
if (!discovery.isApplicable()) {
System.err.println("Not running in Slurm environment");
System.exit(1);
}
DistributedActorSystem system = new DistributedActorSystem(
discovery.getMyNodeId(),
discovery.getMyHost(),
discovery.getMyPort()
);
// Register all remote nodes
for (NodeInfo node : discovery.getAllNodes()) {
if (!node.getNodeId().equals(discovery.getMyNodeId())) {
system.registerRemoteNode(
node.getNodeId(),
node.getHost(),
node.getPort()
);
}
}
}
- Since:
- 2.5.0
- Author:
- devteam@scivics-lab.com
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a SlurmNodeDiscovery with default port 8080.SlurmNodeDiscovery(int defaultPort) Constructs a SlurmNodeDiscovery with specified port. -
Method Summary
Modifier and TypeMethodDescriptionReturns information about all nodes in the cluster.Returns the hostname or IP address for the current node.Returns the unique identifier for the current node.intReturns the default port number for actor communication.booleanChecks if this discovery implementation is applicable to the current environment.
-
Constructor Details
-
SlurmNodeDiscovery
public SlurmNodeDiscovery()Constructs a SlurmNodeDiscovery with default port 8080. -
SlurmNodeDiscovery
public SlurmNodeDiscovery(int defaultPort) Constructs a SlurmNodeDiscovery with specified port.- Parameters:
defaultPort- the default port for actor communication
-
-
Method Details
-
isApplicable
public boolean isApplicable()Description copied from interface:NodeDiscoveryChecks if this discovery implementation is applicable to the current environment.- Specified by:
isApplicablein interfaceNodeDiscovery- Returns:
- true if this discovery can be used in current environment
-
getMyNodeId
Description copied from interface:NodeDiscoveryReturns the unique identifier for the current node.- Specified by:
getMyNodeIdin interfaceNodeDiscovery- Returns:
- the node ID
-
getMyHost
Description copied from interface:NodeDiscoveryReturns the hostname or IP address for the current node.- Specified by:
getMyHostin interfaceNodeDiscovery- Returns:
- the host address
-
getMyPort
public int getMyPort()Description copied from interface:NodeDiscoveryReturns the default port number for actor communication.This can be overridden by the user if needed.
- Specified by:
getMyPortin interfaceNodeDiscovery- Returns:
- the port number
-
getAllNodes
Description copied from interface:NodeDiscoveryReturns information about all nodes in the cluster.This includes the current node and all remote nodes.
- Specified by:
getAllNodesin interfaceNodeDiscovery- Returns:
- list of all node information
-