Bug 8621 - Add shutdown-prefix-shard-replica rpc to MdsalLowLevelTestProvider 78/58578/5
authorJakub Morvay <jmorvay@cisco.com>
Fri, 9 Jun 2017 07:45:14 +0000 (09:45 +0200)
committerJakub Morvay <jmorvay@cisco.com>
Thu, 22 Jun 2017 09:23:05 +0000 (09:23 +0000)
csit testing scenarios require clean shutdown of shard's local replica
funcionality. This introduces shutdown-prefix-shard-replica rpc to
MdsalLowLevelTestProvider. Upon invoking this rpc, local replica of
specified prefix-based shard is gracefully stopped.

Change-Id: I620b7ae2dbc9978dd155c64f703d421d46108e3d
Signed-off-by: Jakub Morvay <jmorvay@cisco.com>
(cherry picked from commit bdf02e09c13b6c8d170202054d44877707642cd9)

opendaylight/md-sal/samples/clustering-test-app/model/src/main/yang/odl-mdsal-lowlevel-control.yang
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java

index bc3e03998c473e92763712f2b0b9f5ba36617212..89d220bcf519ec590e783e63d31e04c3099dbd1d 100644 (file)
@@ -524,4 +524,17 @@ module odl-mdsal-lowlevel-control {
             }
         }
     }
+
+    rpc shutdown-prefix-shard-replica {
+        description "Upon receiving this, the member will try to gracefully shutdown local configuration
+            data store prefix-based shard replica.";
+        input {
+            leaf prefix {
+                description "The prefix of the configuration data store prefix-based shard to be shutdown
+                    gracefully.";
+                mandatory true;
+                type instance-identifier;
+            }
+        }
+    }
 }
index f0569fa07dc4e8842d92504168b117832b99acec..688e7c0a51dab318a2fbb17f62d3e92980ac924e 100644 (file)
@@ -85,6 +85,7 @@ import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.l
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterSingletonConstantInput;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemovePrefixShardInput;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemoveShardReplicaInput;
+import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ShutdownPrefixShardReplicaInput;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ShutdownShardReplicaInput;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.StartPublishNotificationsInput;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeYnlInput;
@@ -581,6 +582,28 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
             return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(rpcError).build());
         }
 
+        return shutdownShardGracefully(shardName);
+    }
+
+    @Override
+    public Future<RpcResult<Void>> shutdownPrefixShardReplica(final ShutdownPrefixShardReplicaInput input) {
+        LOG.debug("Received shutdown-prefix-shard-replica rpc, input: {}", input);
+
+        final InstanceIdentifier shardPrefix = input.getPrefix();
+
+        if (shardPrefix == null) {
+            final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "bad-element",
+                    "A valid shard prefix must be specified");
+            return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(rpcError).build());
+        }
+
+        final YangInstanceIdentifier shardPath = bindingNormalizedNodeSerializer.toYangInstanceIdentifier(shardPrefix);
+        final String cleanPrefixShardName = ClusterUtils.getCleanShardName(shardPath);
+
+        return shutdownShardGracefully(cleanPrefixShardName);
+    }
+
+    private SettableFuture<RpcResult<Void>> shutdownShardGracefully(final String shardName) {
         final SettableFuture<RpcResult<Void>> rpcResult = SettableFuture.create();
         final ActorContext context = configDataStore.getActorContext();
 
@@ -614,7 +637,6 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
                 }
             }
         }, context.getClientDispatcher());
-
         return rpcResult;
     }