#include "workflow_graph.hpp" #include "cxios.hpp" namespace xios { std::vector *CWorkflowGraph::vectorOfNodes_ = 0; std::vector *CWorkflowGraph::vectorOfEdges_ = 0; std::vector *CWorkflowGraph::vectorOfContexts_ = 0; std::vector *CWorkflowGraph::vectorOfNodes_srv_ = 0; std::vector *CWorkflowGraph::vectorOfEdges_srv_ = 0; std::vector *CWorkflowGraph::vectorOfContexts_srv_ = 0; bool CWorkflowGraph::clientGraphBuilt = false; bool CWorkflowGraph::serverGraphBuilt = false; bool CWorkflowGraph::build_begin = false; std::unordered_map *CWorkflowGraph::mapHashFilterID_ = 0; std::unordered_map *CWorkflowGraph::mapHashFilterID_srv_ = 0; CWorkflowGraph::CWorkflowGraph() { } //****************************************************** void CWorkflowGraph::outputWorkflowGraph_client_stdout() { std::cout<<"\n\nbuild workflow graph ..."<size(); i++) { std::cout<<"Node["<size(); i++) { std::cout<<"Edge["<size(); i++) { info(100)<<"Node["<size(); i++) { info(100)<<"Edge["<; std::string currentContextId = CContext::getCurrent()->getId(); graph_edge_object edge_obj; edge_obj.from = from; edge_obj.to = to; edge_obj.date = packet->date; edge_obj.timestamp = packet->timestamp; edge_obj.field = packet->graphPackage->currentField; edge_obj.show = true; if(vectorOfNodes_->at(from).filter_class == 2) // from pass through filter { edge_obj.label_info = vectorOfNodes_->at(from).label_field_id; } if(vectorOfNodes_->at(to).filter_class == 3) // to temporal filter { vectorOfNodes_->at(to).expected_entry_nb++; } for(int i=0; isize(); i++) { if(vectorOfContexts_->at(i) == currentContextId) { edge_obj.context = i; edge_obj.context_id = currentContextId; break; } } edge_obj.attributes = packet->graphPackage->currentField->recordXiosAttributes(); vectorOfEdges_->push_back(edge_obj); //info(100)<<"****************** Add Edge from "<at(from).filter_filled = true; } else { if(!vectorOfEdges_srv_) vectorOfEdges_srv_ = new std::vector; std::string currentContextId = CContext::getCurrent()->getId(); graph_edge_object edge_obj; edge_obj.from = from; edge_obj.to = to; edge_obj.date = packet->date; edge_obj.timestamp = packet->timestamp; edge_obj.field = packet->graphPackage->currentField; edge_obj.show = true; for(int i=0; isize(); i++) { if(vectorOfContexts_srv_->at(i) == currentContextId) { edge_obj.context = i; edge_obj.context_id = currentContextId; break; } } edge_obj.attributes = packet->graphPackage->currentField->recordXiosAttributes(); vectorOfEdges_srv_->push_back(edge_obj); //info(100)<<"****************** Server side : Add Edge from "<at(from).filter_filled = true; } } CATCH void CWorkflowGraph::addNode(StdString filterName, int filterClass, bool filterFilled, int entryNb, CDataPacketPtr packet) TRY { if(CXios::isClient) { //if(vectorOfEdges_&&vectorOfNodes_) outputWorkflowGraph_client_stdout(); // std::cout<<"Trying to add a node naming "<; if(!vectorOfContexts_) vectorOfContexts_ = new std::vector; if(!mapHashFilterID_) mapHashFilterID_ = new std::unordered_map ; std::string currentContextId = CContext::getCurrent()->getId(); if ( std::find(vectorOfContexts_->begin(), vectorOfContexts_->end(), currentContextId) == vectorOfContexts_->end() ) vectorOfContexts_->push_back(currentContextId); graph_node_object node_obj; node_obj.filter_name = filterName; node_obj.filter_class = filterClass; node_obj.filter_filled = filterFilled; node_obj.expected_entry_nb = entryNb; node_obj.date = packet->date; node_obj.timestamp = packet->timestamp; for(int i=0; isize(); i++) { if(vectorOfContexts_->at(i) == currentContextId) { node_obj.context = i; node_obj.context_id = currentContextId; break; } } node_obj.attributes = packet->graphPackage->currentField->recordXiosAttributes(); vectorOfNodes_->push_back(node_obj); } else { if(!vectorOfNodes_srv_) vectorOfNodes_srv_ = new std::vector; if(!vectorOfContexts_srv_) vectorOfContexts_srv_ = new std::vector; if(!mapHashFilterID_srv_) mapHashFilterID_srv_ = new std::unordered_map ; std::string currentContextId = CContext::getCurrent()->getId(); if ( std::find(vectorOfContexts_srv_->begin(), vectorOfContexts_srv_->end(), currentContextId) == vectorOfContexts_srv_->end() ) vectorOfContexts_srv_->push_back(currentContextId); graph_node_object node_obj; node_obj.filter_name = filterName; node_obj.filter_class = filterClass; node_obj.filter_filled = filterFilled; node_obj.expected_entry_nb = entryNb; node_obj.date = packet->date; node_obj.timestamp = packet->timestamp; for(int i=0; isize(); i++) { if(vectorOfContexts_srv_->at(i) == currentContextId) { node_obj.context = i; node_obj.context_id = currentContextId; break; } } node_obj.attributes = packet->graphPackage->currentField->recordXiosAttributes(); vectorOfNodes_srv_->push_back(node_obj); } } CATCH int CWorkflowGraph::getNodeSize() TRY { if(CXios::isClient) { return !vectorOfNodes_? 0 : vectorOfNodes_->size(); } else { return !vectorOfNodes_srv_? 0 : vectorOfNodes_srv_->size(); } } CATCH void CWorkflowGraph::outputWorkflowGraph_client() { int graph_rank; MPI_Comm_rank(MPI_COMM_WORLD, &graph_rank); std::ofstream *outfiles; outfiles = new std::ofstream[vectorOfContexts_->size()]; for(int ctx=0; ctxsize(); ctx++) { StdString graphFileName="graph_data_"+vectorOfContexts_->at(ctx)+"_client_"+to_string(graph_rank)+".json"; outfiles[ctx].open(graphFileName); outfiles[ctx] << "{\"nodes\":["<size(); i++) { int ctx = vectorOfNodes_->at(i).context; if(i!=0) outfiles[ctx] << ","; outfiles[ctx] << "{\"id\":"<at(i).filter_name<<"\","<at(i).filter_class<<","<at(i).filter_filled)<<","<at(i).context_id<<"\","<at(i).expected_entry_nb<<"\","<at(i).attributes<<"\","<size(); ctx++) { outfiles[ctx] << std::endl<<"],"<size(); i++) { int ctx = vectorOfEdges_->at(i).context; if(i!=0) outfiles[ctx] << ","; outfiles[ctx] << "{\"id\":"<at(i).from<<","<at(i).to<<","<at(i).label_info != "none") { if(vectorOfEdges_->at(i).show) outfiles[ctx] << "\"label\":"<<"\""<at(i).label_info<<"\\n"<at(i).date<<"\","<at(i).date<<"\","<at(i).show) outfiles[ctx] << "\"label\":"<<"\""<at(i).field->getId()<<"\\n"<at(i).date<<"\","<at(i).date<<"\","<at(i).context_id<<"\","<at(i).attributes<<"\","<at(i).date<<"\"}"<size(); ctx++) { outfiles[ctx] << std::endl<<"]}"<size()]; for(int ctx=0; ctxsize(); ctx++) { StdString graphFileName="graph_data_"+vectorOfContexts_srv_->at(ctx)+"_client_"+to_string(graph_rank)+".json"; outfiles[ctx].open(graphFileName); outfiles[ctx] << "{\"nodes\":["<size(); i++) { int ctx = vectorOfNodes_srv_->at(i).context; if(i!=0) outfiles[ctx] << ","; outfiles[ctx] << "{\"id\":"<at(i).filter_name<<"\","<at(i).filter_class<<","<at(i).filter_filled)<<","<at(i).context_id<<"\","<at(i).expected_entry_nb<<"\","<at(i).attributes<<"\","<size(); ctx++) { outfiles[ctx] << std::endl<<"],"<size(); i++) { int ctx = vectorOfEdges_srv_->at(i).context; if(i!=0) outfiles[ctx] << ","; outfiles[ctx] << "{\"id\":"<at(i).from<<","<at(i).to<<","<at(i).show) outfiles[ctx] << "\"label\":"<<"\""<at(i).field->getId()<<"\\n"<at(i).date<<"\","<at(i).date<<"\","<at(i).context_id<<"\","<at(i).attributes<<"\","<at(i).date<<"\"}"<size(); ctx++) { outfiles[ctx] << std::endl<<"]}"<