@Test public void cleanupFailedNodesEmpty() throws KaramelException { Map<NodeMetadata, Throwable> failedNodes = new HashMap<>(); NovaLauncher novaLauncher = new NovaLauncher(novaContext, sshKeyPair); boolean cleanupSuccessful = novaLauncher.cleanupFailedNodes(failedNodes); assertTrue(cleanupSuccessful); }
public boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes) { boolean success; if (failedNodes.size() > 0) { Set<String> lostIds = Sets.newLinkedHashSet(); for (Map.Entry<NodeMetadata, Throwable> lostNode : failedNodes.entrySet()) { lostIds.add(lostNode.getKey().getId()); } int numberOfNodesToDelete = lostIds.size(); logger.info(String.format("Destroying failed nodes with ids: %s", lostIds.toString())); Set<? extends NodeMetadata> destroyedNodes = novaContext.getComputeService().destroyNodesMatching( Predicates.in(failedNodes.keySet())); lostIds.clear(); for (NodeMetadata destroyed : destroyedNodes) { lostIds.add(destroyed.getId()); } logger.info("Failed nodes destroyed ;)"); int numberOfNodesSuccesfullyDeleted = lostIds.size(); success = numberOfNodesSuccesfullyDeleted == numberOfNodesToDelete; } else { success = true; } return success; }
NovaLauncher extends Launcher { public boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes) { boolean success; if (failedNodes.size() > 0) { Set<String> lostIds = Sets.newLinkedHashSet(); for (Map.Entry<NodeMetadata, Throwable> lostNode : failedNodes.entrySet()) { lostIds.add(lostNode.getKey().getId()); } int numberOfNodesToDelete = lostIds.size(); logger.info(String.format("Destroying failed nodes with ids: %s", lostIds.toString())); Set<? extends NodeMetadata> destroyedNodes = novaContext.getComputeService().destroyNodesMatching( Predicates.in(failedNodes.keySet())); lostIds.clear(); for (NodeMetadata destroyed : destroyedNodes) { lostIds.add(destroyed.getId()); } logger.info("Failed nodes destroyed ;)"); int numberOfNodesSuccesfullyDeleted = lostIds.size(); success = numberOfNodesSuccesfullyDeleted == numberOfNodesToDelete; } else { success = true; } return success; } }
NovaLauncher extends Launcher { public boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes) { boolean success; if (failedNodes.size() > 0) { Set<String> lostIds = Sets.newLinkedHashSet(); for (Map.Entry<NodeMetadata, Throwable> lostNode : failedNodes.entrySet()) { lostIds.add(lostNode.getKey().getId()); } int numberOfNodesToDelete = lostIds.size(); logger.info(String.format("Destroying failed nodes with ids: %s", lostIds.toString())); Set<? extends NodeMetadata> destroyedNodes = novaContext.getComputeService().destroyNodesMatching( Predicates.in(failedNodes.keySet())); lostIds.clear(); for (NodeMetadata destroyed : destroyedNodes) { lostIds.add(destroyed.getId()); } logger.info("Failed nodes destroyed ;)"); int numberOfNodesSuccesfullyDeleted = lostIds.size(); success = numberOfNodesSuccesfullyDeleted == numberOfNodesToDelete; } else { success = true; } return success; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); }
NovaLauncher extends Launcher { public boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes) { boolean success; if (failedNodes.size() > 0) { Set<String> lostIds = Sets.newLinkedHashSet(); for (Map.Entry<NodeMetadata, Throwable> lostNode : failedNodes.entrySet()) { lostIds.add(lostNode.getKey().getId()); } int numberOfNodesToDelete = lostIds.size(); logger.info(String.format("Destroying failed nodes with ids: %s", lostIds.toString())); Set<? extends NodeMetadata> destroyedNodes = novaContext.getComputeService().destroyNodesMatching( Predicates.in(failedNodes.keySet())); lostIds.clear(); for (NodeMetadata destroyed : destroyedNodes) { lostIds.add(destroyed.getId()); } logger.info("Failed nodes destroyed ;)"); int numberOfNodesSuccesfullyDeleted = lostIds.size(); success = numberOfNodesSuccesfullyDeleted == numberOfNodesToDelete; } else { success = true; } return success; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); static NovaContext validateCredentials(NovaCredentials novaCredentials, ContextBuilder builder); static NovaCredentials readCredentials(Confs confs); String createSecurityGroup(String clusterName, String groupName, Nova nova, Set<String> ports); boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld); boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes); @Override void cleanup(JsonCluster definition, ClusterRuntime runtime); void cleanup(String clusterName, Set<String> vmIds, Set<String> vmNames, Map<String, String> groupRegion); @Override String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name); @Override List<MachineRuntime> forkMachines(JsonCluster definition, ClusterRuntime runtime, String name); static Predicate<NodeMetadata> withPredicate(final Set<String> ids, final Set<String> names,
                                                      final Set<String> groupNames); }
NovaLauncher extends Launcher { public boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes) { boolean success; if (failedNodes.size() > 0) { Set<String> lostIds = Sets.newLinkedHashSet(); for (Map.Entry<NodeMetadata, Throwable> lostNode : failedNodes.entrySet()) { lostIds.add(lostNode.getKey().getId()); } int numberOfNodesToDelete = lostIds.size(); logger.info(String.format("Destroying failed nodes with ids: %s", lostIds.toString())); Set<? extends NodeMetadata> destroyedNodes = novaContext.getComputeService().destroyNodesMatching( Predicates.in(failedNodes.keySet())); lostIds.clear(); for (NodeMetadata destroyed : destroyedNodes) { lostIds.add(destroyed.getId()); } logger.info("Failed nodes destroyed ;)"); int numberOfNodesSuccesfullyDeleted = lostIds.size(); success = numberOfNodesSuccesfullyDeleted == numberOfNodesToDelete; } else { success = true; } return success; } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); static NovaContext validateCredentials(NovaCredentials novaCredentials, ContextBuilder builder); static NovaCredentials readCredentials(Confs confs); String createSecurityGroup(String clusterName, String groupName, Nova nova, Set<String> ports); boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld); boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes); @Override void cleanup(JsonCluster definition, ClusterRuntime runtime); void cleanup(String clusterName, Set<String> vmIds, Set<String> vmNames, Map<String, String> groupRegion); @Override String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name); @Override List<MachineRuntime> forkMachines(JsonCluster definition, ClusterRuntime runtime, String name); static Predicate<NodeMetadata> withPredicate(final Set<String> ids, final Set<String> names,
                                                      final Set<String> groupNames);  }