예제 #1
0
bool NetworkProfiler::creatSimpleModuleGraph(yarp::profiler::graph::Graph& graph, yarp::profiler::graph::Graph& subgraph) {
    subgraph.clear();
    pvertex_const_iterator itr;
    const pvertex_set& vertices = graph.vertices();
    //insert machines
    for(itr = vertices.begin(); itr!=vertices.end(); itr++) {

        if(!dynamic_cast<MachineVertex*>(*itr))
                continue;
        else
        {
            auto* mv1 = dynamic_cast<MachineVertex*>(*itr);
            if (mv1)
            {
                MachineVertex* mv2 = new MachineVertex(mv1->property.find("os").asString(),
                                                       mv1->property.find("hostname").asString());
                mv2->property = mv1->property;
                subgraph.insert(*mv2);
            }
        }
    }

    for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
        if(!dynamic_cast<ProcessVertex*>(*itr))
            continue;
        auto* pv1 = dynamic_cast<ProcessVertex*>(*itr);
        if (pv1)
        {
            ProcessVertex* pv2 = new ProcessVertex(pv1->property.find("pid").asInt32(),
                                                   pv1->property.find("hostname").asString());
            pv2->property = pv1->property;
            subgraph.insert(*pv2);
        }
    }
    // insert edges
    for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
        if(!dynamic_cast<ProcessVertex*>(*itr))
            continue;
        Vertex* v1 = (*itr);
        const edge_set& outs = v1->outEdges();
        edge_const_iterator eitr;
        for(eitr = outs.begin(); eitr!=outs.end(); eitr++) {
            const Edge& e = (*eitr);
            const Vertex& p1 = e.second();

            const edge_set& pouts = p1.outEdges();
            edge_const_iterator peitr;
            for(peitr = pouts.begin(); peitr!=pouts.end(); peitr++) {
                const Vertex& p2 = (*peitr).second();
                Property prop((*peitr).property);
                string lable = p1.property.find("name").asString();
                lable.append(" - ").append(p2.property.find("name").asString());
                prop.put("lable", lable);
                subgraph.insertEdge(*v1, p2.outEdges()[0].second(), prop);
            }
        }
    }
    return true;
}
예제 #2
0
bool NetworkProfiler::updateConnectionQosStatus(yarp::profiler::graph::Graph& graph) {
    // adding all process nodes and subgraphs
    pvertex_const_iterator itr;
    const pvertex_set& vertices = graph.vertices();

    for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
        const Vertex &v1 = (**itr);
        for(size_t i=0; i<v1.outEdges().size(); i++) {
            Edge& edge = (Edge&) v1.outEdges()[i];
            const Vertex &v2 = edge.second();
            if(!v1.property.check("hidden") && !v2.property.check("hidden")) {
                if(edge.property.find("type").asString() == "connection") {
                    //yInfo()<<v1.property.find("name").asString()<<"->"<<v2.property.find("name").asString()<<lable;
                    yarp::os::QosStyle fromStyle, toStyle;
                    if(yarp::os::NetworkBase::getConnectionQos(v1.property.find("name").asString(),
                                                               v2.property.find("name").asString(), fromStyle, toStyle)) {
                        // source
                        edge.property.put("FromThreadPriority", fromStyle.getThreadPriority());
                        edge.property.put("FromThreadPolicy", fromStyle.getThreadPolicy());
                        edge.property.put("FromPacketPriority", fromStyle.getPacketPriorityAsLevel());
                        edge.property.put("ToThreadPriority", toStyle.getThreadPriority());
                        edge.property.put("ToThreadPolicy", toStyle.getThreadPolicy());
                        edge.property.put("ToPacketPriority", toStyle.getPacketPriorityAsLevel());
                    }
                    else
                        yWarning()<<"Cannot retrive Qos property of"<<v1.property.find("name").asString()<<"->"<<v2.property.find("name").asString();
                }
            }
        }
    }
    return true;
}
예제 #3
0
bool Algorithm::calcSCC(yarp::profiler::graph::Graph& graph, graph_subset &scc) {
    scc.clear();

    // clear corresponding nodes propperties
    pvertex_const_iterator vitr;
    const pvertex_set& vertices = graph.vertices();
    for(vitr = vertices.begin(); vitr!=vertices.end(); vitr++) {
        Vertex* v = (*vitr);
        v->property.unput("onStack");
        v->property.unput("index");
        v->property.unput("lowlink");
    }

    std::stack<Vertex*> S;
    int index = 0;
    for(vitr = vertices.begin(); vitr!=vertices.end(); vitr++) {
        Vertex* v = (*vitr);
        if(!v->property.check("index"))
            strongConnect(v, scc, S, index);
    }
    return true;
}
예제 #4
0
bool NetworkProfiler::creatNetworkGraph(ports_detail_set details, yarp::profiler::graph::Graph& graph) {

    // adding the ports and processor nodes
    if(NetworkProfiler::progCallback)
        NetworkProfiler::progCallback->onProgress(0);

    ports_detail_iterator itr;
    unsigned int itr_count = 0;
    for(itr = details.begin(); itr!=details.end(); itr++) {
        PortDetails info = (*itr);

        // port node
        PortVertex* port = new PortVertex(info.name);
        if(!info.inputs.size() && !info.outputs.size())
            port->property.put("orphan", true);
        graph.insert(*port);

        //process node (owner)
        ProcessVertex* process = new ProcessVertex(info.owner.pid, info.owner.hostname);
        //prop.clear();
        process->property.put("name", info.owner.name);
        process->property.put("arguments", info.owner.arguments);
        process->property.put("hostname", info.owner.hostname);
        process->property.put("priority", info.owner.priority);
        process->property.put("policy", info.owner.policy);
        process->property.put("os", info.owner.os);
        process->property.put("hidden", false);
        pvertex_iterator itrVert=graph.insert(*process);
        // create connection between ports and its process
        if(dynamic_cast<ProcessVertex*> (*itrVert))
            port->setOwner((ProcessVertex*)(*itrVert));



        //machine node (owner of the process)
        MachineVertex* machine = new MachineVertex(info.owner.os, info.owner.hostname);
        graph.insert(*machine);
        //todo do the same done for the process.
        process->setOwner(machine);

        if(!info.inputs.size() && !info.outputs.size())
            graph.insertEdge(*process, *port, Property("(type ownership) (dir unknown)"));

        // calculate progress
        if(NetworkProfiler::progCallback) {
            NetworkProfiler::progCallback->onProgress((unsigned int) (++itr_count/((float)(details.size()*2)) * 100.0) );
        }
    }


    // create connection between ports
    for(itr = details.begin(); itr!=details.end(); itr++) {
        PortDetails info = (*itr);
        // find the current port vertex in the graph
        pvertex_iterator vi1 = graph.find(PortVertex(info.name));
        yAssert(vi1 != graph.vertices().end());
        for(size_t i=0; i<info.outputs.size(); i++) {
            ConnectionInfo cnn = info.outputs[i];
            pvertex_iterator vi2 = graph.find(PortVertex(cnn.name));
            if(vi2 != graph.vertices().end()) {
                //yInfo()<<"connecting "<<(*vi1)->property.find("name").asString()<<"->"<<(*vi2)->property.find("name").asString();
                Property edge_prop("(type connection)");
                edge_prop.put("carrier", cnn.carrier);
                graph.insertEdge(vi1, vi2, edge_prop);
            }
            else
                yWarning()<<"Found a nonexistent port ("<<cnn.name<<")"<<"in the output list of"<<(*vi1)->property.find("name").asString();
        }
        // calculate progress
        if(NetworkProfiler::progCallback) {
            NetworkProfiler::progCallback->onProgress((unsigned int) (++itr_count/((float)(details.size()*2)) * 100.0) );
        }
    }
    if(NetworkProfiler::progCallback)
        NetworkProfiler::progCallback->onProgress(100); // is it really needed? :p
    return true;
}