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

Examples of com.sun.sgs.impl.service.nodemap.affinity.graph.WeightedEdge


        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]);
        graph.addEdge(new WeightedEdge(), nodes[4], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[4], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[4], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[5], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[6], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[7], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[7], nodes[5]);
        graph.addEdge(new WeightedEdge(), nodes[7], nodes[6]);
        graph.addEdge(new WeightedEdge(), nodes[8], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[8], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[8], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[8], nodes[4]);
        graph.addEdge(new WeightedEdge(), nodes[9], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[9], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[10], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[11], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[11], nodes[5]);
        graph.addEdge(new WeightedEdge(), nodes[11], nodes[6]);
        graph.addEdge(new WeightedEdge(), nodes[12], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[13], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[13], nodes[4]);
        graph.addEdge(new WeightedEdge(), nodes[14], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[14], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[14], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[14], nodes[4]);
        graph.addEdge(new WeightedEdge(), nodes[17], nodes[6]);
        graph.addEdge(new WeightedEdge(), nodes[17], nodes[7]);
        graph.addEdge(new WeightedEdge(), nodes[18], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[18], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[20], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[20], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[22], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[22], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[26], nodes[24]);
        graph.addEdge(new WeightedEdge(), nodes[26], nodes[25]);
        graph.addEdge(new WeightedEdge(), nodes[28], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[28], nodes[24]);
        graph.addEdge(new WeightedEdge(), nodes[28], nodes[25]);
        graph.addEdge(new WeightedEdge(), nodes[29], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[30], nodes[24]);
        graph.addEdge(new WeightedEdge(), nodes[30], nodes[27]);
        graph.addEdge(new WeightedEdge(), nodes[31], nodes[2]);
        graph.addEdge(new WeightedEdge(), nodes[31], nodes[9]);
        graph.addEdge(new WeightedEdge(), nodes[32], nodes[1]);
        graph.addEdge(new WeightedEdge(), nodes[32], nodes[25]);
        graph.addEdge(new WeightedEdge(), nodes[32], nodes[26]);
        graph.addEdge(new WeightedEdge(), nodes[32], nodes[29]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[3]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[9]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[15]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[16]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[19]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[21]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[23]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[24]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[30]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[31]);
        graph.addEdge(new WeightedEdge(), nodes[33], nodes[32]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[9]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[10]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[14]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[15]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[16]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[19]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[20]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[21]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[23]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[24]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[27]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[28]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[29]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[30]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[31]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[32]);
        graph.addEdge(new WeightedEdge(), nodes[34], nodes[33]);
        Assert.assertEquals(34, graph.getVertexCount());
        Assert.assertEquals(78, graph.getEdgeCount());

        return graph;
    }
View Full Code Here


                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]);
            graph.addEdge(new WeightedEdge(), nodes[2], nodes[3]);
            graph.addEdge(new WeightedEdge(), nodes[2], nodes[4]);
            graph.addEdge(new WeightedEdge(), nodes[4], nodes[5]);

            Assert.assertEquals(5, graph.getVertexCount());
            Assert.assertEquals(5, graph.getEdgeCount());
            return graph;
        }
View Full Code Here

                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]);
            graph.addEdge(new WeightedEdge(2), nodes[2], nodes[3]);
            graph.addEdge(new WeightedEdge(2), nodes[2], nodes[4]);
            graph.addEdge(new WeightedEdge(2), nodes[4], nodes[5]);

            Assert.assertEquals(5, graph.getVertexCount());
            Assert.assertEquals(5, graph.getEdgeCount());
            return graph;
        }
View Full Code Here

            synchronized (bipartiteGraph) {
                // For each modified edge in the graph, update weights
                for (Map.Entry<WeightedEdge, Integer> entry :
                     periodEdgeIncrements.entrySet())
                {
                    WeightedEdge edge = entry.getKey();
                    int weight = entry.getValue();
                    if (edge.getWeight() == weight) {
                        Pair<Object> endpts = bipartiteGraph.getEndpoints(edge);
                        bipartiteGraph.removeEdge(edge);
                        for (Object end : endpts) {
                            if (bipartiteGraph.degree(end) == 0) {
                                bipartiteGraph.removeVertex(end);
                            }
                        }
                    } else {
                        edge.addWeight(-weight);
                    }
                }
            }

            // For each conflict, update values
