forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItWorkVO.java
More file actions
178 lines (141 loc) · 4.33 KB
/
ItWorkVO.java
File metadata and controls
178 lines (141 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.utils.time.InaccurateClock;
import com.cloud.vm.VirtualMachine.State;
@Entity
@Table(name="op_it_work")
public class ItWorkVO {
enum ResourceType {
Volume,
Nic,
Host
}
enum Step {
Prepare,
Starting,
Started,
Release,
Done,
Migrating
}
@Id
@Column(name="id")
String id;
@Column(name="created_at")
long createdAt;
@Column(name="mgmt_server_id")
long managementServerId;
@Column(name="type")
State type;
@Column(name="thread")
String threadName;
@Column(name="step")
Step step;
@Column(name="updated_at")
long updatedAt;
@Column(name="instance_id")
long instanceId;
public long getInstanceId() {
return instanceId;
}
@Column(name="resource_id")
long resourceId;
@Column(name="resource_type")
ResourceType resourceType;
@Column(name="vm_type")
@Enumerated(value=EnumType.STRING)
VirtualMachine.Type vmType;
public VirtualMachine.Type getVmType() {
return vmType;
}
public long getResourceId() {
return resourceId;
}
public void setResourceId(long resourceId) {
this.resourceId = resourceId;
}
public ResourceType getResourceType() {
return resourceType;
}
public void setResourceType(ResourceType resourceType) {
this.resourceType = resourceType;
}
protected ItWorkVO() {
}
protected ItWorkVO(String id, long managementServerId, State type, VirtualMachine.Type vmType, long instanceId) {
this.id = id;
this.managementServerId = managementServerId;
this.type = type;
this.threadName = Thread.currentThread().getName();
this.step = Step.Prepare;
this.instanceId = instanceId;
this.resourceType = null;
this.createdAt = InaccurateClock.getTimeInSeconds();
this.updatedAt = createdAt;
this.vmType = vmType;
}
public String getId() {
return id;
}
public Long getCreatedAt() {
return createdAt;
}
public long getManagementServerId() {
return managementServerId;
}
public void setManagementServerId(long managementServerId) {
this.managementServerId = managementServerId;
}
public State getType() {
return type;
}
public void setType(State type) {
this.type = type;
}
public String getThreadName() {
return threadName;
}
public Step getStep() {
return step;
}
public void setStep(Step step) {
this.step = step;
}
public long getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(long updatedAt) {
this.updatedAt = updatedAt;
}
public long getSecondsTaskIsInactive() {
return InaccurateClock.getTimeInSeconds() - this.updatedAt;
}
public long getSecondsTaskHasBeenCreated() {
return InaccurateClock.getTimeInSeconds() - this.createdAt;
}
@Override
public String toString() {
return new StringBuilder("ItWork[").append(id).append("-").append(type.toString()).append("-").append(instanceId).append("-").append(step.toString()).append("]").toString();
}
}