Package org.agilewiki.jfile.transactions.transactionAggregator

Examples of org.agilewiki.jfile.transactions.transactionAggregator.AggregateTransaction


        TransactionAggregator transactionAggregator = new org.agilewiki.jfile.transactions.transactionAggregator.TransactionAggregator();
        transactionAggregator.initialize(mailboxFactory.createAsyncMailbox(), factory);
        transactionAggregator.setNext(transactionProcessor);

        (new AggregateTransaction("helloWorldTransaction")).sendEvent(transactionAggregator);
        (new AggregateTransaction("helloWorldTransaction")).sendEvent(transactionAggregator);
        (new AggregateTransaction("helloWorldTransaction")).send(future, transactionAggregator);

        mailboxFactory.close();
    }
View Full Code Here


    final public static IncrementIntegerTransactionFactory fac = new IncrementIntegerTransactionFactory();

    public static AggregateTransaction at(Mailbox mailbox, String key)
            throws Exception {
        byte[] gitBytes = IncrementIntegerTransaction.bytes(mailbox, key);
        return new AggregateTransaction(fac, gitBytes);
    }
View Full Code Here

    final public static AddIntegerTransactionFactory fac = new AddIntegerTransactionFactory();

    public static AggregateTransaction at(Mailbox mailbox, String key, Integer increment)
            throws Exception {
        byte[] gitBytes = AddIntegerTransaction.bytes(mailbox, key, increment);
        return new AggregateTransaction(fac, gitBytes);
    }
View Full Code Here

    final public static GetIntegerTransactionFactory fac = new GetIntegerTransactionFactory();

    public static AggregateTransaction at(Mailbox mailbox, String key)
            throws Exception {
        byte[] gitBytes = GetIntegerTransaction.bytes(mailbox, key);
        return new AggregateTransaction(fac, gitBytes);
    }
View Full Code Here

        (new JFileFactories()).initialize(factoryMailbox, factory);
        factory.defineActorType("inc", IncrementCounterTransaction.class);
        factory.defineActorType("get", GetCounterTransaction.class);
        Path directoryPath = FileSystems.getDefault().getPath("CounterTest");
        JAFuture future = new JAFuture();
        AggregateTransaction inc = new AggregateTransaction("inc");
        AggregateTransaction get = new AggregateTransaction("get");

        System.out.println("db1");
        CounterDB db1 = new CounterDB(mailboxFactory, factory, directoryPath);
        db1.clearDirectory();
        (new OpenDbFile(10000)).send(future, db1);
        TransactionAggregator transactionAggregator1 = db1.getTransactionAggregator();
        inc.sendEvent(transactionAggregator1);
        int total1 = (Integer) (new AggregateTransaction("get")).send(future, transactionAggregator1);
        assertEquals(1, total1);
        db1.closeDbFile();

        System.out.println("db2");
        CounterDB db2 = new CounterDB(mailboxFactory, factory, directoryPath);
        (new OpenDbFile(10000)).send(future, db2);
        TransactionAggregator transactionAggregator2 = db2.getTransactionAggregator();
        inc.sendEvent(transactionAggregator2);
        inc.sendEvent(transactionAggregator2);
        int total2 = (Integer) (new AggregateTransaction("get")).send(future, transactionAggregator2);
        assertEquals(3, total2);
        db2.closeDbFile();

        System.out.println("db3");
        CounterDB db3 = new CounterDB(mailboxFactory, factory, directoryPath);
        (new OpenDbFile(10000)).send(future, db3);
        TransactionAggregator transactionAggregator3 = db3.getTransactionAggregator();
        inc.sendEvent(transactionAggregator3);
        inc.sendEvent(transactionAggregator3);
        inc.sendEvent(transactionAggregator3);
        int total3 = (Integer) get.send(future, transactionAggregator3);
        assertEquals(6, total3);
        db3.closeDbFile();

        mailboxFactory.close();
    }
View Full Code Here

        factory.initialize(factoryMailbox);
        (new JFileFactories()).initialize(factoryMailbox, factory);
        IncrementCounterFactory ntf = new IncrementCounterFactory("n");
        factory.registerActorFactory(ntf);
        JAFuture future = new JAFuture();
        AggregateTransaction aggregateTransaction = new AggregateTransaction(ntf);

        Path directoryPath = FileSystems.getDefault().getPath("TransactionLoggerTimingTest");
        CounterDB db = new CounterDB(mailboxFactory, factory, directoryPath);
        db.clearDirectory();
        (new OpenDbFile(10000)).send(future, db);
