Skip to content

InProcessTestCluster Methods

A host class for local testing with Orleans using in-process silos.

DeactivateAsync(GrainId)

View source
public Task DeactivateAsync(GrainId grainId)
Deactivates the current activation of the specified grain and waits for deactivation to complete.

Parameters

grainIdGrainId
The ID of the grain to deactivate.

Returns

A task that completes when the grain has been deactivated.

Examples

await cluster.DeactivateAsync(grain.GetGrainId());

DeactivateAsync(IAddressable)

View source
public Task DeactivateAsync(IAddressable grain)
Deactivates the current activation of the specified grain and waits for deactivation to complete.

Parameters

grainIAddressable
The grain to deactivate.

Returns

A task that completes when the grain has been deactivated.

Examples

await cluster.DeactivateAsync(grain.GetGrainId());

DeployAsync

View source
public Task DeployAsync()
Deploys the cluster using the specified configuration and starts the client in-process.

Dispose

View source
public void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

DisposeAsync

View source
public ValueTask DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

Returns

A task that represents the asynchronous dispose operation.

GetActiveSilos

View source
public IEnumerable<InProcessSiloHandle> GetActiveSilos()
Get the list of current active silos.

Returns

List of current silos.

GetLivenessStabilizationTime(ClusterMembershipOptions, bool)

static
View source
public static TimeSpan GetLivenessStabilizationTime(ClusterMembershipOptions clusterMembershipOptions, bool didKill = false)
Get the timeout value to use to wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.

Parameters

clusterMembershipOptionsClusterMembershipOptions
didKillbool

GetSiloForAddress(SiloAddress)

View source
public InProcessSiloHandle? GetSiloForAddress(SiloAddress siloAddress)
Find the silo handle for the specified silo address.

Parameters

siloAddressSiloAddress
Silo address to be found.

Returns

SiloHandle of the appropriate silo, or null if not found.

GetSiloServiceProvider(SiloAddress)

View source
public IServiceProvider GetSiloServiceProvider(SiloAddress silo = null)
Returns the System.IServiceProvider associated with the given silo.

Parameters

siloSiloAddress
The silo process to the the service provider for.

MigrateAsync(GrainId, SiloAddress?)

View source
public Task MigrateAsync(GrainId grainId, SiloAddress? targetSilo = null)
Migrates the current activation of the specified grain to a different silo and waits for migration to complete. If targetSilo is specified, a placement hint is set to guide migration to that silo.

Parameters

grainIdGrainId
The ID of the grain to migrate.
targetSiloSiloAddress?
The target silo address, or null to let the placement director choose.

Returns

A task that completes when the grain has been migrated (deactivated on the source silo).

Examples

var targetSilo = cluster.GetActiveSilos().First(s => s.SiloAddress != originalHost).SiloAddress;
await cluster.MigrateAsync(grain.GetGrainId(), targetSilo);

MigrateAsync(IAddressable, SiloAddress?)

View source
public Task MigrateAsync(IAddressable grain, SiloAddress? targetSilo = null)
Migrates the current activation of the specified grain to a different silo and waits for migration to complete. If targetSilo is specified, a placement hint is set to guide migration to that silo.

Parameters

grainIAddressable
The grain to migrate.
targetSiloSiloAddress?
The target silo address, or null to let the placement director choose.

Returns

A task that completes when the grain has been migrated (deactivated on the source silo).

Examples

var targetSilo = cluster.GetActiveSilos().First(s => s.SiloAddress != originalHost).SiloAddress;
await cluster.MigrateAsync(grain.GetGrainId(), targetSilo);

RestartSiloAsync(InProcessSiloHandle)

View source
public Task<InProcessSiloHandle?> RestartSiloAsync(InProcessSiloHandle instance)
Do a Stop or Kill of the specified silo, followed by a restart.

Parameters

instanceInProcessSiloHandle
Silo to be restarted.

StartAdditionalSilo

View source
public InProcessSiloHandle StartAdditionalSilo()
Start an additional silo, so that it joins the existing cluster.

Returns

SiloHandle for the newly started silo.

StartAdditionalSilo(bool)

View source
[System.Obsolete(Use overload which does not have a 'startAdditionalSiloOnNewPort' parameter.)]
public InProcessSiloHandle StartAdditionalSilo(bool startAdditionalSiloOnNewPort)
Start an additional silo, so that it joins the existing cluster.

Parameters

startAdditionalSiloOnNewPortbool

Returns

SiloHandle for the newly started silo.

StartAdditionalSiloAsync

View source
public Task<InProcessSiloHandle> StartAdditionalSiloAsync()
Start an additional silo, so that it joins the existing cluster.

Returns

SiloHandle for the newly started silo.

StartAdditionalSiloAsync(bool)

View source
public Task<InProcessSiloHandle> StartAdditionalSiloAsync(bool startAdditionalSiloOnNewPort)
Start an additional silo, so that it joins the existing cluster.

Parameters

startAdditionalSiloOnNewPortbool

Returns

SiloHandle for the newly started silo.

StartSiloAsync(int, InProcessTestClusterOptions)

View source
public Task<InProcessSiloHandle> StartSiloAsync(int instanceNumber, InProcessTestClusterOptions clusterOptions)
Starts a new silo.

Parameters

instanceNumberint
The instance number to deploy
clusterOptionsInProcessTestClusterOptions
The options to use.

Returns

A handle to the deployed silo.

