use of com.yahoo.vespa.clustercontroller.core.RemoteClusterControllerTaskScheduler in project vespa by vespa-engine.
the class UnitPathResolver method visit.
public Request<? extends T> visit(String[] path, Visitor<T> visitor) throws StateRestApiException {
if (path.length == 0) {
return visitor.visitGlobal();
}
RemoteClusterControllerTaskScheduler fc = fleetControllers.get(path[0]);
if (fc == null)
throw new MissingUnitException(path, 0);
Id.Cluster cluster = new Id.Cluster(path[0]);
if (path.length == 1) {
return visitor.visitCluster(cluster);
}
Id.Service service;
try {
service = new Id.Service(cluster, NodeType.get(path[1]));
} catch (IllegalArgumentException e) {
throw new MissingUnitException(path, 1);
}
if (path.length == 2) {
return visitor.visitService(service);
}
Id.Node node;
try {
node = new Id.Node(service, Integer.valueOf(path[2]));
} catch (NumberFormatException e) {
throw new MissingUnitException(path, 2);
}
if (path.length == 3) {
return visitor.visitNode(node);
}
Id.Partition partition;
try {
partition = new Id.Partition(node, Integer.valueOf(path[3]));
} catch (NumberFormatException e) {
throw new MissingUnitException(path, 3);
}
if (path.length == 4) {
return visitor.visitPartition(partition);
}
throw new MissingUnitException(path, 4);
}
Aggregations