Search in sources :

Example 6 with Component

use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.

the class KafkaServiceRegistrar method validateComponents.

@Override
protected boolean validateComponents(Map<Component, List<ComponentProcess>> components) {
    return components.entrySet().stream().anyMatch(componentEntry -> {
        Component component = componentEntry.getKey();
        List<ComponentProcess> componentProcesses = componentEntry.getValue();
        if (component.getName().equals(COMPONENT_KAFKA_BROKER)) {
            return isComponentProcessesWithProtocolRequiredValid(componentProcesses);
        }
        return false;
    });
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 7 with Component

use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.

the class ZookeeperServiceRegistrar method validateComponents.

@Override
protected boolean validateComponents(Map<Component, List<ComponentProcess>> components) {
    // 1. ZOOKEEPER_SERVER should be available, and it should have one or more hosts and one port
    return components.entrySet().stream().anyMatch(componentEntry -> {
        Component component = componentEntry.getKey();
        List<ComponentProcess> componentProcesses = componentEntry.getValue();
        if (component.getName().equals(ZOOKEEPER_SERVER.name())) {
            return isComponentProcessesValid(componentProcesses);
        }
        return false;
    });
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 8 with Component

use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.

the class ZookeeperServiceRegistrar method createZookeeperServerComponent.

private Pair<Component, List<ComponentProcess>> createZookeeperServerComponent(Config config, Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_ZOOKEEPER_SERVER_HOSTNAMES)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_SERVER_HOSTNAMES + " not present.");
    }
    if (!config.contains(PARAM_ZOOKEEPER_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_PORT + " not present.");
    }
    List<String> zookeeperServerHosts;
    try {
        zookeeperServerHosts = config.getAny(PARAM_ZOOKEEPER_SERVER_HOSTNAMES);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_SERVER_HOSTNAMES + " should be list of string.");
    }
    Number zookeeperPort;
    try {
        zookeeperPort = config.getAny(PARAM_ZOOKEEPER_PORT);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_PORT + " should be number.");
    }
    Component zookeeperServer = new Component();
    zookeeperServer.setName(COMPONENT_ZOOKEEPER_SERVER);
    List<ComponentProcess> componentProcesses = zookeeperServerHosts.stream().map(host -> {
        ComponentProcess cp = new ComponentProcess();
        cp.setHost(host);
        cp.setPort(zookeeperPort.intValue());
        return cp;
    }).collect(toList());
    return new Pair<>(zookeeperServer, componentProcesses);
}
Also used : Config(com.hortonworks.streamline.common.Config) ComponentPropertyPattern(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern) Pair(org.apache.commons.math3.util.Pair) ZOOKEEPER_SERVER(com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern.ZOOKEEPER_SERVER) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) HashMap(java.util.HashMap) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Constants(com.hortonworks.streamline.streams.cluster.Constants) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ServiceConfigurations(com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Map(java.util.Map) Collections(java.util.Collections) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess) Pair(org.apache.commons.math3.util.Pair)

Example 9 with Component

use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.

the class ComponentCatalogResource method removeComponent.

@DELETE
@Path("/services/{serviceId}/components/{id}")
@Timed
public Response removeComponent(@PathParam("serviceId") Long serviceId, @PathParam("id") Long componentId, @Context SecurityContext securityContext) {
    SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), WRITE);
    Component removeComponent = environmentService.removeComponent(componentId);
    if (removeComponent != null) {
        return WSUtils.respondEntity(removeComponent, CREATED);
    }
    throw EntityNotFoundException.byId(componentId.toString());
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 10 with Component

use of com.hortonworks.streamline.streams.cluster.catalog.Component in project streamline by hortonworks.

the class ComponentCatalogResource method getComponentById.

@GET
@Path("/services/{serviceId}/components/{id}")
@Timed
public Response getComponentById(@PathParam("serviceId") Long serviceId, @PathParam("id") Long componentId, @Context SecurityContext securityContext) {
    SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), READ);
    Component component = environmentService.getComponent(componentId);
    if (component != null) {
        if (component.getServiceId() == null || !component.getServiceId().equals(serviceId)) {
            throw EntityNotFoundException.byId("service: " + serviceId.toString());
        }
        return WSUtils.respondEntity(component, OK);
    }
    throw EntityNotFoundException.byId(buildMessageForCompositeId(serviceId, componentId));
}
Also used : Component(com.hortonworks.streamline.streams.cluster.catalog.Component) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

Component (com.hortonworks.streamline.streams.cluster.catalog.Component)28 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)15 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)13 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)11 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)10 Config (com.hortonworks.streamline.common.Config)7 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Timed (com.codahale.metrics.annotation.Timed)5 Constants (com.hortonworks.streamline.streams.cluster.Constants)5 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)5 List (java.util.List)5 Path (javax.ws.rs.Path)5 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)4 Collections (java.util.Collections)4 Pair (org.apache.commons.math3.util.Pair)4 Test (org.junit.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3