Examples of EasyBatchEngine


Examples of org.easybatch.core.impl.EasyBatchEngine

        System.out.println(COMMENT_SEPARATOR);
        System.out.println("Running a single Easy Batch instance");
        System.out.println(COMMENT_SEPARATOR);
        long singleInstanceStartTime = System.nanoTime();
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        EasyBatchReport easyBatchReport = easyBatchEngine.call();
        System.out.println(easyBatchReport);

        long singleInstanceEndTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - singleInstanceStartTime);

        System.out.println(COMMENT_SEPARATOR);
        System.out.println("Running two Easy Batch instances in parallel");
        System.out.println(COMMENT_SEPARATOR);
        long parallelInstancesStartTime = System.nanoTime();

        // To avoid any thread-safety issues,
        // we will create 2 engines with separate instances of record readers and processors

        // Build an easy batch engine1
        EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordFilter(new RecordNumberGreaterThanRecordFilter(5)) // filter records 6-10
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        // Build an easy batch engine2
        EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordFilter(new RecordNumberLowerThanRecordFilter(6)) // filter records 1-5
                .registerRecordProcessor(new MessageEncrypter())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

public class Launcher {

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id", "name"}))
                .registerRecordValidator(new BeanValidationRecordValidator<Greeting>())
                .registerRecordProcessor(new GreetingProcessor())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

        // To avoid any thread-safety issues,
        // we will create 2 engines with separate instances of record readers and processors

        // Build an easy batch engine1
        EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages-part1.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        // Build an easy batch engine2
        EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[1]))) //read data from secret-messages-part2.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        //create a 2 threads pool to call Easy Batch engines in parallel
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

public class Launcher {

    public static void main(String[] args) throws Exception {

        ApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml");
        EasyBatchEngine easyBatchEngine = (EasyBatchEngine) context.getBean("easyBatchEngine");
        easyBatchEngine.call();

    }
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

         */
        DatabaseUtil.startEmbeddedDatabase();
        DatabaseUtil.initializeSessionFactory();

        // Build an easy batch engine to read greetings from csv file
        EasyBatchEngine easyBatchCsvEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id","name"}))
                .registerRecordProcessor(new GreetingDataLoader())
                .build();

        // Build an easy batch engine to read greetings from xml file
        EasyBatchEngine easyBatchXmlEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new XmlRecordReader("greeting", new File(args[1])))
                .registerRecordMapper(new XmlRecordMapper<Greeting>(Greeting.class))
                .registerRecordProcessor(new GreetingDataLoader())
                .build();

        //create a 2 threads pool to call Easy Batch engines in parallel
        ExecutorService executorService = Executors.newFixedThreadPool(2);

        Future<EasyBatchReport> easyBatchReport1 = executorService.submit(easyBatchCsvEngine);
        Future<EasyBatchReport> easyBatchReport2 = executorService.submit(easyBatchXmlEngine);

        easyBatchReport1.get();
        easyBatchReport2.get();

        executorService.shutdown();

        // Build an easy batch engine to generate JSON products data from the database
        EasyBatchEngine easyBatchJsonEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new JdbcRecordReader(DatabaseUtil.getDatabaseConnection(), "select * from greeting"))
                .registerRecordMapper(new JdbcRecordMapper<Greeting>(Greeting.class))
                .registerRecordProcessor(new GreetingJsonGenerator())
                .build();

        easyBatchJsonEngine.call();

        //close database session factory
        DatabaseUtil.closeSessionFactory();

    }
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

        productMapper.setDelimiter("|");
        productMapper.setQualifier("\"");
        productMapper.registerTypeConverter(Origin.class, new OriginTypeConverter());

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from products.csv
                .registerRecordMapper(productMapper)
                .registerRecordProcessor(new ProductProcessor())
                .build();

        // Run easy batch engine and get execution report
        EasyBatchReport easyBatchReport = easyBatchEngine.call();

        // Print Easy Batch report
        System.out.println(easyBatchReport);

        // Get the batch computation result
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

public class Launcher {

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new XmlRecordReader("greeting", new File(args[0])))
                .registerRecordMapper(new XmlRecordMapper<Greeting>(Greeting.class, new File(args[1])))
                .registerRecordProcessor(new GreetingProcessor())
                .build();

        // Run easy batch engine
        EasyBatchReport easyBatchReport = easyBatchEngine.call();

        // Print the batch execution report
        System.out.println(easyBatchReport);

    }
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngine

        //start embedded JMS broker
        JMSUtil.startBroker();

        // Build easy batch engines
        EasyBatchEngine easyBatchEngine1 = buildEasyBatchEngine(1);
        EasyBatchEngine easyBatchEngine2 = buildEasyBatchEngine(2);

        //create a 2 threads pool to call Easy Batch engines in parallel
        ExecutorService executorService = Executors.newFixedThreadPool(2);

        Future<EasyBatchReport> batchReportFuture1 = executorService.submit(easyBatchEngine1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.