Package org.agilewiki.jactor

Examples of org.agilewiki.jactor.MailboxFactory


            mailboxFactory.close();
        }
    }

    public void test9() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Mailbox mailbox = mailboxFactory.createMailbox();
            JAFactory factory = new JAFactory();
            factory.initialize(mailbox);
            (new JidFactories()).initialize(mailbox, factory);
            BMapJid<Integer, IntegerJid> m = (BMapJid) factory.newActor(JidFactories.INTEGER_INTEGER_BMAP_JID_TYPE);
            int i = 0;
            while (i < 10000) {
                m.kMake(i);
                IntegerJid ij0 = m.kGet(i);
                ij0.setValue(i);
                i += 1;
            }
            i = 0;
            while (i < 10000) {
                m.kRemove(9999 - i);
                i += 1;
            }
            assertTrue(m.isLeaf());
            assertEquals(0, m.size());
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here


import org.agilewiki.jid.scalar.vlens.string.SetString;
import org.agilewiki.jid.scalar.vlens.string.StringJidFactory;

public class ActorJidTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            ActorJidFactory actorJidAFactory = new ActorJidFactory();
            Actor jidJid1 = actorJidAFactory.newActor(factory.getMailbox(), factory);
            int sl = GetSerializedLength.req.send(future, jidJid1);
            assertEquals(4, sl);
            Clear.req.send(future, jidJid1);
            sl = GetSerializedLength.req.send(future, jidJid1);
            assertEquals(4, sl);
            Actor jidJid1a = GetActor.req.send(future, jidJid1);
            assertNull(jidJid1a);
            Actor rpa = (new ResolvePathname("")).send(future, jidJid1);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid1);
            rpa = (new ResolvePathname("0")).send(future, jidJid1);
            assertNull(rpa);
            Actor jidJid11 = (new CopyJID()).send(future, jidJid1);
            assertNotNull(jidJid11);
            sl = GetSerializedLength.req.send(future, jidJid11);
            assertEquals(4, sl);
            rpa = (new ResolvePathname("")).send(future, jidJid11);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid11);
            rpa = (new ResolvePathname("0")).send(future, jidJid11);
            assertNull(rpa);

            StringJidFactory stringJidAFactory = StringJidFactory.fac;
            Actor string1 = stringJidAFactory.newActor(factory.getMailbox(), factory);
            (new SetString("abc")).send(future, string1);
            byte[] sb = GetSerializedBytes.req.send(future, string1);
            (new SetActorBytes(stringJidAFactory, sb)).send(future, jidJid1);
            Actor sj = GetActor.req.send(future, jidJid1);
            assertEquals("abc", GetString.req.send(future, sj));

            Actor jidJid2 = ActorJidFactory.fac.newActor(factory.getMailbox(), factory);
            sl = GetSerializedLength.req.send(future, jidJid2);
            assertEquals(4, sl);
            SetActor sjvj = new SetActor(JidFactories.JID_TYPE);
            sjvj.send(future, jidJid2);
            MakeActor mjvj = new MakeActor(JidFactories.JID_TYPE);
            boolean made = mjvj.send(future, jidJid2);
            assertEquals(false, made);
            Actor jidJid2a = GetActor.req.send(future, jidJid2);
            assertNotNull(jidJid2a);
            sl = GetSerializedLength.req.send(future, jidJid2a);
            assertEquals(0, sl);
            sl = GetSerializedLength.req.send(future, jidJid2);
            assertEquals(14, sl);
            rpa = (new ResolvePathname("")).send(future, jidJid2);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid2);
            rpa = (new ResolvePathname("0")).send(future, jidJid2);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid2a);
            Actor jidJid22 = (new CopyJID()).send(future, jidJid2);
            Clear.req.send(future, jidJid2);
            sl = GetSerializedLength.req.send(future, jidJid2);
            assertEquals(4, sl);
            jidJid2a = GetActor.req.send(future, jidJid2);
            assertNull(jidJid2a);
            assertNotNull(jidJid22);
            sl = GetSerializedLength.req.send(future, jidJid22);
            assertEquals(14, sl);
            rpa = (new ResolvePathname("")).send(future, jidJid22);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid22);
            rpa = (new ResolvePathname("0")).send(future, jidJid22);
            assertNotNull(rpa);
            sl = GetSerializedLength.req.send(future, rpa);
            assertEquals(0, sl);

            Actor jidJid3 = ActorJidFactory.fac.newActor(factory.getMailbox(), factory);
            sl = GetSerializedLength.req.send(future, jidJid3);
            assertEquals(4, sl);
            MakeActor mjvjj = new MakeActor(JidFactories.ACTOR_JID_TYPE);
            made = mjvjj.send(future, jidJid3);
            assertEquals(true, made);
            made = mjvjj.send(future, jidJid3);
            assertEquals(false, made);
            Actor jidJid3a = GetActor.req.send(future, jidJid3);
            assertNotNull(jidJid3a);
            sl = GetSerializedLength.req.send(future, jidJid3a);
            assertEquals(4, sl);
            sl = GetSerializedLength.req.send(future, jidJid3);
            assertEquals(30, sl);
            made = mjvj.send(future, jidJid3a);
            assertEquals(true, made);
            made = mjvj.send(future, jidJid3a);
            assertEquals(false, made);
            Actor jidJid3b = GetActor.req.send(future, jidJid3a);
            assertNotNull(jidJid3b);
            sl = GetSerializedLength.req.send(future, jidJid3b);
            assertEquals(0, sl);
            sl = GetSerializedLength.req.send(future, jidJid3a);
            assertEquals(14, sl);
            sl = GetSerializedLength.req.send(future, jidJid3);
            assertEquals(40, sl);
            rpa = (new ResolvePathname("")).send(future, jidJid3);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid3);
            rpa = (new ResolvePathname("0")).send(future, jidJid3);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid3a);
            rpa = (new ResolvePathname("0/0")).send(future, jidJid3);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid3b);
            Actor jidJid33 = (new CopyJID()).send(future, jidJid3);
            Clear.req.send(future, jidJid3a);
            sl = GetSerializedLength.req.send(future, jidJid3a);
            assertEquals(4, sl);
            sl = GetSerializedLength.req.send(future, jidJid3);
            assertEquals(30, sl);
            jidJid3b = GetActor.req.send(future, jidJid3a);
            assertNull(jidJid2a);
            Actor jidJid3aa = GetActor.req.send(future, jidJid3);
            assertEquals(jidJid3a, jidJid3aa);
            assertNotNull(jidJid33);
            sl = GetSerializedLength.req.send(future, jidJid33);
            assertEquals(40, sl);
            rpa = (new ResolvePathname("")).send(future, jidJid33);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid33);
            rpa = (new ResolvePathname("0")).send(future, jidJid33);
            assertNotNull(rpa);
            sl = GetSerializedLength.req.send(future, rpa);
            assertEquals(14, sl);
            rpa = (new ResolvePathname("0/0")).send(future, jidJid33);
            assertNotNull(rpa);
            sl = GetSerializedLength.req.send(future, rpa);
            assertEquals(0, sl);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.string.SetString;
