Permalink
Browse files

Include expired but non-destroyed VMs in nimbus-admin output

VMs which expired but failed to be destroyed (for example when the VMM
is offline) were not included in the nimbus-admin output because the
destroy tentative threw an exception which removed them from the list.

With this commit the exception is thrown only when the destroy action
has succeeded.

Closes #113.
  • Loading branch information...
priteau committed Aug 17, 2012
1 parent 38e8f87 commit b926c280faaf163d6e04fabf4fe49b19a5b8b90c
@@ -72,11 +72,11 @@ public boolean isActiveWorkspaceID(String id)
// DESTRUCTION
// -------------------------------------------------------------------------
- public void destroy(int id)
+ public boolean destroy(int id)
throws ManageException, DoesNotExistException;
- public void destroy(String id)
+ public boolean destroy(String id)
throws ManageException, DoesNotExistException;
@@ -343,8 +343,10 @@ public InstanceResource find(String id)
final Calendar currTime = Calendar.getInstance();
final Calendar termTime = resource.getTerminationTime();
if (termTime != null && termTime.before(currTime)) {
- this.destroy(id);
- throw new DoesNotExistException(Lager.id(id) + " expired");
+ boolean destroyed = this.destroy(id);
+ if (destroyed) {
+ throw new DoesNotExistException(Lager.id(id) + " expired");
+ }
}
} else {
@@ -410,21 +412,23 @@ public InstanceResource find(int id)
// DESTROY
// -------------------------------------------------------------------------
- public void destroy(int id)
+ public boolean destroy(int id)
throws ManageException, DoesNotExistException {
- this.destroy(this.convertID(id));
+ return this.destroy(this.convertID(id));
}
/**
* @param id key
* @throws ManageException error
* @throws DoesNotExistException already gone
*/
- public void destroy(String id)
+ public boolean destroy(String id)
throws ManageException, DoesNotExistException {
+ boolean destroyed;
+
if (id == null) {
throw new IllegalArgumentException("id may not be null");
}
@@ -446,14 +450,17 @@ public void destroy(String id)
try {
final InstanceResource resource = this.find(id);
- if (resource.remove()) {
+ destroyed = resource.remove();
+ if (destroyed) {
this.cache.remove(id);
}
} finally {
lock.unlock();
destroy_lock.unlock();
}
+
+ return destroyed;
}
public String destroyMultiple(int[] workspaces, String sourceStr) {

0 comments on commit b926c28

Please sign in to comment.