⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oracle.cc

📁 这是关于覆盖网的各种负载均衡算法的程序。好好研究
💻 CC
字号:
/* $Id: oracle.cc,v 1.7 2005/08/02 19:35:49 jonathan Exp $ * Jonathan Ledlie, Harvard University. * Copyright 2005.  All rights reserved. */#include <stdio.h>#include "lb.h"void oracleAllocateVsUniform (Distribution *keyDist,			      PhysicalServer *ps) {  double nodeCapacity = 0;    for (int i = 0; i < psCount; i++) {    nodeCapacity += ps[i].getCapacity();  }  double id = 0.;  for (int i = 0; i < psCount; i++) {    id += (double)(ps[i].getCapacity())/(nodeCapacity);    if (id <= 0. || id > 1.01) {      printf ("problem id : %1.14f\n", id);      ASSERT (id > 0. && id <= 1.);    }    ps[i].addVs (id);  }}void oracleAllocateVsZipf (Distribution *keyDist,			      PhysicalServer *ps) {  ZipfDistribution *zipfDist = (ZipfDistribution*)keyDist;  // make a map of the cap/id of the nodes that are going to be up  // replace multimap with map (twice)when running on solaris machine  ASSERT (0);  map<double,int> capacity2index;  //  multimap<double,int> capacity2index;  for (int i = 0; i < psCount; i++) {    capacity2index.insert(pair<double,int>(ps[i].getCapacity(),i));  }  // sort it by capacity (this is done automatically by insertion)  ASSERT (zipfDist->zipfKeys.size() >= capacity2index.size());    // assign ids to nodes from the zipfkey distribution  map<double,double>::iterator z = zipfDist->zipfKeys.begin();  for (map<double,int>::reverse_iterator c = capacity2index.rbegin();       //  for (multimap<double,int>::reverse_iterator c = capacity2index.rbegin();       c != capacity2index.rend(); c++) {    int index = c->second;    double id = z->second;    ps[index].addVs (id);    z++;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -