use of com.epam.pipeline.entity.cluster.NodeInstanceAddress in project cloud-pipeline by epam.
the class NodesManager method terminateNode.
public NodeInstance terminateNode(String name) {
NodeInstance nodeInstance = getNode(name);
Assert.isTrue(!isNodeProtected(nodeInstance), messageHelper.getMessage(MessageConstants.ERROR_NODE_IS_PROTECTED, name));
if (nodeInstance.getPipelineRun() != null) {
PipelineRun run = nodeInstance.getPipelineRun();
pipelineRunManager.updatePipelineStatusIfNotFinal(run.getId(), TaskStatus.STOPPED, null);
}
Optional<NodeInstanceAddress> internalIP = nodeInstance.getAddresses().stream().filter(a -> a.getType() != null && a.getType().equalsIgnoreCase("internalip")).findAny();
if (internalIP.isPresent()) {
String command = buildCommand(internalIP.get().getAddress(), nodeInstance.getName(), nodeTerminateScript);
LOGGER.debug("Terminating node. Command: {}.", command);
cmdExecutor.executeCommand(command);
}
return nodeInstance;
}
use of com.epam.pipeline.entity.cluster.NodeInstanceAddress in project cloud-pipeline by epam.
the class CAdvisorMonitoringManagerTest method getNodeInstance.
private NodeInstance getNodeInstance(String address, String type, String nodeName) {
NodeAddress nodeAddress = new NodeAddress(address, type);
NodeInstanceAddress nodeInstanceAddress = new NodeInstanceAddress(nodeAddress);
NodeInstance nodeWithIP = new NodeInstance();
nodeWithIP.setName(nodeName);
nodeWithIP.setAddresses(Collections.singletonList(nodeInstanceAddress));
return nodeWithIP;
}
use of com.epam.pipeline.entity.cluster.NodeInstanceAddress in project cloud-pipeline by epam.
the class NodesManager method filterNodes.
public List<NodeInstance> filterNodes(FilterNodesVO filterNodesVO) {
List<NodeInstance> result;
Config config = new Config();
try (KubernetesClient client = new DefaultKubernetesClient(config)) {
Map<String, String> labelsMap = new HashedMap<>();
if (!StringUtils.isNullOrEmpty(filterNodesVO.getRunId())) {
labelsMap.put(NodeInstance.RUN_ID_LABEL, filterNodesVO.getRunId());
}
Predicate<NodeInstance> addressFilter = node -> true;
if (!StringUtils.isNullOrEmpty(filterNodesVO.getAddress())) {
Predicate<NodeInstanceAddress> addressEqualsPredicate = address -> !StringUtils.isNullOrEmpty(address.getAddress()) && address.getAddress().equalsIgnoreCase(filterNodesVO.getAddress());
addressFilter = node -> node.getAddresses() != null && node.getAddresses().stream().filter(addressEqualsPredicate).count() > 0;
}
result = client.nodes().withLabels(labelsMap).list().getItems().stream().map(NodeInstance::new).filter(addressFilter).collect(Collectors.toList());
this.attachRunsInfo(result);
}
return result;
}
Aggregations