use of com.hortonworks.streamline.streams.cluster.catalog.Namespace in project streamline by hortonworks.
the class TopologyActionsService method setUpClusterArtifacts.
public void setUpClusterArtifacts(Topology topology, TopologyActions topologyActions) throws IOException {
Namespace namespace = environmentService.getNamespace(topology.getNamespaceId());
if (namespace == null) {
throw new RuntimeException("Corresponding namespace not found: " + topology.getNamespaceId());
}
ObjectMapper objectMapper = new ObjectMapper();
Path artifactsDir = topologyActions.getArtifactsLocation(CatalogToLayoutConverter.getTopologyLayout(topology));
makeEmptyDir(artifactsDir);
Collection<NamespaceServiceClusterMap> serviceClusterMappings = environmentService.listServiceClusterMapping(namespace.getId());
for (NamespaceServiceClusterMap serviceClusterMapping : serviceClusterMappings) {
Service service = environmentService.getServiceByName(serviceClusterMapping.getClusterId(), serviceClusterMapping.getServiceName());
if (service != null) {
Collection<ServiceConfiguration> serviceConfigurations = environmentService.listServiceConfigurations(service.getId());
if (serviceConfigurations != null) {
for (ServiceConfiguration serviceConfiguration : serviceConfigurations) {
writeConfigurationFile(objectMapper, artifactsDir, serviceConfiguration);
}
}
}
}
}
use of com.hortonworks.streamline.streams.cluster.catalog.Namespace in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testAddTimeSeriesDBWhenTimeSeriesDBAlreadyExistsViaMapServiceToClusterInNamespace.
@Test
public void testAddTimeSeriesDBWhenTimeSeriesDBAlreadyExistsViaMapServiceToClusterInNamespace() throws Exception {
Long testNamespaceId = 1L;
Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
new Expectations() {
{
environmentService.getNamespace(testNamespaceId);
result = testNamespace;
environmentService.listServiceClusterMapping(testNamespaceId);
result = existingMappings;
}
};
NamespaceServiceClusterMap newMapping = new NamespaceServiceClusterMap(testNamespaceId, TEST_TIME_SERIES_DB, 2L);
try {
namespaceCatalogResource.mapServiceToClusterInNamespace(testNamespaceId, newMapping, securityContext);
Assert.fail("Should throw BadRequestException");
} catch (BadRequestException e) {
// passed
}
new Verifications() {
{
environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
times = 0;
}
};
}
use of com.hortonworks.streamline.streams.cluster.catalog.Namespace in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testExcludeStreamingEngineViaSetServicesToClusterInNamespace.
@Test
public void testExcludeStreamingEngineViaSetServicesToClusterInNamespace() throws Exception {
Long testNamespaceId = 1L;
Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
setupExpectationForSimulatingTopologyIsRunning(testNamespaceId, testNamespace, existingMappings);
List<NamespaceServiceClusterMap> mappingsToApply = existingMappings.stream().filter(m -> !m.getServiceName().equals(TEST_STREAMING_ENGINE)).collect(toList());
try {
namespaceCatalogResource.setServicesToClusterInNamespace(testNamespaceId, mappingsToApply, securityContext);
Assert.fail("Should throw BadRequestException");
} catch (BadRequestException e) {
// passed
}
new Verifications() {
{
// request fails before removing existing mappings
environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
times = 0;
}
};
}
use of com.hortonworks.streamline.streams.cluster.catalog.Namespace in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testAddStreamingEngineWhenStreamingEngineAlreadyExistsViaMapServiceToClusterInNamespace.
@Test
public void testAddStreamingEngineWhenStreamingEngineAlreadyExistsViaMapServiceToClusterInNamespace() throws Exception {
Long testNamespaceId = 1L;
Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
new Expectations() {
{
environmentService.getNamespace(testNamespaceId);
result = testNamespace;
environmentService.listServiceClusterMapping(testNamespaceId);
result = existingMappings;
}
};
NamespaceServiceClusterMap newMapping = new NamespaceServiceClusterMap(testNamespaceId, TEST_STREAMING_ENGINE, 2L);
try {
namespaceCatalogResource.mapServiceToClusterInNamespace(testNamespaceId, newMapping, securityContext);
Assert.fail("Should throw BadRequestException");
} catch (BadRequestException e) {
// passed
}
new Verifications() {
{
environmentService.addOrUpdateServiceClusterMapping(withAny(new NamespaceServiceClusterMap()));
times = 0;
}
};
}
use of com.hortonworks.streamline.streams.cluster.catalog.Namespace in project streamline by hortonworks.
the class NamespaceCatalogResourceTest method testUnmapStreamingEngineWhenTopologyIsRunningViaUnmapAllServiceToClusterInNamespace.
@Test
public void testUnmapStreamingEngineWhenTopologyIsRunningViaUnmapAllServiceToClusterInNamespace() throws Exception {
Long testNamespaceId = 1L;
Namespace testNamespace = createTestNamespace(testNamespaceId, TEST_STREAMING_ENGINE, TEST_TIME_SERIES_DB);
Collection<NamespaceServiceClusterMap> existingMappings = createTestMappingsForExisting(testNamespaceId);
setupExpectationForSimulatingTopologyIsRunning(testNamespaceId, testNamespace, existingMappings);
try {
namespaceCatalogResource.unmapAllServicesToClusterInNamespace(testNamespaceId, securityContext);
Assert.fail("Should throw BadRequestException");
} catch (BadRequestException e) {
// passed
}
new Verifications() {
{
environmentService.removeServiceClusterMapping(testNamespaceId, anyString, anyLong);
times = 0;
}
};
}
Aggregations