@Override public void setupCluster() { try { HadoopClusterConfig hadoopClusterConfig = manager.getHadoopManager().getCluster(config.getHadoopClusterName()); if (hadoopClusterConfig == null) { throw new ClusterSetupException( String.format("Hadoop cluster %s not found", config.getHadoopClusterName())); } Environment env; try { env = manager.getEnvironmentManager().loadEnvironment(hadoopClusterConfig.getEnvironmentId()); } catch (EnvironmentNotFoundException e) { throw new ClusterSetupException(e); } ClusterSetupStrategy s = manager.getClusterSetupStrategy(env, config, trackerOperation); s.setup(); trackerOperation.addLogDone("Done"); } catch (ClusterSetupException ex) { trackerOperation.addLogFailed("Failed to setup cluster: " + ex.getMessage()); } }
@Override public void destroyCluster() { LuceneConfig config = manager.getCluster(clusterName); if (config == null) { trackerOperation.addLogFailed( String.format("Cluster with name %s does not exist. Operation aborted", clusterName)); return; } TrackerOperation po = trackerOperation; po.addLog("Uninstalling Lucene..."); Set<EnvironmentContainerHost> nodes; try { nodes = manager .getEnvironmentManager() .loadEnvironment(config.getEnvironmentId()) .getContainerHostsByIds(config.getNodes()); } catch (ContainerHostNotFoundException e) { trackerOperation.addLogFailed( String.format("Failed obtaining environment containers: %s", e)); return; } catch (EnvironmentNotFoundException e) { trackerOperation.addLogFailed(String.format("Environment not found: %s", e)); return; } for (EnvironmentContainerHost containerHost : nodes) { CommandResult result; try { result = containerHost.execute(new RequestBuilder(Commands.uninstallCommand)); if (!result.hasSucceeded()) { po.addLog(result.getStdErr()); po.addLogFailed("Uninstallation failed"); return; } } catch (CommandException e) { LOG.error(e.getMessage(), e); } } po.addLog("Updating db..."); manager.getPluginDao().deleteInfo(LuceneConfig.PRODUCT_KEY, config.getClusterName()); po.addLogDone("Cluster info deleted from DB\nDone"); }