Finding a partition key for a stateful service in Azure Service Fabric

I followed the steps to create a reverse proxy in my resource group in Azure. https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reverseproxy

I believe the reverse proxy works because I was getting 404 error, now I get 400 Bad Request.

Error Code: FABRIC_E_INVALID_PARTITION_KEY

This approach makes sense, since the documentation says that for services that do not use a singleton partition, you must specify the key of the partition and the type of partition, for example:

http://mycluster.eastus.cloudapp.azure.com:19008/MyApp/MyService?PartitionKey=3&PartitionKind=Int64Range

My question is: how do I get this section key? The documentation explicitly states that this is not a GUID generated in Explorer, so I cannot use this. I access this service with statefulness from an external application, outside the fabric.

+4
source share
2 answers

PartitionIdthat you see in Service Explorer is the unique identifier for the section where the service request ends. PartitionKey- this is not the same as, PartitionIdbut rather, the key that is included in the hashing of partitions and is based on the fact that the partition on which the query ends with this key is calculated from.

In ApplicationManifest.xmlthe application project, the separation key for the newly created service is as follows:

<Service Name="MyService">
  <StatefulService ServiceTypeName="MyServiceType" 
                   TargetReplicaSetSize="[MyService_TargetReplicaSetSize]"
                   MinReplicaSetSize="[MyService_MinReplicaSetSize]">
    <UniformInt64Partition PartitionCount="[MyService_PartitionCount]"
                           LowKey="-9223372036854775808"
                           HighKey="9223372036854775807" />
  </StatefulService>
</Service>

UniformInt64Partition , Int64Range. LowKey HighKey . PartitionCount , . , . , , specificik. :.

  <Parameters>
      ...
      <Parameter Name="MyService_PartitionCount" DefaultValue="2" />
      ...
  </Parameters>
  ...
<Service Name="MyService">
  <StatefulService ServiceTypeName="MyServiceType" 
                   TargetReplicaSetSize="[MyService_TargetReplicaSetSize]"
                   MinReplicaSetSize="[MyService_MinReplicaSetSize]">
    <UniformInt64Partition PartitionCount="[MyService_PartitionCount]"
                           LowKey="0"
                           HighKey="11" />
  </StatefulService>
</Service>

2 , :

  • 0 - 5: 0
  • 6 - 11: 1

, , , , . () 4, :

  • 0 - 2: 0
  • 3 - 5: 1
  • 6 - 8: 2
  • 9 - 11: 3

, , . . Stateless.

Microsoft : https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-concepts-partitioning

, LowKey HighKey, ( UniformInt64Partition). , FABRIC_E_INVALID_PARTITION_KEY, , . , FABRIC_E_KEY_NOT_FOUND .

+6

.

  • .
  • Int64RangePartitions Int64, "" "". ()

:

SF . "Essentials" ().

- - , . . - . (, / int64)

+4

Source: https://habr.com/ru/post/1666318/


All Articles