Author: asavu
Date: Sun Nov 13 07:36:48 2011
New Revision: 1201411
URL: http://svn.apache.org/viewvc?rev=1201411&view=rev
Log:
WHIRR-414. Ignore missing instances file on partial failures (asavu)
Modified:
whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java
whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterStateStore.java
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java?rev=1201411&r1=1201410&r2=1201411&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java Sun Nov 13
07:36:48 2011
@@ -135,6 +135,10 @@ public class Cluster {
}
}
+ public static Cluster empty() {
+ return new Cluster(Sets.<Instance>newHashSet());
+ }
+
private Set<Instance> instances;
private Properties configuration;
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java?rev=1201411&r1=1201410&r2=1201411&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java Sun
Nov 13 07:36:48 2011
@@ -139,14 +139,14 @@ public class ClusterController {
public void destroyCluster(ClusterSpec clusterSpec) throws IOException,
InterruptedException {
- ClusterStateStore store = getClusterStateStore(clusterSpec);
- Cluster cluster = store.load();
+ ClusterStateStore stateStore = getClusterStateStore(clusterSpec);
+ Cluster cluster = stateStore.tryLoadOrEmpty();
DestroyClusterAction destroyer = new DestroyClusterAction(getCompute(),
HandlerMapFactory.create());
destroyer.execute(clusterSpec, cluster);
- getClusterStateStore(clusterSpec).destroy();
+ stateStore.destroy();
}
public void destroyInstance(ClusterSpec clusterSpec, String instanceId)
throws IOException {
Modified:
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterStateStore.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterStateStore.java?rev=1201411&r1=1201410&r2=1201411&view=diff
==============================================================================
---
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterStateStore.java
(original)
+++
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterStateStore.java
Sun Nov 13 07:36:48 2011
@@ -31,6 +31,8 @@ import org.apache.whirr.Cluster;
import org.apache.whirr.ClusterSpec;
import org.apache.whirr.util.DnsUtil;
import org.jclouds.domain.Credentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Interface for cluster state storage facilities.
@@ -38,6 +40,8 @@ import org.jclouds.domain.Credentials;
*/
public abstract class ClusterStateStore {
+ private static final Logger LOG =
LoggerFactory.getLogger(ClusterStateStore.class);
+
/**
* Deserializes cluster state from storage.
*
@@ -47,6 +51,21 @@ public abstract class ClusterStateStore
public abstract Cluster load() throws IOException;
/**
+ * Try to load the cluster state or return an empty instance
+ *
+ * @return
+ */
+ public Cluster tryLoadOrEmpty() {
+ try {
+ return load();
+
+ } catch (Exception e) {
+ LOG.info("Unable to load cluster state, assuming it has no running
nodes.", e);
+ return Cluster.empty();
+ }
+ }
+
+ /**
* Saves cluster state to storage.
*
* @param cluster