void perBeadStateMaskClass::init(BkgModelWorkInfo* pBase_bkinfo) { // assert if known memory type assert(memTypeHost() || memTypeDevice()); if(memTypeHost()) { initHost(pBase_bkinfo); } else { perBeadStateMaskClass tmpHostBeadStateMask(getParams(), HostMem); tmpHostBeadStateMask.initHost(pBase_bkinfo); this->copy(tmpHostBeadStateMask); } }
void perBeadPolyClonalCubeClass::init(BkgModelWorkInfo* pBase_bkinfo) { // assert if known memory type assert(memTypeHost() || memTypeDevice()); if(memTypeHost()) { initHost(pBase_bkinfo); } else { perBeadPolyClonalCubeClass tmpHostPolyClonalCube(getParams(), HostMem); tmpHostPolyClonalCube.initHost(pBase_bkinfo); this->copy(tmpHostPolyClonalCube); } }
/* * 函数名 : process_XML2_Node * 功能 : 处理XML2每个节点获取相关值 * 传入参数 : xmlTextReaderPtr reader,int *pmcount,int *vmcount,int *grcount,int *frcount * 参数reader : XML读入的数据内容 * 参数pmcount : 物理机个数 * 参数vmcount : 虚拟机的数量 * 参数grcount : 物理机组的个数 * 参数frcount : 框的个数 * 返回值 : 无 * @created by 陈建海 in 2013.5.12 */ void process_XML2_Node(xmlTextReaderPtr reader, int *pmcount,int *vmcount, int *grcount,int *frcount) { xmlChar *name, *att; char *endptr,iput[20]; int rr,nt; double aValue; framePtr p_fr; pmPtr p_pm; vmPtr p_vm; pmgPtr p_pmg; cls_st_host hs; int kk=-1,ll=-1,ff=-1,gg=-1;//用kk记录物理机的索引值 kk=*pmcount; ll=*vmcount; ff=*frcount; gg=*grcount; name = xmlTextReaderName(reader); if (name == NULL) name = xmlStrdup(BAD_CAST "--"); nt=xmlTextReaderNodeType(reader); /*如果元素名称是FRAME,则获取属性ID,NAME, PMIDS等值*/ if (xmlStrcmp(name, (const xmlChar *) "FRAME")==0) { if(nt==XML_READER_TYPE_ELEMENT) { ff++; p_fr=&_xpthis->sd->framelist[ff]; p_fr->id=ff;//置序号 //获取框的SID getstr_attrib(reader,"ID",p_fr->sid); //获取框的所有物理机ID getstr_attrib(reader,"PMIDS",p_fr->pmids); } } /*如果元素名称是GROUP,则获取属性ID,NAME, PMIDS等值*/ if (xmlStrcmp(name, (const xmlChar *) "GROUP")==0) { if(nt==XML_READER_TYPE_ELEMENT) { gg++; p_pmg =&_xpthis->sd->pmglist[gg]; p_pmg->id=gg;//置序号 /*获取组的SID*/ getstr_attrib(reader,"ID",p_pmg->sid); //获取zu的所有物理机ID getstr_attrib(reader,"PMIDS",p_pmg->pmids); } } /*如果元素名称是PM,则获取属性ID,IP,STAT等值*/ if (xmlStrcmp(name, (const xmlChar *) "PM")==0) { if(nt==XML_READER_TYPE_ELEMENT) { kk++; p_pm=&_xpthis->sd->pmlist[kk]; p_pm->host.id=kk; /*获取PM的SID*/ getstr_attrib(reader,"ID",p_pm->host.sid); /*获取PM的IP*/ getstr_attrib(reader,"IP",p_pm->host.ip); //获取PM状态 p_pm->host.stat=getint_attrib(reader,"STAT"); if(DEBUG) printf("\n----\n"); } //return; } /*如果元素名称是VM,则获取属性ID,IP,STAT等值*/ if (xmlStrcmp(name, (const xmlChar *) "VM")==0) { if(nt==XML_READER_TYPE_ELEMENT) { ll++; p_vm=&_xpthis->sd->vmlist[ll]; p_vm->host.id=ll; //获取主机Id getstr_attrib(reader,"ID",p_vm->host.sid); //获取主机IP getstr_attrib(reader,"IP",p_vm->host.ip); //获取主机的状态 p_vm->host.stat=getint_attrib(reader,"STAT"); //获取VM所在PM att=xmlTextReaderGetAttribute(reader,"AT"); if(att!=NULL) { /*获得的是pm0,需要获取相应的pmid*/ initHost(&hs); hs.sd = _xpthis->sd; p_pm=hs.getpmbysid(att); if(p_pm!=NULL) _xpthis->sd->vmlist[ll].at=p_pm->host.id; if(DEBUG) printf("atpm: %s ",att); } xmlFree(att); if(DEBUG) printf("\n-----\n"); } } /*如果元素名称是METRIC,则获取属性NAME,USED,TOTAL, RESERVED等值*/ if (xmlStrcmp(name, (const xmlChar *) "METRIC")==0) { att=xmlTextReaderGetAttribute(reader,"NAME"); //{ CPU = 0, MEM, DISKIO, FPGA, ETH0, ETH1, ETH2, ETH3 }; rr=0; if(xmlStrcmp(att, (const xmlChar *) "cpu")==0) rr=CPU; else if(xmlStrcmp(att, (const xmlChar *) "mem")==0) rr=MEM; else if(xmlStrcmp(att, (const xmlChar *) "diskio")==0) rr=DISKIO; else if(xmlStrcmp(att, (const xmlChar *) "fpga")==0) rr=FPGA; else if(xmlStrcmp(att, (const xmlChar *) "eth0")==0) rr=ETH0; else if(xmlStrcmp(att, (const xmlChar *) "eth1")==0) rr=ETH1; else if(xmlStrcmp(att, (const xmlChar *) "eth2")==0) rr=ETH2; else if(xmlStrcmp(att, (const xmlChar *) "eth3")==0) rr=ETH3; //get the attribute value metricname if(ll==-1) strcpy(_xpthis->sd->pmlist[kk].host.load[rr].metric_name,att); else strcpy(_xpthis->sd->vmlist[ll].host.load[rr].metric_name,att); if(DEBUG) printf(" %s ",att); xmlFree(att); //get the attribute value used att=xmlTextReaderGetAttribute(reader,"USED"); if(att!=NULL) { //strcpy(iput,att); aValue = strtod(att,&endptr); if(ll==-1)//PM { _xpthis->sd->pmlist[kk].host.load[rr].used=aValue; if(DEBUG) printf("used: %.3f ",_xpthis->sd->pmlist[kk].host.load[rr].used); } else { _xpthis->sd->vmlist[ll].host.load[rr].used=aValue; if(DEBUG) printf("used: %.3f ",_xpthis->sd->vmlist[ll].host.load[rr].used); } } xmlFree(att); //get the attribute value total att=xmlTextReaderGetAttribute(reader,"TOTAL"); if(att!=NULL) { strcpy(iput,att); aValue = strtod(iput,&endptr); if(ll==-1)//PM { _xpthis->sd->pmlist[kk].host.load[rr].total=aValue; if(DEBUG) printf("total: %.3f ",_xpthis->sd->pmlist[kk].host.load[rr].total); } else { _xpthis->sd->vmlist[ll].host.load[rr].total=aValue; if(DEBUG) printf("total: %.3f ",_xpthis->sd->vmlist[ll].host.load[rr].total); } } xmlFree(att); //get the attribute value reserved att=xmlTextReaderGetAttribute(reader,"RESERVED"); if(att!=NULL) { //strcpy(iput,att); aValue = strtod(att,&endptr); if(ll==-1)//PM { _xpthis->sd->pmlist[kk].host.load[rr].reserved=aValue; if(DEBUG) printf("reserved: %.3f ",_xpthis->sd->pmlist[kk].host.load[rr].reserved); } else { _xpthis->sd->vmlist[ll].host.load[rr].reserved=aValue; if(DEBUG) printf("reserved: %.3f ",_xpthis->sd->vmlist[ll].host.load[rr].reserved); } } xmlFree(att); if(DEBUG) printf("\n"); } *pmcount=kk;//set PM count *vmcount=ll; //set VM count *frcount=ff; *grcount=gg; xmlFree(name); }
void process_XML22_Node(xmlTextReaderPtr reader, int *vdcount) { /* handling of a node in the tree */ xmlChar *name, *att; char *endptr; char *strvm[MAX_VM_COUNT_PER_GROUP]; char t_vmids[PMIDS_SIZE]; int nt,k; double aValue; int vd=-1;//用vd记录流量关系的索引值 vd=*vdcount; name = xmlTextReaderName(reader); if (name == NULL) name = xmlStrdup(BAD_CAST "--"); nt=xmlTextReaderNodeType(reader); /*如果元素名称是AFFINITY,则获取属性VMIDS,TRAFFIC,DELAY,TYPE,AT等值*/ if (xmlStrcmp(name, (xmlChar *) "AFFINITY")==0) { if(nt==XML_READER_TYPE_ELEMENT) vd++; //AFFTYPE att=xmlTextReaderGetAttribute(reader,"TYPE"); if(att!=NULL) { aValue = strtod(att,&endptr); _xpthis->sd->v2vlist[vd].affinity=(int)aValue; _xpthis->sd->v2vlist[vd].affinity=(int)aValue; if(DEBUG) printf("type:%3d ",_xpthis->sd->v2vlist[vd].affinity); } xmlFree(att); //TRAFFIC att=xmlTextReaderGetAttribute(reader,"TRAFFIC"); if(att!=NULL) { aValue = strtod(att,&endptr); _xpthis->sd->v2vlist[vd].traffic=aValue; _xpthis->sd->v2vlist[vd].traffic=aValue; printf("TRAFFIC:%5.f ",_xpthis->sd->v2vlist[vd].traffic); } xmlFree(att); //DELAY 时延要求 att=xmlTextReaderGetAttribute(reader,"DELAY"); if(att!=NULL) { aValue = strtod(att,&endptr); _xpthis->sd->v2vlist[vd].delay=aValue; printf("DELAY:%4.f ",_xpthis->sd->v2vlist[vd].delay); } xmlFree(att); //AT att=xmlTextReaderGetAttribute(reader,"AT"); if(att!=NULL) { strcpy(_xpthis->sd->v2vlist[vd].at,att); strcpy(_xpthis->sd->v2vlist[vd].at,att); printf("AT: %6s ",_xpthis->sd->v2vlist[vd].at); } xmlFree(att); /*VMIDS*/ att=xmlTextReaderGetAttribute(reader,"VMIDS"); if(att!=NULL) { strcpy(_xpthis->sd->v2vlist[vd].vmids,att); printf("VMIDS:%s ",_xpthis->sd->v2vlist[vd].vmids); } xmlFree(att); /*从vmids处理得到p_vms*/ { cls_st_host hh; initHost(&hh); hh.sd = _xpthis->sd; strcpy(t_vmids,_xpthis->sd->v2vlist[vd].vmids); _xpthis->sd->v2vlist[vd].countofvm=split_str(t_vmids,",",strvm); for(k=0;k<_xpthis->sd->v2vlist[vd].countofvm;k++) _xpthis->sd->v2vlist[vd].p_vms[k]=hh.getvmbysid(strvm[k]); } att=xmlTextReaderGetAttribute(reader,"SRCID"); if(att!=NULL) { aValue = strtod(att,&endptr); _xpthis->sd->v2vlist[vd].p_src_vm=&_xpthis->sd->vmlist[(int)aValue]; printf("nodetype :%d, id: %d ",nt,_xpthis->sd->v2vlist[vd].p_src_vm->host.id); } xmlFree(att); att=xmlTextReaderGetAttribute(reader,"DSTID"); if(att!=NULL) { aValue = strtod(att,&endptr); _xpthis->sd->v2vlist[vd].p_dst_vm=&_xpthis->sd->vmlist[(int)aValue]; printf("DSTID: %s ",_xpthis->sd->v2vlist[vd].p_dst_vm->host.sid); } xmlFree(att); printf("\n"); //return; } *vdcount=vd;//set v2v count xmlFree(name); }