Fix formCluster to remove raft log files associated with stand-alone cluster configuration
Change-Id: Icdacec468c95403ac6c97ae7be5b5fcc63661c76
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
index 5f6f0d0..0041547 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ClusterManager.java
@@ -15,8 +15,8 @@
*/
package org.onosproject.cluster.impl;
-import com.google.common.collect.Collections2;
import com.google.common.collect.Sets;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -26,6 +26,7 @@
import org.apache.karaf.system.SystemService;
import org.joda.time.DateTime;
import org.onlab.packet.IpAddress;
+import org.onlab.util.Tools;
import org.onosproject.cluster.ClusterAdminService;
import org.onosproject.cluster.ClusterEvent;
import org.onosproject.cluster.ClusterEventListener;
@@ -152,6 +153,8 @@
clusterMetadataAdminService.setClusterMetadata(metadata);
try {
log.warn("Shutting down container for cluster reconfiguration!");
+ // Clean up persistent state associated with previous cluster configuration.
+ Tools.removeDirectory(System.getProperty("karaf.data") + "/partitions");
systemService.reboot("now", SystemService.Swipe.NONE);
} catch (Exception e) {
log.error("Unable to reboot container", e);
@@ -184,10 +187,7 @@
List<ControllerNode> sorted = new ArrayList<>(nodes);
Collections.sort(sorted, (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()));
Set<Partition> partitions = Sets.newHashSet();
- // add p0 partition
- partitions.add(new DefaultPartition(PartitionId.from(0),
- Sets.newHashSet(Collections2.transform(nodes, ControllerNode::id))));
- // add extended partitions
+ // add partitions
int length = nodes.size();
int count = Math.min(3, length);
for (int i = 0; i < length; i++) {