Package com.sun.sgs.test.util

Examples of com.sun.sgs.test.util.DummyIdentity


            // node2: 2,5,8,11,14,17,20,23,26,29,32
            // node3: 3,6,9,12,15,18,21,24,27,30,33
            // Actual round robin policy might assign these differently...
            NodeMappingService nms = node1.getNodeMappingService();
            for (int i = 1; i < 35; i++) {
                idents[i] = new DummyIdentity(String.valueOf(i));
                nms.assignNode(this.getClass(), idents[i]);
            }
           
            // Node 1 uses.
            AffinityGraphBuilder builder1 = driver1.getGraphBuilder();
View Full Code Here


        // fission in small group,
        // Journal of Anthropological Research 33, 452-473 (1977)
        LabelVertex[] nodes = new LabelVertex[35];
        for (int i = 1; i < nodes.length; i++) {
            // Add identities 1-34
            nodes[i] = new LabelVertex(new DummyIdentity(String.valueOf(i)));
            graph.addVertex(nodes[i]);
        }
        graph.addEdge(new WeightedEdge(), nodes[2], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[3], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[3], nodes[2]);
View Full Code Here

        AffinityGraphBuilder builder = new TestToyBuilder();

        final long gen = 1;
        Collection<AffinityGroup> group1 = new HashSet<AffinityGroup>();
        HashSet<Identity> identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("1"));
        identitySet.add(new DummyIdentity("2"));
        identitySet.add(new DummyIdentity("3"));
        AffinitySet a = new AffinitySet(1, gen, identitySet);
        group1.add(a);
        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("4"));
        identitySet.add(new DummyIdentity("5"));
        AffinitySet b = new AffinitySet(2, gen, identitySet);
        group1.add(b);

        double modularity =
            AffinityGroupGoodness.calcModularity(builder.getAffinityGraph(),
                                                 group1);
        Assert.assertEquals(0.22, modularity, .001);

        Collection<AffinityGroup> group2 = new HashSet<AffinityGroup>();
        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("1"));
        identitySet.add(new DummyIdentity("3"));
        a = new AffinitySet(3, gen, identitySet);
        group2.add(a);
        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("2"));
        identitySet.add(new DummyIdentity("4"));
        identitySet.add(new DummyIdentity("5"));
        b = new AffinitySet(4, gen, identitySet);
        group2.add(b);

        modularity =
            AffinityGroupGoodness.calcModularity(builder.getAffinityGraph(),
View Full Code Here

        AffinityGraphBuilder builder = new TestToyWeightBuilder();

        final long gen = 1;
        Collection<AffinityGroup> group1 = new HashSet<AffinityGroup>();
        HashSet<Identity> identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("1"));
        identitySet.add(new DummyIdentity("2"));
        identitySet.add(new DummyIdentity("3"));
        AffinitySet a = new AffinitySet(1, gen, identitySet);
        group1.add(a);
        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("4"));
        identitySet.add(new DummyIdentity("5"));
        AffinitySet b = new AffinitySet(2, gen, identitySet);
        group1.add(b);

        double modularity =
            AffinityGroupGoodness.calcModularity(builder.getAffinityGraph(),
                                                 group1);
        Assert.assertEquals(0.22, modularity, .001);

        Collection<AffinityGroup> group2 = new HashSet<AffinityGroup>();
        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("1"));
        identitySet.add(new DummyIdentity("3"));
        a = new AffinitySet(3, gen, identitySet);
        group2.add(a);
        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("2"));
        identitySet.add(new DummyIdentity("4"));
        identitySet.add(new DummyIdentity("5"));
        b = new AffinitySet(4, gen, identitySet);
       
        group2.add(b);

        modularity =