View Full Code Here

        Path directoryPath = FileSystems.getDefault().getPath("ImdbTimingTest");
        OpenDbFile openDbFile = new OpenDbFile(10000);
        System.out.println("online");

        AggregateTransaction aggregateIncrementTransaction =
                IncrementIntegerTransactionFactory.at(factoryMailbox, "counter");

        IMDB db1 = new IMDB(mailboxFactory, factory, directoryPath);
        db1.clearDirectory();
        openDbFile.send(future, db1);
        TransactionAggregator transactionAggregator1 = db1.getTransactionAggregator();

        TransactionAggregatorDriver transactionAggregatorDriver =
                new TransactionAggregatorDriver();
        transactionAggregatorDriver.initialize(mailboxFactory.createAsyncMailbox(), transactionAggregator1);
        transactionAggregatorDriver.setInitialBufferCapacity(1024);
        transactionAggregatorDriver.win = 3;
        transactionAggregatorDriver.aggregateTransaction = aggregateIncrementTransaction;

        transactionAggregatorDriver.batch = 1;
        transactionAggregatorDriver.count = 1;

        //System.out.println("###########################################################");
        //transactionAggregatorDriver.batch = 10000;
        //transactionAggregatorDriver.count = 1000;

        Go.req.send(future, transactionAggregatorDriver);
        GetIntegerTransaction git = new GetIntegerTransaction();
        git.initialize(factoryMailbox);
        git.setValue("counter");
        byte[] gitBytes = git.getSerializedBytes();
        AggregateTransaction aggregateGetTransaction =
                new AggregateTransaction(JFileFactories.GET_INTEGER_TRANSACTION, gitBytes);
        long t8 = System.currentTimeMillis();
        int k = 0;
        int total1 = 0;
        while (k < 10) {
            total1 = (Integer) aggregateGetTransaction.send(future, transactionAggregator1);
            k += 1;
        }
        long t9 = System.currentTimeMillis();
        assertEquals(transactionAggregatorDriver.batch * transactionAggregatorDriver.count, total1);
        System.out.println("latency = " + (t9 - t8) + " microseconds");
View Full Code Here

        (new JFileFactories()).initialize(factoryMailbox, factory);
        JAFuture future = new JAFuture();
        Path directoryPath = FileSystems.getDefault().getPath("CheckpointTest");
        OpenDbFile openDbFile = new OpenDbFile(10000);

        AggregateTransaction aggregateAddTransaction =
                AddIntegerTransactionFactory.at(factoryMailbox, "counter", 2);
        AggregateTransaction aggregateIncrementTransaction =
                IncrementIntegerTransactionFactory.at(factoryMailbox, "counter");
        AggregateTransaction aggregateGetTransaction =
                GetIntegerTransactionFactory.at(factoryMailbox, "counter");

        System.out.println("db1");
        IMDB db1 = new IMDB(mailboxFactory, factory, directoryPath);
        db1.clearDirectory();
        openDbFile.send(future, db1);
        System.out.println("online");
        TransactionAggregator transactionAggregator1 = db1.getTransactionAggregator();
        aggregateIncrementTransaction.sendEvent(transactionAggregator1);
        int total1 = (Integer) aggregateGetTransaction.send(future, transactionAggregator1);
        assertEquals(1, total1);
        db1.closeDbFile();

        System.out.println("db2");
        IMDB db2 = new IMDB(mailboxFactory, factory, directoryPath);
        openDbFile.send(future, db2);
        System.out.println("online");
        TransactionAggregator transactionAggregator2 = db2.getTransactionAggregator();
        aggregateIncrementTransaction.sendEvent(transactionAggregator2);
        aggregateIncrementTransaction.sendEvent(transactionAggregator2);
        int total2 = (Integer) aggregateGetTransaction.send(future, transactionAggregator2);
        assertEquals(3, total2);
        db2.closeDbFile();

        System.out.println("db3");
        IMDB db3 = new IMDB(mailboxFactory, factory, directoryPath);
        openDbFile.send(future, db3);
        System.out.println("online");
        TransactionAggregator transactionAggregator3 = db3.getTransactionAggregator();
        aggregateIncrementTransaction.sendEvent(transactionAggregator3);
        aggregateIncrementTransaction.sendEvent(transactionAggregator3);
        aggregateAddTransaction.sendEvent(transactionAggregator3);
        int total3 = (Integer) aggregateGetTransaction.send(future, transactionAggregator3);
        assertEquals(7, total3);
        db3.closeDbFile();

        mailboxFactory.close();
    }
View Full Code Here

TOP

Related Classes of org.agilewiki.jfile.transactions.transactionAggregator.AggregateTransaction

Copyright © 2018 www.massapicom. 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.