Examples of LabelPropagation


Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

    @Test
    public void testLPAAlgorithm() throws Exception {
        // Create three clients.
        // We'll just use the server's watchdog - safe because we aren't
        // testing node failures here.
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        LabelPropagation lp2 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE2),
                    wdog, PartialToyBuilder.NODE2, props);
        LabelPropagation lp3 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE3),
                    wdog, PartialToyBuilder.NODE3, props);
        Set<RelocatingAffinityGroup> groups = server.findAffinityGroups();
        assertTrue(groups.size() != 0);
    }
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

    @Test
    public void testLPAAlgorithmTwice() throws Exception {
        // Create three clients.
        // We'll just use the server's watchdog - safe because we aren't
        // testing node failures here.
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        LabelPropagation lp2 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE2),
                    wdog, PartialToyBuilder.NODE2, props);
        LabelPropagation lp3 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE3),
                    wdog, PartialToyBuilder.NODE3, props);
        Set<RelocatingAffinityGroup> groups = server.findAffinityGroups();
        assertTrue(groups.size() != 0);
        groups = server.findAffinityGroups();
        assertTrue(groups.size() != 0);
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

        // testing node failures here.
        //
        // We choose node 3 here because it has no reported conflicts with
        // other nodes, so it doesn't fail immediately because the other nodes
        // are down.
        LabelPropagation lp3 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE3),
                    wdog, PartialToyBuilder.NODE3, props);
        Set<RelocatingAffinityGroup> groups = server.findAffinityGroups();
        assertTrue(groups.size() != 0);
    }
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

    @Ignore
    @Test(expected = IOException.class)
    public void testServerShutdown() throws Throwable {
        // We'll just use the server's watchdog - safe because we aren't
        // testing node failures here.
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        server.shutdown();
        lp1.prepareAlgorithm(1);
    }
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

    /* -- Client tests -- */
    // Tests for idempotent behavior when key LPAClient methods are called
    // more than once by the server.
    @Test
    public void testAffinityGroupsTwice() throws Exception {
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        lp1.prepareAlgorithm(1);
        int count = 0;
        while (server.readyToBeginCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        Set<AffinityGroup> groups1 = lp1.getAffinityGroups(1, false);
        Set<AffinityGroup> groups2 = lp1.getAffinityGroups(1, false);
        assertEquals(groups1.size(), groups2.size());
        // Because we haven't actually run the algorithm, I know the groups
        // correspond to the vertices on the node
        for (AffinityGroup g : groups1) {
            assertTrue(g.getId() == 1 || g.getId() == 2);
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

        }
    }

    @Test
    public void testPrepareTwice() throws Exception {
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        lp1.prepareAlgorithm(1);
        lp1.prepareAlgorithm(1);
        int count = 0;
        while (server.readyToBeginCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

        assertEquals(1, server.readyToBeginCount());
    }

    @Test
    public void testIterationTwice() throws Exception {
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        lp1.prepareAlgorithm(1);
        int count = 0;
        while (server.readyToBeginCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        lp1.startIteration(1);
        lp1.startIteration(1);
        count = 0;
        while (server.finishedIterationCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

    }

    // Client test:  run mismatch
    @Test(expected = IllegalArgumentException.class)
    public void testAffinityGroupsRunMismatch() throws Exception {
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        lp1.prepareAlgorithm(1);
        int count = 0;
        while (server.readyToBeginCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        Set<AffinityGroup> groups1 = lp1.getAffinityGroups(2, false);
    }
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

    }

    // Client test: iteration mismatch
    @Test
    public void testIterationMismatch() throws Exception {
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        lp1.prepareAlgorithm(1);
        int count = 0;
        while (server.readyToBeginCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        lp1.startIteration(1);
        count = 0;
        while (server.finishedIterationCount() < 1) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        lp1.startIteration(2);
        count = 0;
        while (server.finishedIterationCount() < 2) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        // this one should be ignored
        lp1.startIteration(1);
        Thread.sleep(50);
        assertEquals(2, server.finishedIterationCount());
    }
View Full Code Here

Examples of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

        assertEquals(2, server.finishedIterationCount());
    }

    @Test
    public void testCrossNodeData() throws Exception {
        LabelPropagation lp1 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
                    wdog, PartialToyBuilder.NODE1, props);
        LabelPropagation lp2 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE2),
                    wdog, PartialToyBuilder.NODE2, props);
        LabelPropagation lp3 =
            new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE3),
                    wdog, PartialToyBuilder.NODE3, props);

        long run = 1;
        lp1.prepareAlgorithm(run);
        lp2.prepareAlgorithm(run);
        lp3.prepareAlgorithm(run);
        // Wait until all 3 callbacks have occurred
        int count = 0;
        while (server.readyToBeginCount() < 3) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }

        // examine the node conflict map -it is public so I can get it here
        assertEquals(2, lp1.getNodeConflictMap().size());
        Set<Long> expected = new HashSet<Long>();
        expected.add(PartialToyBuilder.NODE2);
        expected.add(PartialToyBuilder.NODE3);
        assertTrue(expected.containsAll(lp1.getNodeConflictMap().keySet()));
        Map<Object, Long> map =
                lp1.getNodeConflictMap().get(PartialToyBuilder.NODE2);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj1"));
        map = lp1.getNodeConflictMap().get(PartialToyBuilder.NODE3);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj2"));

        assertEquals(1, lp2.getNodeConflictMap().size());
        map = lp2.getNodeConflictMap().get(PartialToyBuilder.NODE1);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj1"));

        assertEquals(1, lp3.getNodeConflictMap().size());
        map = lp3.getNodeConflictMap().get(PartialToyBuilder.NODE1);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj2"));

        //public Map<Long, Map<Object, Integer>> nodeConflictMap
        System.out.println("NODE1 nodeConflictMap");
        printNodeConflictMap(lp1);
        System.out.println("NODE2 nodeConflictMap");
        printNodeConflictMap(lp2);
        System.out.println("NODE3 nodeConflictMap");
        printNodeConflictMap(lp3);

        // Clear out old information
        lp1.getAffinityGroups(run, true);
        lp2.getAffinityGroups(run, true);
        lp3.getAffinityGroups(run, true);
        server.clear();
        System.out.println("Exchanging info a second time");
        run++;
        lp3.prepareAlgorithm(run);
        lp2.prepareAlgorithm(run);
        lp1.prepareAlgorithm(run);
        // Wait until all 3 callbacks have occurred
        count = 0;
        while (server.readyToBeginCount() < 3) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }

        // examine the node conflict map -it is public so I can get it here
        // Expect same result as above
        assertEquals(2, lp1.getNodeConflictMap().size());
        expected = new HashSet<Long>();
        expected.add(PartialToyBuilder.NODE2);
        expected.add(PartialToyBuilder.NODE3);
        assertTrue(expected.containsAll(lp1.getNodeConflictMap().keySet()));
        map = lp1.getNodeConflictMap().get(PartialToyBuilder.NODE2);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj1"));
        map = lp1.getNodeConflictMap().get(PartialToyBuilder.NODE3);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj2"));

        assertEquals(1, lp2.getNodeConflictMap().size());
        map = lp2.getNodeConflictMap().get(PartialToyBuilder.NODE1);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj1"));

        assertEquals(1, lp3.getNodeConflictMap().size());
        map = lp3.getNodeConflictMap().get(PartialToyBuilder.NODE1);
        assertEquals(1, map.size());
        assertTrue(map.containsKey("obj2"));

        //public Map<Long, Map<Object, Integer>> nodeConflictMap
        System.out.println("NODE1 nodeConflictMap");
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.