Madan Jampani
Committed by Gerrit Code Review

Fix formCluster to remove raft log files associated with stand-alone cluster configuration

Change-Id: Icdacec468c95403ac6c97ae7be5b5fcc63661c76
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
15 */ 15 */
16 package org.onosproject.cluster.impl; 16 package org.onosproject.cluster.impl;
17 17
18 -import com.google.common.collect.Collections2;
19 import com.google.common.collect.Sets; 18 import com.google.common.collect.Sets;
19 +
20 import org.apache.felix.scr.annotations.Activate; 20 import org.apache.felix.scr.annotations.Activate;
21 import org.apache.felix.scr.annotations.Component; 21 import org.apache.felix.scr.annotations.Component;
22 import org.apache.felix.scr.annotations.Deactivate; 22 import org.apache.felix.scr.annotations.Deactivate;
...@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Service; ...@@ -26,6 +26,7 @@ import org.apache.felix.scr.annotations.Service;
26 import org.apache.karaf.system.SystemService; 26 import org.apache.karaf.system.SystemService;
27 import org.joda.time.DateTime; 27 import org.joda.time.DateTime;
28 import org.onlab.packet.IpAddress; 28 import org.onlab.packet.IpAddress;
29 +import org.onlab.util.Tools;
29 import org.onosproject.cluster.ClusterAdminService; 30 import org.onosproject.cluster.ClusterAdminService;
30 import org.onosproject.cluster.ClusterEvent; 31 import org.onosproject.cluster.ClusterEvent;
31 import org.onosproject.cluster.ClusterEventListener; 32 import org.onosproject.cluster.ClusterEventListener;
...@@ -152,6 +153,8 @@ public class ClusterManager ...@@ -152,6 +153,8 @@ public class ClusterManager
152 clusterMetadataAdminService.setClusterMetadata(metadata); 153 clusterMetadataAdminService.setClusterMetadata(metadata);
153 try { 154 try {
154 log.warn("Shutting down container for cluster reconfiguration!"); 155 log.warn("Shutting down container for cluster reconfiguration!");
156 + // Clean up persistent state associated with previous cluster configuration.
157 + Tools.removeDirectory(System.getProperty("karaf.data") + "/partitions");
155 systemService.reboot("now", SystemService.Swipe.NONE); 158 systemService.reboot("now", SystemService.Swipe.NONE);
156 } catch (Exception e) { 159 } catch (Exception e) {
157 log.error("Unable to reboot container", e); 160 log.error("Unable to reboot container", e);
...@@ -184,10 +187,7 @@ public class ClusterManager ...@@ -184,10 +187,7 @@ public class ClusterManager
184 List<ControllerNode> sorted = new ArrayList<>(nodes); 187 List<ControllerNode> sorted = new ArrayList<>(nodes);
185 Collections.sort(sorted, (o1, o2) -> o1.id().toString().compareTo(o2.id().toString())); 188 Collections.sort(sorted, (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()));
186 Set<Partition> partitions = Sets.newHashSet(); 189 Set<Partition> partitions = Sets.newHashSet();
187 - // add p0 partition 190 + // add partitions
188 - partitions.add(new DefaultPartition(PartitionId.from(0),
189 - Sets.newHashSet(Collections2.transform(nodes, ControllerNode::id))));
190 - // add extended partitions
191 int length = nodes.size(); 191 int length = nodes.size();
192 int count = Math.min(3, length); 192 int count = Math.min(3, length);
193 for (int i = 0; i < length; i++) { 193 for (int i = 0; i < length; i++) {
......