View Full Code Here

        final long gen = 1;
        AffinityGraphBuilder builder = new ZachBuilder();
        Collection<AffinityGroup> groups = new HashSet<AffinityGroup>();

        HashSet<Identity> identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("1"));
        identitySet.add(new DummyIdentity("2"));
        identitySet.add(new DummyIdentity("3"));
        identitySet.add(new DummyIdentity("4"));
        identitySet.add(new DummyIdentity("5"));
        identitySet.add(new DummyIdentity("6"));
        identitySet.add(new DummyIdentity("7"));
        identitySet.add(new DummyIdentity("8"));
        identitySet.add(new DummyIdentity("11"));
        identitySet.add(new DummyIdentity("12"));
        identitySet.add(new DummyIdentity("13"));
        identitySet.add(new DummyIdentity("14"));
        identitySet.add(new DummyIdentity("17"));
        identitySet.add(new DummyIdentity("18"));
        identitySet.add(new DummyIdentity("20"));
        identitySet.add(new DummyIdentity("22"));
        AffinitySet a = new AffinitySet(1, gen, identitySet);
        groups.add(a);

        identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("9"));
        identitySet.add(new DummyIdentity("10"));
        identitySet.add(new DummyIdentity("15"));
        identitySet.add(new DummyIdentity("16"));
        identitySet.add(new DummyIdentity("19"));
        identitySet.add(new DummyIdentity("21"));
        identitySet.add(new DummyIdentity("23"));
        identitySet.add(new DummyIdentity("24"));
        identitySet.add(new DummyIdentity("25"));
        identitySet.add(new DummyIdentity("26"));
        identitySet.add(new DummyIdentity("27"));
        identitySet.add(new DummyIdentity("28"));
        identitySet.add(new DummyIdentity("29"));
        identitySet.add(new DummyIdentity("30"));
        identitySet.add(new DummyIdentity("31"));
        identitySet.add(new DummyIdentity("32"));
        identitySet.add(new DummyIdentity("33"));
        identitySet.add(new DummyIdentity("34"));
        AffinitySet b = new AffinitySet(2, gen, identitySet);
        groups.add(b);

        double modularity =
            AffinityGroupGoodness.calcModularity(builder.getAffinityGraph(),
View Full Code Here

    @Test
    public void testModularityCalc() {
        final long gen = 1;
        AffinityGraphBuilder builder = new ZachBuilder();
        Collection<AffinityGroup> groups = new HashSet<AffinityGroup>();
        AffinitySet a = new AffinitySet(49, gen, new DummyIdentity("17"));
        groups.add(a);

        HashSet<Identity> identitySet = new HashSet<Identity>();
        identitySet.add(new DummyIdentity("1"));
        identitySet.add(new DummyIdentity("2"));
        identitySet.add(new DummyIdentity("3"));
        identitySet.add(new DummyIdentity("4"));
        identitySet.add(new DummyIdentity("5"));
        identitySet.add(new DummyIdentity("6"));
        identitySet.add(new DummyIdentity("7"));
        identitySet.add(new DummyIdentity("8"));
        identitySet.add(new DummyIdentity("9"));
        identitySet.add(new DummyIdentity("10"));
        identitySet.add(new DummyIdentity("11"));
        identitySet.add(new DummyIdentity("12"));
        identitySet.add(new DummyIdentity("13"));
        identitySet.add(new DummyIdentity("14"));
        identitySet.add(new DummyIdentity("15"));
        identitySet.add(new DummyIdentity("16"));
//        identitySet.add(new DummyIdentity("17"));
        identitySet.add(new DummyIdentity("18"));
        identitySet.add(new DummyIdentity("19"));
        identitySet.add(new DummyIdentity("20"));
        identitySet.add(new DummyIdentity("21"));
        identitySet.add(new DummyIdentity("22"));
        identitySet.add(new DummyIdentity("23"));
        identitySet.add(new DummyIdentity("24"));
        identitySet.add(new DummyIdentity("25"));
        identitySet.add(new DummyIdentity("26"));
        identitySet.add(new DummyIdentity("27"));
        identitySet.add(new DummyIdentity("28"));
        identitySet.add(new DummyIdentity("29"));
        identitySet.add(new DummyIdentity("30"));
        identitySet.add(new DummyIdentity("31"));
        identitySet.add(new DummyIdentity("32"));
        identitySet.add(new DummyIdentity("33"));
        identitySet.add(new DummyIdentity("34"));
        AffinitySet b = new AffinitySet(2, gen, identitySet);
        groups.add(b);

        double modularity =
            AffinityGroupGoodness.calcModularity(builder.getAffinityGraph(),
View Full Code Here

            LabelVertex[] nodes = new LabelVertex[6];
            for (int i = 1; i < nodes.length; i++) {
                // Add identities 1-5
                nodes[i] =
                        new LabelVertex(new DummyIdentity(String.valueOf(i)));
                graph.addVertex(nodes[i]);
            }

            graph.addEdge(new WeightedEdge(), nodes[1], nodes[2]);
            graph.addEdge(new WeightedEdge(), nodes[1], nodes[3]);
View Full Code Here

            LabelVertex[] nodes = new LabelVertex[6];
            for (int i = 1; i < nodes.length; i++) {
                // Add identities 1-5
                nodes[i] =
                        new LabelVertex(new DummyIdentity(String.valueOf(i)));
                graph.addVertex(nodes[i]);
            }

            graph.addEdge(new WeightedEdge(2), nodes[1], nodes[2]);
            graph.addEdge(new WeightedEdge(2), nodes[1], nodes[3]);
View Full Code Here

            DummyIdentity[] idents = new DummyIdentity[35];
            int nodeAsInt = (int) node;
            // Create a partial graph
            for (int i = nodeAsInt; i < nodes.length; i+=3) {
                // Add identities 1, 4, etc.
                idents[i] = new DummyIdentity(String.valueOf(i));
                nodes[i] = new LabelVertex(idents[i]);
                graph.addVertex(nodes[i]);
            }
            // Obj uses
            Map<Identity, Long> tempMap = new HashMap<Identity, Long>();
View Full Code Here

    public void testDistributedFramework() throws Exception {
        final long generation = 1;
        Set<AffinityGroup> group1 = new HashSet<AffinityGroup>();
        {
            HashSet<Identity> identitySet = new HashSet<Identity>();
            identitySet.add(new DummyIdentity("1"));
            identitySet.add(new DummyIdentity("2"));
            identitySet.add(new DummyIdentity("3"));
            AffinitySet a = new AffinitySet(1, generation, identitySet);
            group1.add(a);
            identitySet = new HashSet<Identity>();
            identitySet.add(new DummyIdentity("4"));
            identitySet.add(new DummyIdentity("5"));
            AffinitySet b = new AffinitySet(2, generation, identitySet);
            group1.add(b);
        }
        Set<AffinityGroup> group2 = new HashSet<AffinityGroup>();
        {
            HashSet<Identity> identitySet = new HashSet<Identity>();
            identitySet.add(new DummyIdentity("6"));
            identitySet.add(new DummyIdentity("7"));
            AffinitySet a = new AffinitySet(1, generation, identitySet);
            group2.add(a);
            identitySet = new HashSet<Identity>();
            identitySet.add(new DummyIdentity("8"));
            identitySet.add(new DummyIdentity("9"));
            AffinitySet b = new AffinitySet(3, generation, identitySet);
           
            group2.add(b);
        }
        Set<AffinityGroup> group3 = new HashSet<AffinityGroup>();
        {
            HashSet<Identity> identitySet = new HashSet<Identity>();
            identitySet.add(new DummyIdentity("10"));
            identitySet.add(new DummyIdentity("11"));
            AffinitySet a = new AffinitySet(4, generation, identitySet);
            group3.add(a);
        }

        HashSet<TestLPAClient> clients = new HashSet<TestLPAClient>();
        TestLPAClient client1 = new TestLPAClient(server, 10, 10, 3, group1);
        TestLPAClient client2 = new TestLPAClient(server, 20, 20, 4, group2);
        TestLPAClient client3 = new TestLPAClient(server, 30, 30, 2, group3);
        clients.add(client1);
        clients.add(client2);
        clients.add(client3);
        server.register(10, client1);
        server.register(20, client2);
        server.register(30, client3);

        long now = System.currentTimeMillis();
        Set<RelocatingAffinityGroup> groups = server.findAffinityGroups();
        System.out.printf("finished in %d milliseconds %n",
                          System.currentTimeMillis() - now);
        for (TestLPAClient client : clients) {
            assertFalse(client.failed);
            assertTrue(client.currentIter >= client.convergeCount);
        }
        for (AffinityGroup ag : groups) {
            Set<Identity> ids = ag.getIdentities();
            if (ag.getId() == 1) {
                assertEquals(5, ids.size());
                assertTrue(ids.contains(new DummyIdentity("1")));
                assertTrue(ids.contains(new DummyIdentity("2")));
                assertTrue(ids.contains(new DummyIdentity("3")));
                assertTrue(ids.contains(new DummyIdentity("6")));
                assertTrue(ids.contains(new DummyIdentity("7")));
            } else if (ag.getId() == 2) {
                assertEquals(2, ids.size());
                assertTrue(ids.contains(new DummyIdentity("4")));
                assertTrue(ids.contains(new DummyIdentity("5")));
            } else if (ag.getId() == 3) {
                assertEquals(2, ids.size());
                assertTrue(ids.contains(new DummyIdentity("8")));
                assertTrue(ids.contains(new DummyIdentity("9")));
            } else if (ag.getId() == 4) {
                assertEquals(2, ids.size());
                assertTrue(ids.contains(new DummyIdentity("10")));
                assertTrue(ids.contains(new DummyIdentity("11")));
            } else {
                fail("Unknown group found " + ag.getId());
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.test.util.DummyIdentity

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.