Revision 1f571426 src/scheduler/src/sched/Scheduler.cc

View differences:

src/scheduler/src/sched/Scheduler.cc
1077 1077
    bool dispatched, matched;
1078 1078
    char * estr;
1079 1079

  
1080
    map<int, ObjectXML*>::const_iterator vm_it;
1080
    vector<Resource *>::const_reverse_iterator i, j, k;
1081 1081

  
1082
    vector<Resource *>::const_reverse_iterator i, j;
1082
    vector<SchedulerPolicy *>::iterator sp_it;
1083 1083

  
1084
    const map<int, ObjectXML*> pending_vms = vmpool->get_objects();
1084
    //--------------------------------------------------------------------------
1085
    // Schedule pending VMs according to the VM policies (e.g. User priority)
1086
    //--------------------------------------------------------------------------
1087
    for (sp_it = vm_policies.begin() ; sp_it != vm_policies.end() ; ++sp_it)
1088
    {
1089
        (*sp_it)->schedule(0);
1090
    }
1091

  
1092
    vmpool->sort_vm_resources();
1085 1093

  
1086
    dss << "Dispatching VMs to hosts:\n" << "\tVMID\tHost\tSystem DS\n"
1087
        << "\t-------------------------\n";
1094
    const vector<Resource *> vm_rs = vmpool->get_vm_resources();
1088 1095

  
1089 1096
    //--------------------------------------------------------------------------
1090
    // Dispatch each VM till we reach the dispatch limit
1097
    dss << "Dispatching VMs to hosts:\n" 
1098
        << "\tVMID\tPriority\tHost\tSystem DS\n"
1099
        << "\t--------------------------------------------------------------\n";
1091 1100
    //--------------------------------------------------------------------------
1092 1101

  
1093
    for (vm_it = pending_vms.begin();
1094
         vm_it != pending_vms.end() &&
1095
            ( dispatch_limit <= 0 || dispatched_vms < dispatch_limit );
1096
         vm_it++)
1102
    //--------------------------------------------------------------------------
1103
    // Dispatch each VM till we reach the dispatch limit
1104
    //--------------------------------------------------------------------------
1105
    for (k = vm_rs.rbegin(); k != vm_rs.rend() &&
1106
            ( dispatch_limit <= 0 || dispatched_vms < dispatch_limit ); ++k)
1097 1107
    {
1098 1108
        dispatched = false;
1099 1109

  
1100
        vm = static_cast<VirtualMachineXML*>(vm_it->second);
1110
        vm = vmpool->get((*k)->oid);
1101 1111

  
1102 1112
        const vector<Resource *> resources = vm->get_match_hosts();
1103 1113

  
......
1273 1283
            //------------------------------------------------------------------
1274 1284
            // Dispatch and update host and DS capacity, and dispatch counters
1275 1285
            //------------------------------------------------------------------
1276
            if (vmpool->dispatch(vm_it->first, hid, dsid, vm->is_resched()) != 0)
1286
            if (vmpool->dispatch((*k)->oid, hid, dsid, vm->is_resched()) != 0)
1277 1287
            {
1278 1288
                continue;
1279 1289
            }
1280 1290

  
1281
            dss << "\t" << vm_it->first << "\t" << hid << "\t" << dsid << "\n";
1291
            //------------------------------------------------------------------
1292
            dss << "\t" << (*k)->oid << "\t" << (*k)->priority << "\t\t" << hid
1293
                << "\t" << dsid << "\n";
1294
            //------------------------------------------------------------------
1282 1295

  
1283 1296
            // DS capacity skip VMs deployed in public cloud hosts
1284 1297
            if (!host->is_public_cloud())
......
1347 1360
        }
1348 1361
    }
1349 1362

  
1350
    if (vm_it != pending_vms.end())
1363
    if (k != vm_rs.rend())
1351 1364
    {
1352 1365
        dss << endl << "MAX_DISPATCH limit of " << dispatch_limit << " reached, "
1353
            << std::distance(vm_it, pending_vms.end())
1366
            << std::distance(k, vm_rs.rend())
1354 1367
            << " VMs were not dispatched";
1355 1368
    }
1356 1369

  

Also available in: Unified diff