Skip to content

Commit 84409bc

Browse files
authored
Merge pull request #191746 from vladelekic/dev/vladeleki/moveCostDocumentation
Report Move Cost on behalf of other partition
2 parents 75cc838 + c21f05b commit 84409bc

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

articles/service-fabric/service-fabric-cluster-resource-manager-movement-cost.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,60 @@ await fabricClient.ServiceManager.UpdateServiceAsync(new Uri("fabric:/AppName/Se
5454

5555
## Dynamically specifying move cost on a per-replica basis
5656

57-
The preceding snippets are all for specifying MoveCost for a whole service at once from outside the service itself. However, move cost is most useful is when the move cost of a specific service object changes over its lifespan. Since the services themselves probably have the best idea of how costly they are to move a given time, there's an API for services to report their own individual move cost during runtime.
57+
The preceding snippets are all for specifying MoveCost for a whole service at once from outside the service itself. However, move cost is most useful when the move cost of a specific service object changes over its lifespan. Since the services themselves probably have the best idea of how costly they are to move a given time, there's an API for services to report their own individual move cost during runtime.
5858

5959
C#:
6060

6161
```csharp
6262
this.Partition.ReportMoveCost(MoveCost.Medium);
6363
```
6464

65+
## Reporting move cost for a partition
66+
67+
The previous section describes how service replicas or instances report MoveCost themselves. We provided Service Fabric API for reporting MoveCost values on behalf of other partitions. Sometimes service replica or instance can't determine the best MoveCost value by itself, and must rely on other services logic. Reporting MoveCost on behalf of other partitions, alongside [reporting load on behalf of other partitions](service-fabric-cluster-resource-manager-metrics.md#reporting-load-for-a-partition), allows you to completely manage partitions from outside. These APIs eliminate needs for [the Sidecar pattern](https://docs.microsoft.com/azure/architecture/patterns/sidecar), from the perspective of the Cluster Resource Manager.
68+
69+
You can report MoveCost updates for a different partition with the same API call. You need to specify PartitionMoveCostDescription object for each partition that you want to update with new values of MoveCost. The API allows multiple ways to update MoveCost:
70+
71+
- A stateful service partition can update its primary replica MoveCost.
72+
- Both stateless and stateful services can update the MoveCost of all its secondary replicas or instances.
73+
- Both stateless and stateful services can update the MoveCost of a specific replica or instance on a node.
74+
75+
Each MoveCost update for partition should contain at least one valid value that will be changed. For example, you could skip primary replica update with assigning _null_ to primary replica entry, other entries will be used during MoveCost update and we will skip MoveCost update for primary replica. Since updating of MoveCost for multiple partitions with single API call is possible, API provides a list of return codes for corresponding partition. If we successfully accept and process a request for MoveCost update, return code will be Success. Otherwise, API provides error code:
76+
77+
- PartitionNotFound - Specified partition ID doesn't exist.
78+
- ReconfigurationPending - Partition is currently reconfiguring.
79+
- InvalidForStatelessServices - An attempt was made to change the MoveCost of a primary replica for a partition belonging to a stateless service.
80+
- ReplicaDoesNotExist - Secondary replica or instance does not exist on a specified node.
81+
- InvalidOperation - Updating MoveCost for a partition that belongs to the System application.
82+
83+
C#:
84+
85+
```csharp
86+
Guid partitionId = Guid.Parse("53df3d7f-5471-403b-b736-bde6ad584f42");
87+
string nodeName0 = "NodeName0";
88+
89+
OperationResult<UpdatePartitionMoveCostResultList> updatePartitionMoveCostResults =
90+
await this.FabricClient.UpdatePartitionMoveCostAsync(
91+
new UpdatePartitionMoveCostQueryDescription
92+
{
93+
new List<PartitionMoveCostDescription>()
94+
{
95+
new PartitionMoveCostDescription(
96+
partitionId,
97+
MoveCost.VeryHigh,
98+
MoveCost.Zero,
99+
new List<ReplicaMoveCostDescription>()
100+
{
101+
new ReplicaMoveCostDescription(nodeName0, MoveCost.Medium)
102+
})
103+
}
104+
},
105+
this.Timeout,
106+
cancellationToken);
107+
```
108+
109+
With this example, you will perform an update of the last reported move cost for a partition _53df3d7f-5471-403b-b736-bde6ad584f42_. Primary replica move cost will be _VeryHigh_. All secondary replicas move cost will be _Zero_, except move cost for a specific secondary replica located at the node _NodeName0_. Move cost for a specific replica will be _Medium_. If you want to skip updating move cost for primary replica or all secondary replicas, you could leave corresponding entry as _null_.
110+
65111
## Impact of move cost
66112
MoveCost has five levels: Zero, Low, Medium, High and VeryHigh. The following rules apply:
67113

0 commit comments

Comments
 (0)