当前位置: 首页>>代码示例>>C++>>正文


C++ Store::isAssignmentPossible方法代码示例

本文整理汇总了C++中Store::isAssignmentPossible方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::isAssignmentPossible方法的具体用法?C++ Store::isAssignmentPossible怎么用?C++ Store::isAssignmentPossible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Store的用法示例。


在下文中一共展示了Store::isAssignmentPossible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: schedule

Algorithm::Result FirstFitAlgorithm::schedule()
{
    for (Requests::iterator i = requests.begin(); i != requests.end(); i++)
    {
        Request * request = *i;
        Assignment * assignment = new Assignment(request);
        Algorithm::Result result = SUCCESS;

        Nodes & vms = request->getVirtualMachines();
        for (Nodes::iterator vmi = vms.begin(); vmi != vms.end(); vmi++)
        {
            Node * vm = *vmi;
            Nodes & nodes = network->getNodes();
            Nodes::iterator n;
            for (n = nodes.begin(); n != nodes.end(); n++)
            {
                Node * node = *n;
                if ( node->isAssignmentPossible(*vm) )
                {
                    node->assign(*vm);
                    assignment->AddAssignment(vm, node);
                    break;
                }  
            }
            
            if ( n == nodes.end() )
            {
                result = FAILURE;
                break;
            }
        }

        Stores & storages = request->getStorages();
        for (Stores::iterator s = storages.begin(); s != storages.end(); s++)
        {
            Store * storage = *s;
            Stores & stores = network->getStores();
            Stores::iterator si;
            for ( si = stores.begin(); si != stores.end(); si++)
            {
                Store * store = *si;
                if ( store->isAssignmentPossible(*storage) )
                {
                    store->assign(*storage);
                    assignment->AddAssignment(storage, store);
                    break;
                }
            }

            if ( si == storages.end() )
            {
                result = FAILURE;
                break;
            }
        }

        Links & vlinks = request->getVirtualLinks();
        for (Links::iterator l = vlinks.begin(); l != vlinks.end(); l++)
        {
            Link * dummy = createDummyLink(*l, assignment);

            if ( dummy == 0 )
            {
                result = FAILURE;
                break;
            }

            NetPath netPath = VirtualLinkRouter::routeDejkstra(dummy, network);
            delete dummy;

            if ( netPath.size() == 0 )
            {
                result = FAILURE;
                break;
            } 

            for ( NetPath::iterator i = netPath.begin(); i != netPath.end(); i++)
            {
               (*i)->assign(**l);
            }
            assignment->AddAssignment(*l, netPath);
        }

        if ( result == FAILURE )
            delete assignment;
        else
            assignments.insert(assignment);
    }

    printf("Assigned total of %d from %d requests", assignments.size(), requests.size());
    if ( assignments.size() == requests.size() )
        return SUCCESS;
    else if ( assignments.size() != 0 )
        return PARTIAL;
    else
        return FAILURE;
}
开发者ID:artacc,项目名称:DataCenters,代码行数:97,代码来源:ffalgorithm.cpp


注:本文中的Store::isAssignmentPossible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。