private PartitionInformation GetBackupServicePartitionInformationFromServicePartitionInformation(ServicePartitionInformation servicePartitionInformation) { PartitionInformation backupServicePartitionInformation = null; switch (servicePartitionInformation.Kind) { case ServicePartitionKind.Singleton: backupServicePartitionInformation = new SingletonPartitionInformation(); break; case ServicePartitionKind.Int64Range: var int64RangePartitionInformation = servicePartitionInformation as Fabric.Int64RangePartitionInformation; ThrowIf.Null(int64RangePartitionInformation, "int64RangePartitionInformation"); backupServicePartitionInformation = new Int64RangePartitionInformation() { HighKey = int64RangePartitionInformation.HighKey, LowKey = int64RangePartitionInformation.LowKey }; break; case ServicePartitionKind.Named: var namedPartitionInformation = servicePartitionInformation as Fabric.NamedPartitionInformation; ThrowIf.Null(namedPartitionInformation, "namedPartitionInformation"); backupServicePartitionInformation = new NamedPartitionInformation() { Name = namedPartitionInformation.Name }; break; default: throw new ArgumentOutOfRangeException(); } return(backupServicePartitionInformation); }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="obj">The object to serialize to JSON.</param> internal static void Serialize(JsonWriter writer, NamedPartitionInformation obj) { // Required properties are always serialized, optional properties are serialized when not null. writer.WriteStartObject(); writer.WriteProperty(obj.ServicePartitionKind, "ServicePartitionKind", ServicePartitionKindConverter.Serialize); if (obj.Id != null) { writer.WriteProperty(obj.Id, "Id", PartitionIdConverter.Serialize); } if (obj.Name != null) { writer.WriteProperty(obj.Name, "Name", JsonWriterExtensions.WriteStringValue); } writer.WriteEndObject(); }
private static async Task <string> GetPartitionEndpointAsync(StatefulServiceContext serviceContext, NamedPartitionInformation partition) { var resolvedPartition = await FabricClient.ServiceManager.ResolveServicePartitionAsync(serviceContext.ServiceName, partition.Name).ConfigureAwait(false); return(resolvedPartition?.GetEndpoint()?.Address); }