This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
DefaultResourceAllocation.java
175 lines (144 loc) · 5.31 KB
/
DefaultResourceAllocation.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
/*
* Copyright 1999-2008 University of Chicago
*
* Licensed 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 org.nimbustools.api.defaults.repr.vm;
import org.nimbustools.api._repr.vm._ResourceAllocation;
public class DefaultResourceAllocation implements _ResourceAllocation {
// -------------------------------------------------------------------------
// INSTANCE VARIABLES
// -------------------------------------------------------------------------
private String architecture;
private int indCpuSpeed = -1;
private int indCpuCount = -1;
private int cpuPercentage = -1;
private int memory;
private int nodeNumber;
private boolean spotInstance;
private String publicNetwork;
private String privateNetwork;
// -------------------------------------------------------------------------
// implements org.nimbustools.api.repr.vm.ResourceAllocation
// -------------------------------------------------------------------------
public String getArchitecture() {
return this.architecture;
}
public int getIndCpuSpeed() {
return this.indCpuSpeed;
}
public int getIndCpuCount() {
return this.indCpuCount;
}
public String getPublicNetwork() {
return this.publicNetwork;
}
public String getPrivateNetwork() {
return this.privateNetwork;
}
public int getCpuPercentage() {
return this.cpuPercentage;
}
public int getMemory() {
return this.memory;
}
public int getNodeNumber() {
return this.nodeNumber;
}
public boolean isSpotInstance() {
return spotInstance;
}
// -------------------------------------------------------------------------
// implements org.nimbustools.api.repr.vm.ResourceAllocation
// -------------------------------------------------------------------------
public void setArchitecture(String architecture) {
this.architecture = architecture;
}
public void setIndCpuSpeed(int indCpuSpeed) {
this.indCpuSpeed = indCpuSpeed;
}
public void setIndCpuCount(int indCpuCount) {
this.indCpuCount = indCpuCount;
}
public void setCpuPercentage(int cpuPercentage) {
this.cpuPercentage = cpuPercentage;
}
public void setMemory(int memory) {
this.memory = memory;
}
public void setPublicNetwork(String publicNetwork) {
this.publicNetwork = publicNetwork;
}
public void setPrivateNetwork(String privateNetwork) {
this.privateNetwork = privateNetwork;
}
public void setNodeNumber(int nodeNumber) {
this.nodeNumber = nodeNumber;
}
public void setSpotInstance(boolean preemptable) {
this.spotInstance = preemptable;
}
// -------------------------------------------------------------------------
// DEBUG STRING
// -------------------------------------------------------------------------
public String toString() {
return "DefaultResourceAllocation{" +
"architecture='" + architecture + '\'' +
", indCpuSpeed=" + indCpuSpeed +
", indCpuCount=" + indCpuCount +
", cpuPercentage=" + cpuPercentage +
", memory=" + memory +
", nodeNumber=" + nodeNumber +
'}';
}
// -------------------------------------------------------------------------
// EQUALS AND HASHCODE
// -------------------------------------------------------------------------
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((architecture == null) ? 0 : architecture.hashCode());
result = prime * result + cpuPercentage;
result = prime * result + indCpuSpeed;
result = prime * result + memory;
result = prime * result + nodeNumber;
result = prime * result + (spotInstance ? 1231 : 1237);
return result;
}
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DefaultResourceAllocation other = (DefaultResourceAllocation) obj;
if (architecture == null) {
if (other.architecture != null)
return false;
} else if (!architecture.equals(other.architecture))
return false;
if (cpuPercentage != other.cpuPercentage)
return false;
if (indCpuSpeed != other.indCpuSpeed)
return false;
if (memory != other.memory)
return false;
if (nodeNumber != other.nodeNumber)
return false;
if (spotInstance != other.spotInstance)
return false;
return true;
}
}