@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"); }
@Before public void setUp() throws Exception { id = UUID.randomUUID().toString(); mySet = new HashSet<>(); mySet.add(containerHost); myUUID = new HashSet<>(); myUUID.add(id); // mock constructor when(stormImpl.getCluster("testClusterName")).thenReturn(stormClusterConfiguration); when(stormImpl.getTracker()).thenReturn(tracker); when(tracker.createTrackerOperation(anyString(), anyString())).thenReturn(trackerOperation); when(trackerOperation.getId()).thenReturn(UUID.randomUUID()); stormNodeOperationHandler = new StormNodeOperationHandler( stormImpl, "testClusterName", "testHostName", NodeOperationType.START); stormNodeOperationHandler2 = new StormNodeOperationHandler( stormImpl, "testClusterName", "testHostName", NodeOperationType.STOP); stormNodeOperationHandler3 = new StormNodeOperationHandler( stormImpl, "testClusterName", "testHostName", NodeOperationType.STATUS); stormNodeOperationHandler4 = new StormNodeOperationHandler( stormImpl, "testClusterName", "testHostName", NodeOperationType.DESTROY); // mock run method when(stormImpl.getCluster(anyString())).thenReturn(stormClusterConfiguration); when(stormImpl.getEnvironmentManager()).thenReturn(environmentManager); when(environmentManager.loadEnvironment(any(String.class))).thenReturn(environment); when(stormClusterConfiguration.getEnvironmentId()).thenReturn(id); // when( stormImpl.getZookeeperManager() ).thenReturn( zookeeper ); // when( zookeeper.getCluster( anyString() ) ).thenReturn( zookeeperClusterConfig ); when(stormClusterConfiguration.getNimbus()).thenReturn(id); when(containerHost.getId()).thenReturn(id); when(containerHost.execute(any(RequestBuilder.class))).thenReturn(commandResult); // when( zookeeper.getCommand( any( CommandType.class ) ) ).thenReturn( "testCommand" ); }