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;
});
}
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;
});
}
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);
}
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());
}
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));
}
Aggregations