Do not use RpcService in toaster-consumer 20/108020/12
authorOleksandr Zharov <oleksandr.zharov@pantheon.tech>
Thu, 28 Sep 2023 17:21:55 +0000 (19:21 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 15 Jan 2024 06:34:46 +0000 (06:34 +0000)
Migrated usage of RpcService to Rpc<?,?> for toaster-consumer.

JIRA: CONTROLLER-2085
Change-Id: I85db90c9a2fe104bded1835ae9d4263e893311bb
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java

index 55b56741afe3dd5e325e4e6337e2eb68fe914ec1..1401363a70ecd4162ce06440fa4cb9ff36408af7 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.sample.kitchen.api.KitchenService;
 import org.opendaylight.controller.sample.kitchen.api.KitchenServiceRuntimeMXBean;
 import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInput;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToast;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInputBuilder;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastOutput;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastOutputBuilder;
@@ -33,7 +33,6 @@ import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterListener;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterOutOfBread;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestocked;
-import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WheatBread;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
@@ -58,7 +57,7 @@ public final class KitchenServiceImpl extends AbstractMXBean
     private static final MakeToastOutput EMPTY_MAKE_OUTPUT = new MakeToastOutputBuilder().build();
 
     private final ExecutorService executor = Executors.newCachedThreadPool();
-    private final ToasterService toaster;
+    private final MakeToast makeToast;
     private final Registration reg;
 
     private volatile boolean toasterOutOfBread;
@@ -68,7 +67,7 @@ public final class KitchenServiceImpl extends AbstractMXBean
     public KitchenServiceImpl(@Reference final RpcConsumerRegistry rpcRegistry,
             @Reference final NotificationService notifService) {
         super("KitchenService", "toaster-consumer", null);
-        toaster = rpcRegistry.getRpcService(ToasterService.class);
+        makeToast = rpcRegistry.getRpc(MakeToast.class);
         reg = notifService.registerNotificationListener(this);
         register();
     }
@@ -128,11 +127,10 @@ public final class KitchenServiceImpl extends AbstractMXBean
         }
 
         // Access the ToasterService to make the toast.
-
-        MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(Uint32.valueOf(toastDoneness))
-                .setToasterToastType(toastType).build();
-
-        return toaster.makeToast(toastInput);
+        return makeToast.invoke(new MakeToastInputBuilder()
+            .setToasterDoneness(Uint32.valueOf(toastDoneness))
+            .setToasterToastType(toastType)
+            .build());
     }
 
     @Override