skocic/server-farm
Composer 安装命令:
composer require skocic/server-farm
包简介
Simulation of allocation of servers and virtual machines in a server farm
README 文档
README
Simulation of allocation of servers and virtual machines in a server farm
Installation
Installed with Composer. Run this command:
composer install
Usage
Usage can be seen from tests.
In essence we create a ServerFarm object by specifying maximum server specs(cpu, ram and hdd size).
We create an array of Virtual machines and store them (bigger than maximum are skipped) with storeVmachines,
and then we:
- read the array of allocated machines with
getServers() - get the count with
count() - see detailed allocation list with
toString()
$vmArray = [ new VmachineModel(1, 1, 2), new VmachineModel(2, 2, 1), new VmachineModel(3, 4, 3), new VmachineModel(2, 1, 2), ]; $sf = new ServerFarmModel(ServerModel::create(5, 6, 7)); $sf->storeVmachines($vmArray); $actual = $sf->toString(); $expected = "Server list\n" . "1. VM(1 MHz, 1 GB, 2 GB) VM(2 MHz, 2 GB, 1 GB) remains VM(1 MHz, 3 GB, 4 GB)\n" . "2. VM(3 MHz, 4 GB, 3 GB) remains VM(1 MHz, 2 GB, 4 GB)\n" . "3. VM(2 MHz, 1 GB, 2 GB) remains VM(2 MHz, 5 GB, 5 GB)\n"; $this->assertSame($expected, $actual); $n = $sf->count(); $this->assertSame(3, $n);
Tests
- Composer is a prerequisite for running the tests. Install composer globally, then run
composer installto install required files. - The tests can be executed by running this command from the root directory:
$ ./vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
License
Please see the license file for more information.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-09