View Full Code Here

            }
            // Obj uses
            Map<Identity, Long> tempMap = new HashMap<Identity, Long>();
            if (node == NODE1) {
                // Update edges
                graph.addEdge(new WeightedEdge(), nodes[4], nodes[1]);
                graph.addEdge(new WeightedEdge(), nodes[7], nodes[1]);
                graph.addEdge(new WeightedEdge(), nodes[13], nodes[1]);
                graph.addEdge(new WeightedEdge(), nodes[13], nodes[4]);
                graph.addEdge(new WeightedEdge(), nodes[22], nodes[1]);
                graph.addEdge(new WeightedEdge(), nodes[28], nodes[25]);
                graph.addEdge(new WeightedEdge(), nodes[34], nodes[10]);
                graph.addEdge(new WeightedEdge(), nodes[34], nodes[16]);
                graph.addEdge(new WeightedEdge(), nodes[34], nodes[19]);
                graph.addEdge(new WeightedEdge(), nodes[34], nodes[28]);
                graph.addEdge(new WeightedEdge(), nodes[34], nodes[31]);

                // Obj uses
                tempMap.put(idents[1], 1L);
                tempMap.put(idents[4], 4L);
                objUseMap.put("o1", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                tempMap.put(idents[7], 1L);
                objUseMap.put("o2", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o3", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[7], 1L);
                objUseMap.put("o4", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o5", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o84", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[4], 1L);
                objUseMap.put("o87", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[10], 1L);
                objUseMap.put("o7", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o8", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o11", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                tempMap.put(idents[13], 1L);
                objUseMap.put("o12", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[4], 1L);
                tempMap.put(idents[13], 1L);
                objUseMap.put("o13", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[7], 1L);
                objUseMap.put("o15", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o16", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o18", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[22], 1L);
                tempMap.put(idents[1], 1L);
                objUseMap.put("o20", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[22], 1L);
                objUseMap.put("o21", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[25], 1L);
                objUseMap.put("o23", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[28], 1L);
                objUseMap.put("o24", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[28], 1L);
                objUseMap.put("o25", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[28], 1L);
                tempMap.put(idents[25], 1L);
                objUseMap.put("o26", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[31], 1L);
                objUseMap.put("o30", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[31], 1L);
                tempMap.put(idents[34], 1L);
                objUseMap.put("o31", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[1], 1L);
                objUseMap.put("o32", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[16], 1L);
                objUseMap.put("o35", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[19], 1L);
                objUseMap.put("o36", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                tempMap.put(idents[10], 1L);
                objUseMap.put("o40", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o41", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o42", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                tempMap.put(idents[16], 1L);
                objUseMap.put("o43", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                tempMap.put(idents[19], 1L);
                objUseMap.put("o44", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o45", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o46", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o47", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o48", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o49", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                tempMap.put(idents[28], 1L);
                objUseMap.put("o50", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o51", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o52", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[34], 1L);
                objUseMap.put("o53", tempMap);


                // conflicts - data cache evictions due to conflict
                // just guessing
                HashMap<Object, Long> conflict = new HashMap<Object, Long>();;
                conflict.put("o1", 1L);
                conflict.put("o2", 1L);
                conflict.put("o18", 1L);
                conflict.put("o21", 1L);
                conflict.put("o41", 1L);
                conflict.put("o45", 1L);
                conflict.put("o47", 1L);
                conflictMap.put(NODE2, conflict);
                conflict = new HashMap<Object, Long>();
                conflict.put("o1", 1L);
                conflict.put("o5", 1L);
                conflict.put("o7", 1L);
                conflict.put("o11", 1L);
                conflict.put("o31", 1L);
                conflict.put("o35", 1L);
                conflict.put("o36", 1L);
                conflict.put("o42", 1L);
                conflict.put("o46", 1L);
                conflict.put("o48", 1L);
                conflict.put("o49", 1L);
                conflictMap.put(NODE3, conflict);
            } else if (node == NODE2) {
                graph.addEdge(new WeightedEdge(), nodes[8], nodes[2]);
                graph.addEdge(new WeightedEdge(), nodes[11], nodes[5]);
                graph.addEdge(new WeightedEdge(), nodes[14], nodes[2]);
                graph.addEdge(new WeightedEdge(), nodes[20], nodes[2]);
                graph.addEdge(new WeightedEdge(), nodes[32], nodes[26]);
                graph.addEdge(new WeightedEdge(), nodes[32], nodes[29]);

                // Obj uses
                tempMap.put(idents[2], 1L);
                tempMap.put(idents[8], 1L);
                objUseMap.put("o1", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[14], 1L);
                objUseMap.put("o84", tempMap);
                tempMap.put(idents[2], 1L);
                tempMap.put(idents[14], 1L);
                objUseMap.put("o85", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[14], 1L);
                objUseMap.put("o86", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[14], 1L);
                objUseMap.put("o87", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[5], 1L);
                objUseMap.put("o2", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[11], 1L);
                objUseMap.put("o8", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[11], 1L);
                tempMap.put(idents[5], 1L);
                objUseMap.put("o9", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[11], 1L);
                objUseMap.put("o10", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[17], 1L);
                objUseMap.put("o14", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[17], 1L);
                objUseMap.put("o15", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[2], 1L);
                objUseMap.put("o17", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[20], 1L);
                objUseMap.put("o18", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[20], 1L);
                tempMap.put(idents[2], 1L);
                objUseMap.put("o19", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[2], 1L);
                objUseMap.put("o21", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[26], 1L);
                objUseMap.put("o22", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[26], 1L);
                tempMap.put(idents[32], 1L);
                objUseMap.put("o23", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[29], 1L);
                objUseMap.put("o27", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[2], 1L);
                objUseMap.put("o30", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[32], 1L);
                tempMap.put(idents[29], 1L);
                objUseMap.put("o66", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[32], 1L);
                objUseMap.put("o32", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[23], 1L);
                objUseMap.put("o38", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[32], 1L);
                objUseMap.put("o39", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[14], 1L);
                objUseMap.put("o41", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[20], 1L);
                objUseMap.put("o45", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[23], 1L);
                objUseMap.put("o47", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[29], 1L);
                objUseMap.put("o51", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[32], 1L);
                objUseMap.put("o53", tempMap);


                // conflicts - data cache evictions due to conflict
                // just guessing
                HashMap<Object, Long> conflict = new HashMap<Object, Long>();
                conflict.put("o2", 1L);
                conflict.put("o8", 1L);
                conflict.put("o15", 1L);
                conflict.put("o23", 1L);
                conflict.put("o30", 1L);
                conflict.put("o32", 1L);
                conflict.put("o51", 1L);
                conflict.put("o53", 1L);
                conflict.put("o84", 1L);
                conflict.put("o87", 1L);
                conflictMap.put(NODE1, conflict);
                conflict = new HashMap<Object, Long>();
                conflict.put("o1", 1L);
                conflict.put("o10", 1L);
                conflict.put("o14", 1L);
                conflict.put("o22", 1L);
                conflict.put("o86", 1L);
                conflictMap.put(NODE3, conflict);
            } else if (node == NODE3) {
                graph.addEdge(new WeightedEdge(), nodes[9], nodes[3]);
                graph.addEdge(new WeightedEdge(), nodes[30], nodes[24]);
                graph.addEdge(new WeightedEdge(), nodes[30], nodes[27]);
                graph.addEdge(new WeightedEdge(), nodes[33], nodes[3]);
                graph.addEdge(new WeightedEdge(), nodes[33], nodes[9]);
                graph.addEdge(new WeightedEdge(), nodes[33], nodes[15]);
                graph.addEdge(new WeightedEdge(), nodes[33], nodes[21]);
                graph.addEdge(new WeightedEdge(), nodes[33], nodes[24]);
                graph.addEdge(new WeightedEdge(), nodes[33], nodes[30]);

                tempMap.put(idents[3], 1L);
                objUseMap.put("o1", tempMap);
                tempMap = new HashMap<Identity, Long>();
                tempMap.put(idents[3], 1L);
View Full Code Here

            LabelVertex[] nodes = new LabelVertex[2];
            for (int i = 0; i < nodes.length; i++) {
                nodes[i] = new LabelVertex(idents[i]);
                graph.addVertex(nodes[i]);
            }
            graph.addEdge(new WeightedEdge(2), nodes[0], nodes[1]);

        } else if (node == PartialToyBuilder.NODE2) {
            // Create a partial graph
            Identity ident = new DummyIdentity("3");
            LabelVertex ver = new LabelVertex(ident);
            graph.addVertex(ver);

        } else if (node == PartialToyBuilder.NODE3) {
            Identity[] idents = {new DummyIdentity("4"),
                                 new DummyIdentity("5")};
            LabelVertex[] nodes = new LabelVertex[2];
            for (int i = 0; i < nodes.length; i++) {
                nodes[i] = new LabelVertex(idents[i]);
                graph.addVertex(nodes[i]);
            }
            graph.addEdge(new WeightedEdge(), nodes[0], nodes[1]);
        }
        return Graphs.unmodifiableUndirectedGraph(graph);
    }
View Full Code Here

                    // edge if the identity isn't the owner
                    if (!ident.equals(owner)) {
                        LabelVertex vident = addOrGetVertex(ident);
                        // Check to see if we already have an edge between
                        // the two vertices.  If so, update its weight.
                        WeightedEdge edge =
                                affinityGraph.findEdge(vowner, vident);
                        if (edge == null) {
                            WeightedEdge newEdge = new WeightedEdge();
                            affinityGraph.addEdge(newEdge, vowner, vident);
                            // period info
                            pruneTask.incrementEdge(newEdge);
                        } else {
                            if (currentVal <= entry.getValue()) {
View Full Code Here

            synchronized (affinityGraph) {
                // For each modified edge in the graph, update weights
                for (Map.Entry<WeightedEdge, Integer> entry :
                     periodEdgeIncrements.entrySet())
                {
                    WeightedEdge edge = entry.getKey();
                    int weight = entry.getValue();
                    if (edge.getWeight() == weight) {
                        Pair<LabelVertex> endpts =
                                affinityGraph.getEndpoints(edge);
                        affinityGraph.removeEdge(edge);
                        for (LabelVertex end : endpts) {
                            if (affinityGraph.degree(end) == 0) {
                                affinityGraph.removeVertex(end);
                                identMap.remove(end.getIdentity());
                            }
                        }
                    } else {
                        edge.addWeight(-weight);
                    }
                }
            }

            stats.processingTimeInc(System.currentTimeMillis() - startTime);
View Full Code Here

                    // edge if the identity isn't the owner
                    if (!ident.equals(owner)) {
                        LabelVertex vident = addOrGetVertex(ident);
                        // Check to see if we already have an edge between
                        // the two vertices.  If so, update its weight.
                        WeightedEdge edge =
                                affinityGraph.findEdge(vowner, vident);
                        if (edge == null) {
                            WeightedEdge newEdge = new WeightedEdge();
                            affinityGraph.addEdge(newEdge, vowner, vident);
                            // period info
                            pruneTask.incrementEdge(newEdge);
                        } else {
                            if (currentVal <= entry.getValue()) {
View Full Code Here

            synchronized (affinityGraph) {
                // For each modified edge in the graph, update weights
                for (Map.Entry<WeightedEdge, Integer> entry :
                     periodEdgeIncrements.entrySet())
                {
                    WeightedEdge edge = entry.getKey();
                    int weight = entry.getValue();
                    if (edge.getWeight() == weight) {
                        Pair<LabelVertex> endpts =
                                affinityGraph.getEndpoints(edge);
                        affinityGraph.removeEdge(edge);
                        for (LabelVertex end : endpts) {
                            if (affinityGraph.degree(end) == 0) {
                                affinityGraph.removeVertex(end);
                                identMap.remove(end.getIdentity());
                            }
                        }
                    } else {
                        edge.addWeight(-weight);
                    }
                }
            }

            // For each conflict, update values
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.service.nodemap.affinity.graph.WeightedEdge

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.