Search in sources :

Example 11 with Service

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

the class EnvironmentService method createService.

public Service createService(Cluster cluster, String serviceName) {
    Service service = new Service();
    service.setId(this.dao.nextId(SERVICE_NAMESPACE));
    service.setName(serviceName);
    service.setClusterId(cluster.getId());
    service.setTimestamp(System.currentTimeMillis());
    return service;
}
Also used : Service(com.hortonworks.streamline.streams.cluster.catalog.Service)

Example 12 with Service

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

the class ServiceConfigurationCatalogResource method addServiceConfiguration.

@POST
@Path("/services/{serviceId}/configurations")
@Timed
public Response addServiceConfiguration(@PathParam("serviceId") Long serviceId, ServiceConfiguration serviceConfiguration, @Context SecurityContext securityContext) {
    SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), WRITE);
    // just overwrite the service id to given path param
    serviceConfiguration.setServiceId(serviceId);
    Service service = environmentService.getService(serviceId);
    if (service == null) {
        throw EntityNotFoundException.byId("service: " + serviceId.toString());
    }
    String configurationName = serviceConfiguration.getName();
    ServiceConfiguration result = environmentService.getServiceConfigurationByName(serviceId, configurationName);
    if (result != null) {
        throw EntityAlreadyExistsException.byName("service id " + serviceId + " and configuration name " + configurationName);
    }
    ServiceConfiguration createdConfiguration = environmentService.addServiceConfiguration(serviceConfiguration);
    return WSUtils.respondEntity(createdConfiguration, CREATED);
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 13 with Service

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

the class ClusterCatalogResource method injectStormViewAsStormConfiguration.

private void injectStormViewAsStormConfiguration(Long clusterId, AmbariServiceNodeDiscoverer discoverer) {
    Service stormService = environmentService.getServiceByName(clusterId, ServiceConfigurations.STORM.name());
    if (stormService != null) {
        // hack: find Storm View and inject to one of ServiceConfiguration for Storm service if available
        String stormViewURL = discoverer.getStormViewUrl();
        if (StringUtils.isNotEmpty(stormViewURL)) {
            ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
            serviceConfiguration.setServiceId(stormService.getId());
            serviceConfiguration.setName(StormMetadataService.SERVICE_STORM_VIEW);
            serviceConfiguration.setConfiguration("{\"" + StormMetadataService.STORM_VIEW_CONFIGURATION_KEY_STORM_VIEW_URL + "\":\"" + stormViewURL + "\"}");
            serviceConfiguration.setDescription("a hack to store Storm View URL");
            environmentService.addServiceConfiguration(serviceConfiguration);
        }
    }
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) StormMetadataService(com.hortonworks.streamline.streams.cluster.service.metadata.StormMetadataService) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService)

Example 14 with Service

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

the class DruidSinkBundleHintProviderTest method getHintsOnCluster.

@Test
public void getHintsOnCluster() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    cluster.setName("cluster1");
    Service service = new Service();
    service.setId(1L);
    service.setName(Constants.Druid.SERVICE_NAME);
    Map<String, String> confMap = new HashMap<>();
    confMap.put(Constants.Druid.PROPERTY_KEY_ZK_SERVICE_HOSTS, "svr1:2181,svr2:2181");
    confMap.put(Constants.Druid.PROPERTY_KEY_INDEXING_SERVICE_NAME, "druid/overlord");
    confMap.put(Constants.Druid.PROPERTY_KEY_DISCOVERY_CURATOR_PATH, "/discovery");
    ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
    serviceConfiguration.setId(1L);
    serviceConfiguration.setName(Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
    serviceConfiguration.setConfiguration(objectMapper.writeValueAsString(confMap));
    new Expectations() {

        {
            environmentService.getServiceByName(cluster.getId(), Constants.Druid.SERVICE_NAME);
            result = service;
            environmentService.getServiceConfigurationByName(service.getId(), Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
            result = serviceConfiguration;
        }
    };
    provider.init(environmentService);
    Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
    Assert.assertNotNull(hints);
    Assert.assertEquals("svr1:2181,svr2:2181", hints.get(DruidSinkBundleHintProvider.FIELD_NAME_ZK_CONNECT));
    Assert.assertEquals("druid/overlord", hints.get(DruidSinkBundleHintProvider.FIELD_NAME_INDEX_SERVICE));
    Assert.assertEquals("/discovery", hints.get(DruidSinkBundleHintProvider.FIELD_NAME_DISCOVERY_PATH));
}
Also used : Expectations(mockit.Expectations) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) HashMap(java.util.HashMap) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 15 with Service

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

the class DruidServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    DruidServiceRegistrar registerer = initializeServiceRegistrar();
    Config config = new Config();
    config.put(DruidServiceRegistrar.PARAM_ZOOKEEPER_CONNECTION_STRING, "zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181");
    config.put(DruidServiceRegistrar.PARAM_INDEXING_SERVICE_NAME, "druid/overlord");
    config.put(DruidServiceRegistrar.PARAM_DISCOVERY_CURATOR_PATH, "/prod/discovery");
    registerer.register(cluster, config, Collections.emptyList());
    Service druidService = environmentService.getServiceByName(cluster.getId(), Constants.Druid.SERVICE_NAME);
    assertNotNull(druidService);
    ServiceConfiguration commonRuntimePropertiesConf = environmentService.getServiceConfigurationByName(druidService.getId(), CONFIGURATION_NAME_COMMON_RUNTIME_PROPERTIES);
    assertNotNull(commonRuntimePropertiesConf);
    Map<String, String> confMap = commonRuntimePropertiesConf.getConfigurationMap();
    assertEquals(config.get(DruidServiceRegistrar.PARAM_ZOOKEEPER_CONNECTION_STRING), confMap.get(DruidServiceRegistrar.PARAM_ZOOKEEPER_CONNECTION_STRING));
    assertEquals(config.get(DruidServiceRegistrar.PARAM_INDEXING_SERVICE_NAME), confMap.get(DruidServiceRegistrar.PARAM_INDEXING_SERVICE_NAME));
    assertEquals(config.get(DruidServiceRegistrar.PARAM_DISCOVERY_CURATOR_PATH), confMap.get(DruidServiceRegistrar.PARAM_DISCOVERY_CURATOR_PATH));
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Aggregations

Service (com.hortonworks.streamline.streams.cluster.catalog.Service)50 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)31 Test (org.junit.Test)26 Config (com.hortonworks.streamline.common.Config)25 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)22 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)21 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)14 Timed (com.codahale.metrics.annotation.Timed)9 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Path (javax.ws.rs.Path)9 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)8 HashMap (java.util.HashMap)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Map (java.util.Map)4 POST (javax.ws.rs.POST)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 DELETE (javax.ws.rs.DELETE)3 PUT (javax.ws.rs.PUT)3