Search in sources :

Example 6 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

the class ConfigBuilderTest method testBuildConfig_IncorrectComponentJVMOptions_ExceptionThrown.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectComponentJVMOptions_ExceptionThrown() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_JVM_OPTIONS_CONFIG.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 7 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

the class ConfigBuilderTest method testBuildConfig_ByteAllocationTooSmall_ExceptionThrown.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_ByteAllocationTooSmall_ExceptionThrown() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_RAM_BYTES.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 8 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

the class ConfigBuilderTest method testBuildConfig_MBAllocationTooSmall_ExceptionThrown.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_MBAllocationTooSmall_ExceptionThrown() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_RAM_MEGABYTES.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 9 with EcoParser

use of com.twitter.heron.eco.parser.EcoParser in project incubator-heron by apache.

the class Eco method main.

public static void main(String[] args) throws Exception {
    Options options = constructOptions();
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        throw new RuntimeException("Error parsing command line options: ", e);
    }
    FileInputStream fin = new FileInputStream(new File(cmd.getOptionValue(ECO_CONFIG_FILE)));
    String propsFile = cmd.getOptionValue(PROPS);
    FileInputStream propsInputStream = null;
    if (propsFile != null) {
        propsInputStream = new FileInputStream(new File(propsFile));
    }
    Boolean filterFromEnv = cmd.hasOption(ENV_PROPS);
    Eco eco = new Eco(new EcoBuilder(new SpoutBuilder(), new BoltBuilder(), new StreamBuilder(), new ComponentBuilder(), new ConfigBuilder()), new EcoParser(), new EcoSubmitter());
    eco.submit(fin, propsInputStream, filterFromEnv);
}
Also used : SpoutBuilder(com.twitter.heron.eco.builder.SpoutBuilder) Options(org.apache.commons.cli.Options) EcoBuilder(com.twitter.heron.eco.builder.EcoBuilder) FileInputStream(java.io.FileInputStream) StreamBuilder(com.twitter.heron.eco.builder.StreamBuilder) CommandLine(org.apache.commons.cli.CommandLine) BoltBuilder(com.twitter.heron.eco.builder.BoltBuilder) ConfigBuilder(com.twitter.heron.eco.builder.ConfigBuilder) EcoParser(com.twitter.heron.eco.parser.EcoParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) ComponentBuilder(com.twitter.heron.eco.builder.ComponentBuilder) EcoSubmitter(com.twitter.heron.eco.submit.EcoSubmitter) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

EcoParser (com.twitter.heron.eco.parser.EcoParser)9 FileInputStream (java.io.FileInputStream)9 Config (com.twitter.heron.api.Config)8 EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 Test (org.junit.Test)8 BoltBuilder (com.twitter.heron.eco.builder.BoltBuilder)1 ComponentBuilder (com.twitter.heron.eco.builder.ComponentBuilder)1 ConfigBuilder (com.twitter.heron.eco.builder.ConfigBuilder)1 EcoBuilder (com.twitter.heron.eco.builder.EcoBuilder)1 SpoutBuilder (com.twitter.heron.eco.builder.SpoutBuilder)1 StreamBuilder (com.twitter.heron.eco.builder.StreamBuilder)1 EcoSubmitter (com.twitter.heron.eco.submit.EcoSubmitter)1 File (java.io.File)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1