use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.
the class StormStatusServiceImplTest method activateTopologyShouldReturnActiveTopologyResponse.
@Test
public void activateTopologyShouldReturnActiveTopologyResponse() throws Exception {
final TopologyStatus topologyStatus = new TopologyStatus();
topologyStatus.setName("bro");
topologyStatus.setId("bro_id");
final TopologySummary topologySummary = new TopologySummary();
topologySummary.setTopologies(new TopologyStatus[] { topologyStatus });
when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/activate", null, Map.class)).thenReturn(new HashMap() {
{
put("status", "success");
}
});
TopologyResponse expected = new TopologyResponse();
expected.setSuccessMessage(TopologyStatusCode.ACTIVE.toString());
assertEquals(expected, stormStatusService.activateTopology("bro"));
}
use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.
the class StormStatusServiceImplTest method deactivateTopologyShouldReturnErrorTopologyResponse.
@Test
public void deactivateTopologyShouldReturnErrorTopologyResponse() throws Exception {
final TopologyStatus topologyStatus = new TopologyStatus();
topologyStatus.setName("bro");
topologyStatus.setId("bro_id");
final TopologySummary topologySummary = new TopologySummary();
topologySummary.setTopologies(new TopologyStatus[] { topologyStatus });
when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/deactivate", null, Map.class)).thenReturn(new HashMap() {
{
put("status", "error message");
}
});
TopologyResponse expected = new TopologyResponse();
expected.setErrorMessage("error message");
assertEquals(expected, stormStatusService.deactivateTopology("bro"));
}
use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.
the class StormStatusServiceImplTest method activateTopologyShouldReturnErrorTopologyResponse.
@Test
public void activateTopologyShouldReturnErrorTopologyResponse() throws Exception {
final TopologyStatus topologyStatus = new TopologyStatus();
topologyStatus.setName("bro");
topologyStatus.setId("bro_id");
final TopologySummary topologySummary = new TopologySummary();
topologySummary.setTopologies(new TopologyStatus[] { topologyStatus });
when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/activate", null, Map.class)).thenReturn(new HashMap() {
{
put("status", "error message");
}
});
TopologyResponse expected = new TopologyResponse();
expected.setErrorMessage("error message");
assertEquals(expected, stormStatusService.activateTopology("bro"));
}
use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.
the class StormStatusServiceImplTest method deactivateTopologyShouldReturnActiveTopologyResponse.
@Test
public void deactivateTopologyShouldReturnActiveTopologyResponse() throws Exception {
final TopologyStatus topologyStatus = new TopologyStatus();
topologyStatus.setName("bro");
topologyStatus.setId("bro_id");
final TopologySummary topologySummary = new TopologySummary();
topologySummary.setTopologies(new TopologyStatus[] { topologyStatus });
when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn(HTTP_STORM_UI);
when(restTemplate.getForObject(HTTP_STORM_UI + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary);
when(restTemplate.postForObject(HTTP_STORM_UI + TOPOLOGY_URL + "/bro_id/deactivate", null, Map.class)).thenReturn(new HashMap() {
{
put("status", "success");
}
});
TopologyResponse expected = new TopologyResponse();
expected.setSuccessMessage(TopologyStatusCode.INACTIVE.toString());
assertEquals(expected, stormStatusService.deactivateTopology("bro"));
}
use of org.apache.metron.rest.model.TopologyStatus in project metron by apache.
the class StormAdminServiceImpl method stopParserTopology.
/**
* Stops a parser topology. The name should either be a sensor name or group name in the case of aggregate parser topologies.
* @param name SensorParserConfig or SensorParserGroup name
* @param stopNow Stop the topology immediately
* @return ToplogyResponse
* @throws RestException Stopping the topology resulted in an error.
*/
@Override
public TopologyResponse stopParserTopology(String name, boolean stopNow) throws RestException {
// Supplied name could be a group so get the actual job name from Storm
TopologyStatus topologyStatus = stormStatusService.getTopologyStatus(name);
String jobName = topologyStatus != null ? topologyStatus.getName() : name;
return createResponse(stormCLIClientWrapper.stopParserTopology(jobName, stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR);
}
Aggregations