public IStatefulServiceReplica CreateReplica(string serviceTypeName, Uri serviceName, byte[] initializationData, Guid partitionId, long replicaId) { StatefulServiceParameters parameters = new StatefulServiceParameters( FabricRuntime.GetActivationContext(), initializationData, partitionId, serviceName, serviceTypeName, replicaId); IReliableStateManager stateManager = new ReliableStateManager(); return new ClusterService( #if LOCAL new FakeClusterOperator(stateManager), new FakeMailer(), #else new ArmClusterOperator(parameters), new SendGridMailer(parameters), #endif ServiceProxy.Create<IApplicationDeployService>(0, new ServiceUriBuilder("ApplicationDeployService").ToUri()), stateManager, parameters, new ClusterConfig()); }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("DinnerMenuServiceType", delegate(StatefulServiceContext context) { var stateMngr = new ReliableStateManager(context); return(new DinnerMenuService(context, new DishStateManager(stateMngr), stateMngr)); }).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(DinnerMenuService).Name); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
public ChannelDirectoryService(StatefulServiceContext serviceContext, ReliableStateManager reliableStateManagerReplica, SubsystemManager subsystemManager, TwitchChannelManager channelManager) : base(serviceContext, reliableStateManagerReplica) { _subsystemManager = subsystemManager; _channelManager = channelManager; }
/// <summary> /// Create an object that implements <see cref="IReliableStateManagerReplica"/> /// </summary> /// <param name="context">Context of the stateful service</param> /// <returns>An object that implements <see cref="IReliableStateManagerReplica"/></returns> public static IReliableStateManagerReplica CreateStateManager(StatefulServiceContext context) { var serializerInstaller = new SerializerInstaller(); var stateManager = new ReliableStateManager( context, new ReliableStateManagerConfiguration(onInitializeStateSerializersEvent: serializerInstaller.OnSerializerSetupAsync)); serializerInstaller.StateManager = stateManager; return(stateManager); }
private static CounterService CreateCounterService(StatefulServiceContext context) { IReliableStateManagerReplica stateManager = new ReliableStateManager(context); var reliableDispatcher = new ReliableDispatcher <int>( new Lazy <IReliableQueue <int> >( () => stateManager.GetOrAddAsync <IReliableQueue <int> >("CounterIncrements").Result), new TransactionFactory(stateManager)); return(new CounterService(context, stateManager, reliableDispatcher)); }
public IStatefulServiceReplica CreateReplica(string serviceTypeName, Uri serviceName, byte[] initializationData, Guid partitionId, long replicaId) { StatefulServiceParameters parameters = new StatefulServiceParameters( FabricRuntime.GetActivationContext(), initializationData, partitionId, serviceName, serviceTypeName, replicaId); IReliableStateManager stateManager = new ReliableStateManager(); return new ApplicationDeployService(stateManager, new FabricClientApplicationOperator(parameters), parameters); }
public static void Main(string[] args) { try { const string ElasticSearchEventListenerId = "ElasticSearchEventListener"; FabricEventListeners.FabricConfigurationProvider configProvider = new FabricEventListeners.FabricConfigurationProvider(ElasticSearchEventListenerId); ElasticSearchListener esListener = null; if (configProvider.HasConfiguration) { esListener = new ElasticSearchListener(configProvider, new FabricEventListeners.FabricHealthReporter(ElasticSearchEventListenerId)); } ServiceRuntime.RegisterServiceAsync( "ClusterServiceType", context => { IReliableStateManager stateManager = new ReliableStateManager(context); return(new ClusterService( #if LOCAL new FakeClusterOperator(stateManager), new FakeMailer(), #else new ArmClusterOperator(context), new SendGridMailer(context), #endif ServiceProxy.Create <IApplicationDeployService>( new ServiceUriBuilder("ApplicationDeployService").ToUri(), new ServicePartitionKey(0)), stateManager, context, new ClusterConfig())); }) .GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ClusterService).Name); Thread.Sleep(Timeout.Infinite); GC.KeepAlive(esListener); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e); throw; } }
public static void Main(string[] args) { try { const string ElasticSearchEventListenerId = "ElasticSearchEventListener"; FabricEventListeners.FabricConfigurationProvider configProvider = new FabricEventListeners.FabricConfigurationProvider(ElasticSearchEventListenerId); ElasticSearchListener esListener = null; if (configProvider.HasConfiguration) { esListener = new ElasticSearchListener(configProvider, new FabricEventListeners.FabricHealthReporter(ElasticSearchEventListenerId)); } ServiceRuntime.RegisterServiceAsync( "ClusterServiceType", context => { IReliableStateManager stateManager = new ReliableStateManager(context); return new ClusterService( #if LOCAL new FakeClusterOperator(stateManager), new FakeMailer(), #else new ArmClusterOperator(context), new SendGridMailer(context), #endif ServiceProxy.Create<IApplicationDeployService>( new ServiceUriBuilder("ApplicationDeployService").ToUri(), new ServicePartitionKey(0)), stateManager, context, new ClusterConfig()); }) .GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ClusterService).Name); Thread.Sleep(Timeout.Infinite); GC.KeepAlive(esListener); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e); throw; } }
public static void Main(string[] args) { try { using (var pipeline = ServiceFabricDiagnosticPipelineFactory.CreatePipeline("PartyCluster.ClusterService")) { ServiceRuntime.RegisterServiceAsync( "ClusterServiceType", context => { IReliableStateManager stateManager = new ReliableStateManager(context); return(new ClusterService( #if LOCAL new FakeClusterOperator(stateManager), new FakeMailer(), #else new ArmClusterOperator(context), new SendGridMailer(context), #endif ServiceProxy.Create <IApplicationDeployService>( new ServiceUriBuilder("ApplicationDeployService").ToUri(), new ServicePartitionKey(0)), stateManager, context, new ClusterConfig())); }) .GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ClusterService).Name); Thread.Sleep(Timeout.Infinite); } } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e); throw; } }