/** * @brief * sum_resources - for each resource found in the collection of vnodes with * the have "host", the resoruces in resources_available and * resources_assigned are summed. */ static void sum_resources(struct batch_status *pbs, struct batch_status *working, char *hostn, struct consumable *consum, int consumable_size, char * various) { char *curhn; int i; char *val; /* clear sums */ for (i=0; i<consumable_size; ++i) { if ((consum+i)->cons_avail_str) { free((consum+i)->cons_avail_str); (consum+i)->cons_avail_str = NULL; } (consum+i)->cons_avail_sum = 0; (consum+i)->cons_assn_sum = 0; } while (pbs) { curhn = get_resource_value(ATTR_rescavail, "host", pbs->attribs); if (curhn && strcasecmp(curhn, hostn) == 0) { for (i=0; i<consumable_size; ++i) { val = get_resource_value(ATTR_rescavail, (consum+i)->cons_resource, pbs->attribs); sum_a_resource(consum+i, 1, val, various); val = get_resource_value(ATTR_rescassn, (consum+i)->cons_resource, pbs->attribs); sum_a_resource(consum+i, 0, val, various); } } pbs = pbs->next; } }
static void build_host_list(struct batch_status *pbst, struct host_list **phost_list, int *host_list_size, struct consumable **consum, int *consumable_size) { int i; char *hostn; struct host_list *newhl; struct attrl *patl; /* clear existing entries for reuse */ for (i=0; i<*host_list_size; ++i) { ((*phost_list)+i)->hl_name[0] = '\0'; ((*phost_list)+i)->hl_node = NULL; } while (pbst) { /* if need be, add host_list entry for this host */ hostn = get_resource_value(ATTR_rescavail, "host", pbst->attribs); if (hostn) { for (i=0; i<*host_list_size; ++i) { if (strcasecmp(hostn, ((*phost_list)+i)->hl_name) == 0) break; } if (i == *host_list_size) { /* need to add slot for this host */ newhl = (struct host_list *)realloc((*phost_list), sizeof(struct host_list) * (*host_list_size+1)); if (newhl) { *phost_list = newhl; (*host_list_size)++; } else { pbs_errno = PBSE_SYSTEM; return; /* memory allocation failure */ } strcpy(((*phost_list)+i)->hl_name, hostn); ((*phost_list)+i)->hl_node = pbst; } else { ((*phost_list)+i)->hl_node = NULL; /* null for multiple */ } } /* now look to see what resources are in "resources_assigned" */ patl = pbst->attribs; while (patl) { if (strcmp(patl->name, ATTR_rescavail) == 0) add_consumable_entry(patl, 0, consum, consumable_size); else if (strcmp(patl->name, ATTR_rescassn) == 0) add_consumable_entry(patl, 1, consum, consumable_size); patl = patl->next; } pbst = pbst->next; } return; }
bool Node_Locator::process_cdd (const ACE_TCHAR *filename) { DANCE_TRACE ("Node_Locator::process_cdd"); if (!filename) { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Node_Locator::process_cdd - ") ACE_TEXT("Error: Provided with nil filename\n"))); return false; } ::DAnCE::Config_Handlers::XML_File_Intf file (filename); file.add_search_path (ACE_TEXT ("DANCE_ROOT"), ACE_TEXT ("/docs/schema/")); ::Deployment::Domain *plan = file.release_domain (); if (!plan) { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Node_Locator::process_cdd - ") ACE_TEXT("Error: Processing file <%C>\n"), filename)); return false; } // install nodes for (CORBA::ULong i=0; i < plan->node.length (); ++i) { ::Deployment::Resource resource; if (!get_resource_value (DAnCE::NODE_RESOURCE_TYPE, plan->node[i].resource, resource)) { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Node_Locator::process_cdd - ") ACE_TEXT("Error: Resource <%C> not found.\n"), DAnCE::NODE_RESOURCE_TYPE)); return false; } const ACE_TCHAR *val = 0; if (!::DAnCE::Utility::get_satisfierproperty_value (DAnCE::NODE_IOR, resource.property, val)) { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Node_Locator::process_cdd - ") ACE_TEXT("Error: Property <%C> not found.\n"), DAnCE::NODE_IOR)); return false; } ACE_CString ior(val); ior += "/"; ior += plan->node[i].name; ior += ".NodeManager"; ACE_CString destination (plan->node[i].name); DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_INFO, DLINFO ACE_TEXT("Node_Locator::process_cdd - ") ACE_TEXT("Storing IOR %C for destination %C\n"), ior.c_str (), destination.c_str ())); this->nodes_.bind (destination, ior); } return true; }