import org.agilewiki.jid.scalar.vlens.string.StringJidFactory;

public class RootJidTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            RootJidFactory rootJidFactory = new RootJidFactory();
            Actor rootJid1 = rootJidFactory.newActor(factory.getMailbox(), factory);
            int sl = GetSerializedLength.req.send(future, rootJid1);
            assertEquals(0, sl);
            Clear.req.send(future, rootJid1);
            sl = GetSerializedLength.req.send(future, rootJid1);
            assertEquals(0, sl);
            Actor rootJid1a = GetActor.req.send(future, rootJid1);
            assertNull(rootJid1a);
            Actor rpa = (new ResolvePathname("")).send(future, rootJid1);
            assertNotNull(rpa);
            assertEquals(rpa, rootJid1);
            rpa = (new ResolvePathname("0")).send(future, rootJid1);
            assertNull(rpa);
            Actor rootJid11 = (new CopyJID()).send(future, rootJid1);
            assertNotNull(rootJid11);
            sl = GetSerializedLength.req.send(future, rootJid11);
            assertEquals(0, sl);
            rpa = (new ResolvePathname("")).send(future, rootJid11);
            assertNotNull(rpa);
            assertEquals(rpa, rootJid11);
            rpa = (new ResolvePathname("0")).send(future, rootJid11);
            assertNull(rpa);

            StringJidFactory stringJidAFactory = StringJidFactory.fac;
            Actor string1 = stringJidAFactory.newActor(factory.getMailbox(), factory);
            (new SetString("abc")).send(future, string1);
            byte[] sb = GetSerializedBytes.req.send(future, string1);
            (new SetActorBytes(stringJidAFactory, sb)).send(future, rootJid1);
            Actor sj = GetActor.req.send(future, rootJid1);
            assertEquals("abc", GetString.req.send(future, sj));

            Actor rootJid2 = RootJidFactory.fac.newActor(factory.getMailbox(), factory);
            sl = GetSerializedLength.req.send(future, rootJid2);
            assertEquals(0, sl);
            SetActor sjvj = new SetActor(JidFactories.JID_TYPE);
            sjvj.send(future, rootJid2);
            MakeActor mjvj = new MakeActor(JidFactories.JID_TYPE);
            boolean made = mjvj.send(future, rootJid2);
            assertEquals(false, made);
            Actor jidJid2a = GetActor.req.send(future, rootJid2);
            assertNotNull(jidJid2a);
            sl = GetSerializedLength.req.send(future, jidJid2a);
            assertEquals(0, sl);
            sl = GetSerializedLength.req.send(future, rootJid2);
            assertEquals(10, sl);
            rpa = (new ResolvePathname("")).send(future, rootJid2);
            assertNotNull(rpa);
            assertEquals(rpa, rootJid2);
            rpa = (new ResolvePathname("0")).send(future, rootJid2);
            assertNotNull(rpa);
            assertEquals(rpa, jidJid2a);
            Actor rootJid22 = (new CopyJID()).send(future, rootJid2);
            Clear.req.send(future, rootJid2);
            sl = GetSerializedLength.req.send(future, rootJid2);
            assertEquals(0, sl);
            jidJid2a = GetActor.req.send(future, rootJid2);
            assertNull(jidJid2a);
            assertNotNull(rootJid22);
            sl = GetSerializedLength.req.send(future, rootJid22);
            assertEquals(10, sl);
            rpa = (new ResolvePathname("")).send(future, rootJid22);
            assertNotNull(rpa);
            assertEquals(rpa, rootJid22);
            rpa = (new ResolvePathname("0")).send(future, rootJid22);
            assertNotNull(rpa);
            sl = GetSerializedLength.req.send(future, rpa);
            assertEquals(0, sl);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.string.StringJid;
