forked from kaskavalci/CloudSim
-
Notifications
You must be signed in to change notification settings - Fork 1
/
VmAllocationPolicy.java
119 lines (105 loc) · 3.01 KB
/
VmAllocationPolicy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
import java.util.List;
import java.util.Map;
/**
* VmAllocationPolicy is an abstract class that represents the provisioning policy of hosts to
* virtual machines in a Datacentre. It supports two-stage commit of reservation of hosts: first, we
* reserve the host and, once commited by the user, it is effectivelly allocated to he/she
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
*/
public abstract class VmAllocationPolicy {
/** The host list. */
private List<? extends Host> hostList;
/**
* Allocates a new VmAllocationPolicy object.
*
* @param list Machines available in this Datacentre
* @pre $none
* @post $none
*/
public VmAllocationPolicy(List<? extends Host> list) {
setHostList(list);
}
/**
* Allocates a host for a given VM. The host to be allocated is the one that was already
* reserved.
*
* @param vm virtual machine which the host is reserved to
* @return $true if the host could be allocated; $false otherwise
* @pre $none
* @post $none
*/
public abstract boolean allocateHostForVm(Vm vm);
/**
* Allocates a specified host for a given VM.
*
* @param vm virtual machine which the host is reserved to
* @return $true if the host could be allocated; $false otherwise
* @pre $none
* @post $none
*/
public abstract boolean allocateHostForVm(Vm vm, Host host);
/**
* Optimize allocation of the VMs according to current utilization.
*
* @param vmList the vm list
* @param utilizationBound the utilization bound
* @param time the time
* @return the array list< hash map< string, object>>
*/
public abstract List<Map<String, Object>> optimizeAllocation(List<? extends Vm> vmList);
/**
* Releases the host used by a VM.
*
* @param vm the vm
* @pre $none
* @post $none
*/
public abstract void deallocateHostForVm(Vm vm);
/**
* Get the host that is executing the given VM belonging to the given user.
*
* @param vm the vm
* @return the Host with the given vmID and userID; $null if not found
* @pre $none
* @post $none
*/
public abstract Host getHost(Vm vm);
/**
* Get the host that is executing the given VM belonging to the given user.
*
* @param vmId the vm id
* @param userId the user id
* @return the Host with the given vmID and userID; $null if not found
* @pre $none
* @post $none
*/
public abstract Host getHost(int vmId, int userId);
/**
* Sets the host list.
*
* @param hostList the new host list
*/
protected void setHostList(List<? extends Host> hostList) {
this.hostList = hostList;
}
/**
* Gets the host list.
*
* @return the host list
*/
@SuppressWarnings("unchecked")
public <T extends Host> List<T> getHostList() {
return (List<T>) hostList;
}
}