本文整理汇总了C++中Topology::IssueContentOnServer方法的典型用法代码示例。如果您正苦于以下问题:C++ Topology::IssueContentOnServer方法的具体用法?C++ Topology::IssueContentOnServer怎么用?C++ Topology::IssueContentOnServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topology
的用法示例。
在下文中一共展示了Topology::IssueContentOnServer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenLineTopo
Topology* Topology::GenLineTopo(int len, int content_num, int content_size, int k, int* cacheSizes)
{
Topology* topo = new Topology();
topo->router_num = len;
topo->routers = new Router[topo->router_num];
topo->content_num = content_num;
topo->size_of_content = content_size;
topo->server_num = 1;
topo->servers = new Server[topo->server_num];
topo->sink_num = 1;
topo->sinks = new Sink[topo->sink_num];
//sink-100-0-1- ... - 8-9-server-10
topo->edges.clear();
//routers
for (int router_id = 0; router_id < topo->router_num; router_id++) {
topo->routers[router_id].Init(router_id, cacheSizes[router_id], k, topo->server_num);
}
//server
for (int server_id = 0; server_id < topo->server_num; server_id++) {
topo->servers[server_id].Init(SERVER_BASE + server_id);
}
//sink
for (int sink_id = 0; sink_id < topo->sink_num; sink_id++) {
topo->sinks[sink_id].Init(SINK_BASE + sink_id, &(topo->routers[sink_id]));
}
//edges
for (int router_id = 0; router_id < (topo->router_num - 1); router_id++) {
Edge* e = new Edge(&topo->routers[router_id], &topo->routers[router_id + 1], router_id, MyRandom::NextDouble());
topo->routers[router_id].AddEdge(e);
topo->routers[router_id + 1].AddEdge(e);
topo->edges.push_back(e);
}
for (int server_id = 0; server_id < topo->server_num; server_id++) {
Edge* e = new Edge(&topo->servers[server_id], &topo->routers[topo->router_num - 1 - server_id],server_id-100,MyRandom::NextDouble());
topo->servers[server_id].AddEdge(e);
topo->routers[topo->router_num - 1 - server_id].AddEdge(e);
topo->edges.push_back(e);
}
for (int sink_id = 0; sink_id < topo->sink_num; sink_id++) {
Edge* e = new Edge(&topo->sinks[sink_id], &topo->routers[sink_id],sink_id + SINK_BASE,MyRandom::NextDouble());
topo->sinks[sink_id].AddEdge(e);
topo->routers[sink_id].AddEdge(e);
topo->edges.push_back(e);
}
topo->IssueContentOnServer();
topo->Announce();
return topo;
}
示例2: GenTreeTopo
Topology* Topology::GenTreeTopo(int tree_level, int tree_degree, int content_num, int content_size, int k, int* cache_sizes)
{
Logger::Log(LOGGER_INFO) << "Topology::GenLineTopo(tree_level=" << tree_level << ",tree_degree=" << tree_degree << ",content_num=" << content_num << ",content_size=" << content_size << ",k=" << k << ")" << endl;
Topology* topo = new Topology();
int router_num = 1;
int level_num = 1;
for(int level = 1; level < tree_level; level++)
{
level_num *= tree_degree;
router_num += level_num;
}
topo->router_num = router_num;
topo->routers = new Router[topo->router_num];
topo->content_num = content_num;
topo->size_of_content = content_size;
topo->server_num = 1;
topo->servers = new Server[topo->server_num];
topo->sink_num = level_num;
topo->sinks = new Sink[topo->sink_num];
// server-10
// router-0
// 1 2
// 3 4 5 6
// sink ...... sink-100
topo->edges.clear();
//routers
for (int router_id = 0; router_id < topo->router_num; router_id++) {
topo->routers[router_id].Init(router_id, cache_sizes[Tree::GetTreeLevel(tree_degree, router_id)], k, topo->server_num);
}
//server
for (int server_id = 0; server_id < topo->server_num; server_id++) {
topo->servers[server_id].Init(SERVER_BASE + server_id);
}
//sink
for (int sink_id = 0; sink_id < topo->sink_num; sink_id++) {
topo->sinks[sink_id].Init(SINK_BASE + sink_id, &(topo->routers[router_num - 1 - sink_id]));
}
//edges
for (int router_id = 0; router_id < (topo->router_num - 1); router_id++) {
Edge* e = new Edge(&topo->routers[router_id], &topo->routers[router_id + 1], router_id, MyRandom::NextDouble());
topo->routers[router_id].AddEdge(e);
topo->routers[router_id + 1].AddEdge(e);
topo->edges.push_back(e);
}
for (int server_id = 0; server_id < topo->server_num; server_id++) {
Edge* e = new Edge(&topo->servers[server_id], &topo->routers[topo->router_num - 1 - server_id],server_id-100,MyRandom::NextDouble());
topo->servers[server_id].AddEdge(e);
topo->routers[topo->router_num - 1 - server_id].AddEdge(e);
topo->edges.push_back(e);
}
for (int sink_id = 0; sink_id < topo->sink_num; sink_id++) {
Edge* e = new Edge(&topo->sinks[sink_id], &topo->routers[sink_id],sink_id + SINK_BASE,MyRandom::NextDouble());
topo->sinks[sink_id].AddEdge(e);
topo->routers[sink_id].AddEdge(e);
topo->edges.push_back(e);
}
//between routers
for (int i = 1; i < router_num; i++)
{
int parent = Tree::GetParentIndex(tree_degree, tree_level, i);
for(int j = 0; j < tree_degree; j++)
{
Edge* e = new Edge(&topo->routers[i], &topo->routers[parent], i * router_num + j + router_num * 2, MyRandom::NextDouble());
topo->edges.push_back(e);
topo->routers[i].AddEdge(e);
topo->routers[parent].AddEdge(e);
}
}
//servers
for (int i = 0; i < topo->server_num; i++)
{
Edge* e = new Edge(&topo->routers[i], &topo->servers[i], -i, MyRandom::NextDouble());
topo->routers[i].AddEdge(e);
topo->servers[i].AddEdge(e);
}
//sinks
for (int i = 0; i < topo->sink_num; i++)
{
Edge* e = new Edge(&topo->routers[router_num - i - 1], &topo->sinks[i], -1, MyRandom::NextDouble());
topo->routers[router_num - i - 1].AddEdge(e);
topo->sinks[i].AddEdge(e);
}
topo->IssueContentOnServer();
topo->Announce();
return topo;
}