Package org.apache.tuscany.sca.registry.hazelcast

Examples of org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry


    @Test
    public void testReplication() throws Exception {

        System.out.println("Starting reg1");
        HazelcastDomainRegistry reg1 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9876&multicast=off", "bar");
        reg1.start();

        System.out.println("Adding ep1");
        RuntimeEndpoint ep1 = createEndpoint("ep1uri");
        ep1.bind(extensionPoints, reg1);
        reg1.addEndpoint(ep1);

        System.out.println("Starting reg3");
        HazelcastDomainRegistry reg2 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9877&multicast=off&wka=127.0.0.1:9876", "bar");
        reg2.start();

        System.out.println("Starting reg2");
        HazelcastDomainRegistry reg3 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9878&multicast=off&wka=127.0.0.1:9877", "bar");
        reg3.start();

        assertExists(reg1, "ep1uri");
        assertExists(reg2, "ep1uri");
        assertExists(reg3, "ep1uri");

        System.out.println("Adding ep2");
        RuntimeEndpoint ep2 = createEndpoint("ep2uri");
        ep2.bind(extensionPoints, reg2);
        reg2.addEndpoint(ep2);

        assertExists(reg2, "ep2uri");
        assertExists(reg1, "ep2uri");
        assertExists(reg3, "ep2uri");
       
        System.out.println("Stopping reg1");
        reg1.stop();
        System.out.println("Stopped reg1");
        Thread.sleep(500);

        Assert.assertNull(reg2.getEndpoint("ep1uri"));
        Assert.assertNull(reg3.getEndpoint("ep1uri"));

        assertExists(reg2, "ep2uri");
        assertExists(reg3, "ep2uri");
       
        System.out.println("Starting reg1");
        reg1.start();
        ep1.bind(extensionPoints, reg1);

        System.out.println("adding ep1");
        reg1.addEndpoint(ep1);
        assertExists(reg1, "ep1uri");
        assertExists(reg2, "ep1uri");
        assertExists(reg3, "ep1uri");
       
        System.out.println("Stopping reg1");
        reg1.stop();
        System.out.println("Stopping reg2");
        reg2.stop();
        System.out.println("Stopping reg3");
        reg3.stop();
        System.out.println("done");
    }
View Full Code Here


        System.out.println("done");
    }

    @Test
    public void testDuplicates() throws Exception {
        HazelcastDomainRegistry reg1 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9876&multicast=off", "bar");
        reg1.start();
        RuntimeEndpoint ep1 = createEndpoint("ep1uri");
        ep1.bind(extensionPoints, reg1);
        reg1.addEndpoint(ep1);

        HazelcastDomainRegistry reg2 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9877&multicast=off&wka=127.0.0.1:9876", "bar");
        reg2.start();

        try {
            reg2.addEndpoint(ep1);
            Assert.fail();
        } catch (IllegalStateException e) {
            // expected
        }
       
        reg1.stop();
       
        Thread.sleep(200);
       
        // now it should work
        reg2.addEndpoint(ep1);

        reg2.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry

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.