internal StatefulServiceDescription(StatefulServiceDescription other) : base(other) { this.HasPersistedState = other.HasPersistedState; this.TargetReplicaSetSize = other.TargetReplicaSetSize; this.MinReplicaSetSize = other.MinReplicaSetSize; this.ReplicaRestartWaitDuration = other.ReplicaRestartWaitDuration; this.StandByReplicaKeepDuration = other.StandByReplicaKeepDuration; this.QuorumLossWaitDuration = other.QuorumLossWaitDuration; }
internal static unsafe ServiceDescription CreateFromNative(IntPtr native) { ReleaseAssert.AssertIfNot(native != IntPtr.Zero, StringResources.Error_NullNativePointer); NativeTypes.FABRIC_SERVICE_DESCRIPTION *casted = (NativeTypes.FABRIC_SERVICE_DESCRIPTION *)native; switch (casted->Kind) { case NativeTypes.FABRIC_SERVICE_DESCRIPTION_KIND.FABRIC_SERVICE_DESCRIPTION_KIND_STATELESS: return(StatelessServiceDescription.CreateFromNative(casted->Value)); case NativeTypes.FABRIC_SERVICE_DESCRIPTION_KIND.FABRIC_SERVICE_DESCRIPTION_KIND_STATEFUL: return(StatefulServiceDescription.CreateFromNative(casted->Value)); default: AppTrace.TraceSource.WriteError("ServiceDescription.CreateFromNative", "Unknown service description type {0}", casted->Kind); ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_UnknownServiceDescriptionType_Formatted, casted->Kind)); break; } return(null); }
internal static new unsafe StatefulServiceDescription CreateFromNative(IntPtr native) { ReleaseAssert.AssertIfNot(native != IntPtr.Zero, StringResources.Error_NullNativePointer); var casted = (NativeTypes.FABRIC_STATEFUL_SERVICE_DESCRIPTION *)native; var description = new StatefulServiceDescription(); description.ApplicationName = NativeTypes.FromNativeUri(casted->ApplicationName); description.ServiceName = NativeTypes.FromNativeUri(casted->ServiceName); description.ServiceTypeName = NativeTypes.FromNativeString(casted->ServiceTypeName); description.PartitionSchemeDescription = PartitionSchemeDescription.CreateFromNative(casted->PartitionScheme, casted->PartitionSchemeDescription); description.TargetReplicaSetSize = casted->TargetReplicaSetSize; description.MinReplicaSetSize = casted->MinReplicaSetSize; description.PlacementConstraints = NativeTypes.FromNativeString(casted->PlacementConstraints); description.HasPersistedState = NativeTypes.FromBOOLEAN(casted->HasPersistedState); description.InitializationData = NativeTypes.FromNativeBytes(casted->InitializationData, casted->InitializationDataSize); description.ParseCorrelations(casted->CorrelationCount, casted->Correlations); description.ParseLoadMetrics(casted->MetricCount, casted->Metrics); if (casted->Reserved == IntPtr.Zero) { return(description); } var ex1 = (NativeTypes.FABRIC_STATEFUL_SERVICE_DESCRIPTION_EX1 *)casted->Reserved; if (ex1->PolicyList != IntPtr.Zero) { var pList = (NativeTypes.FABRIC_SERVICE_PLACEMENT_POLICY_LIST *)ex1->PolicyList; description.ParsePlacementPolicies(pList->PolicyCount, pList->Policies); } if (ex1->FailoverSettings != IntPtr.Zero) { var failoverSettings = (NativeTypes.FABRIC_STATEFUL_SERVICE_FAILOVER_SETTINGS *)ex1->FailoverSettings; if ((failoverSettings->Flags & (uint)NativeTypes.FABRIC_STATEFUL_SERVICE_FAILOVER_SETTINGS_FLAGS.FABRIC_STATEFUL_SERVICE_SETTINGS_REPLICA_RESTART_WAIT_DURATION) != 0) { description.ReplicaRestartWaitDuration = TimeSpan.FromSeconds(failoverSettings->ReplicaRestartWaitDurationSeconds); } if ((failoverSettings->Flags & (uint)NativeTypes.FABRIC_STATEFUL_SERVICE_FAILOVER_SETTINGS_FLAGS.FABRIC_STATEFUL_SERVICE_SETTINGS_QUORUM_LOSS_WAIT_DURATION) != 0) { description.QuorumLossWaitDuration = TimeSpan.FromSeconds(failoverSettings->QuorumLossWaitDurationSeconds); } if (failoverSettings->Reserved != IntPtr.Zero) { var failoverSettingsEx1 = (NativeTypes.FABRIC_STATEFUL_SERVICE_FAILOVER_SETTINGS_EX1 *)failoverSettings->Reserved; if (failoverSettingsEx1 == null) { throw new ArgumentException(StringResources.Error_UnknownReservedType); } if ((failoverSettings->Flags & (uint)NativeTypes.FABRIC_STATEFUL_SERVICE_FAILOVER_SETTINGS_FLAGS.FABRIC_STATEFUL_SERVICE_SETTINGS_STANDBY_REPLICA_KEEP_DURATION) != 0) { description.StandByReplicaKeepDuration = TimeSpan.FromSeconds(failoverSettingsEx1->StandByReplicaKeepDurationSeconds); } } } if (ex1->Reserved == IntPtr.Zero) { return(description); } var ex2 = (NativeTypes.FABRIC_STATEFUL_SERVICE_DESCRIPTION_EX2 *)ex1->Reserved; if (NativeTypes.FromBOOLEAN(ex2->IsDefaultMoveCostSpecified)) { // This will correctly set the property IsDefaultMoveCostSpecified to true if move cost is valid. description.ParseDefaultMoveCost(ex2->DefaultMoveCost); } if (ex2->Reserved == IntPtr.Zero) { return(description); } var ex3 = (NativeTypes.FABRIC_STATEFUL_SERVICE_DESCRIPTION_EX3 *)ex2->Reserved; description.ServicePackageActivationMode = InteropHelpers.FromNativeServicePackageActivationMode(ex3->ServicePackageActivationMode); description.ServiceDnsName = NativeTypes.FromNativeString(ex3->ServiceDnsName); if (ex3->Reserved == IntPtr.Zero) { return(description); } var ex4 = (NativeTypes.FABRIC_STATEFUL_SERVICE_DESCRIPTION_EX4 *)ex3->Reserved; description.ParseScalingPolicies(ex4->ScalingPolicyCount, ex4->ServiceScalingPolicies); return(description); }