This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
/
PersistenceAdapter.java
325 lines (213 loc) · 10.1 KB
/
PersistenceAdapter.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
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
324
325
/*
* 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.globus.workspace.persistence;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Hashtable;
import java.util.List;
import org.globus.workspace.async.AsyncRequest;
import org.globus.workspace.async.backfill.Backfill;
import org.globus.workspace.creation.IdempotentReservation;
import org.globus.workspace.network.AssociationEntry;
import org.globus.workspace.scheduler.defaults.ResourcepoolEntry;
import org.globus.workspace.service.CoschedResource;
import org.globus.workspace.service.GroupResource;
import org.globus.workspace.service.InstanceResource;
import org.nimbustools.api.repr.SpotPriceEntry;
import org.globus.workspace.service.binding.vm.FileCopyNeed;
import org.nimbustools.api.services.rm.DoesNotExistException;
/**
* TODO: each module implementation needs to encapsulate its own persistence,
* the persistence package will go away entirely
*/
public interface PersistenceAdapter {
public void setState(int id, int state, Throwable t)
throws WorkspaceDatabaseException;
public void setTargetState(int id, int targetState)
throws WorkspaceDatabaseException;
public void setOpsEnabled(int id, boolean enabled)
throws WorkspaceDatabaseException;
public void setNetwork(int id, String network)
throws WorkspaceDatabaseException;
public void setVMMaccessOK(int resourceID, boolean vmmAccessOK)
throws WorkspaceDatabaseException;
public void setHostname(int id, String hostname)
throws WorkspaceDatabaseException;
public void setRootUnpropTarget(int id, String path)
throws WorkspaceDatabaseException;
public void setFileCopyOnImage(int id, FileCopyNeed need)
throws WorkspaceDatabaseException;
public void setStartTime(int id, Calendar startTime)
throws WorkspaceDatabaseException;
public void setTerminationTime(int id, Calendar termTime)
throws WorkspaceDatabaseException;
public void remove(int id, InstanceResource resource)
throws WorkspaceDatabaseException;
public void removeGroup(String id)
throws WorkspaceDatabaseException;
public void removeEnsemble(String id)
throws WorkspaceDatabaseException;
public int[] findActiveWorkspacesIDs()
throws WorkspaceDatabaseException;
public boolean isActiveWorkspaceID(int id)
throws WorkspaceDatabaseException;
public int[] findVMsInGroup(String groupID)
throws WorkspaceDatabaseException;
public int[] findVMsInEnsemble(String ensembleID)
throws WorkspaceDatabaseException;
public int[] findVMsByOwner(String ownerID)
throws WorkspaceDatabaseException;
public void add(InstanceResource resource)
throws WorkspaceDatabaseException;
public void addGroup(GroupResource resource)
throws WorkspaceDatabaseException;
public void addEnsemble(CoschedResource resource)
throws WorkspaceDatabaseException;
public void load(int id, InstanceResource resource)
throws DoesNotExistException,
WorkspaceDatabaseException;
public void loadGroup(String id, GroupResource resource)
throws DoesNotExistException,
WorkspaceDatabaseException;
public void loadEnsemble(String id, CoschedResource resource)
throws DoesNotExistException,
WorkspaceDatabaseException;
public void replaceAssocations(Hashtable associations)
throws WorkspaceDatabaseException;
public void replaceAssociationEntry(String name,
AssociationEntry entry)
throws WorkspaceDatabaseException;
public Hashtable currentAssociations()
throws WorkspaceDatabaseException;
public Hashtable currentAssociations(boolean cachedIsFine)
throws WorkspaceDatabaseException;
public void updateResourcepoolEntryAvailableMemory(String hostname,
int newAvailMemory,
int preemptibleMemory)
throws WorkspaceDatabaseException;
public int memoryUsedOnPoolnode(String poolnode)
throws WorkspaceDatabaseException;
public List<ResourcepoolEntry> currentResourcepoolEntries() throws WorkspaceDatabaseException;
public ResourcepoolEntry getResourcepoolEntry(String hostname)
throws WorkspaceDatabaseException;
public void addResourcepoolEntry(ResourcepoolEntry entry)
throws WorkspaceDatabaseException;
public boolean removeResourcepoolEntry(String hostname)
throws WorkspaceDatabaseException;
public void addCustomizationNeed(int id, FileCopyNeed need)
throws WorkspaceDatabaseException;
public int readPropagationCounter()
throws WorkspaceDatabaseException;
public long currentCursorPosition()
throws WorkspaceDatabaseException;
public void updatePropagationCounter(int n)
throws WorkspaceDatabaseException;
public void updateCursorPosition(long currentPosition)
throws WorkspaceDatabaseException;
//SQL processing
public List<ResourcepoolEntry> getAvailableEntriesSortedByFreeMemoryPercentage(int requestedMem)
throws WorkspaceDatabaseException;
// returns true if memory request is bigger than any VMM could ever handle
public boolean isInfeasibleRequest(int requestedMem) throws WorkspaceDatabaseException;
//Spot Instances
public Integer getTotalMaxMemory()
throws WorkspaceDatabaseException;
public Integer getTotalAvailableMemory()
throws WorkspaceDatabaseException;
/**
* Gets the total available memory as
* a sum of integer available chunks from
* each resource pool entry
*
* This is useful for knowing the exact
* amount of memory that is readily available
* for allocations of that chunk size (ie. 128MB),
* and not incurring the risk of having
* 64MB in one VMM and 64MB in another,
* what will not suffice to allocate a 128MB
* VM (although 128MB are theoretically
* available)
*
* @param multipleOf size of the chunk
* @return the total available memory as a
* multiple of the chunk size (ie: result%multipleOf = 0)
* @throws WorkspaceDatabaseException DB error
*/
public Integer getTotalAvailableMemory(Integer multipleOf)
throws WorkspaceDatabaseException;
public Integer getTotalPreemptableMemory()
throws WorkspaceDatabaseException;
public Integer getUsedNonPreemptableMemory()
throws WorkspaceDatabaseException;
public void addSpotPriceHistory(Calendar timeStamp,
Double newPrice)
throws WorkspaceDatabaseException;
public List<SpotPriceEntry> getSpotPriceHistory(Calendar startDate,
Calendar endDate)
throws WorkspaceDatabaseException;
public Double getLastSpotPrice()
throws WorkspaceDatabaseException;
boolean updateResourcepoolEntry(String hostname,
String pool,
String networks,
Integer memoryMax,
Integer memoryAvail,
Boolean active)
throws WorkspaceDatabaseException;
/**
* Returns stored backfill settings from previous launch or null if there was nothing
* stored (for example in a clean install).
*
* @return stored settings or null
* @throws WorkspaceDatabaseException DB error
*/
public Backfill getStoredBackfill() throws WorkspaceDatabaseException;
/**
* @param backfill current backfill settings, may not be null
* @throws WorkspaceDatabaseException
*/
public void setBackfill(Backfill backfill) throws WorkspaceDatabaseException;
/**
* Retrieves idempotency reservation
* @param creatorId initiating client user
* @param clientToken client-provided idempotency token
* @return stored reservation, or null of not found
* @throws WorkspaceDatabaseException DB error
*/
public IdempotentReservation getIdempotentReservation(String creatorId, String clientToken)
throws WorkspaceDatabaseException;
/**
* Stores idempotency reservation
* @param reservation the reservation to store
* @throws WorkspaceDatabaseException DB error
*/
public void addIdempotentReservation(IdempotentReservation reservation)
throws WorkspaceDatabaseException;
/**
* Removes existing idempotency reservation
* @param creatorId initiating client user
* @param clientToken client-provided idempotency token
* @throws WorkspaceDatabaseException DB error
*/
public void removeIdempotentReservation(String creatorId, String clientToken)
throws WorkspaceDatabaseException;
public void addAsyncRequest(AsyncRequest asyncRequest)
throws WorkspaceDatabaseException;
public AsyncRequest getAsyncRequest(String id)
throws WorkspaceDatabaseException;
public ArrayList<AsyncRequest> getAllAsyncRequests()
throws WorkspaceDatabaseException;
}