From 8e199d1d7d568caf7dd0a896625d8f1e3d43c6bd Mon Sep 17 00:00:00 2001
From: zihzhan <43592314+zihzhan@users.noreply.github.com>
Date: Fri, 29 May 2020 16:52:08 -0700
Subject: [PATCH] Switch HueBotSample from SFStateful to SFStateless. (#248)
---
.../LocalMediaSamples/HueBot/HueBot/Bot/Bot.cs | 4 ++--
.../HueBot/Controllers/JoinCallController.cs | 10 +++++-----
.../LocalMediaSamples/HueBot/HueBot/HueBot.cs | 15 +++++++--------
.../HueBot/HueBot/PackageRoot/ServiceManifest.xml | 2 +-
.../ApplicationManifest.xml | 10 ++++------
.../HueBotSF/ApplicationParameters/Cloud.xml | 6 ++----
.../ApplicationParameters/Local.1Node.xml | 4 +---
.../ApplicationParameters/Local.5Node.xml | 4 +---
8 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Bot/Bot.cs b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Bot/Bot.cs
index 5f73679e..5ec2b61f 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Bot/Bot.cs
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Bot/Bot.cs
@@ -43,7 +43,7 @@ public class Bot
/// The bot options.
/// The graph logger.
/// Service context.
- public Bot(BotOptions options, IGraphLogger graphLogger, StatefulServiceContext serviceContext)
+ public Bot(BotOptions options, IGraphLogger graphLogger, StatelessServiceContext serviceContext)
{
this.Options = options;
this.logger = graphLogger;
@@ -320,7 +320,7 @@ private CallHandler GetHandlerOrThrow(string callId)
/// The bot options.
/// Service context.
/// A representing the asynchronous operation.
- private MediaPlatformSettings MediaInit(BotOptions options, StatefulServiceContext serviceContext)
+ private MediaPlatformSettings MediaInit(BotOptions options, StatelessServiceContext serviceContext)
{
var instanceNumber = serviceContext.NodeInstance();
var publicMediaUrl = options.BotMediaProcessorUrl ?? options.BotBaseUrl;
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Controllers/JoinCallController.cs b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Controllers/JoinCallController.cs
index e9f18512..3d2973e6 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Controllers/JoinCallController.cs
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/Controllers/JoinCallController.cs
@@ -18,19 +18,19 @@ namespace Sample.HueBot.Controllers
public class JoinCallController : Controller
{
private Bot bot;
- private StatefulServiceContext statefulServiceContext;
+ private StatelessServiceContext statelessServiceContext;
private BotOptions botOptions;
///
/// Initializes a new instance of the class.
///
/// Bot instance.
- /// The service context.
+ /// The service context.
/// The bot options.
- public JoinCallController(Bot bot, StatefulServiceContext statefulServiceContext, BotOptions botOptions)
+ public JoinCallController(Bot bot, StatelessServiceContext statelessServiceContext, BotOptions botOptions)
{
this.bot = bot;
- this.statefulServiceContext = statefulServiceContext;
+ this.statelessServiceContext = statelessServiceContext;
this.botOptions = botOptions;
}
@@ -48,7 +48,7 @@ public async Task JoinCallAsync([FromBody] JoinCallBody joinCallB
var call = await this.bot.JoinCallAsync(joinCallBody).ConfigureAwait(false);
var serviceURL = new UriBuilder($"{this.Request.Scheme}://{this.Request.Host}");
- serviceURL.Port = this.botOptions.BotBaseUrl.Port + this.statefulServiceContext.NodeInstance();
+ serviceURL.Port = this.botOptions.BotBaseUrl.Port + this.statelessServiceContext.NodeInstance();
return this.Ok(new JoinCallResponseBody
{
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/HueBot.cs b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/HueBot.cs
index f32ff346..12fa48c7 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/HueBot.cs
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/HueBot.cs
@@ -24,7 +24,7 @@ namespace HueBot
///
/// The FabricRuntime creates an instance of this class for each service type instance.
///
- internal sealed class HueBot : StatefulService
+ internal sealed class HueBot : StatelessService
{
private IGraphLogger logger;
private SampleObserver observer;
@@ -35,10 +35,10 @@ internal sealed class HueBot : StatefulService
///
/// Initializes a new instance of the class.
///
- /// Stateful service context from service fabric.
+ /// Stateless service context from service fabric.
/// Global logger instance.
/// Global observer instance.
- public HueBot(StatefulServiceContext context, IGraphLogger logger, SampleObserver observer)
+ public HueBot(StatelessServiceContext context, IGraphLogger logger, SampleObserver observer)
: base(context)
{
this.logger = logger;
@@ -54,7 +54,7 @@ public HueBot(StatefulServiceContext context, IGraphLogger logger, SampleObserve
/// Optional override to create listeners (like tcp, http) for this service instance.
///
/// The collection of listeners.
- protected override IEnumerable CreateServiceReplicaListeners()
+ protected override IEnumerable CreateServiceInstanceListeners()
{
this.configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
@@ -65,10 +65,10 @@ protected override IEnumerable CreateServiceReplicaListe
this.bot = new Bot(this.botOptions, this.logger, this.Context);
- var serviceReplicaListeners = new List();
+ var serviceInstanceListeners = new List();
foreach (string endpointName in new[] { "ServiceEndpoint", "SignalingPort", "LocalEndpoint" })
{
- serviceReplicaListeners.Add(new ServiceReplicaListener(
+ serviceInstanceListeners.Add(new ServiceInstanceListener(
serviceContext =>
new HttpSysCommunicationListener(serviceContext, endpointName, (url, listener) =>
{
@@ -78,7 +78,7 @@ protected override IEnumerable CreateServiceReplicaListe
endpointName));
}
- return serviceReplicaListeners.ToArray();
+ return serviceInstanceListeners.ToArray();
}
///
@@ -102,7 +102,6 @@ private IWebHost CreateHueBotWebHost(string url)
services => services
.AddSingleton(this.logger)
.AddSingleton(this.observer)
- .AddSingleton(this.StateManager)
.AddSingleton(this.Context)
.AddSingleton(this.botOptions)
.AddSingleton(this.bot)
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/PackageRoot/ServiceManifest.xml b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/PackageRoot/ServiceManifest.xml
index d63c639f..e5e70e4b 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/PackageRoot/ServiceManifest.xml
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBot/PackageRoot/ServiceManifest.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationPackageRoot/ApplicationManifest.xml b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationPackageRoot/ApplicationManifest.xml
index bb064365..26440163 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationPackageRoot/ApplicationManifest.xml
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationPackageRoot/ApplicationManifest.xml
@@ -1,9 +1,7 @@
-
-
-
+
-
-
-
+
+
+
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Cloud.xml b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Cloud.xml
index 91066421..c4b878a6 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Cloud.xml
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Cloud.xml
@@ -1,8 +1,6 @@
-
-
-
+
-
+
\ No newline at end of file
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.1Node.xml b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.1Node.xml
index 9cc2f5b7..38340fec 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.1Node.xml
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.1Node.xml
@@ -1,8 +1,6 @@
-
-
-
+
\ No newline at end of file
diff --git a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.5Node.xml b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.5Node.xml
index b212f59a..38340fec 100644
--- a/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.5Node.xml
+++ b/Samples/V1.0Samples/LocalMediaSamples/HueBot/HueBotSF/ApplicationParameters/Local.5Node.xml
@@ -1,8 +1,6 @@
-
-
-
+
\ No newline at end of file