import org.agilewiki.jid.scalar.vlens.string.StringJidFactory;

public class UnionJidTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            Mailbox mailbox = mailboxFactory.createMailbox();
            JAFactory factory = new JAFactory();
            factory.initialize(mailbox);
            (new JidFactories()).initialize(mailbox, factory);
            UnionJidFactory siuf =
                    new UnionJidFactory("siUnion", StringJidFactory.fac.actorType, "siUnion");
            factory.registerActorFactory(siuf);
            UnionJid siu1 = (UnionJid) factory.newActor("siUnion");
            assertNull(siu1.getValue());
            UnionJid siu2 = (UnionJid) siu1.copyJID(mailbox);
            assertNull(siu2.getValue());
            siu2.setValue(StringJidFactory.fac);
            StringJid sj2 = (StringJid) siu2.getValue();
            assertNotNull(sj2);
            UnionJid siu3 = (UnionJid) siu2.copyJID(mailbox);
            StringJid sj3 = (StringJid) siu3.getValue();
            assertNotNull(sj3);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.actor.ActorJidFactory;
import org.agilewiki.jid.scalar.vlens.actor.SetActor;

public class BooleanTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            JAFuture future = new JAFuture();
            JidFactories factory = new JidFactories();
            factory.initialize(mailboxFactory.createMailbox());

            BooleanJid boolean1 = (BooleanJid) BooleanJidFactory.fac.newActor(factory.getMailbox(), factory);
            BooleanJid boolean2 = (BooleanJid) (new CopyJID()).send(future, boolean1);
            (new SetBoolean(true)).send(future, boolean2);
            BooleanJid boolean3 = (BooleanJid) (new CopyJID()).send(future, boolean2);

            int sl = GetSerializedLength.req.send(future, boolean1);
            assertEquals(1, sl);
            sl = GetSerializedLength.req.send(future, boolean2);
            assertEquals(1, sl);
            sl = GetSerializedLength.req.send(future, boolean3);
            assertEquals(1, sl);

            assertFalse(GetBoolean.req.send(future, boolean1));
            assertTrue(GetBoolean.req.send(future, boolean2));
            assertTrue(GetBoolean.req.send(future, boolean3));

            Actor jidJid1 = ActorJidFactory.fac.newActor(factory.getMailbox(), factory);
            SetActor sjvb = new SetActor(JidFactories.BOOLEAN_JID_TYPE);
            sjvb.send(future, jidJid1);
            BooleanJid rpa = (BooleanJid) (new ResolvePathname("0")).send(future, jidJid1);
            assertFalse(GetBoolean.req.send(future, rpa));
            (new SetBoolean(true)).send(future, rpa);
            rpa = (BooleanJid) (new ResolvePathname("0")).send(future, jidJid1);
            assertTrue(GetBoolean.req.send(future, rpa));

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

