Class NodeDiscoveryFactory
java.lang.Object
com.scivicslab.pojoactor.core.distributed.discovery.NodeDiscoveryFactory
Factory for automatic node discovery based on runtime environment.
This factory detects the execution environment (Slurm, Kubernetes,
Grid Engine) and returns an appropriate NodeDiscovery implementation.
Supported Environments
- Slurm - Detects SLURM_JOB_NODELIST environment variable
- Kubernetes - Detects POD_NAME and KUBERNETES_SERVICE_HOST
- Grid Engine - Detects PE_HOSTFILE environment variable
Usage Example
public static void main(String[] args) throws IOException {
// Auto-detect environment and discover nodes
NodeDiscovery discovery = NodeDiscoveryFactory.autoDetect();
// Create distributed actor system
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()
);
}
}
// Register actors and start processing
// ...
}
Helper Method
For even simpler usage, use
:invalid reference
#createDistributedSystem(int)
public static void main(String[] args) throws IOException {
// Auto-detect environment and create system with all nodes registered
DistributedActorSystem system = NodeDiscoveryFactory.createDistributedSystem(8080);
// All remote nodes are already registered - just add actors
// ...
}
- Since:
- 2.5.0
- Author:
- devteam@scivicslab.com
-
Method Summary
Modifier and TypeMethodDescriptionstatic NodeDiscoveryAutomatically detects the execution environment and returns an appropriate NodeDiscovery implementation.static NodeDiscoveryautoDetect(int port) Automatically detects the execution environment and returns an appropriate NodeDiscovery implementation with specified port.
-
Method Details
-
autoDetect
Automatically detects the execution environment and returns an appropriate NodeDiscovery implementation.Detection priority:
- Slurm (checks SLURM_JOB_NODELIST)
- Kubernetes (checks POD_NAME and KUBERNETES_SERVICE_HOST)
- Grid Engine (checks PE_HOSTFILE)
- Returns:
- a NodeDiscovery implementation for the detected environment
- Throws:
IllegalStateException- if no supported environment is detected
-
autoDetect
Automatically detects the execution environment and returns an appropriate NodeDiscovery implementation with specified port.- Parameters:
port- the default port for actor communication- Returns:
- a NodeDiscovery implementation for the detected environment
- Throws:
IllegalStateException- if no supported environment is detected
-