Statistics
| Branch: | Tag: | Revision:

one / src / scheduler / src / sched / mm_sched.cc @ 1f571426

History | View | Annotate | Download (2.31 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2017, OpenNebula Project, OpenNebula Systems                */
3
/*                                                                            */
4
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
5
/* not use this file except in compliance with the License. You may obtain    */
6
/* a copy of the License at                                                   */
7
/*                                                                            */
8
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
9
/*                                                                            */
10
/* Unless required by applicable law or agreed to in writing, software        */
11
/* distributed under the License is distributed on an "AS IS" BASIS,          */
12
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
13
/* See the License for the specific language governing permissions and        */
14
/* limitations under the License.                                             */
15
/* -------------------------------------------------------------------------- */
16

    
17
#include "Scheduler.h"
18
#include "SchedulerTemplate.h"
19
#include "RankPolicy.h"
20
#include "UserPriorityPolicy.h"
21
#include <unistd.h>
22
#include <sys/types.h>
23
#include <sys/stat.h>
24
#include <fcntl.h>
25

    
26
#include <iostream>
27
#include <sstream>
28

    
29

    
30
using namespace std;
31

    
32
class RankScheduler : public Scheduler
33
{
34
public:
35

    
36
    RankScheduler():Scheduler(),rp_host(0),rp_ds(0),rp_vm(0){};
37

    
38
    ~RankScheduler()
39
    {
40
        delete rp_host;
41
        delete rp_ds;
42

    
43
        delete rp_vm;
44
    };
45

    
46
    void register_policies(const SchedulerTemplate& conf)
47
    {
48
        rp_host = new RankHostPolicy(hpool, conf.get_policy(), 1.0);
49

    
50
        add_host_policy(rp_host);
51

    
52
        rp_ds = new RankDatastorePolicy(dspool, conf.get_ds_policy(), 1.0);
53

    
54
        add_ds_policy(rp_ds);
55

    
56
        rp_vm = new UserPriorityPolicy(vmpool, 1.0);
57

    
58
        add_vm_policy(rp_vm);
59
    };
60

    
61
private:
62
    RankPolicy * rp_host;
63
    RankPolicy * rp_ds;
64

    
65
    UserPriorityPolicy * rp_vm;
66
};
67

    
68
int main(int argc, char **argv)
69
{
70
    RankScheduler ss;
71

    
72
    try
73
    {
74
        ss.start();
75
    }
76
    catch (exception &e)
77
    {
78
        cout << e.what() << endl;
79

    
80
        return -1;
81
    }
82

    
83
    return 0;
84
}