Search in sources :

Example 6 with Cluster

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()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster)

Example 7 with Cluster

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()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster)

Example 8 with Cluster

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);
}
Also used : Permission(com.hortonworks.streamline.streams.security.Permission) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 9 with Cluster

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());
}
Also used : Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 10 with Cluster

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));
}
Also used : Expectations(mockit.Expectations) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Test(org.junit.Test)

Aggregations

Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)49 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)31 Test (org.junit.Test)30 Config (com.hortonworks.streamline.common.Config)25 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)15 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Timed (com.codahale.metrics.annotation.Timed)8 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)8 Path (javax.ws.rs.Path)8 Expectations (mockit.Expectations)8 NamespaceServiceClusterMap (com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)7 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)6 HashMap (java.util.HashMap)5 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Map (java.util.Map)4 POST (javax.ws.rs.POST)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3