import org.agilewiki.jid.scalar.vlens.actor.RootJid;
import org.agilewiki.jid.scalar.vlens.actor.SetActor;

public class BigBooleanListTest extends TestCase {
    public void test1() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        JAFuture future = new JAFuture();

        JidFactories factory = new JidFactories();
        factory.initialize(mailboxFactory.createMailbox());

        RootJid root = new RootJid();
        root.initialize(mailbox, factory);

        SetActor setList = new SetActor(JidFactories.BOOLEAN_LIST_JID_TYPE);
        setList.send(future, root);
        ListJid list = (ListJid) GetActor.req.send(future, root);

        IAdd iAdd = new IAdd(-1);
        int i = 0;
        while (i < 100) {
            iAdd.send(future, list);
            i += 1;
        }

        mailboxFactory.close();
    }
View Full Code Here

        mailboxFactory.close();
    }

    public void test2() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        JAFuture future = new JAFuture();

        JidFactories factory = new JidFactories();
        factory.initialize(mailboxFactory.createMailbox());

        RootJid root = new RootJid();
        root.initialize(mailbox, factory);

        SetActor setList = new SetActor(JidFactories.BOOLEAN_LIST_JID_TYPE);
        setList.send(future, root);
        ListJid list = (ListJid) GetActor.req.send(future, root);

        BooleanAppender ba = new BooleanAppender();
        ba.initialize(mailbox, factory);

        ba.count = 10;
        ba.repeat = 10;

        //System.out.println("###########################################################");
        //ba.count = 10000;
        //ba.repeat = 10000;
        //Appends per second = 36,023,054

        ba.list = list;
        TimeBooleanAppender.req.send(future, ba);
        long t = TimeBooleanAppender.req.send(future, ba);
        System.out.println("list size = " + ba.count);
        System.out.println("repeats = " + ba.repeat);
        if (t > 0) {
            long ips = 1000L * ba.count * ba.repeat / t;
            System.out.println("appends per second = " + ips);
        }

        mailboxFactory.close();
    }
