Search in sources :

Example 36 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class EmailServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    EmailServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.setAny("host", "host");
    config.setAny("port", 1111);
    config.setAny("ssl", true);
    config.setAny("starttls", true);
    config.setAny("protocol", "smtp");
    config.setAny("auth", true);
    registrar.register(cluster, config, Collections.emptyList());
    Service emailService = environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
    assertNotNull(emailService);
    ServiceConfiguration propertiesConf = environmentService.getServiceConfigurationByName(emailService.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
    assertNotNull(propertiesConf);
}
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)

Example 37 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class StormTopologyActionsImpl method createYamlFile.

private String createYamlFile(TopologyLayout topology, boolean deploy) throws Exception {
    Map<String, Object> yamlMap;
    File f;
    OutputStreamWriter fileWriter = null;
    try {
        f = new File(this.getFilePath(topology));
        if (f.exists()) {
            if (!f.delete()) {
                throw new Exception("Unable to delete old storm " + "artifact for topology id " + topology.getId());
            }
        }
        yamlMap = new LinkedHashMap<>();
        yamlMap.put(StormTopologyLayoutConstants.YAML_KEY_NAME, generateStormTopologyName(topology));
        TopologyDag topologyDag = topology.getTopologyDag();
        LOG.debug("Initial Topology config {}", topology.getConfig());
        StormTopologyFluxGenerator fluxGenerator = new StormTopologyFluxGenerator(topology, conf, getExtraJarsLocation(topology));
        topologyDag.traverse(fluxGenerator);
        for (Map.Entry<String, Map<String, Object>> entry : fluxGenerator.getYamlKeysAndComponents()) {
            addComponentToCollection(yamlMap, entry.getValue(), entry.getKey());
        }
        Config topologyConfig = fluxGenerator.getTopologyConfig();
        putAutoTokenDelegationConfig(topologyConfig, topologyDag);
        registerEventLogger(topologyConfig);
        Map<String, Object> properties = topologyConfig.getProperties();
        if (!deploy) {
            LOG.debug("Disabling topology event logger for test mode...");
            properties.put("topology.eventlogger.executors", 0);
        }
        LOG.debug("Final Topology properties {}", properties);
        addTopologyConfig(yamlMap, properties);
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        options.setSplitLines(false);
        // options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
        Yaml yaml = new Yaml(options);
        fileWriter = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
        yaml.dump(yamlMap, fileWriter);
        return f.getAbsolutePath();
    } finally {
        if (fileWriter != null) {
            fileWriter.close();
        }
    }
}
Also used : Config(com.hortonworks.streamline.common.Config) ClientConfig(org.glassfish.jersey.client.ClientConfig) StormTopologyFluxGenerator(com.hortonworks.streamline.streams.layout.storm.StormTopologyFluxGenerator) TopologyNotAliveException(com.hortonworks.streamline.streams.exception.TopologyNotAliveException) IOException(java.io.IOException) Yaml(org.yaml.snakeyaml.Yaml) FileOutputStream(java.io.FileOutputStream) DumperOptions(org.yaml.snakeyaml.DumperOptions) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag)

Example 38 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class TopologyTestHelper method createStreamlineSink.

public static StreamlineSink createStreamlineSink(String id) {
    StreamlineSink sink = new StreamlineSink();
    sink.setId(id);
    sink.setName("testSink_" + id);
    sink.setConfig(new Config());
    sink.setTransformationClass("dummyTransformation");
    return sink;
}
Also used : Config(com.hortonworks.streamline.common.Config) StreamlineSink(com.hortonworks.streamline.streams.layout.component.StreamlineSink)

Example 39 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class TopologyTestHelper method createStreamlineSource.

public static StreamlineSource createStreamlineSource(String id) {
    Stream stream = createDefaultStream();
    StreamlineSource source = new StreamlineSource(Sets.newHashSet(stream));
    source.setId(id);
    source.setName("testSource_" + id);
    source.setConfig(new Config());
    source.setTransformationClass("dummyTransformation");
    return source;
}
Also used : Config(com.hortonworks.streamline.common.Config) Stream(com.hortonworks.streamline.streams.layout.component.Stream) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource)

Example 40 with Config

use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.

the class TestTopologyDagCreatingVisitor method visit.

@Override
public void visit(StreamlineSink sink) {
    String id = sink.getId();
    String sinkName = sink.getName();
    if (!testRunSinksForEachSink.containsKey(sinkName)) {
        throw new IllegalStateException("Not all sinks have corresponding TestRunSink instance. sink name: " + sinkName);
    }
    Config config = new Config(sink.getConfig());
    TestRunSink testRunSink = testRunSinksForEachSink.get(sinkName);
    testRunSink.setId(id);
    testRunSink.setName(sinkName);
    testRunSink.setConfig(config);
    testRunSink.setTransformationClass(TestRunSinkBoltFluxComponent.class.getName());
    testTopologyDag.add(testRunSink);
    sinkToReplacedTestSinkMap.put(sinkName, testRunSink);
    copyEdges(sink);
}
Also used : TestRunSinkBoltFluxComponent(com.hortonworks.streamline.streams.layout.storm.TestRunSinkBoltFluxComponent) Config(com.hortonworks.streamline.common.Config) TestRunSink(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink)

Aggregations

Config (com.hortonworks.streamline.common.Config)41 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)25 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)25 Test (org.junit.Test)24 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)15 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)8 Map (java.util.Map)8 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Constants (com.hortonworks.streamline.streams.cluster.Constants)5 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)5 Collections (java.util.Collections)5 List (java.util.List)4 Collectors.toList (java.util.stream.Collectors.toList)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)3 Stream (com.hortonworks.streamline.streams.layout.component.Stream)3 HashMap (java.util.HashMap)3