StartSiloAsync(int, InProcessTestClusterOptions, IReadOnlyList<IConfigurationSource>, bool)

View source
[System.Obsolete(Use the overload which does not have a 'startSiloOnNewPort' parameter.)]
public Task<InProcessSiloHandle> StartSiloAsync(int instanceNumber, InProcessTestClusterOptions clusterOptions, IReadOnlyList<IConfigurationSource> configurationOverrides, bool startSiloOnNewPort)
Starts a new silo.

Parameters

instanceNumberint
The instance number to deploy
clusterOptionsInProcessTestClusterOptions
The options to use.
configurationOverridesIReadOnlyList<IConfigurationSource>
Configuration overrides.
startSiloOnNewPortbool
Whether we start this silo on a new port, instead of the default one

Returns

A handle to the deployed silo.

StartSiloAsync(InProcessTestCluster, int, InProcessTestClusterOptions)

static
View source
public static Task<InProcessSiloHandle> StartSiloAsync(InProcessTestCluster cluster, int instanceNumber, InProcessTestClusterOptions clusterOptions)
Start a new silo in the target cluster

Parameters

clusterInProcessTestCluster
The InProcessTestCluster in which the silo should be deployed
instanceNumberint
The instance number to deploy
clusterOptionsInProcessTestClusterOptions
The options to use.

Returns

A handle to the silo deployed

StartSiloAsync(InProcessTestCluster, int, InProcessTestClusterOptions, IReadOnlyList<IConfigurationSource>, bool)

static
View source
[System.Obsolete(Use the overload which does not have a 'startSiloOnNewPort' parameter.)]
public static Task<InProcessSiloHandle> StartSiloAsync(InProcessTestCluster cluster, int instanceNumber, InProcessTestClusterOptions clusterOptions, IReadOnlyList<IConfigurationSource> configurationOverrides, bool startSiloOnNewPort)
Start a new silo in the target cluster

Parameters

clusterInProcessTestCluster
The InProcessTestCluster in which the silo should be deployed
instanceNumberint
The instance number to deploy
clusterOptionsInProcessTestClusterOptions
The options to use.
configurationOverridesIReadOnlyList<IConfigurationSource>
Configuration overrides.
startSiloOnNewPortbool
Whether we start this silo on a new port, instead of the default one

Returns

A handle to the silo deployed

StartSilosAsync(int)

View source
public Task<List<InProcessSiloHandle>> StartSilosAsync(int silosToStart)
Start a number of additional silo, so that they join the existing cluster.

Parameters

silosToStartint
Number of silos to start.

Returns

List of SiloHandles for the newly started silos.

StartSilosAsync(int, bool)

View source
[System.Obsolete(Use overload which does not have a 'startAdditionalSiloOnNewPort' parameter.)]
public Task<List<InProcessSiloHandle>> StartSilosAsync(int silosToStart, bool startAdditionalSiloOnNewPort)
Start a number of additional silo, so that they join the existing cluster.

Parameters

silosToStartint
Number of silos to start.
startAdditionalSiloOnNewPortbool

Returns

List of SiloHandles for the newly started silos.

StopClusterClientAsync

View source
public Task StopClusterClientAsync()
Stop cluster client as an asynchronous operation.

Returns

A System.Threading.Tasks.Task representing the asynchronous operation.

TryGetGrainContext(GrainId, IGrainContext?)

View source
public bool TryGetGrainContext(GrainId grainId, out IGrainContext? grainContext)
Attempts to find the IGrainContext for the grain with the specified grainId by searching all silos in the cluster.

Parameters

grainIdGrainId
The ID of the grain to find.
grainContextIGrainContext?
When this method returns, contains the grain context if found; otherwise, null.

Returns

true if the grain was found in one of the silos; otherwise, false.

WaitForClusterManifestToStabilizeAsync(bool)

View source
public Task WaitForClusterManifestToStabilizeAsync(bool didKill = false)
Wait for active silos to observe cluster manifest updates for all active silos.

Parameters

didKillbool
Whether recent membership changes were done by graceful Stop.

WaitForDeactivationAsync(GrainId)

View source
public Task WaitForDeactivationAsync(GrainId grainId)
Gets a System.Threading.Tasks.Task that completes when the current activation of the specified grain finishes deactivating. If the grain is not currently activated, returns System.Threading.Tasks.Task.CompletedTask.

Parameters

grainIdGrainId
The ID of the grain to observe.

Returns

A task that completes when the grain's current activation has deactivated.

Examples

var deactivated = cluster.WaitForDeactivationAsync(grain.GetGrainId());
await grain.DoDeactivate();
await deactivated;

WaitForDeactivationAsync(IAddressable)

View source
public Task WaitForDeactivationAsync(IAddressable grain)
Gets a System.Threading.Tasks.Task that completes when the current activation of the specified grain finishes deactivating. If the grain is not currently activated, returns System.Threading.Tasks.Task.CompletedTask.

Parameters

grainIAddressable
The grain to observe.

Returns

A task that completes when the grain's current activation has deactivated.

Examples

var deactivated = cluster.WaitForDeactivationAsync(grain.GetGrainId());
await grain.DoDeactivate();
await deactivated;

WaitForLivenessToStabilizeAsync(bool)

View source
public Task WaitForLivenessToStabilizeAsync(bool didKill = false)
Wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.

Parameters

didKillbool
Whether recent membership changes we done by graceful Stop.