View Full Code Here

        mailboxFactory.close();
    }

    public void test3() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        JAFuture future = new JAFuture();

        JidFactories factory = new JidFactories();
        factory.initialize(mailboxFactory.createMailbox());

        RootJid root = new RootJid();
        root.initialize(mailbox, factory);

        SetActor setList = new SetActor(JidFactories.BOOLEAN_LIST_JID_TYPE);
        setList.send(future, root);
        ListJid list = (ListJid) GetActor.req.send(future, root);

        BooleanAppender ba = new BooleanAppender();
        ba.initialize(mailbox, factory);

        ba.count = 10;
        ba.repeat = 10;

        //System.out.println("###########################################################");
        //ba.count = 10000;
        //ba.repeat = 10000;
        //Appends per second = 34,940,600

        list.initialCapacity = ba.count;

        ba.list = list;
        TimeBooleanAppender.req.send(future, ba);
        long t = TimeBooleanAppender.req.send(future, ba);
        System.out.println("list size = " + ba.count);
        System.out.println("repeats = " + ba.repeat);
        if (t > 0) {
            long ips = 1000L * ba.count * ba.repeat / t;
            System.out.println("appends per second = " + ips);
        }

        mailboxFactory.close();
    }
View Full Code Here

        mailboxFactory.close();
    }

    public void test4() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        JAFuture future = new JAFuture();

        JidFactories factory = new JidFactories();
        factory.initialize(mailboxFactory.createMailbox());

        RootJid root = new RootJid();
        root.initialize(mailbox, factory);

        SetActor setList = new SetActor(JidFactories.BOOLEAN_LIST_JID_TYPE);
        setList.send(future, root);
        ListJid list = (ListJid) GetActor.req.send(future, root);

        BooleanSAppender ba = new BooleanSAppender();
        ba.initialize(mailbox, factory);

        ba.count = 10;
        ba.repeat = 10;

        //System.out.println("###########################################################");
        //ba.count = 10000;
        //ba.repeat = 10000;
        //Appends and serializes per second = 27,382,256

        list.initialCapacity = ba.count;

        ba.list = list;
        TimeBooleanSAppender.req.send(future, ba);
        long t = TimeBooleanSAppender.req.send(future, ba);
        System.out.println("list size = " + ba.count);
        System.out.println("repeats = " + ba.repeat);
        if (t > 0) {
            long ips = 1000L * ba.count * ba.repeat / t;
            System.out.println("appends and serializes per second = " + ips);
        }

        mailboxFactory.close();
    }
View Full Code Here

        mailboxFactory.close();
    }

    public void test5() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        JAFuture future = new JAFuture();

        JidFactories factory = new JidFactories();
        factory.initialize(mailboxFactory.createMailbox());

        RootJid root = new RootJid();
        root.initialize(mailbox, factory);

        SetActor setList = new SetActor(JidFactories.BOOLEAN_LIST_JID_TYPE);
        setList.send(future, root);
        ListJid list = (ListJid) GetActor.req.send(future, root);

        BooleanUAppender ba = new BooleanUAppender();
        ba.initialize(mailbox, factory);

        ba.count = 10;
        ba.repeat = 10;

        //System.out.println("###########################################################");
        //ba.count = 10000;
        //ba.repeat = 10000;
        //Updates per second = 28,785,261

        list.initialCapacity = ba.count;

        ba.list = list;
        TimeBooleanUAppender.req.send(future, ba);
        long t = TimeBooleanUAppender.req.send(future, ba);
        System.out.println("list size = " + ba.count);
        System.out.println("repeats = " + ba.repeat);
        if (t > 0) {
            long ips = 1000L * ba.count * ba.repeat / t;
            System.out.println("Updates per second = " + ips);
        }

        mailboxFactory.close();
    }
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor.MailboxFactory

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.