forked from AcademySoftwareFoundation/OpenCue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHostDao.java
More file actions
323 lines (283 loc) · 8.48 KB
/
Copy pathHostDao.java
File metadata and controls
323 lines (283 loc) · 8.48 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*
* Copyright Contributors to the OpenCue Project
*
* 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 com.imageworks.spcue.dao;
import java.sql.Timestamp;
import com.imageworks.spcue.AllocationInterface;
import com.imageworks.spcue.DispatchHost;
import com.imageworks.spcue.HostEntity;
import com.imageworks.spcue.HostInterface;
import com.imageworks.spcue.LocalHostAssignment;
import com.imageworks.spcue.Source;
import com.imageworks.spcue.grpc.host.HardwareState;
import com.imageworks.spcue.grpc.host.HostTagType;
import com.imageworks.spcue.grpc.host.LockState;
import com.imageworks.spcue.grpc.host.ThreadMode;
import com.imageworks.spcue.grpc.report.HostReport;
import com.imageworks.spcue.grpc.report.RenderHost;
/**
* HostDao contains all SQL queries pretaining to host records.
*/
public interface HostDao {
/**
* Attempt to obtain an exclusive lock on the host. If another thread alrady has the host
* locked, a ResourceReservationFailureException is thrown.
*
* @param host HostInterface
* @throws ResourceReservationFailureException when an exclusive lock cannot be made.
*/
void lockForUpdate(HostInterface host);
/**
* returns true if the specified host id is locked
*
* @param host HostInterface
* @return Boolean
*/
boolean isHostLocked(HostInterface host);
/**
* deletes the passed host
*
* @param host HostInterface object to delete
*/
void deleteHost(HostInterface host);
/**
* deletes the down state hosts
*/
void deleteDownHosts();
/**
* updates a host with the passed hardware state
*
* @param host HostInterface
* @param state HardwareState
*/
void updateHostState(HostInterface host, HardwareState state);
/**
* updates a host with the passed free temporary directory
*
* @param host
* @param freeTempDir
*/
void updateHostFreeTempDir(HostInterface host, Long freeTempDir);
/**
* returns a full host detail
*
* @param host HostInterface
* @return HostDetail
*/
HostEntity getHostDetail(HostInterface host);
/**
* returns full host detail
*
* @param id String
* @return HostEntity
*/
HostEntity getHostDetail(String id);
/**
* returns full host detail
*
* @param name String
* @return HostEntity
*/
HostEntity findHostDetail(String name);
/**
* Return a DispatchHost object from its unique host name
*
* @param fqdn String
* @return DispatchHost
*/
DispatchHost findDispatchHost(String fqdn);
/**
* Return a dispatch host object by id
*
* @param id String
* @return DispatchHost
*/
DispatchHost getDispatchHost(String id);
/**
* Returns a host object by name
*
* @param name String
* @return HostInterface
*/
HostInterface findHost(String name);
/**
* Returns a host object by ID.
*
* @param id String
* @return HostInterface
*/
HostInterface getHost(String id);
/**
* Return the host involved with the given LocalJobAssignment.
*
* @param l LocalHostAssignment
* @return HostInterface
*/
HostInterface getHost(LocalHostAssignment l);
/**
* Inserts a render host and its supporting procs into an allocation.
*
* @param report RenderHost
* @param a AllocationInterface
* @param useLongNames boolean
*/
void insertRenderHost(RenderHost report, AllocationInterface a, boolean useLongNames);
/**
* Checks to see if a render host exists by name and returns true if it does, false if it
* doesn't.
*
* @param hostname String
* @return boolean
*/
boolean hostExists(String hostname);
/**
* Updates the host's lock state. Open, Locked, NimbyLocked. Records the source of the lock.
*
* @param host HostInterface
* @param state LockState
* @param source Source
*/
void updateHostLock(HostInterface host, LockState state, Source source);
/**
* Sets the reboot when idle boolean to true or false. If true the cue will issue the reboot
* command to hosts that ping in idle then set the flag back to false.
*
* @param host HostInterface
* @param enabled boolean
*/
void updateHostRebootWhenIdle(HostInterface host, boolean enabled);
/**
* Updates a host's allocation
*
* @param host HostInterface
* @param alloc AllocationInterface
*/
void updateHostSetAllocation(HostInterface host, AllocationInterface alloc);
/**
*
* @param id String
* @param tag String
* @param type HostTagType
*/
void tagHost(String id, String tag, HostTagType type);
/**
*
* @param host HostInterface
* @param tag String
* @param type HostTagType
*/
void tagHost(HostInterface host, String tag, HostTagType type);
/**
*
* @param host HostInterface
* @param type HostTagType
*/
void removeTagsByType(HostInterface host, HostTagType type);
/**
* removes a tag
*
* @param host HostInterface
* @param tag String
*/
void removeTag(HostInterface host, String tag);
/**
* renames a tag from oldTag to newTag
*
* @param host HostInterface
* @param oldTag String
* @param newTag String
*/
void renameTag(HostInterface host, String oldTag, String newTag);
/**
* You must run this AFTER you've changed any type of job tags. The reason this is not a trigger
* or something of that nature is because is an intense process.
*
* @param id String
*/
void recalcuateTags(final String id);
/**
*
* @param host HostInterface
* @param mode ThreadMode
*/
void updateThreadMode(HostInterface host, ThreadMode mode);
/**
* Update the specified host's hardware information.
*
* @param host HostInterface
* @param totalMemory long
* @param freeMemory long
* @param totalSwap long
* @param freeSwap long
* @param totalMcp long
* @param freeMcp long
* @param totalGpuMemory long
* @param freeGpuMemory long
* @param load int
* @param os String
*/
void updateHostStats(HostInterface host, long totalMemory, long freeMemory, long totalSwap,
long freeSwap, long totalMcp, long freeMcp, long totalGpuMemory, long freeGpuMemory,
int load, Timestamp bootTime, String os, int runningProcs);
/**
* Return true if the HardwareState is Up, false if it is anything else.
*
* @param host HostInterface
* @return boolean
*/
boolean isHostUp(HostInterface host);
/**
* Return the number of whole stranded cores on this host. The must have less than
* Dispacher.MEM_STRANDED_THRESHHOLD for the cores to be considered stranded.
*
* @param h HostInterface
* @return int
*/
int getStrandedCoreUnits(HostInterface h);
/**
* Return the number of whole stranded gpus on this host. The must have less than
* Dispacher.MEM_STRANDED_THRESHHOLD for the gpus to be considered stranded.
*
* @param h HostInterface
* @return int
*/
int getStrandedGpus(HostInterface h);
/**
* Return true if the host is preferring a particular show.
*
* @param h HostInterface
* @return boolean
*/
boolean isPreferShow(HostInterface h);
/**
* Return true if the host is a NIMBY host.
*
* @param h HostInterface
* @return boolean
*/
boolean isNimbyHost(HostInterface h);
/**
* Update the host's operating system setting.
*
* @param host HostInterface
* @param os String
*/
void updateHostOs(HostInterface host, String os);
/**
* Update a host's resource pool using the latest host report.
*
* @param host HostInterface
* @param report HostReport
*/
void updateHostResources(HostInterface host, HostReport report);
}