Restart-ServiceFabricNode

Restarts a Service Fabric node to simulate a cluster node failure.

Syntax

Restart-ServiceFabricNode
       [-NodeName] <String>
       [[-NodeInstanceId] <BigInteger>]
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -PartitionId <Guid>
       -ServiceName <Uri>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -PartitionId <Guid>
       -ServiceName <Uri>
       [-ReplicaKindPrimary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -PartitionId <Guid>
       -ServiceName <Uri>
       [-ReplicaKindRandomSecondary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -PartitionId <Guid>
       -ServiceName <Uri>
       -ReplicaOrInstanceId <Int64>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindSingleton]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindNamed]
       -PartitionKey <String>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindUniformInt64]
       -PartitionKey <String>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindSingleton]
       [-ReplicaKindRandomSecondary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindNamed]
       -PartitionKey <String>
       [-ReplicaKindRandomSecondary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindUniformInt64]
       -PartitionKey <String>
       [-ReplicaKindRandomSecondary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindSingleton]
       [-ReplicaKindPrimary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindNamed]
       -PartitionKey <String>
       [-ReplicaKindPrimary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindUniformInt64]
       -PartitionKey <String>
       [-ReplicaKindPrimary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindSingleton]
       -ReplicaOrInstanceId <Int64>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindNamed]
       -PartitionKey <String>
       -ReplicaOrInstanceId <Int64>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-PartitionKindUniformInt64]
       -PartitionKey <String>
       -ReplicaOrInstanceId <Int64>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-ReplicaKindPrimary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       [-ReplicaKindRandomSecondary]
       [-TimeoutSec <Int32>]
       [<CommonParameters>]
Restart-ServiceFabricNode
       [-CommandCompletionMode <CompletionMode>]
       [-CreateFabricDump]
       -ServiceName <Uri>
       -ReplicaOrInstanceId <Int64>
       [-TimeoutSec <Int32>]
       [<CommonParameters>]

Description

The Restart-ServiceFabricNode cmdlet restarts a Service Fabric node by restarting the Fabric.exe process that hosts the node. This cmdlet simulates Service Fabric node failures in the cluster, which tests the failover recovery paths of your service. For more information, see Using test actions.

The Service Fabric node to be restarted can specified in the following ways:

  • Specify node name and optionally the node instance ID.
  • Specify a stateful service replica or stateless service instance and let the cmdlet identify and restart the node that hosts it. The folowing implicit behaviors for replica/instance selection are worth noting:
    • If the service does not use a Singleton partition and neither the PartitionId nor PartitionKey parameter is specified, then the cmdlet picks a partition randomly.
    • If the service is a stateful service and none of the Primary, RandomSecondary and ReplicaOrInstanceId parameters are specified, then the cmdlet randomly picks a replica, regardless of its role.
    • If the service is a stateless service and the ReplicaOrInstanceId parameter is not specified, then the cmdlet randomly picks an instance.

If you specify a non-zero value for the NodeInstanceId parameter, that ID is compared with the active node ID. If the IDs do not match, the process is not restarted and an error occurs. A stale message can cause this error.

If you specify the CreateFabricDump parameter, this cmdlet causes the Fabric.exe process to crash on the specified node during restart. This crash creates a process dump for Fabric.exe.

Before you perform any operation on a Service Fabric cluster, establish a connection to the cluster by using the Connect-ServiceFabricCluster cmdlet.

Examples

Example 1: Restart a node that hosts a primary replica

PS C:\> Restart-ServiceFabricNode -ReplicaKindPrimary -PartitionKindNamed -PartitionKey "Partition3" -CommandCompletionMode Verify

This command restarts the node that hosts the primary replica of the partition named Partition3. Because the CommandCompletionMode parameter is specified with a value of Verify, the command waits for the target node to restart before it completes.

Example 2: Restart a specified node

PS C:\> Restart-ServiceFabricNode -NodeName "Node01" -CommandCompletionMode DoNotVerify

This command restarts the node named Node01. Because the CommandCompletionMode parameter is specified with a value of DoNotVerify, the command does not wait for the node to restart before it completes.

Parameters

-CommandCompletionMode

Specifies whether the action waits for the restart to complete. Specify Verify to make the cmdlet wait for restart to complete, and DoNotVerify to make the cmdlet return without waiting for restart to complete.

Type:CompletionMode
Accepted values:Invalid, DoNotVerify, Verify
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CreateFabricDump

Indicates that a process dump should be created for Fabric.exe on specified node.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-NodeInstanceId

Specifies a node instance ID. Unless you specify 0, the node instance ID that you specify must match the currently running node. To obtain node instance IDs, run Get-ServiceFabricNode for the target node. For example, for the node N0050, the command Get-ServiceFabricNode -NodeName "N0050" returns a Node object that contains the node instance ID.

Type:BigInteger
Position:1
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-NodeName

Specifies the name of a Service Fabric node. The cmdlet restarts the node that you specify.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PartitionId

Specifies the partition ID of a Service Fabric service partition. The cmdlet restarts a node that hosts a replica or instance of this partition.

Type:Guid
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PartitionKey

Specifies a partition key for a Service Fabric service partition. The cmdlet identifies the partition that this partition key maps to and restarts a node that hosts a replica or instance of that partition..

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PartitionKindNamed

Indicates that the PartitionKey parameter specifies a partition key for a service that uses Named partitioning scheme.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-PartitionKindSingleton

Indicates that the service specified in the ServiceName parameter uses a Singleton partition.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-PartitionKindUniformInt64

Indicates that the PartitionKey parameter specifies a partition key for a service that uses UniformInt64 partitioning scheme.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ReplicaKindPrimary

Indicates that this cmdlet restarts the node that hosts the primary replica of the specified partition.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ReplicaKindRandomSecondary

Indicates that this cmdlet restarts the node that hosts a random secondary replica of the specified partition.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ReplicaOrInstanceId

Specifies a Service Fabric service replica or instance ID. The cmdlet restarts the node that hosts the specified replica or instance.

Type:Int64
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ServiceName

Specifies the name of a Service Fabric service. The cmdlet restarts a node that hosts a replica or instance of this service.

Type:Uri
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TimeoutSec

Specifies the time-out period, in seconds, for the operation.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

System.String

System.Nullable`1[[System.Numerics.BigInteger, System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

System.Guid

System.Uri

System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

Outputs

System.Object