source: xssim/src/test/rewolucja/reservation/ReservationNew.java @ 104

Revision 104, 2.9 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.rewolucja.reservation;
2
3import java.util.List;
4
5import org.joda.time.DateTime;
6
7import schedframe.resources.ResourceDescription;
8import schedframe.scheduling.ReservedHost;
9import schedframe.scheduling.TimeResourceAllocation;
10import schedframe.scheduling.utils.ResourceParameterName;
11
12public class ReservationNew extends TimeResourceAllocation {
13
14        private static final long serialVersionUID = 7837525861926610754L;
15
16        protected Status status;
17
18        protected DateTime creationTime;
19       
20        protected String resourceName;
21       
22        protected List<ReservedHost> reservedHosts;
23       
24        protected String jobId;
25       
26        protected String taskId;
27       
28        protected String userId;
29       
30        public ReservationNew(ResourceDescription allocatedResource,
31                        DateTime startTime, DateTime endTime, DateTime creationTime) {
32                super(allocatedResource, startTime, endTime);
33                this.creationTime = creationTime;
34        }
35       
36        public ReservationNew(ReservationNew r){
37                super(r);
38                this.status = r.getStatus();
39                this.creationTime = new DateTime(r.getCreationTime());
40                this.resourceName = r.getResourceName();
41        }
42
43        public Status getStatus(){
44                return this.status;
45        }
46       
47        public synchronized void setStatus(Status status){
48                this.status = status;
49        }
50       
51        public String getResourceName(){
52                return this.resourceName;
53        }
54       
55        public void setResourceName(String resourceName){
56                this.resourceName = resourceName;
57        }
58       
59        public DateTime getCreationTime(){
60                return this.creationTime;
61        }
62       
63        public boolean equals(Object obj){
64                if(obj instanceof ReservationNew == false)
65                        return false;
66               
67                if(! super.equals(obj)) return false;
68               
69                ReservationNew r = (ReservationNew) obj;
70               
71                if(creationTime != null && ! creationTime.equals(r.getCreationTime())) return false;
72               
73                if(resourceName != null && ! resourceName.equals(r.resourceName)) return false;
74               
75                if(status != r.getStatus())
76                        throw new RuntimeException("Two objects, representing reservation "+ this.id +
77                                        " have different status.");
78               
79                return true;
80        }
81       
82        public String toString(){
83                String s = null;
84                try {
85                        s = "reservation id/jobId/taskId/start/end: " +
86                        id + "/" + jobId + "/" + taskId + "/" + getStart() + "/" + getEnd() +
87                        " res amount: " + allocatedResource.getResourceUnit(ResourceParameterName.CPUCOUNT).getUsedAmount();
88                } catch (NoSuchFieldException e) {
89                        e.printStackTrace();
90                }
91                return s;
92        }
93       
94        public String getJobId() {
95                return jobId;
96        }
97
98        public void setJobId(String jobId) {
99                this.jobId = jobId;
100        }
101
102        public String getTaskId() {
103                return taskId;
104        }
105
106        public void setTaskId(String taskId) {
107                this.taskId = taskId;
108        }
109
110        public String getUserId() {
111                return userId;
112        }
113
114        public void setUserId(String userId) {
115                this.userId = userId;
116        }
117       
118        public List<ReservedHost> getReservedHosts(){
119                return this.reservedHosts;
120        }
121       
122        public void setReservedHosts(List<ReservedHost> list){
123                this.reservedHosts = list;
124        }
125       
126        public enum Status{
127                INITIAL(),
128                COMMITTED(),
129                ACTIVE(),
130                EXPIRED(),
131                CANCELED(),
132                FINISHED();
133        }
134}
Note: See TracBrowser for help on using the repository browser.