Project

General

Profile

Revision 706

Tagging version 1.0

View differences:

tags/Release 1.0/doc/manual/title.tex
1
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
2

  
3
\begin{titlepage}
4
 
5
\begin{center}
6
 
7
% Title
8
\HRule \\[0.4cm]
9
\includegraphics[width=0.6\textwidth]{images/haizea.png}\\[1cm]
10
\textsc{ \huge The Haizea Manual}\\{\large 1.0}\\{\large 12/17/09}\\[0.4cm]
11
 
12
\HRule \\[1.5cm]
13
\url{http://haizea.cs.uchicago.edu/}
14

  
15
\vfill
16
 
17
\begin{flushright} \large
18
Borja Sotomayor\\
19
Department of Computer Science\\
20
University of Chicago\\
21
\texttt{borja@cs.uchicago.edu}
22
\end{flushright}
23
 
24
\end{center}
25
 
26
\end{titlepage}
tags/Release 1.0/doc/manual/opennebula.tex
1
OpenNebula (\url{http://www.opennebula.org/}) is a virtual infrastructure manager that enables the dynamic deployment and re-allocation of virtual machines on a pool of physical resources. Haizea can be used to extend OpenNebula's scheduling capabilities, allowing it to support advance reservation of resources and queueing of best effort requests. OpenNebula and Haizea complement each other, since OpenNebula provides all the enactment muscle (OpenNebula can manage Xen, KVM, and VMWare VMs on a cluster) and Haizea provides the scheduling brains. Using both of them together is simple, since Haizea acts as a drop-in replacement for OpenNebula's scheduling daemon. 
2

  
3
This chapter explains how to use OpenNebula and Haizea together, and explains how to submit requests to OpenNebula to use Haizea's scheduling capabilities.
4

  
5
\section{Installing OpenNebula and Haizea}
6

  
7
If you have not already done so, you will need to install OpenNebula 1.4 and the latest version of Haizea. Start by installing OpenNebula, and then installing Haizea.
8

  
9
Before proceeding, you may want to follow the OpenNebula quickstart guide (\url{http://www.opennebula.org/doku.php?id=documentation:rel1.4:qg}) to verify that your OpenNebula installation is working fine. The rest of this document assumes that OpenNebula is correctly installed, and that you know what a \emph{virtual machine template} is (``VM templates'' is how VMs are requested to OpenNebula, so we'll be working with them quite a bit). You may also want to follow the Haizea Quickstart Guide (see Chapter~\ref{chap:quickstart}, to verify that Haizea is correctly installed.
10

  
11
\section{Configuring Haizea}
12

  
13
Haizea must be configured to run in OpenNebula mode. Haizea includes a sample OpenNebula configuration file that you can use as a starting point. This file is installed, by default, in \texttt{/usr/share/haizea/etc/sample\_opennebula.conf} (there is also a \texttt{sample\_opennebula\_barebones.conf} file that has the same options, but without any documentation). In OpenNebula mode, Haizea will process requests coming from OpenNebula, and will send all enactment commands to OpenNebula. To activate this mode, the \texttt{mode} option of the \texttt{general} section in the Haizea configuration file must be set to \texttt{opennebula}:
14

  
15
\begin{wideshellverbatim}
16
[general]
17
...
18
mode: opennebula
19
...
20
\end{wideshellverbatim}
21

  
22
Haizea interacts with OpenNebula through it's XML-RPC API, so you need to tell Haizea what host OpenNebula is on. This is done in the \texttt{opennebula} section:
23

  
24
\begin{wideshellverbatim}
25
[opennebula]
26
# Typically, OpenNebula and Haizea will be installed
27
# on the same host, so the following option should be
28
# set to 'localhost'. If they're on different hosts,
29
# make sure you modify this option accordingly.
30
host: localhost
31
\end{wideshellverbatim}
32

  
33
Additionally, if OpenNebula is not listening on its default port (2633), you can use the \texttt{port} option in the \texttt{opennebula} section to specify a different port.
34

  
35
There are also a couple options in the \texttt{scheduling} section that are relevant to OpenNebula mode, but which you do not need to concern yourself with yet (they are described at the end of this chapter).
36

  
37
\section{Running OpenNebula and Haizea together}
38

  
39
Now that Haizea is configured to run alongside OpenNebula, running them is as simple as starting the OpenNebula daemon:
40

  
41
\begin{wideshellverbatim}
42
oned
43
\end{wideshellverbatim}
44

  
45
Followed by Haizea:
46

  
47
\begin{wideshellverbatim}
48
haizea -c /usr/share/haizea/etc/sample_opennebula.conf
49
\end{wideshellverbatim}
50

  
51
The above assumes that you are running OpenNebula and Haizea in the same machine and with the same user. If this is not the case, you have to set the \texttt{ONE\_AUTH} environment variable (as described in the OpenNebula documentation) for the user and machine running Haizea. The variable must contain the path to a file containing the username and password of the OpenNebula administrator user (typically called \texttt{oneadmin}) with the format \texttt{username:password}. 
52

  
53
By default, Haizea runs as a daemon when running in OpenNebula mode. For this chapter, you may want to run it in the foreground so you can see the Haizea log messages in your console:
54

  
55
\begin{wideshellverbatim}
56
haizea --fg -c /usr/share/haizea/etc/sample_opennebula.conf
57
\end{wideshellverbatim}
58

  
59
When Haizea starts up, it will print out something like this:
60

  
61
\begin{wideshellverbatim}
62
[                      ] ENACT.ONE.INFO Fetched N nodes from OpenNebula
63
[2009-07-30 18:36:54.07] RM      Starting resource manager
64
[2009-07-30 18:36:54.07] RPCSERVER RPC server started on port 42493
65
[2009-07-30 18:36:54.07] CLOCK   Starting clock
66
\end{wideshellverbatim}
67

  
68
This means that Haizea has correctly started up, contacted OpenNebula and detected that there are N physical nodes (the value of N will depend, of course, on how many nodes you have in your system).
69

  
70
\begin{warning}
71
Haizea is a drop-in replacement for OpenNebula's default scheduler (\texttt{mm\_sched}). Do not run Haizea and \texttt{mm\_sched} at the same time, or funny things will happen.
72
\end{warning}
73

  
74
\section{A quick test}
75

  
76
At this point, OpenNebula and Haizea are both running together, and waiting for you to submit a VM request. From the user's perspective, you will still be submitting your requests to OpenNebula, and Haizea will do all the scheduling work backstage. However, you will be able to add an \texttt{HAIZEA} parameter to your OpenNebula request to access Haizea's features.
77

  
78
So, to test that OpenNebula and Haizea are working correctly, start by taking a known-good OpenNebula template. Just to be on the safe side, you may want to try it with the default scheduler first, to make sure that the VM itself works correctly, etc. Then, just add the following parameter to the template:
79

  
80
\begin{wideshellverbatim}
81
HAIZEA = [
82
  start        = "+00:00:30",
83
  duration     = "00:01:00",
84
  preemptible  = "no"
85
]
86
\end{wideshellverbatim}
87

  
88
The exact meaning of these parameters is explained later on in this document. In a nutshell, the values specified above tell Haizea to schedule the VM to start exactly 30 seconds in the future, to run for one minute, and to not allow the allocated resources to be preempted by other requests. This corresponds to an Haizea \emph{advance reservation lease} (see Chapter~\ref{chap:leases}).
89

  
90
Before you submit your request to OpenNebula, take a look at the Haizea log. You should see something like this repeating every minute:
91

  
92
\begin{wideshellverbatim}
93
[2009-07-30 18:38:44.00] CLOCK   Waking up to manage resources
94
[2009-07-30 18:38:44.00] CLOCK   Wake-up time recorded as 2009-07-30 18:38:44.00
95
[2009-07-30 18:38:44.01] CLOCK   Going back to sleep. 
96
                                 Waking up at 2009-07-30 18:38:54.00 
97
                                 to see if something interesting has happened by then.
98
\end{wideshellverbatim}
99

  
100
Haizea is configured, by default, to ask OpenNebula if there are any pending requests every minute. Since you haven't submitted anything, Haizea just wakes up every minute and goes right back to sleep. So, go ahead and submit your request (the one where you added the HAIZEA parameter). Assuming you named the template ar.one, run the following:
101

  
102
\begin{wideshellverbatim}
103
onevm submit ar.one
104
\end{wideshellverbatim}
105

  
106
If you run \texttt{onevm list} to see the VMs managed by OpenNebula, you'll see that the request is in a \texttt{pending} state:
107

  
108
\begin{wideshellverbatim}
109
  ID     USER     NAME STAT CPU     MEM        HOSTNAME        TIME
110
-------------------------------------------------------------------
111
  42    borja     test pend   0       0                 00 00:00:02
112
\end{wideshellverbatim}
113

  
114
Next time Haizea wakes up, you should see something like this:
115

  
116
\begin{wideshellverbatim}
117
[2009-07-30 18:41:49.16] CLOCK   Waking up to manage resources
118
[2009-07-30 18:41:49.16] CLOCK   Wake-up time recorded as 2009-07-30 18:41:49.00
119
[2009-07-30 18:41:49.19] LSCHED  Lease #1 has been requested.
120
[2009-07-30 18:41:49.19] LSCHED  Lease #1 has been marked as pending.
121
[2009-07-30 18:41:49.19] LSCHED  Scheduling AR lease #1, 1 nodes 
122
                                     from 2009-07-30 18:42:15.00 
123
                                       to 2009-07-30 18:43:15.00.
124
[2009-07-30 18:41:49.19] LSCHED  AR lease #1 has been scheduled.
125

  
126
[2009-07-30 18:41:49.19] CLOCK   Going back to sleep. 
127
                                 Waking up at 2009-07-30 18:42:15.00 
128
                                 to handle slot table event.
129
\end{wideshellverbatim}
130

  
131
Notice how Haizea detected that OpenNebula had an AR request, and then scheduled it to start 30 seconds in the future. In fact, Haizea takes care to wake up at that time so the VM can start at exactly that time.
132

  
133
\begin{warning}
134
If you run \texttt{onevm list}, the request will still be shown as \texttt{pending}. OpenNebula doesn't track Haizea's internal states, so it will consider the request "pending" until Haizea starts up the VM. You can check the state of Haizea leases using the \texttt{haizea-list-leases} command.
135
\end{warning}
136

  
137
\begin{warning}
138
Currently, Haizea has to poll OpenNebula every minute to ask if there are any new requests. An upcoming version of Haizea will support an event-based model where OpenNebula can send Haizea a notification as soon as a new request is received (so the user doesn't have to wait until the next time Haizea wakes up to process the request).
139
\end{warning}
140

  
141
When the VM is scheduled to start, you will see the following in the Haizea logs:
142

  
143
\begin{wideshellverbatim}
144
[2009-07-30 18:42:15.02] CLOCK   Waking up to manage resources
145
[2009-07-30 18:42:15.02] CLOCK   Wake-up time recorded as 2009-07-30 18:42:15.00
146
[2009-07-30 18:42:15.04] VMSCHED Started VMs for lease 1 on nodes [2]
147
[2009-07-30 18:42:15.09] CLOCK   Going back to sleep. 
148
                                 Waking up at 2009-07-30 18:43:00.00 
149
                                 to handle slot table event.
150
\end{wideshellverbatim}
151

  
152
Haizea has instructed OpenNebula to start the VM for the advance reservation. If you run \texttt{onevm list}, the VM will now show up as running:
153

  
154
\begin{wideshellverbatim}
155
  ID     USER     NAME STAT CPU     MEM        HOSTNAME        TIME
156
-------------------------------------------------------------------
157
  42    borja     test runn  10   65536       cluster05 00 00:00:52
158
\end{wideshellverbatim}
159

  
160
You should be able to access the VM (if you configured it with networking and SSH). However, since we requested the VM to run for just a minute, you will soon see the following in the Haizea logs:
161

  
162
\begin{wideshellverbatim}
163
[2009-07-30 18:43:00.04] CLOCK   Waking up to manage resources
164
[2009-07-30 18:43:00.04] CLOCK   Wake-up time recorded as 2009-07-30 18:43:00.00
165
[2009-07-30 18:43:00.05] VMSCHED Stopped VMs for lease 1 on nodes [2]
166
[2009-07-30 18:43:05.07] CLOCK   Going back to sleep. 
167
                                 Waking up at 2009-07-30 18:43:15.00 
168
                                 to handle slot table event.
169

  
170
[2009-07-30 18:43:15.00] CLOCK   Waking up to manage resources
171
[2009-07-30 18:43:15.00] CLOCK   Wake-up time recorded as 2009-07-30 18:43:15.00
172
[2009-07-30 18:43:15.00] VMSCHED Lease 1's VMs have shutdown.
173
[2009-07-30 18:43:15.01] CLOCK   Going back to sleep. 
174
                                 Waking up at 2009-07-30 18:44:15.00 
175
                                 to see if something interesting has happened by then.
176
\end{wideshellverbatim}
177

  
178
\section{The \texttt{HAIZEA} parameter in OpenNebula}
179

  
180
The previous section showed how you can add an \texttt{HAIZEA} parameter to your OpenNebula VM template to request a simple advance reservation. The three Haizea options (\texttt{start}, \texttt{duration}, and \texttt{preemptible}) can take other values:
181

  
182
\begin{itemize}
183
\item \texttt{start}: This option specifies when the VM will start. Valid values are:
184
\begin{itemize}
185
\item \texttt{best\_effort}: The VM will be scheduled as soon as resources are available. If resources are not available right now, the request is put on a queue and it remains there until there are sufficient resources (requests are scheduled on a first-come-first-serve basis).
186
\item \texttt{now}: The VM will be scheduled right now. If resources are not available right now, the request is rejected.
187
\item Exact ISO timestamp: i.e., \texttt{YYYY-MM-DD HH:MM:SS}. The VM must start at exactly that time. If enough resources are not available at that time, the resource is not requested.
188
\item Relative ISO timestamp: For convenience's sake (and also for testing) this provides an easy way of specifying that a VM must start "at T time after the VM is submitted". The format would be \texttt{+HH:MM:SS} (the "\texttt{+}" is not ISO, but is used by Haizea to determine that it is a relative timestamp)
189
\end{itemize}
190
\item \texttt{duration}: The duration of the lease. Possible values are:
191
\begin{itemize}
192
\item \texttt{unlimited}: The lease will run forever, until explicitly stopped
193
\item ISO-formatted time: i.e., \texttt{HH:MM:SS}
194
\end{itemize}
195
\item \texttt{preemptible}: This option can be either yes or no. %TODO: Refer to lease documentation
196
\item \texttt{group}: This option can take on any string value, and allows you to schedule several VMs as a group (or, in Haizea terminology, as a single lease with multiple nodes). All OpenNebula VM templates with the same group name will be considered part of the same lease (i.e., all the VMs will be scheduled in a all-or-nothing fashion: all VMs must be able to start/stop at the same time). Future versions of OpenNebula will automatically manage this option, so users don't have to worry about manually setting this option in multiple VM templates (which can be error-prone). 
197
\end{itemize}
198

  
199
Usually, you will want to use these options to create one of Haizea's supported lease types:
200

  
201
\subsection{Advance reservations}
202

  
203
When you need your VM available at a specific time, this is called an advance reservation, or AR. The VM we used above is an example of an AR:
204

  
205
\begin{wideshellverbatim}
206
HAIZEA = [
207
  start        = "+00:00:30",
208
  duration     = "00:01:00",
209
  preemptible  = "no"
210
]
211
\end{wideshellverbatim}
212

  
213
Of course, instead of specifying that you want your VM to start after a certain amount of time has passed (30 seconds, in this case), you can also specify an exact start time:
214

  
215
\begin{wideshellverbatim}
216
HAIZEA = [
217
  start        = "2008-11-04 11:00:00",
218
  duration     = "03:00:00",
219
  preemptible  = "no"
220
]
221
\end{wideshellverbatim}
222

  
223
NOTE: Haizea currently only supports non-preemptible ARs.
224

  
225
\subsection{Best-effort provisioning}
226

  
227
When you instruct Haizea to determine the start time on a best-effort basis, your request will be allocated resources as soon as they become available. Take into account that your request may be placed on a queue, and you'll have to wait until your turn is up. You can use the \texttt{haizea-list-leases} and \texttt{haizea-show-queue} to check on the state of your lease.
228

  
229
\begin{wideshellverbatim}
230
HAIZEA = [
231
  start        = "best_effort",
232
  duration     = "01:00:00",
233
  preemptible  = "yes"
234
]
235
\end{wideshellverbatim}
236

  
237
A best-effort VM can be preemptible or non-preemptible. If you request a non-preemptible VM, you may still have to wait in the queue until you get your resources but, once you do, no one can take them from you.
238

  
239
\subsection{Immediate provisioning}
240

  
241
Sometimes, you need a VM right now or not at all. In that case, you can set the starting time to \texttt{now}.
242

  
243
\begin{wideshellverbatim}
244
HAIZEA = [
245
  start        = "now",
246
  duration     = "unlimited",
247
  preemptible  = "no"
248
]
249
\end{wideshellverbatim}
250

  
251
\section{Additional OpenNebula configuration options}
252

  
253
When running Haizea with OpenNebula, you must specify at least the \texttt{host} option in the \texttt{[opennebula]} section of the configuration file. However, there are additional options in other sections that you can tweak:
254

  
255
\subsection{Wakeup interval}
256

  
257
This is the interval, in seconds, at which Haizea will wake up to process pending requests in OpenNebula. The default is 60 seconds.
258

  
259
\begin{wideshellverbatim}
260
[scheduling]
261
...
262
wakeup-interval: 60
263
...
264
\end{wideshellverbatim}
265

  
266
\subsection{Suspend/resume rate interval}
267

  
268
This option provides Haizea with an estimate of how long it takes for OpenNebula to suspend or resume a virtual machine. This is estimated in MB per second, and is largely dependent on the disk read/write transfer speeds on your system (so, if a VM has 1024 MB of memory, and the suspend rate is estimated to be 64MB/s, Haizea will estimate that suspension will take 16 seconds). If you do not specify a value, Haizea will conservatively assume a rate of 32MB/s. A good estimate will allow Haizea to more correctly schedule resources, but an incorrect estimate will not result in an error (although a warning will be noted in the logs).
269

  
270
\begin{wideshellverbatim}
271
[scheduling]
272
...
273
suspend-rate: 32
274
resume-rate: 32
275
...
276
\end{wideshellverbatim}
277

  
278
Additionally, since OpenNebula currently only supports suspending to a global filesystem (i.e., the RAM file created when suspending a VM is saved to a global filesystem, such as an NFS drive), you will need to specify that suspensions and resumptions must be globally exclusive (to make sure that no more than one RAM file is being saved to the global filesystem at any one time). You can control this using the \texttt{suspendresume-exclusion} option in the \texttt{[scheduling]} section:
279

  
280
\begin{wideshellverbatim}
281
[scheduling]
282
...
283
suspendresume-exclusion: global
284
...
285
\end{wideshellverbatim}
286

  
287
This option is set to \texttt{global} in the sample OpenNebula configuration file, but defaults to \texttt{local} when not specified.
288

  
289
\subsection{Non-schedulable interval}
290

  
291
The minimum amount of time that must pass between when a request is scheduled to when it can actually start (i.e., this makes sure that the scheduling function doesn't make reservations with starting times that will be in the past by the time the scheduling function ends). The default (10 seconds) should be good for most configurations, but may need to be increased if you're dealing with exceptionally high loads.
292

  
293
\begin{wideshellverbatim}
294
[scheduling]
295
...
296
non-schedulable-interval: 10
297
...
298
\end{wideshellverbatim}
299

  
300
\section{Known issues and limitations}
301

  
302
The following are known issues and limitations when using Haizea with OpenNebula:
303

  
304
\begin{itemize}
305
\item As pointed out in this guide, Haizea has to poll OpenNebula every minute to ask if there are any new requests.  Although OpenNebula 1.4 added a ``hook mechanism'' that allows actions to be carried out when certain events happen (such as sending Haizea notifications of a VM that has died, a suspend operation that finished before expected, etc.), Haizea currently does not use this hook mechanism.
306
\item Haizea currently cannot do any image deployment with OpenNebula, and VM images are assumed to be predeployed on the physical nodes, or available on a shared NFS filesystem. Although OpenNebula includes support for interfacing with a \emph{transfer manager} to handle various VM deployment scenarios, Haizea currently does not access this functionality.
307
\item Haizea cannot enact cold migrations in OpenNebula (i.e., migrating a suspended VM to a different node if resources become available earlier on a different node than the one where the VM was suspended on). Haizea actually has all the scheduling code for this, and only the enactment "glue" is missing.
308
\end{itemize}
tags/Release 1.0/doc/manual/install.tex
1
Haizea has been tested only on Unix systems, and these installation instructions are given with a Unix system in mind. However, Haizea includes a small amount of platform-specific code, and should run fine on other systems with minimal effort. If there is enough interest, we can produce installers and installation instructions for other platforms.
2

  
3
Installing Haizea can be accomplished in four simple steps:
4

  
5
\section{Install dependencies}
6

  
7
Haizea has a couple of software dependencies. Let's get them out of the way first:
8

  
9
\begin{itemize}
10
\item Python 2.5. (\url{http://www.python.org/})
11
\item mxDateTime 3.1.0 (\url{http://www.egenix.com/products/python/mxBase/mxDateTime/}), part of the eGenix.com mx Base Distribution).
12
\item Optional: Mako Templates for Python 0.2.2 (\url{http://www.makotemplates.org/}). This package is only necessary if you want to automate running multiple simulation experiments (if this doesn't make any sense, you can skip this prerequisite for now; you will be pointed to this prerequisite again in the documentation when you get to running multiple experiments).
13
\item Optional: Psyco 1.6 (\url{http://psyco.sourceforge.net/}). This package optimises the execution of Python code, resulting in the simulation code running much faster. You can skip this prerequisite if you are not going to use Haizea to run simulations, or if you are only going to run short simulations.
14
\end{itemize}
15

  
16
Note that mxDateTime, Mako, and Psyco are all available as packages (DEB, RPM, etc.) on most Linux distributions. If you don't install any of the optional dependencies, Haizea will still run fine, but some functionality may not be available, as noted above.
17

  
18
\section{Download Haizea}
19

  
20
Go to the \htmladdnormallink{download page}{http://haizea.cs.uchicago.edu/download.html} and download the latest version of Haizea. This will be a tarball called \texttt{haizea-XXX.tar.gz}, where XXX will be the version number. For the remainder of the instructions, let's assume that you've saved this file in a directory called \texttt{\$HAIZEA\_INST}.
21

  
22
\section{Install Haizea}
23

  
24
Go into directory \texttt{\$HAIZEA\_INST} and un-tar the installation package:
25

  
26
\begin{shellverbatim}
27
tar xvzf haizea-XXX.tar.gz
28
\end{shellverbatim}
29

  
30
This will create a directory called \texttt{haizea-XXX} in \texttt{\$HAIZEA\_INST}. Go into that directory, and as root, run the following:
31

  
32
\begin{shellverbatim}
33
python setup.py install
34
\end{shellverbatim}
35

  
36
If you do not have root access, or want to install Haizea in your home directory, run the following:
37

  
38
\begin{shellverbatim}
39
python setup.py install --home=$HOME
40
\end{shellverbatim}
41

  
42
Note: If you have never installed a Python package in your home directory before, make sure you set the environment variable \texttt{PYTHONPATH} appropriately so Python will be aware of the Haizea modules.
43

  
44
\begin{shellverbatim}
45
export PYTHONPATH=$HOME/lib/python
46
\end{shellverbatim}
47

  
48
After running the setup script, you should see a long list of installation and build messages, ending with the following:
49

  
50
\begin{wideshellverbatim}
51
creating /usr/share/haizea/traces/multi
52
copying traces/multi/inj1.lwf -> /usr/share/haizea/traces/multi
53
copying traces/multi/inj2.lwf -> /usr/share/haizea/traces/multi
54
copying traces/multi/withprematureend.lwf -> /usr/share/haizea/traces/multi
55
copying traces/multi/withoutprematureend.lwf -> /usr/share/haizea/traces/multi
56
running install_egg_info
57
Writing /usr/lib/python2.5/site-packages/haizea-XXX.egg-info
58
\end{wideshellverbatim}
59

  
60
If you see this, installation has been successful!
61

  
62
\section{Verify installation}
63

  
64
Haizea includes some sample configuration files and lease request tracefiles that you can use to test Haizea. If you installed Haizea as root, you can run the following to test your installation:
65

  
66
\begin{shellverbatim}
67
haizea -c /usr/share/haizea/etc/sample_trace.conf
68
\end{shellverbatim}
69

  
70
This will use a sample configuration file to simulate running the scheduler with no requests, resulting in the following (somewhat anticlimactic) output:
71

  
72
\begin{wideshellverbatim}
73
[2006-11-25 13:00:00.00] RM      Starting resource manager
74
[2006-11-25 13:00:00.00] TFILE   Loading tracefile /usr/share/haizea/traces/sample.lwf
75
[2006-11-25 13:00:00.00] TFILE   Loaded workload with 0 requests ()
76
[2006-11-25 13:00:00.00] CLOCK   Starting simulated clock
77
[2006-11-25 13:00:00.00] CLOCK   Simulated clock has stopped
78
[2006-11-25 13:00:00.00] RM      Stopping resource manager gracefully...
79
[2006-11-25 13:00:00.00] RM      --- Haizea status summary ---
80
[2006-11-25 13:00:00.00] RM      Number of leases (not including completed): 0
81
[2006-11-25 13:00:00.00] RM      Completed leases: 0
82
[2006-11-25 13:00:00.00] RM      Completed best-effort leases: 0
83
[2006-11-25 13:00:00.00] RM      Queue size: 0
84
[2006-11-25 13:00:00.00] RM      Accepted AR leases: 0
85
[2006-11-25 13:00:00.00] RM      Rejected AR leases: 0
86
[2006-11-25 13:00:00.00] RM      Accepted IM leases: 0
87
[2006-11-25 13:00:00.00] RM      Rejected IM leases: 0
88
[2006-11-25 13:00:00.00] RM      ---- End summary ----
89
\end{wideshellverbatim}
90

  
91
Ok, not terribly exciting, but if you see this then the basic machinery is working fine. We will see how to do more elaborate simulations, and how to use Haizea to manage real hardware, in the next chapters.
92

  
93
Note: If you installed Haizea in your home directory, you will have to run the following:
94

  
95
\begin{shellverbatim}
96
haizea -c $HOME/share/haizea/etc/sample_trace.conf
97
\end{shellverbatim}
98

  
99
Additionally, you will have to modify the tracefile option in the sample configuration so it will point to the sample tracefile located in \texttt{\$HOME/share/haizea/traces/sample.lwf} (instead of under the \texttt{/usr} directory).
tags/Release 1.0/doc/manual/analysing.tex
1
While Haizea is running, it collects data that can be analysed offline (accepted/rejected leases, waiting times, etc.). This data is saved to disk when Haizea stops running so, for now, this information is (in practice) only useful for simulation experiments. In the future, Haizea will save data periodically to disk so it can also be analysed online.
2

  
3
The information that is collected can be specified through a series of \emph{probes}. For example, there is a \texttt{best-effort} probe that collects information relevant to best-effort leases, such as the time the lease had to wait in the queue until it was allocated resources. Haizea includes several probes (see Appendix~\ref{app:probes}) and also allows you to write your own probes (see Chapter~\ref{chap:accounting})
4

  
5
The file where the collected data will be saved and the probes to use are specified in the \texttt{[accounting]} section of the configuration file:
6

  
7
\begin{wideshellverbatim}
8
[accounting]
9
datafile: /var/tmp/haizea.dat
10
probes: ar best-effort immediate utilization
11
\end{wideshellverbatim}
12

  
13
This file is not human-readable, and there are two ways of accessing its contents: using the \texttt{haizea-convert-data} command or programmatically through Python. Both are described in this chapter.
14

  
15
\section{Type of data collected}
16

  
17
Accounting probes can collect three types of data:
18

  
19
\begin{description}
20
\item[Per-lease data]: Data attributable to individual leases or derived from how each lease was scheduled. For example, as mentioned earlier, the \texttt{best-effort} probe collects the waiting time of each best-effort lease.
21
\item[Per-run data]: Data from a single run of Haizea. For example, the \texttt{ar} probe collects the total number of AR leases that were accepted and rejected during the entire run.
22
\item[Counters]: A counter is a time-ordered list showing how some metric varied throughout a single run of Haizea. For example, the \texttt{best-effort} probe keeps track of the length of the queue. 
23
\end{description}
24

  
25
See Appendix~\ref{app:probes}) for a list of probes included with Haizea, and a description of the specific data they collect.
26

  
27

  
28
\section{The \texttt{haizea-convert-data} command}
29
\label{sec:haizea-convert-data}
30

  
31
The \texttt{haizea-convert-data} command will convert the contents of the data file into a CSV file. 
32

  
33
To print out all the per-lease data, simply run the following: 
34

  
35
\begin{shellverbatim}
36
haizea-convert-data -t per-lease /var/tmp/haizea.dat
37
\end{shellverbatim}
38

  
39
This will print out one line per lease, showing its lease ID and all data collected for that lease. Take into account that some fields will be empty, as a probe might collect data just for one specific type of lease (e.g., AR leases will have empty values for the `Waiting time' information collected by the \texttt{best-effort}).
40

  
41
To print out all the per-run data, run the following:
42

  
43
\begin{shellverbatim}
44
haizea-convert-data -t per-run /var/tmp/haizea.dat
45
\end{shellverbatim}
46

  
47
To print out a counter, run the following:
48

  
49
\begin{shellverbatim}
50
haizea-convert-data -t counter -c countername /var/tmp/haizea.dat
51
\end{shellverbatim}
52

  
53
Where \texttt{countername} should be substituted for the counter you want to access. If you do not know what counters are included in the file, the following will print out a list of counters:
54

  
55
\begin{shellverbatim}
56
haizea-convert-data -l /var/tmp/haizea.dat
57
\end{shellverbatim}
58

  
59
When running multiple simulations (as described in \ref{sec:multiplesim}), Haizea will generate one data file for each simulation profile, which are all stored in the same directory. \texttt{haizea-convert-data} can also be used to produce aggregate statistics from all these data files. For example:
60

  
61
\begin{shellverbatim}
62
haizea-convert-data -t per-run /var/tmp/results/*.dat
63
\end{shellverbatim}
64

  
65
This will print out one line per simulation run, each with the per-run data for the run along with the simulation profile, tracefile, and injection file used in that run. Similarly, you can run \texttt{haizea-convert-data} with \texttt{-t per-lease} or \texttt{-t counter} to print the per-lease data or a counter from multiple simulation runs, using the simulation profile, tracefile, and injection file columns to disambiguate the run the data originated from.
66

  
67
\section{Analysing data programmatically} 
68

  
69
The data file generated by Haizea is a Python-pickled \texttt{AccountingData} object. This object contains all the per-lease and per-run data, along with all the counters. You can analyse the data programmatically by unpickling the file from your own Python code and accessing the data contained in the \texttt{AccountingData} object (see the generated pydoc documentation linked from the Haizea website for details on the object's attributes). An example of how this file is unpickled, and some of its information accessed, can be found in function \texttt{haizea\_convert\_data} in module \texttt{haizea.cli.commands}.
70

  
71

  
tags/Release 1.0/doc/manual/accounting.tex
1
In Chapter~\ref{chap:analysing} we saw that Haizea collects data while running through the use of \emph{probes}. While Haizea includes several probes, it is also possible for you to write your own probes by implementing a class that extends from the \texttt{AccountingProbe} class. A barebones probe would look like this:
2

  
3
\begin{wideshellverbatim}
4
from haizea.core.accounting import AccountingProbe
5

  
6
class MyProbe(AccountingProbe):
7
    
8
    def __init__(self, accounting):
9
        AccountingProbe.__init__(self, accounting)
10
        # Create counters, per-lease stats, per-run stats
11
    
12
    def finalize_accounting(self):
13
	# Collect information
14

  
15
    def at_timestep(self, lease_scheduler):
16
	# Collect information
17

  
18
    def at_lease_request(self, lease):
19
	# Collect information 
20

  
21
    def at_lease_done(self, lease):
22
	# Collect information 
23
\end{wideshellverbatim}
24

  
25
All the methods shown above are also present in \texttt{AccountingProbe}, but don't do anything. You have to override some or all of the methods to make sure that data gets collected. More specifically:
26

  
27
\begin{description}
28
\item[\texttt{at\_timestep}] Override this method to perform any actions every time the Haizea scheduler wakes up. The \texttt{lease\_scheduler} parameter contains Haizea's lease scheduler (an instance of the \texttt{LeaseScheduler} class), which you can use to gather scheduling data.
29
\item[\texttt{at\_lease\_request}] Override this method to collect data after a lease has been requested.
30
\item[\texttt{at\_lease\_done}] Override this method to collect data after a lease is done (this includes successful completion and rejected/cancelled/failed leases).
31
\item[\texttt{finalize\_accounting}] Override this method to perform any actions when data collection stops. This is usually where per-run data is computed.
32
\end{description}
33

  
34
Probes can collect three types of data:
35

  
36
\begin{description}
37
\item[Per-lease data:] Data attributable to individual leases or derived from how each lease was scheduled. 
38
\item[Per-run data:] Data from an entire run of Haizea
39
\item[Counters:] A counter is a time-ordered list showing how some metric varied throughout a single run of Haizea. 
40
\end{description}
41

  
42
The probe's constructor should create the counters and specify what per-lease data and per-run data will be collected by your probe (the methods to do this are described next). Notice how a probe's constructor receives a \texttt{accounting} parameter. When creating your probe, Haizea will pass an \texttt{AccountingDataCollection} object that you will be able to use in your probe's other methods to store data.
43

  
44
Once a probe has been implemented, it can be used in Haizea by specifying its full name in the \texttt{probes} option of the \texttt{accounting} section of the configuration file. For example, suppose you created a class called \texttt{MyProbe} in the {foobar.probes} module. To use the probe, the \texttt{probes} option would look like this:
45

  
46
\begin{wideshellverbatim}
47
probes: foobar.probes.MyProbe
48
\end{wideshellverbatim}
49

  
50
When running Haizea, you have to make sure that \texttt{foobar.probes.MyProbe} is in your \texttt{PYTHONPATH}. After running Haizea with your probe, you can access the data it collects using the \texttt{haizea-convert-data} command described in Section~\ref{sec:haizea-convert-data}
51

  
52
\section{Collecting per-lease data}
53

  
54
To collect per-lease data, you first have to specify the new type of data (or ``stat'') you will be collecting in your probe's constructor. This is done using the \verb+create_lease_stat+ method in \texttt{AccountingDataCollection} (which is stored in an \texttt{accounting} attribute in all probes). For example, let's assume you want to keep track of an admittedly silly statistic: whether the lease's identifier is odd or even. You could create a stat called \texttt{Odd or even?}:
55

  
56
\begin{wideshellverbatim}
57
from haizea.core.accounting import AccountingProbe
58

  
59
class MyProbe(AccountingProbe):
60
    
61
    def __init__(self, accounting):
62
        AccountingProbe.__init__(self, accounting)
63
        self.accounting.create_lease_stat("Odd or even?")	
64
\end{wideshellverbatim}
65

  
66
To set the value of this stat, you must use the \verb+set_lease_stat+ method in \texttt{AccountingDataCollection}. For this stat, it would make sense to call this method from the \texttt{at\_lease\_request} method in the probe:
67

  
68
\begin{wideshellverbatim}
69
def at_lease_request(self, lease):
70
    if lease.id \% 2 == 1:
71
        value = "odd"
72
    else:
73
        value = "even"
74
    self.accounting.set_lease_stat("Odd or even?", lease.id, value)	
75
\end{wideshellverbatim}
76

  
77
If you run Haizea with this probe, and then use \texttt{haizea-convert-data} to print the per-lease data collected by the probes, there will be an additional column titled \texttt{Odd or even?} in the generated CSV file.
78

  
79

  
80
\section{Collecting per-run data}
81

  
82
Collecting per-run data is similar to collecting per-lease data, and relies on two methods in \texttt{AccountingDataCollection}: \verb+create_stat+ to create the stat in the probe constructor and \verb+set_stat+ to set the value of the stat. Given that per-run data summarizes information from the entire run, \verb+set_stat+ will usually be called from the probe's \texttt{finalize\_accounting} method.
83

  
84

  
85
\section{Creating and updating counters}
86

  
87
To collect data using a counter you must first create the counter from the probe's constructor using the \verb+create_counter+ method in \texttt{AccountingDataCollection}:
88

  
89
\begin{wideshellverbatim}
90
create_counter(counter_id, avgtype)
91
\end{wideshellverbatim}
92

  
93
The first parameter is the name of the counter. The second parameter specifies the type of average to compute for the counter; Counters can store not just the value of the counter throughout time, but also a running average. There are three types of averages that can be specified through the \texttt{avgtype}
94
        
95
\begin{description}
96
\item[\texttt{AccountingDataCollection.AVERAGE\_NONE}:] Don't compute an average
97
\item[\texttt{AccountingDataCollection.AVERAGE\_NORMAL}:] For each entry, compute the average of all the values including and preceding that entry.
98
\item[\texttt{AccountingDataCollection.AVERAGE\_TIMEWEIGHTED}:]  For each entry, compute the average of all the values including and preceding that entry, weighing the average according to the time between each entry.
99
\end{description}
100

  
101
All counters are initialized to zero.
102

  
103
The counter can be updated using one of the following three methods:
104

  
105
\begin{wideshellverbatim}
106
incr_counter(counter_id, lease_id):
107
decr_counter(counter_id, lease_id):
108
append_to_counter(counter_id, value, lease_id):
109
\end{wideshellverbatim}
110

  
111
All three methods receive the name of the counter (\verb+counter_id+) and, optionally, the identifier of the lease that caused the update. \verb+incr_counter+ and \verb+decr_counter+ increment or decrement the counter, respectively, while \verb+append_to_counter+ changes the counter's value to the value specified by the \verb+value+ parameter.
112

  
113

  
114
\section{Examples}
115

  
116
See the \texttt{haizea.pluggable.accounting} module for the source code of the default probes included with Haizea.
tags/Release 1.0/doc/manual/quickstart.tex
1
This chapter provides a quick hands-on introduction to using Haizea in simulation mode. Even if you intend to use Haizea in combination with another system, such as OpenNebula, you may still find this guide useful to familiarise yourself with the Haizea configuration file and command-line interface. This chapter assumes that Haizea is installed on your system. If you have arrived at this chapter directly, you may want to read Chapter~\ref{chap:whatis} (``What is Haizea?'') first, although you should still be able to follow the instructions in this chapter without reading Chapter~\ref{chap:whatis} first.
2

  
3
\section{The \texttt{haizea} command}
4

  
5
The main command in the Haizea system is, unsurprisingly, the \texttt{haizea} command. Running this command starts up the Haizea lease manager, which is then ready to receive and schedule lease requests. As described in Chapter~\ref{chap:whatis}, Haizea can run in one of three modes: unattended simulated mode, interactive simulated mode, and OpenNebula mode. In this chapter we will focus on the simulation modes, starting with the ``unattended'' variety. Both simulation modes, and the OpenNebula mode, will be described in more detail in the next chapters.
6

  
7
When running Haizea in unattended simulation mode, the inputs to Haizea are going to be the following:
8

  
9
\begin{description}
10
 \item [The Haizea configuration file:] A text file containing all the options
11
 \item [A request \emph{tracefile}:] A text file containing a list of lease requests. Since we are using ``simulated time'', we won't be able to use Haizea interactively (we will be able to do this when we switch to the ``real time'' mode later in the chapter). Instead, we need to provide all the lease requests beforehand.
12
\end{description}
13

  
14
Based on the configuration file and the lease requests, the simulator produces a schedule for those leases, which you will be able to follow through logging messages printed by Haizea. At the end of the simulation, Haizea also saves a fair amount of raw data and statistics to disk which can be used to produce reports and graphs (a module to do this for you is in the works). This particular mode, with simulated time, is particularly useful when you want to take a list of request (potentially spanning weeks or months) to see what happens when you tweak the scheduling options (without having to wait weeks or months for the result).
15

  
16
So, let's start by writing a configuration file specifying the simulation options (e.g., the characteristics of the simulated cluster) and the scheduling options.
17

  
18
\section{The configuration file}
19

  
20
A sample configuration file is provided with Haizea and is located in \texttt{/usr/share/haizea/etc/sample\_trace.conf} (or \texttt{\$HOME/share/haizea/etc/sample\_trace.conf} if you installed Haizea in your home directory). For this guide, you may want to make a copy of this file and use that instead (so you can preserve the original sample file). If you look at the contents of the file, you will see that it also includes documentation on every option (if you find the documentation gets in the way, there is also a \texttt{sample\_trace\_barebones.conf} file that has the same options, but without any documentation). For now, take a look at the following three options:
21

  
22
\begin{wideshellverbatim}
23
[simulation]
24
starttime: 2006-11-25 13:00:00
25
resources: 4  CPU:100 Memory:1024
26
\end{wideshellverbatim}
27

  
28
These options are used to describe the characteristics of our simulated cluster. In particular, we're using a 4-node cluster, each node with 1 CPU, 1024 MB of memory. In this document, we will represent this cluster over time like this:
29

  
30
\begin{center}
31
\includegraphics{images/quickstart_leasegraph1.png}
32
\end{center}
33

  
34
For example, the following figure shows a lease scheduled on Node 1 from 13:00 to 14:00:
35

  
36
\begin{center}
37
\includegraphics{images/quickstart_leasegraph2.png}
38
\end{center}
39

  
40
The \texttt{starttime} option is used to specify the time at which the simulated clock should start. As you will see, the configuration file has an abundance of other options. We will cover some of them in this chapter, but a more complete reference can be found in Appendix~\ref{app:conffile}.
41

  
42
\section{The tracefile}
43

  
44
As mentioned earlier, the simulator will read trace requests from a tracefile. The location of this tracefile is specified in the configuration file, in the \texttt{[tracefile]} section:
45

  
46
\begin{wideshellverbatim}
47
[tracefile]
48
tracefile: /usr/share/haizea/traces/sample.lwf 
49
\end{wideshellverbatim}
50

  
51
The default value is a sample tracefile included with Haizea. If you copy the file to a different location, make sure to update the \texttt{tracefile} option accordingly. The format of this file is LWF (Lease Workload Format), an XML format which is particular to Haizea. For now, don't worry about parsing the trace format in detail; it is fairly human-readable and you can also find details on the LWF format in Appendix~\ref{app:lwf}.
52

  
53
\begin{wideshellverbatim}
54
<lease-workload name="sample">
55
	<description>
56
	A simple trace where an AR lease preempts a 
57
	best-effort lease that is already running. 
58
	</description>
59

  
60
	<lease-requests>
61
	
62
	<!-- The lease requests are initially commented out -->
63
	
64
	<!-- First lease request -->
65
	<!--
66
	...
67
	-->
68

  
69
	<!-- Second lease request -->
70
	<!--
71
	...
72
	-->
73
	
74
	</lease-requests>
75
</lease-workload>
76
\end{wideshellverbatim}
77

  
78
As you can see, there are two lease requests in the file, but they are initially commented out. We will take a closer look at each of these requests next.
79

  
80
\section{Running the simulator}
81

  
82
Now that we have a configuration file and a tracefile, we can run the simulator. You can run Haizea with the sample configuration file like this:
83

  
84
\begin{shellverbatim}
85
haizea -c /usr/share/haizea/etc/sample_trace.conf 
86
\end{shellverbatim}
87

  
88
Which results in the following output:
89

  
90
\begin{wideshellverbatim}
91
[2006-11-25 13:00:00.00] RM      Starting resource manager
92
[2006-11-25 13:00:00.00] TFILE   Loading tracefile /usr/share/haizea/traces/sample.lwf
93
[2006-11-25 13:00:00.00] TFILE   Loaded workload with 0 requests ()
94
[2006-11-25 13:00:00.00] CLOCK   Starting simulated clock
95
[2006-11-25 13:00:00.00] CLOCK   Simulated clock has stopped
96
[2006-11-25 13:00:00.00] RM      Stopping resource manager gracefully...
97
[2006-11-25 13:00:00.00] RM      --- Haizea status summary ---
98
[2006-11-25 13:00:00.00] RM      Number of leases (not including completed): 0
99
[2006-11-25 13:00:00.00] RM      Completed leases: 0
100
[2006-11-25 13:00:00.00] RM      Completed best-effort leases: 0
101
[2006-11-25 13:00:00.00] RM      Queue size: 0
102
[2006-11-25 13:00:00.00] RM      Accepted AR leases: 0
103
[2006-11-25 13:00:00.00] RM      Rejected AR leases: 0
104
[2006-11-25 13:00:00.00] RM      Accepted IM leases: 0
105
[2006-11-25 13:00:00.00] RM      Rejected IM leases: 0
106
[2006-11-25 13:00:00.00] RM      ---- End summary ----
107
\end{wideshellverbatim}
108

  
109
Now that you've seen the tracefile, you can see why the simulator starts up and immediately stops: all the lease requests in the tracefile are commented out, and there's nothing to schedule. Go ahead and uncomment the first lease request, which looks like this:
110

  
111
\begin{wideshellverbatim}
112
<lease-request arrival="00:00:00">
113
<lease preemptible="true">
114
	<nodes>
115
		<node-set numnodes="1">
116
			<res type="CPU" amount="100"/>
117
			<res type="Memory" amount="1024"/>
118
		</node-set>
119
	</nodes>	
120
	<start></start>
121
	<duration time="01:00:00"/>
122
	<software>
123
		<disk-image id="foobar.img" size="1024"/>
124
	</software>
125
</lease>
126
</lease-request>
127
\end{wideshellverbatim}
128

  
129
This is a request for a best-effort lease (notice how the starting time is left empty, meaning it's up to Haizea to determine the start time), requested at time 00:00:00 (right at the start of the simulation), requiring 1 hour, and only one node. Now run Haizea again. You should now see the following:
130

  
131
\begin{wideshellverbatim}
132
[2006-11-25 13:00:00.00] RM      Starting resource manager
133
[2006-11-25 13:00:00.00] TFILE   Loading tracefile /usr/share/haizea/traces/sample.lwf
134
[2006-11-25 13:00:00.00] TFILE   Loaded workload with 1 requests (1 Best-effort)
135
[2006-11-25 13:00:00.00] CLOCK   Starting simulated clock
136
[2006-11-25 13:00:00.00] LSCHED  Lease #1 has been requested.
137
[2006-11-25 13:00:00.00] LSCHED  Lease #1 has been marked as pending.
138
[2006-11-25 13:00:00.00] LSCHED  Queued best-effort lease request #1, 1 nodes for 01:00:00.00.
139
[2006-11-25 13:00:00.00] LSCHED  Next request in the queue is lease 1. Attempting to schedule...
140
[2006-11-25 13:00:00.00] VMSCHED Lease #1 has been scheduled on nodes [1] 
141
                                 from 2006-11-25 13:00:00.00 
142
                                   to 2006-11-25 14:00:00.00
143
[2006-11-25 13:00:00.00] VMSCHED Started VMs for lease 1 on nodes [1]
144
[2006-11-25 14:00:00.00] VMSCHED Stopped VMs for lease 1 on nodes [1]
145
[2006-11-25 14:00:00.00] VMSCHED Lease 1's VMs have shutdown.
146
[2006-11-25 14:00:00.00] CLOCK   Simulated clock has stopped
147
[2006-11-25 14:00:00.00] RM      Stopping resource manager gracefully...
148
[2006-11-25 14:00:00.00] RM      --- Haizea status summary ---
149
[2006-11-25 14:00:00.00] RM      Number of leases (not including completed): 0
150
[2006-11-25 14:00:00.00] RM      Completed leases: 1
151
[2006-11-25 14:00:00.00] RM      Completed best-effort leases: 1
152
[2006-11-25 14:00:00.00] RM      Queue size: 0
153
[2006-11-25 14:00:00.00] RM      Accepted AR leases: 0
154
[2006-11-25 14:00:00.00] RM      Rejected AR leases: 0
155
[2006-11-25 14:00:00.00] RM      Accepted IM leases: 0
156
[2006-11-25 14:00:00.00] RM      Rejected IM leases: 0
157
[2006-11-25 14:00:00.00] RM      ---- End summary ----
158
\end{wideshellverbatim}
159

  
160
The above corresponds to the following schedule:
161

  
162
\begin{center}
163
\includegraphics{images/quickstart_leasegraph2.png}
164
\end{center}
165

  
166
A best-effort request is received at 13:00 and, since the cluster is empty, it is scheduled immediately. Notice how the VMs for the lease start at 13:00 and stop at 14:00. For now, we're assuming that the disk images are predeployed on the physical nodes (we will modify this option in the next section).
167

  
168
Now go ahead and uncomment the second lease request, which looks like this:
169

  
170
\begin{wideshellverbatim}
171
<lease-request arrival="00:15:00">
172
<lease preemptible="false">
173
	<nodes>
174
		<node-set numnodes="4">
175
			<res type="CPU" amount="100"/>
176
			<res type="Memory" amount="1024"/>
177
		</node-set>
178
	</nodes>
179
	<start>
180
		<exact time="00:30:00"/>
181
	</start>
182
	<duration time="00:30:00"/>
183
	<software>
184
		<disk-image id="foobar.img" size="1024"/>
185
	</software>
186
</lease>
187
</lease-request>
188
\end{wideshellverbatim}
189

  
190
This is a request for an advance reservation lease (notice how there is an exact starting time specified), requesting all four nodes for 30 minutes. So, what would happen if we also added this AR lease? Since it requires all the cluster resources from 13:30 to 14:00, the best-effort lease will be unable to run in that time interval. Since the leases are implemented as VMs, Haizea will still schedule the best-effort lease to start at 13:00, but will suspend it before the AR lease starts, and will resume it once the AR lease has finished. In effect, we want the schedule to look like this:
191

  
192
\begin{center}
193
\includegraphics{images/quickstart_leasegraph3.png}
194
\end{center}
195

  
196
Uncomment the AR lease request, and run Haizea again. You should now see the following:
197

  
198
\begin{wideshellverbatim}
199
[2006-11-25 13:00:00.00] RM      Starting resource manager
200
[2006-11-25 13:00:00.00] TFILE   Loading tracefile /usr/share/haizea/traces/sample.lwf
201
[2006-11-25 13:00:00.00] TFILE   Loaded workload with 2 requests (1 Best-effort + 1 AR)
202
[2006-11-25 13:00:00.00] CLOCK   Starting simulated clock
203
[2006-11-25 13:00:00.00] LSCHED  Lease #1 has been requested.
204
[2006-11-25 13:00:00.00] LSCHED  Lease #1 has been marked as pending.
205
[2006-11-25 13:00:00.00] LSCHED  Queued best-effort lease request #1, 1 nodes for 01:00:00.00.
206
[2006-11-25 13:00:00.00] LSCHED  Next request in the queue is lease 1. Attempting to schedule...
207
[2006-11-25 13:00:00.00] VMSCHED Lease #1 has been scheduled on nodes [1] 
208
                                 from 2006-11-25 13:00:00.00 
209
                                   to 2006-11-25 14:00:00.00
210
[2006-11-25 13:00:00.00] VMSCHED Started VMs for lease 1 on nodes [1]
211

  
212
[2006-11-25 13:15:00.00] LSCHED  Lease #2 has been requested.
213
[2006-11-25 13:15:00.00] LSCHED  Lease #2 has been marked as pending.
214
[2006-11-25 13:15:00.00] LSCHED  Scheduling AR lease #2, 4 nodes
215
                                 from 2006-11-25 13:30:00.00 
216
                                   to 2006-11-25 14:00:00.00.
217
[2006-11-25 13:15:00.00] LSCHED  Must preempt leases [1] to make room for lease #2
218
[2006-11-25 13:15:00.00] LSCHED  Preempting lease #1...
219
[2006-11-25 13:15:00.00] LSCHED  ... lease #1 will be suspended 
220
                                     at 2006-11-25 13:30:00.00.
221
[2006-11-25 13:15:00.00] LSCHED  AR lease #2 has been scheduled.
222

  
223
[2006-11-25 13:29:28.00] VMSCHED Stopped VMs for lease 1 on nodes [1]
224
[2006-11-25 13:29:28.00] VMSCHED Suspending lease 1...
225

  
226
[2006-11-25 13:30:00.00] VMSCHED Lease 1 suspended.
227
[2006-11-25 13:30:00.00] VMSCHED Started VMs for lease 2 on nodes [2, 3, 4, 1]
228
[2006-11-25 13:30:00.00] LSCHED  Next request in the queue is lease 1. Attempting to schedule...
229
[2006-11-25 13:30:00.00] VMSCHED Lease #1 has been scheduled on nodes [1]
230
                                 from 2006-11-25 14:00:00.00 (resuming) 
231
                                   to 2006-11-25 14:31:04.00
232

  
233
[2006-11-25 14:00:00.00] VMSCHED Stopped VMs for lease 2 on nodes [2, 3, 4, 1]
234
[2006-11-25 14:00:00.00] VMSCHED Resuming lease 1...
235
[2006-11-25 14:00:00.00] VMSCHED Lease 2's VMs have shutdown.
236

  
237
[2006-11-25 14:00:32.00] VMSCHED Resumed lease 1
238
[2006-11-25 14:00:32.00] VMSCHED Started VMs for lease 1 on nodes [1]
239

  
240
[2006-11-25 14:31:04.00] VMSCHED Stopped VMs for lease 1 on nodes [1]
241
[2006-11-25 14:31:04.00] VMSCHED Lease 1's VMs have shutdown.
242
[2006-11-25 14:31:04.00] CLOCK   Simulated clock has stopped
243
[2006-11-25 14:31:04.00] RM      Stopping resource manager gracefully...
244
\end{wideshellverbatim}
245

  
246
Notice how the above corresponds to the previous figure. In particular, notice the following:
247

  
248
\begin{itemize}
249
 \item  When the AR lease request is received, Haizea looks at the schedule and determines that the only way to schedule the AR lease is to preempt the best-effort lease. However, instead of cancelling that lease, it will just reschedule it so it is suspended right before the AR lease start. Note that Haizea will always try to minimise the number of preemption (in this case, we're forcing the situation for demonstration purposes) by assigning the AR lease to resources that are available without preempting other leases.
250
 \item Shortly before the AR lease starts, the best-effort lease is suspended (the time required to do this is estimated by Haizea based on an option in the configuration file). When the AR lease ends at 14:00, Haizea begins resuming the suspended best-effort lease.
251
\end{itemize}
252

  
253
\section{The scheduling options}
254

  
255
Haizea has several scheduling options that control how Haizea selects resources and schedules leases. For example, the above example assumed that leases can be suspended (which they generally always can be when running as virtual machines). What would happen if this were not possible? You can modify the suspension option in the \texttt{[scheduling]} section to find out:
256

  
257
\begin{wideshellverbatim}
258
[scheduling]
259
...
260

  
261
suspension: none
262

  
263
...
264
\end{wideshellverbatim}
265

  
266
Rerun Haizea. Now, when the AR lease arrives at 13:15, the scheduler will realise it has to preempt the best-effort lease to make room for the AR lease, but will no longer be able to suspend it. The only option is to cancel the best-effort lease and resubmit it to the queue:
267

  
268
\begin{wideshellverbatim}
269
[2006-11-25 13:15:00.00] LSCHED  Preempting lease #1...
270
[2006-11-25 13:15:00.00] LSCHED  ... lease #1 has been cancelled and requeued
271
\end{wideshellverbatim}
272

  
273
Now, the best-effort lease can only be scheduled after the AR lease, at 14:00:
274

  
275
\begin{wideshellverbatim}
276
[2006-11-25 13:15:00.00] VMSCHED Lease #1 has been scheduled on nodes [1] 
277
                                 from 2006-11-25 14:00:00.00 
278
                                   to 2006-11-25 15:00:00.00
279
\end{wideshellverbatim}
280

  
281
So, the schedule would end up looking like this:
282

  
283
\begin{center}
284
\includegraphics{images/quickstart_leasegraph4.png}
285
\end{center}
286

  
287
Notice how, although suspending a lease is a disruptive activity which can delay the completion time of a best-effort request, it is still much better than completely cancelling a request and waiting for enough resources to accommodate the entire (uninterrupted) duration of the lease.
288

  
289
Another scheduling option you can modify is whether Haizea should transfer the VM's disk image from an image repository before the lease can start. You can do this by modifying the \texttt{lease-deployment} option:
290

  
291
\begin{wideshellverbatim}
292
[general]
293
...
294
lease-preparation: imagetransfer
295
...
296
\end{wideshellverbatim}
297

  
298
If you look at the bottom of the sample configuration file, you will find a section called \texttt{[deploy-imagetransfer]} with all the image transfer options.
299

  
300
Rerun Haizea again. You should get a schedule similar to the previous one, but with some extra messages indicating that image transfers are taking place:
301

  
302
\begin{wideshellverbatim}
303
[2006-11-25 13:00:00.00] DEPLOY  Starting image transfer for lease 1
304
[2006-11-25 13:01:22.00] DEPLOY  Completed image transfer for lease 1
305
\end{wideshellverbatim}
306

  
307
As you can see, the best-effort lease can no longer start right at 13:00, since an image transfer has to take place before the starting time. The same is true of the AR lease, but notice how Haizea schedules the image transfer in such a way that the AR lease can still start at 13:30 as planned (instead of delaying the starting time until 13:31:22).
308

  
309
There are several other options you can modify in the \texttt{[scheduling]} section, such as what backfilling algorithm to use, whether to allow lease migration or not, etc. These options are described in the following chapters, and in Appendix~\ref{app:conffile}.
310

  
311
\section{Interactive simulations} 
312

  
313
Up to this point, Haizea has been scheduling leases in ``simulated time''. This meant that we provided Haizea with a lease workload beforehand, ran it, and got the results of scheduling that workload much earlier than it would have actually taken to run the leases (e.g., if we requested a 30 minute lease, we didn't have to wait 30 minutes for the lease to complete; Haizea just skipped from the start to the end of the lease). This ``fast forward'' approach is useful if you want to experiment with different scheduling parameters and workloads. However, you can also run Haizea in simulation and in ``real time''. To do this, you need to change the \texttt{clock} option of the \texttt{[simulation]} section:
314

  
315
\begin{wideshellverbatim}
316
[simulation]
317
...
318
clock: real
319
...
320
\end{wideshellverbatim}
321

  
322
If you run Haizea in this mode, it will run a daemon that is ready to accept your requests interactively through a command-line interface, instead of processing a list of requests provided beforehand. You should see the following when running the \texttt{haizea} command:
323

  
324
\begin{wideshellverbatim}
325
Started Haizea daemon with pid NNNN
326
\end{wideshellverbatim}
327

  
328
You will then get control of your console back. If you're wondering where all the logging messages are being saved to, they're now being sent to a file. The default logfile is \texttt{/var/tmp/haizea.log}. You can take a peek at it like this:
329

  
330
\begin{shellverbatim}
331
tail /var/tmp/haizea.log
332
\end{shellverbatim}
333

  
334
You will notice messages like this:
335

  
336
\begin{wideshellverbatim}
337
[2008-09-24 14:14:18.58] CLOCK   Going back to sleep. 
338
                                 Waking up at 2008-09-24 14:15:19.00 
339
                                 to see if something interesting has 
340
                                 happened by then.
341
\end{wideshellverbatim}
342

  
343
Since time is not simulated, Haizea doesn't know what the ``next time'' to skip to will be, so it will simply wake up periodically to see if anything interesting has happened (like a new request). This interval can be changed in the configuration file:
344

  
345
\begin{wideshellverbatim}
346
[simulation]
347
...
348
wakeup-interval: 10
349
...
350
\end{wideshellverbatim}
351

  
352
However, when Haizea plans an event (e.g., leases that have to start or end), it will wake up specifically to handle that event (instead of waiting for the wakeup interval to conclude).
353

  
354
So, let's give Haizea something to do. The \texttt{haizea-request-lease} command is used to request leases. For example, the following command is used to request an 1-node AR lease one minute in the future, for ten minutes:
355

  
356
\begin{wideshellverbatim}
357
haizea-request-lease -t +00:02:00 -d 00:10:00 -n 1 --non-preemptible \
358
                     -c 1 -m 512 -i foobar.img -z 600 
359
\end{wideshellverbatim}
360

  
361
Additionally, you can also write a lease request using the XML format seen previous, save it to a file, and have \texttt{haizea-request-lease} command parse it:
362

  
363
\begin{wideshellverbatim}
364
haizea-request-lease -f request.xml
365
\end{wideshellverbatim}
366

  
367
You can find more details on this command's parameters by running \texttt{haizea-request-lease -h} or taking a look at Appendix~\ref{app:cli}. Once you've submitted the lease, you should see the following:
368

  
369
\begin{wideshellverbatim}
370
Lease submitted correctly.
371
Lease ID: 1
372
\end{wideshellverbatim}
373

  
374
You can check the status of your submitted lease by looking at the log file or, more conveniently, using this command:
375

  
376
\begin{shellverbatim}
377
haizea-list-leases
378
\end{shellverbatim}
379

  
380
You should see the following:
381

  
382
\begin{wideshellverbatim}
383
 ID   Type          State      Starting time           Duration      Nodes  
384
 1    AR            Scheduled  2009-08-04 11:25:57.00  00:10:00.00   1        
385
\end{wideshellverbatim}
386

  
387
Note: You may not see your lease right away, since Haizea has to ``become aware'' of it (which won't happen until it wakes up to check if there are any new requests). Future versions of Haizea will enable it to be notified immediately of incoming requests.
388

  
389
Remember that the lease has been requested one minute into the future, so it will remain in a ``Scheduled'' state for a couple seconds. If you run \texttt{haizea-list-leases} periodically, you should see it pass through a couple other states. If image transfers are still enabled, it will first transition to the ``Preparing'' state:
390

  
391
\begin{wideshellverbatim}
392
 ID   Type          State      Starting time           Duration      Nodes  
393
 1    AR            Preparing  2009-08-04 11:25:57.00  00:10:00.00   1       
394
\end{wideshellverbatim}
395

  
396
And then to the ``Active'' state:
397

  
398
\begin{wideshellverbatim}
399
 ID   Type          State      Starting time           Duration      Nodes  
400
 1    AR            Active     2009-08-04 11:25:57.00  00:10:00.00   1       
401
\end{wideshellverbatim}
402

  
403
Now let's request a best-effort lease:
404

  
405
\begin{wideshellverbatim}
406
haizea-request-lease -t best_effort -d 00:10:00 -n 4 --non-preemptible \
407
                     -c 1 -m 512 -i foobar.img -z 600
408
\end{wideshellverbatim}
409

  
410
The list of leases will now look like this:
411

  
412
\begin{wideshellverbatim}
413
 ID   Type          State      Starting time           Duration      Nodes  
414
 1    AR            Active     2009-08-04 11:25:57.00  00:10:00.00   1       
415
 2    Best-effort   Scheduled  Unspecified             00:10:00.00   4       
416
\end{wideshellverbatim}
417

  
418
Note how, for best-effort leases, the starting time is set to ``Unspecified'', which means this time is not specified by the user, but instead determined on a best-effort basis by the scheduler. Since the lease is in a ``Scheduled'' state, that means that it has been assigned a starting time (although that information is currently not available through the command-line interface; it can be seen in the Haizea log).
419

  
420
Now try to rerun the \texttt{haizea-request-lease} command a couple times (i.e., lets submit a couple more best-effort requests). The scheduler won't be able to schedule them, since they require all the available nodes, and the AR lease is using up one of them. The previous best-effort lease was scheduled because Haizea's default behaviour is to schedule at most one best-effort lease in the future if resources cannot be found right away (this is due to Haizea's use of backfilling algorithms; for now, don't worry if you don't know what they are). Anyway, the list of leases should now look like this:
421

  
422
\begin{wideshellverbatim}
423
 ID   Type  State      Starting time           Duration      Nodes  
424
 1    AR            Active     2009-08-04 11:25:57.00  00:10:00.00   1       
425
 2    Best-effort   Scheduled  Unspecified             00:10:00.00   4       
426
 3    Best-effort   Queued     Unspecified             00:10:00.00   4       
427
 4    Best-effort   Queued     Unspecified             00:10:00.00   4       
428
 5    Best-effort   Queued     Unspecified             00:10:00.00   4       
429
 6    Best-effort   Queued     Unspecified             00:10:00.00   4       
430
\end{wideshellverbatim}
431

  
432
Notice how the extra best-effort requests have been queued. If you only want to see the contents of the queue, you can use the following command:
433

  
434
\begin{shellverbatim}
435
haizea-show-queue
436
\end{shellverbatim}
437

  
438
This should show the following:
439

  
440
\begin{wideshellverbatim}
441
 ID   Type          State      Starting time           Duration      Nodes  
442
 3    Best-effort   Queued     Unspecified             00:10:00.00   4       
443
 4    Best-effort   Queued     Unspecified             00:10:00.00   4       
444
 5    Best-effort   Queued     Unspecified             00:10:00.00   4       
445
 6    Best-effort   Queued     Unspecified             00:10:00.00   4       
446
\end{wideshellverbatim}
447

  
448
When you're done, you can shut Haizea down cleanly by running the following:
449

  
450
\begin{shellverbatim}
451
haizea --stop
452
\end{shellverbatim}
453

  
454

  
455
\section{Other things you can do with Haizea}
456

  
457
At this point, we have seen how to run simple simulations with Haizea. However, there is a lot more that Haizea can do:
458

  
459
\begin{description}
460
\item[Run on real hardware] First and foremost, almost everything you just saw above in simulation can be done on real hardware. This is accomplished by using Haizea with the OpenNebula virtual infrastructure manager. So, if you have a Xen or KVM cluster, you can just install OpenNebula and Haizea to enable your users to request VM-based leases on your cluster. This is explained in Chapter~\ref{chap:opennebula}.
461
\item[Run complex simulations] This chapter concerned itself mostly with scheduling two leases on a 4-node cluster during a span of roughly 2 hours. \emph{Boring}. Haizea can handle more complex simulations, and also provides the necessary tools for you to easily run multiple simulations with different profiles. For example, in the Haizea paper ``Combining Batch Execution and Leasing Using Virtual Machines'' (see the Haizea publication page: \url{http://haizea.cs.uchicago.edu/pubs.html}) we simulated running 72 30-day workloads in six different configurations, or 36 years of lease scheduling. Running multiple simulations is explained in Section~\ref{sec:multiplesim}
462
\item[Produce reports and graphs] The above examples relied on reading the Haizea log messages or peeking into Haizea's schedule using command-line tools. This is ok for a simple simulation, but no fun when you're scheduling thousands of leases. Haizea saves a fair amount of raw data to disk with scheduling metrics, utilization information, etc. which can be used to generate reports and graphs. We are in the process of producing tools that will allow you to easily analyse that data and create graphs, although some pointers on how to interpret the raw data produced by Haizea are presented in Chapter~\ref{chap:analysing}.
463
\end{description}
tags/Release 1.0/doc/manual/gen_probe_doc.py
1
from haizea.common.utils import rst2latex
2
from haizea.pluggable.accounting import probe_class_mappings
3
from haizea.pluggable.accounting.leases import ARProbe, BEProbe, IMProbe
4
from haizea.pluggable.accounting.utilization import  CPUUtilizationProbe, DiskUsageProbe
5

  
6
probes = [ARProbe, BEProbe, IMProbe, CPUUtilizationProbe, DiskUsageProbe]
7

  
8
inv_mappings = dict([(v,k) for k,v in probe_class_mappings.items()])
9

  
10
for probe in probes:
11
    fullname = probe.__module__ + "." + probe.__name__
12
    print "\\section{\\texttt{%s}}" % probe.__name__
13
    print "\\noindent\\textbf{Full name:} \\texttt{%s}" % fullname
14
    if inv_mappings.has_key(fullname):
15
        print "\\\\ \\textbf{Short name:} \\texttt{%s}" % inv_mappings[fullname]
16
    print "\\\\ \\textbf{Description:} \\\\"
17
    print rst2latex(probe.__doc__)
tags/Release 1.0/doc/manual/manual.tex
1
\documentclass[11pt,oneside]{scrbook}
2
\usepackage[pdftex]{graphicx}
3
\usepackage{url}
4
\usepackage{html}
5
\usepackage{notes}
6
\usepackage{fullpage}
7

  
8
\include{utils}
9
\setcounter{tocdepth}{1}
10

  
11
\begin{document}
12
\frontmatter
13
\title{The Haizea Manual}
14
\author{Borja Sotomayor}
15

  
16
\begin{latexonly}
17
\input{title}
18
\end{latexonly}
19
\begin{htmlonly}
20
\maketitle
21
\end{htmlonly}
22

  
23
\tableofcontents
24

  
25
\chapter{Preface}
26
\input{intro}
27

  
28
\mainmatter
29

  
30
\part{Fundamental Concepts}
31

  
32
\chapter{What is Haizea?}
33
\label{chap:whatis}
34

  
35
\input{whatis}
36

  
37
\chapter{Resource leases}
38
\label{chap:leases}
39
\input{leases}
40

  
41
\part{Using Haizea}
42

  
43
\chapter{Installing Haizea}
44
\label{chap:install}
45
\input{install}
46

  
47
\chapter{Quickstart guide}
48
\label{chap:quickstart}
49
\input{quickstart}
50

  
51
\chapter{Running scheduling simulations}
52
\label{chap:simulation}
53
\input{simulation}
54

  
55
\chapter{Haizea and OpenNebula}
56
\label{chap:opennebula}
57
\input{opennebula}
58

  
59
\chapter{Analysing scheduling data}
60
\label{chap:analysing}
61
\input{analysing}
62

  
63

  
64
\part{Customizing Haizea}
65

  
66
\chapter{Writing your own policies}
67
\label{chap:policies}
68
\input{policies}
69

  
70
\chapter{Writing accounting probes}
71
\label{chap:accounting}
72
\input{accounting}
73

  
74
%\chapter{Writing your own resource mapper}
75
%\label{chap:mapper}
76
%\input{mapper}
77

  
78

  
79
\part{Appendices}
80
\appendix
81

  
82
\chapter{Command-line interface reference}
83
\label{app:cli}
84
\input{appendix_cli}
85

  
86
\chapter{Configuration file reference}
87
\label{app:conffile}
88
\input{appendix_conf}
89

  
90
\chapter{XML format reference}
91
\label{app:lwf}
92
\input{appendix_lwf}
93

  
94
\chapter{Accounting probes reference}
95
\label{app:probes}
96
\input{appendix_probes}
97

  
98
%\chapter{XML-RPC API}
99
%\label{app:rpc}
100
%\input{appendix_rpc}
101

  
102
\end{document}
tags/Release 1.0/doc/manual/gen_html.sh
1
#!/bin/bash
2

  
3
python gen_cli_doc.py > appendix_cli.tex
4
python gen_config_doc.py > appendix_conf.tex
5
python gen_probe_doc.py > appendix_probes.tex
6

  
7
latex2html -split 4 -dir ../../html/manual -show_section_numbers -local_icons -toc_depth 3 -link 2 -top_navigation -bottom_navigation manual.tex
8
tar cvzf ../../html/downloads/haizea-manual-multiple.tar.gz ../../html/manual
9

  
10
latex2html -split 0 -no_navigation -dir ../../html/manual_single -show_section_numbers -local_icons -toc_depth 3 manual.tex 
11
tar cvzf ../../html/downloads/haizea-manual-single.tar.gz ../../html/manual_single
12
#tidy --clean y --doctype "transitional" --output-xhtml y --indent "auto" --wrap "90" --char-encoding "utf8" --logical-emphasis y
13

  
14
cp manual.pdf ../../html/haizea_manual.pdf
15

  
16

  
17

  
tags/Release 1.0/doc/manual/whatis.tex
1
Haizea is an open-source VM-based lease management architecture. Let's break that down, shall we?
2

  
3
\begin{description}
4
\item[Haizea is a resource manager] (or, depending on who you ask, a "resource scheduler"): Haizea is a software component that can manage a set of computers (typically a cluster), allowing users to request exclusive use of those resources described in a variety of terms, such as "I need 10 nodes, each with 1 GB of memory, right now" or "I need 4 nodes, each with 2 CPUs and 2GB of memory, from 2pm to 4pm tomorrow".
5
\item[Haizea uses leases] The fundamental resource provisioning abstraction in Haizea is the lease. Intuitively, a lease is some form of contract where one party agrees to provide a set of resources (an apartment, a car, etc.) to another party. When a user wants to request computational resources from Haizea, it does so in the form of a lease. When applied to computational resources, the lease abstraction is a powerful and general construct with a lot of nuances. Leases are described in more detail in Chapter~\ref{chap:leases}
6
\item[Haizea is VM-based] We hold that the best way of implementing resource leases is using virtual machines (VMs). Therefore, Haizea's scheduling algorithms are geared towards managing virtual machines, factoring in all the extra operations (and overhead) involved in managing VMs. The Globus Virtual Workspaces group, where Haizea was originally developed, has an extensive list of publications that argue how using virtual machines for resource leasing is \textsf{A Good Thing} (and also \textsf{Not A Trivial Thing}).
7
\item[Haizea is open source] Haizea is published under the Apache License 2.0, a BSD-like OSI-compatible license.
8
\end{description}
9

  
10
\section{What can you do with Haizea?}
11

  
12
Haizea is, primarily, a VM resource management component that takes lease requests and makes scheduling decisions based on those requests, but doesn't actually know anything about how to enact those decisions. For example, Haizea may determine at what times a set of VMs representing a lease must start and stop, but it doesn't actually know how to instruct a virtual machine manager (such as Xen, KVM, etc.) to do these actions. Haizea can, however, delegate these enactment actions to an external component using a simple API. Haizea can currently interface with the OpenNebula (\url{http://www.opennebula.org/}) virtual infrastructure manager to enact its scheduling decisions. Haizea can also simulate enactment actions, which makes it useful for doing scheduling research involving leases or VMs (in fact, the Haizea simulator has been used in a couple of papers).
13

  
14
So, Haizea can be used in three modes: OpenNebula mode, unattended simulation mode, and interactive simulation mode.
15

  
16
\subsection{OpenNebula mode}
17

  
18
\begin{center}
19
\includegraphics{images/mode_opennebula.png}
20
\end{center}
21

  
22
Haizea can be used as a drop-in replacement for OpenNebula's scheduling daemon. OpenNebula is a virtual infrastructure manager that enables the dynamic deployment and re-allocation of virtual machines on a pool of physical resources. OpenNebula and Haizea complement each other, since OpenNebula provides all the enactment muscle (OpenNebula can manage Xen and KVM virtual machines on a cluster, with VMWare support to follow shortly) while Haizea provides all the scheduling brains. 
23

  
24
Chapter~\ref{chap:opennebula} describes how to use Haizea and OpenNebula together.
25

  
26
\subsection{Unattended simulation mode}
27

  
28
\begin{center}
29
\includegraphics{images/mode_unattended_simulation.png}
30
\end{center}
31

  
32
In this mode, Haizea takes a list of lease requests (specified in a \emph{tracefile}) and a configuration file specifying simulation and scheduling options (such as the characteristics of the hardware to simulate), and processes them in ``simulated time''. In other words, the goal of this mode is to obtain the final schedule for a set of leases, without having to wait for all those leases to complete in real time (this makes this mode particularly useful to find out what effect a certain scheduling option could have over a period of weeks or months). In fact, the final result of an unattended simulation is a datafile with raw scheduling data and metrics which can be used to generate reports and graphs. 
33

  
34
Chapter~\ref{chap:quickstart} provides a quickstart-style introduction to running Haizea in unattended simulation mode, and Chapter~\ref{chap:simulation} explains simulation options in more detail. Analysis of the scheduling data generated by an unattended simulation is covered in Chapter~\ref{chap:analysing} 
35

  
36
\subsection{Interactive simulation mode}
37

  
38
\begin{center}
39
\includegraphics{images/mode_interactive_simulation.png}
40
\end{center}
41

  
42
In this mode, enactment actions are simulated, but Haizea runs in ``real time''. This means that, instead of having to provide a list of lease requests beforehand, your can use Haizea's command-line interface to request leases interactively and query the status of Haizea's schedule (e.g., to find out the state of lease you've requested). Obviously, this mode is not useful if you want to simulate weeks or months of requests, but it is handy if you want to experiment with leases and track the schedule in a more user-friendly way (since the datafile produced by the unattended simulation is mostly meant for consumption by other programs, e.g., to generate graphs and reports).
43

  
44
Chapter~\ref{chap:quickstart}, the quickstart-style introduction, also includes instructions on how to run Haizea in interactive simulation mode.
45

  
46
\section{Haizea architecture}
47

  
48
\begin{figure}
49
\begin{center}
50
\includegraphics[width=0.4\textwidth]{images/architecture.png}
51
\end{center}
52
\caption{The Haizea architecture}
53
\label{fig:arch}
54
\end{figure}
55

  
56
The Haizea architecture (see Figure~\ref{fig:arch}) is divided into the following three layers:
57

  
58
\begin{description}
59
\item[The request frontend] This is where lease requests arrive. Haizea can currently accept requests from OpenNebula, through a command-line interface, or read them from a tracefile (in SWF format or using the Haizea-specific LWF format).
60
\item[The scheduling core] This is where the lease requests are processed and scheduled, resulting in enactment actions happening at specific points in time (e.g., "Start VM for lease X in node Y at time T", etc.)
61
\item[The enactment modules] These take care of the "dirty work" of carrying out the enactment actions generated by the scheduler. Haizea can currently send enactment actions to OpenNebula, resulting in Haizea being able to manage Xen and KVM clusters (VMWare support coming soon), or to a simulated cluster.
62
\end{description}
63

  
64
The Haizea architecture keeps these three layers completely decoupled, which means that adding support for an additional enactment backend only requires writing an enactment module for that backend. The API for enactment modules is still not fully defined, and integration with OpenNebula is currently driving this effort. However, if you'd be interested in using Haizea in another system, please do let us know. We'd be very interested in hearing what your requirements are for the frontend and enactment APIs.
tags/Release 1.0/doc/manual/policies.tex
1
Haizea uses several scheduling algorithms internally to determine what resources to allocate to a lease. For the most part, modifying these algorithms requires digging deep into the Haizea code. However, several scheduling decisions that depend on an organizations own resource allocation policies are factored out of the main scheduling code into pluggable \emph{policy decision module}. In particular, the following decisions are factored out:
2

  
3
\begin{description}
4
 \item[Lease admission]: Should a lease request be accepted or rejected? Take into account that this decision takes place before Haizea determines if the request is even feasible. For example, an organization may require that all AR leases must be requested at least one hour in advance, regardless of whether there would be enough resources to satisfy the request before that time. However, being accepted doesn't guarantee the lease will get resources (although this could factor into the decision too); an AR lease could meet the ``one hour advance warning'' requirement, but still end up being rejected because there are no resources available at the requested time.
5
 \item[Lease preemptability]: How preemptable is a lease? Not all leases are created equal and, if the scheduler determines that a lease request can only be satisfied by preempting other leases, it may have to determine what leases are better candidates for preemption. For example, given a choice of preempting a lease that's been running for a week and another that's been running for five minutes, an organization might prefer to not interrupt the long-running lease.
6
 \item[Host selection]: What hosts should a lease be scheduled in? When the scheduler has a choice of several physical hosts on which to deploy VMs, some might be preferable than others. For example, an organization might want to pack as many VMs into the same hosts, to shut down those that are not running VMs, while another might want to spread those VMs across several hosts, leaving some free resources available in each host in case the VMs need extra capacity further down the road.
7
\end{description}
8

  
9
As you can see, these are all policy decisions that are driven by an organization's own goals for its resources. Thus, Haizea makes it simple to write your own policy decision code \emph{without} having to modify Haizea's code. All you have to do is write a simple Python module, and then ``plug it'' into Haizea by instructing it (through the configuration file) to use that module. This chapter describes how this is done.
10

  
11
\begin{warning}
12
This documentation refers to Haizea objects, such as \texttt{Lease} and \texttt{SlotTable} that are not yet documented in this manual. For now, you will need to read the Haizea Pydoc documentation (linked from the Documentation section of the Haizea website) to see what attributes and methods these classes have. A more complete documentation will be included in the final 1.0 release.
13
\end{warning}
14

  
15
\section{Lease admission}
16

  
17
A lease admission policy module looks like this:
18

  
19
\begin{wideshellverbatim}
20
from haizea.core.scheduler.policy import LeaseAdmissionPolicy
21

  
22
class MyPolicy(LeaseAdmissionPolicy):
23
    def __init__(self, slottable):
24
        LeaseAdmissionPolicy.__init__(self, slottable)
25
        
26
    def accept_lease(self, lease):
27
        # Your code goes here
28
\end{wideshellverbatim}
29

  
30
The \texttt{accept\_lease} method receives a \texttt{Lease} object, and must return \texttt{True} if the lease can be accepted, and \texttt{False} if it should be rejected. You can also add code to the constructor, but cannot alter its parameter list. Haizea includes some built-in admission policies that you can see in \texttt{src/haizea/policies/admission.py}
31

  
32
The lease admission policy that Haizea must use is specified using the \texttt{policy-admission} option of the \texttt{[scheduling]} section in the configuration file. So, assuming you save your module as \texttt{policies.py}, you would specify the following in the configuration file:
33

  
34
\begin{wideshellverbatim}
35
[scheduling]
36
...
37
policy-admission: policies.MyPolicy
38
...
39
\end{wideshellverbatim}
40

  
41
For this to work, you have to make sure that the \texttt{policies.py} module you created is in your \texttt{PYTHONPATH} when you start Haizea.
42

  
43
For example, let's suppose we want to write an admission policy that, as described earlier, will reject AR leases that are not requested at least one hour in advance. This policy module would look like this:
44

  
45
\begin{wideshellverbatim}
46
from haizea.core.scheduler.policy import LeaseAdmissionPolicy
47
from haizea.core.leases import Lease
48
from haizea.common.utils import get_clock
49
from mx.DateTime import TimeDelta
50

  
51
class MyPolicy(LeaseAdmissionPolicy):
52
    def __init__(self, slottable):
53
        LeaseAdmissionPolicy.__init__(self, slottable)
54
        
55
    def accept_lease(self, lease):
56
        allowed = TimeDelta(hours=1)
57
        now = get_clock().get_time()
58
        
59
        if lease.get_type() == Lease.ADVANCE_RESERVATION:
60
            if lease.start.requested - now <= allowed:
61
                return False
62
        return True
63
\end{wideshellverbatim}
64

  
65
Save this file as \texttt{policies.py}, make sure the directory it's in is in your \texttt{PYTHONPATH}, and set \texttt{[scheduling].policy-admission} to \texttt{policies.MyPolicy} in the configuration file. If you rerun the example from the quickstart guide, instead of seeing this:
66

  
67
\begin{wideshellverbatim}
68
[2006-11-25 13:15:00.00] LSCHED  Lease #2 has been requested.
69
[2006-11-25 13:15:00.00] LSCHED  Lease #2 has been marked as pending.
70
\end{wideshellverbatim}
71

  
72
You will see that the AR lease, which is requested 15 minutes before it starts, is rejected:
73

  
74
\begin{wideshellverbatim}
75
[2006-11-25 13:15:00.00] LSCHED  Lease #2 has been requested.
76
[2006-11-25 13:15:00.00] LSCHED  Lease #2 has not been accepted
77
\end{wideshellverbatim}
78

  
79
In fact, if you modify the starting time to be the following:
80

  
81
\begin{wideshellverbatim}
82
<start>
83
	<exact time="02:00:00"/>
84
</start>
85
\end{wideshellverbatim}
86

  
87
The lease will be accepted again, although it will start later than before:
88

  
89
\begin{wideshellverbatim}
90
[2006-11-25 15:00:00.00] VMSCHED Started VMs for lease 2 on nodes [1, 2, 3, 4]
91
[2006-11-25 15:30:00.00] VMSCHED Stopped VMs for lease 2 on nodes [1, 2, 3, 4]
92
\end{wideshellverbatim}
93

  
94
\section{Lease preemptability}
95

  
96
A lease preemptability policy module looks like this:
97

  
98
\begin{wideshellverbatim}
99
from haizea.core.leases import Lease
100
from haizea.core.scheduler.policy import PreemptabilityPolicy
101

  
102
class MyPolicy(PreemptabilityPolicy):
103
    def __init__(self, slottable):
104
        PreemptabilityPolicy.__init__(self, slottable)
105
    
106
    def get_lease_preemptability_score(self, preemptor, preemptee, time):
107
        # Your code goes here
108
\end{wideshellverbatim}
109

  
110
The \texttt{get\_lease\_preemptability\_score} receives two \texttt{Lease} objects, the lease that wants to preempt resources (the \texttt{preemptor}) and the lease that is being considered for preemption (the \texttt{preemptee}), and the time at which the preemption would take place. The method should return the \emph{preemptability score} of the preemptee, indicating how preemptable the lease is. This score can take on the following values:
111

  
112
\begin{itemize}
113
 \item $-1$: Cannot be preempted under any circumstances
114
 \item $0.0 \leq \textrm{score} \leq 1.0$: The lease can be preempted. The higher the score, the "more preemptable" it is. Take into account that this is a relative measure: the score will be used by the scheduler to determine which of several leases is a better candidate for preemption.
115
\end{itemize}
116

  
117
The lease preemptability policy to use is specified using the \texttt{policy-preemption} option of the \texttt{[scheduling]} section in the configuration file. So, assuming you save your module as \texttt{policies.py}, you would specify the following in the configuration file:
118

  
119
\begin{wideshellverbatim}
120
[scheduling]
121
...
122
policy-preemption: policies.MyPolicy
123
...
124
\end{wideshellverbatim}
125

  
126
\section{Host selection}
127

  
128
A host selection policy module looks like this:
129

  
130
\begin{wideshellverbatim}
131
from haizea.core.scheduler.policy import HostSelectionPolicy
132

  
133
class NoPolicy(HostSelectionPolicy):
134
    def __init__(self, slottable):
135
        HostSelectionPolicy.__init__(self, slottable)
136
    
137
    
138
    def get_host_score(self, node, time, lease):       
139
        # Your code goes here
140
\end{wideshellverbatim}
141

  
142
The \texttt{get\_host\_score} method receives a physical host (the integer node identifier used in the slot table, which all policy modules have access to), a time, and a \texttt{Lease} object we would like to schedule at that time. This method returns a score indicating how desirable that host is for that lease at that time. The score can be between 0.0 and 1.0, and the higher the score,       the "more desirable" the physical host is. Like the lease preemptability score, this is a relative measure; the score will be used to determine which of several physical hosts is more desirable for this lease.
143

  
144
The host selection policy to use is specified using the \texttt{policy-host-selection} option of the \texttt{[scheduling]} section in the configuration file. So, assuming you save your module as \texttt{policies.py}, you would specify the following in the configuration file:
145

  
146
\begin{wideshellverbatim}
147
[scheduling]
148
...
149
policy-host-selection: policies.MyPolicy
150
...
151
\end{wideshellverbatim}
tags/Release 1.0/doc/manual/gen_config_doc.py
1
from haizea.core.configfile import HaizeaConfig
2
from haizea.common.config import OPTTYPE_INT, OPTTYPE_FLOAT, OPTTYPE_STRING, OPTTYPE_BOOLEAN, OPTTYPE_DATETIME, OPTTYPE_TIMEDELTA 
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff