Package com.sun.sgs.impl.service.nodemap.affinity.dlpa

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


                       String.valueOf(serverPort));
            props.put("com.sun.sgs.impl.service.nodemap.affinity.numThreads",
                    String.valueOf(numThreads));
            server = new LabelPropagationServer(collector, wdog, props);

            LabelPropagation lp1 =
                new LabelPropagation(
                    new DistributedZachBuilder(DistributedZachBuilder.NODE1),
                        wdog, DistributedZachBuilder.NODE1, props);
            LabelPropagation lp2 =
                new LabelPropagation(
                    new DistributedZachBuilder(DistributedZachBuilder.NODE2),
                        wdog, DistributedZachBuilder.NODE2, props);
            LabelPropagation lp3 =
                new LabelPropagation(
                    new DistributedZachBuilder(DistributedZachBuilder.NODE3),
                        wdog, DistributedZachBuilder.NODE3, props);
        }

        for (int i = 0; i < WARMUP_RUNS; i++) {
View Full Code Here


                new LabelPropagationServer(collector, wdog, props);
        props.put("com.sun.sgs.impl.service.nodemap.affinity.numThreads",
                    String.valueOf(numThreads));
        props.put(LPADriver.GRAPH_CLASS_PROPERTY, builderName);

        LabelPropagation lp1 =
            new LabelPropagation(
                new DistributedZachBuilder(DistributedZachBuilder.NODE1),
                    wdog, DistributedZachBuilder.NODE1, props);
        LabelPropagation lp2 =
            new LabelPropagation(
                new DistributedZachBuilder(DistributedZachBuilder.NODE2),
                    wdog, DistributedZachBuilder.NODE2, props);
        LabelPropagation lp3 =
            new LabelPropagation(
                new DistributedZachBuilder(DistributedZachBuilder.NODE3),
                    wdog, DistributedZachBuilder.NODE3, props);

        AffinityGroupFinderMXBean bean = (AffinityGroupFinderMXBean)
            collector.getRegisteredMBean(AffinityGroupFinderMXBean.MXBEAN_NAME);
View Full Code Here

        // These match the ones from the partial toy builder
        Identity id1 = new DummyIdentity("1");
        Identity id2 = new DummyIdentity("2");
        Identity id3 = new DummyIdentity("3");
        Identity id4 = new DummyIdentity("4");
        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);
        lp1.prepareAlgorithm(1);
        lp2.prepareAlgorithm(1);
        lp3.prepareAlgorithm(1);
        int count = 0;
        while (server.readyToBeginCount() < 3) {
            Thread.sleep(5);
            if (++count > MAX_SLEEP_COUNT) {
                fail("Too much time sleeping");
            }
        }
        Set<Object> objIds = new HashSet<Object>();
        objIds.add("obj1");
        objIds.add("obj2");

        Map<Object, Map<Integer, List<Long>>> labelMap =
                lp1.getRemoteLabels(objIds);
        assertEquals(2, labelMap.size());
        assertTrue(labelMap.keySet().equals(objIds));
        Map<Integer, List<Long>> obj1Map = labelMap.get("obj1");
        assertEquals(2, obj1Map.size());
        for (Integer label : obj1Map.keySet()) {
            assertTrue(label.equals(1) || label.equals(2));
        }
        // Check returned weights
        List<Long> oneWeightList = obj1Map.get(1);
        assertEquals(1, oneWeightList.size());
        for (Long weight : oneWeightList) {
            assertEquals(2, weight.intValue());
        }
        List<Long> twoWeightList = obj1Map.get(2);
        assertEquals(1, twoWeightList.size());
        for (Long weight : twoWeightList) {
            assertEquals(2, weight.intValue());
        }
        Map<Integer, List<Long>> obj2Map = labelMap.get("obj2");
        assertEquals(1, obj2Map.size());
        for (Integer label : obj2Map.keySet()) {
            assertTrue(label.equals(2));
        }
        twoWeightList = obj2Map.get(2);
        assertEquals(1, twoWeightList.size());
        for (Long weight : twoWeightList) {
            assertEquals(1, weight.intValue());
        }


        // Call the private implementation to update the remote label
        // maps, and check it.  We do this, rather than running an iteration,
        // because we don't want the labels to change.
        Method updateRemoteLabelsMethod =
            UtilReflection.getMethod(LabelPropagation.class,
                                     "updateRemoteLabels");

        updateRemoteLabelsMethod.invoke(lp1);
        updateRemoteLabelsMethod.invoke(lp2);
        updateRemoteLabelsMethod.invoke(lp3);

        // node 1
        ConcurrentMap<Identity, Map<Integer, Long>> rlm =
                lp1.getRemoteLabelMap();
        assertEquals(2, rlm.size());
        for (Identity id : rlm.keySet()) {
            assertTrue (id.equals(id1) || id.equals(id2));
        }
        Map<Integer, Long> labelWeight = rlm.get(id1);
        assertEquals(1, labelWeight.size());
        Long weight = labelWeight.get(3);
        assertTrue(weight != null);
        assertEquals(1, weight.intValue());

        labelWeight = rlm.get(id2);
        assertEquals(2, labelWeight.size());
        weight = labelWeight.get(3);
        assertTrue(weight != null);
        assertEquals(1, weight.intValue());
        weight = labelWeight.get(4);
        assertTrue(weight != null);
        assertEquals(1, weight.intValue());

        // node 2
        rlm = lp2.getRemoteLabelMap();
        assertEquals(1, rlm.size());
        for (Identity id : rlm.keySet()) {
            assertEquals(id3, id);
        }
        labelWeight = rlm.get(id3);
        assertEquals(2, labelWeight.size());
        weight = labelWeight.get(1);
        assertTrue(weight != null);
        assertEquals(1, weight.intValue());
        weight = labelWeight.get(2);
        assertTrue(weight != null);
        assertEquals(1, weight.intValue());

        // node 3
        rlm = lp3.getRemoteLabelMap();
        assertEquals(1, rlm.size());
        for (Identity id : rlm.keySet()) {
            assertEquals(id4, id);
        }
        labelWeight = rlm.get(id4);
View Full Code Here

            stats = null;
        } else if (type == NodeType.appNode) {
            lpaServer = null;
            DataService dataService = txnProxy.getService(DataService.class);
            long nodeId = dataService.getLocalNodeId();
            lpa = new LabelPropagation(this, wdog, nodeId, properties);

            // TODO: Register ourselves with the data servce as a listener
            // for conflict info.

            // Create our JMX MBean
View Full Code Here

            pruneTask = null;
        } else if (type == NodeType.appNode) {
            lpaServer = null;
            DataService dataService = txnProxy.getService(DataService.class);
            long nodeId = dataService.getLocalNodeId();      
            lpa = new LabelPropagation(this, wdog, nodeId, properties);

            // TODO: Register ourselves with the data servce as a listener
            // for conflict info.

            // Create our JMX MBean
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.service.nodemap.affinity.dlpa.LabelPropagation

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.