forked from ryanflorin/parkinglot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJob.cpp
85 lines (73 loc) · 2.3 KB
/
Job.cpp
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
//File: Job.cpp
//Description:
#include "Job.hpp"
Job::Job()
{
jobStatus = Idle;
jobProcessingTime = 0;
jobProcessingTimeLeft = 999;
JobArrivalTime = -1;
JobStartTime = -1;
VMMigrationJob = NULL;
timeSpentInProcessing = 0;
timeSpentInInitialSetup = 0;
timeSpentInBackup = 0;
timeSpentInFinalization = 0;
timeSpentInVMMigration = 0;
}
void Job::printJobDetails(bool printChildDetails, std::string tab)
{
Logger log;
*log.debug << tab << "Job Assigned" << std::endl;
*log.debug << tab << " Job Number: " << job_number << std::endl;
*log.debug << tab << " Job Status: " << PrintJobStatus(jobStatus) << std::endl;
*log.debug << tab << " Car Number: " << car->car_spot_number << std::endl;
*log.debug << tab << " Job Processing: " << jobProcessingTimeLeft << " of " << jobProcessingTime << " left to process" << std::endl;
if (printChildDetails)
{
std::list<JobTask*>::iterator it_jobTask;
if(!JobTasks.empty())
{
for(it_jobTask = JobTasks.begin(); it_jobTask != JobTasks.end(); it_jobTask++)
{
(*it_jobTask)->printJobTaskDetails(true, tab + " ");
}
}
std::list<MigrationJob*>::iterator it;
if(!DataMigrationJobs.empty())
{
for(it = DataMigrationJobs.begin(); it != DataMigrationJobs.end(); it++)
{
(*it)->printMigrationJobDetails(true, tab + " ");
}
}
if(VMMigrationJob != NULL)
{
VMMigrationJob->printMigrationJobDetails(true, tab + " ");
}
}
}
std::string Job::PrintJobStatus(JobStatus jobStatus)
{
switch (jobStatus)
{
case Idle:
return "Idle";
case InitialSetup:
return "Initial Setup";
case Processing:
return "Processing";
case VMMigrating:
return "VMMigrating";
case VMMigrationComplete:
return "VMMigrationComplete";
case DataMigrating:
return "DataMigrating";
case Complete:
return "Complete";
case FinalMigration:
return "Final Migration";
default:
return "Status Not Mapped";
}
}