Merge "HA - Cache synch for Topology Manager"
[controller.git] / opendaylight / forwarding / staticrouting / src / main / java / org / opendaylight / controller / forwarding / staticrouting / internal / StaticRoutingImplementation.java
index ad6ea6bc105328691f3221fa6ccbe1b7302ad7bb..4afd4fb8e444136562b2d59fff79728c74bc763f 100644 (file)
@@ -44,12 +44,12 @@ import org.opendaylight.controller.forwarding.staticrouting.StaticRouteConfig;
 import org.opendaylight.controller.hosttracker.IfIptoHost;
 import org.opendaylight.controller.hosttracker.IfNewHostNotify;
 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
-import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.IObjectReader;
 import org.opendaylight.controller.sal.utils.ObjectReader;
 import org.opendaylight.controller.sal.utils.ObjectWriter;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -131,8 +131,8 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         }
     }
 
-    @Override
-    public Status saveConfig() {
+
+    private Status saveConfig() {
         // Publish the save config event to the cluster nodes
         configSaveEvent.put(new Date().getTime(), SAVE);
         return saveConfigInternal();
@@ -154,7 +154,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
     }
 
     @SuppressWarnings("deprecation")
-       private void allocateCaches() {
+        private void allocateCaches() {
         if (this.clusterContainerService == null) {
             log
                     .info("un-initialized clusterContainerService, can't create cache");
@@ -206,22 +206,6 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         }
     }
 
-    @SuppressWarnings("deprecation")
-       private void destroyCaches() {
-        if (this.clusterContainerService == null) {
-            log
-                    .info("un-initialized clusterContainerService, can't destroy cache");
-            return;
-        }
-
-        clusterContainerService.destroyCache("forwarding.staticrouting.routes");
-        clusterContainerService
-                .destroyCache("forwarding.staticrouting.configs");
-        clusterContainerService
-                .destroyCache("forwarding.staticrouting.configSaveEvent");
-
-    }
-
     @Override
     public void entryCreated(Long key, String cacheName, boolean local) {
     }
@@ -390,16 +374,16 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
             return status;
         }
         if (staticRouteConfigs.get(config.getName()) != null) {
-               return new Status(StatusCode.CONFLICT,
-                               "A valid Static Route configuration with this name " +
-                                               "already exists. Please use a different name");
+                return new Status(StatusCode.CONFLICT,
+                                "A valid Static Route configuration with this name " +
+                                                "already exists. Please use a different name");
         }
         for (StaticRouteConfig s : staticRouteConfigs.values()) {
             if (s.equals(config)) {
-               return new Status(StatusCode.CONFLICT,
-                               "This conflicts with an existing Static Route " +
-                                       "Configuration. Please check the configuration " +
-                                               "and try again");
+                return new Status(StatusCode.CONFLICT,
+                                "This conflicts with an existing Static Route " +
+                                        "Configuration. Please check the configuration " +
+                                                "and try again");
             }
         }
 
@@ -407,7 +391,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         StaticRoute sRoute = new StaticRoute(config);
         staticRoutes.put(config.getName(), sRoute);
         checkAndUpdateListeners(sRoute, true);
-        return status; 
+        return status;
     }
 
     public Status removeStaticRoute(String name) {
@@ -417,8 +401,8 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
             checkAndUpdateListeners(sRoute, false);
             return new Status(StatusCode.SUCCESS, null);
         }
-        return new Status(StatusCode.NOTFOUND, 
-                       "Static Route with name " + name + " is not found");
+        return new Status(StatusCode.NOTFOUND,
+                        "Static Route with name " + name + " is not found");
     }
 
     void setClusterContainerService(IClusterContainerServices s) {
@@ -488,7 +472,6 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
         log.debug("Destroy all the Static Routing Rules given we are "
                 + "shutting down");
 
-        destroyCaches();
         gatewayProbeTimer.cancel();
 
         // Clear the listener so to be ready in next life