C# Class PartyCluster.ClusterService.ClusterService

Stateful service that manages the lifetime of the party clusters.
Inheritance: StatefulService, IClusterService
ファイルを表示 Open project: Azure-Samples/service-fabric-dotnet-management-party-cluster

Public Methods

Method Description
ClusterService ( IClusterOperator clusterOperator, ISendMail mailer, IApplicationDeployService applicationDeployService, IReliableStateManager stateManager, StatefulServiceContext serviceContext, PartyCluster.ClusterService.ClusterConfig config ) : System

Creates a new instance of the service class.

GetClusterListAsync ( ) : Task>

Gets a list of all currently active clusters.

JoinClusterAsync ( int clusterId, string userEmail ) : Task

Processes a request to join a cluster.

Protected Methods

Method Description
CreateServiceReplicaListeners ( ) : IEnumerable
OnOpenAsync ( ReplicaOpenMode openMode, CancellationToken cancellationToken ) : Task
RunAsync ( CancellationToken cancellationToken ) : Task

Main entry point for the service. This runs a continuous loop that manages the party clusters.

Private Methods

Method Description
BalanceClustersAsync ( int target, CancellationToken cancellationToken ) : Task

Adds clusters by the given amount without going over the max threshold and without resulting in below the min threshold.

CodePackageActivationContext_ConfigurationPackageModifiedEvent ( object sender, PackageModifiedEventArgs e ) : void

Handler for config package updates.

CreateClusterId ( ) : int

Creates a new cluster ID.

CreateClusterInternalName ( ) : string

Creates a name for a cluster resource.

GetActiveClusters ( Cluster>.IReliableDictionary clusterDictionary, CancellationToken cancellationToken ) : Cluster>>>.Task

Gets a list of active clusters. Clusters that are new, being created, or ready and not expired are considered active.

GetTargetClusterCapacityAsync ( CancellationToken cancellationToken ) : Task

Determines how many clusters there should be based on user activity and min/max thresholds.

When the user count goes below the low percent threshold, decrease capacity by (high - low)% When the user count goes above the high percent threshold, increase capacity by (1 - high)%

LoadConfigPackageAndSubscribe ( ) : void

Loads configuration settings from a config package named "Config" and subscribes to update events.

ProcessClusterStatusAsync ( PartyCluster.ClusterService.Cluster cluster ) : Task

Processes a cluster based on its current state.

ProcessClustersAsync ( CancellationToken cancellationToken ) : Task

Processes each cluster that is currently in the list of clusters managed by this service.

ProcessCreatingClusterAsync ( PartyCluster.ClusterService.Cluster cluster ) : Task

Processes a cluster in the "Creating" stage.

ProcessDeletingClusterAsync ( PartyCluster.ClusterService.Cluster cluster ) : Task

Processes a cluster that is in the "Deleting" stage.

ProcessNewClusterAsync ( PartyCluster.ClusterService.Cluster cluster ) : Task

Processes a new cluster.

ProcessReadyClusterAsync ( PartyCluster.ClusterService.Cluster cluster ) : Task

Processes clusters in the "Ready" stage.

ProcessRemoveClusterAsync ( PartyCluster.ClusterService.Cluster cluster ) : Task

Processes a cluster in the "Remove" stage.

UpdateClusterConfigSettings ( ConfigurationSettings settings ) : void

Updates the service's ClusterConfig instance with new settings from the given ConfigurationSettings.

Method Details

ClusterService() public method

Creates a new instance of the service class.
public ClusterService ( IClusterOperator clusterOperator, ISendMail mailer, IApplicationDeployService applicationDeployService, IReliableStateManager stateManager, StatefulServiceContext serviceContext, PartyCluster.ClusterService.ClusterConfig config ) : System
clusterOperator IClusterOperator
mailer ISendMail
applicationDeployService IApplicationDeployService
stateManager IReliableStateManager
serviceContext StatefulServiceContext
config PartyCluster.ClusterService.ClusterConfig
return System

CreateServiceReplicaListeners() protected method

protected CreateServiceReplicaListeners ( ) : IEnumerable
return IEnumerable

GetClusterListAsync() public method

Gets a list of all currently active clusters.
public GetClusterListAsync ( ) : Task>
return Task>

JoinClusterAsync() public method

Processes a request to join a cluster.
public JoinClusterAsync ( int clusterId, string userEmail ) : Task
clusterId int
userEmail string
return Task

OnOpenAsync() protected method

protected OnOpenAsync ( ReplicaOpenMode openMode, CancellationToken cancellationToken ) : Task
openMode ReplicaOpenMode
cancellationToken System.Threading.CancellationToken
return Task

RunAsync() protected method

Main entry point for the service. This runs a continuous loop that manages the party clusters.
protected RunAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken
return Task