use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.
the class EnvironmentService method removeCluster.
public Cluster removeCluster(Long clusterId) {
Cluster cluster = new Cluster();
cluster.setId(clusterId);
return dao.remove(new StorableKey(CLUSTER_NAMESPACE, cluster.getPrimaryKey()));
}
use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.
the class EnvironmentService method getCluster.
public Cluster getCluster(Long clusterId) {
Cluster cluster = new Cluster();
cluster.setId(clusterId);
return this.dao.get(new StorableKey(CLUSTER_NAMESPACE, cluster.getPrimaryKey()));
}
use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.
the class ClusterCatalogResource method addCluster.
@Timed
@POST
@Path("/clusters")
public Response addCluster(Cluster cluster, @Context SecurityContext securityContext) {
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_SERVICE_POOL_ADMIN);
String clusterName = cluster.getName();
String ambariImportUrl = cluster.getAmbariImportUrl();
Cluster result = environmentService.getClusterByNameAndImportUrl(clusterName, ambariImportUrl);
if (result != null) {
throw EntityAlreadyExistsException.byName(cluster.getNameWithImportUrl());
}
Cluster createdCluster = environmentService.addCluster(cluster);
SecurityUtil.addAcl(authorizer, securityContext, NAMESPACE, createdCluster.getId(), EnumSet.allOf(Permission.class));
return WSUtils.respondEntity(createdCluster, CREATED);
}
use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.
the class ClusterCatalogResource method getClusterById.
@GET
@Path("/clusters/{id}")
@Timed
public Response getClusterById(@PathParam("id") Long clusterId, @javax.ws.rs.QueryParam("detail") Boolean detail, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_SERVICE_POOL_USER, NAMESPACE, clusterId, READ);
Cluster result = environmentService.getCluster(clusterId);
if (result != null) {
return buildClusterGetResponse(result, detail);
}
throw EntityNotFoundException.byId(clusterId.toString());
}
use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.
the class AbstractHDFSBundleHintProviderTest method getHintsOnCluster.
@Test
public void getHintsOnCluster() throws Exception {
String expectedFsUrl = "hdfs://localhost:8020";
new Expectations() {
{
hdfsMetadataService.getDefaultFsUrl();
result = expectedFsUrl;
}
};
Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setName("cluster1");
Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
Assert.assertEquals(1, hints.size());
Assert.assertEquals(expectedFsUrl, hints.get(TEST_FIELD_NAME_FS_URL));
}
Aggregations