Пример #1
0
        internal static unsafe ServiceCorrelationDescription CreateFromNative(IntPtr nativePtr)
        {
            ReleaseAssert.AssertIfNot(nativePtr != IntPtr.Zero, StringResources.Error_NullNativePointer);

            ServiceCorrelationDescription correlation = new ServiceCorrelationDescription();

            NativeTypes.FABRIC_SERVICE_CORRELATION_DESCRIPTION *casted = (NativeTypes.FABRIC_SERVICE_CORRELATION_DESCRIPTION *)nativePtr;

            correlation.ServiceName = NativeTypes.FromNativeUri(casted->ServiceName);

            switch (casted->Scheme)
            {
            case NativeTypes.FABRIC_SERVICE_CORRELATION_SCHEME.FABRIC_SERVICE_CORRELATION_SCHEME_AFFINITY:
                correlation.Scheme = ServiceCorrelationScheme.Affinity;
                break;

            case NativeTypes.FABRIC_SERVICE_CORRELATION_SCHEME.FABRIC_SERVICE_CORRELATION_SCHEME_ALIGNED_AFFINITY:
                correlation.Scheme = ServiceCorrelationScheme.AlignedAffinity;
                break;

            case NativeTypes.FABRIC_SERVICE_CORRELATION_SCHEME.FABRIC_SERVICE_CORRELATION_SCHEME_NONALIGNED_AFFINITY:
                correlation.Scheme = ServiceCorrelationScheme.NonAlignedAffinity;
                break;

            default:
                AppTrace.TraceSource.WriteError("ServiceCorrelationDescription.CreateFromNative", "Invalid service correlation scheme {0}", casted->Scheme);
                ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_InvalidServiceCorrelationScheme_Formatted, casted->Scheme));
                break;
            }

            return(correlation);
        }
Пример #2
0
        internal static void Validate(ServiceDescription serviceDescription)
        {
            Requires.Argument <Uri>("serviceDescription.ServiceName", serviceDescription.ServiceName).NotNullOrWhiteSpace();
            Requires.Argument <string>("serviceDescription.ServiceTypeName", serviceDescription.ServiceTypeName).NotNullOrWhiteSpace();
            Requires.Argument <PartitionSchemeDescription>("serviceDescription.PartitionSchemeDescription", serviceDescription.PartitionSchemeDescription).NotNull();

            foreach (var correlation in serviceDescription.Correlations)
            {
                ServiceCorrelationDescription.Validate(correlation);
            }

            foreach (var metric in serviceDescription.Metrics)
            {
                ServiceLoadMetricDescription.Validate(metric);
            }
        }
Пример #3
0
        internal unsafe void ParseCorrelations(uint count, IntPtr array)
        {
            if (count == 0)
            {
                return;
            }

            ReleaseAssert.AssertIfNot(array != IntPtr.Zero, StringResources.Error_NullArrayWithNonZeroSize);

            var nativeCorrelations = (NativeTypes.FABRIC_SERVICE_CORRELATION_DESCRIPTION *)array;

            for (int i = 0; i < count; i++)
            {
                var item = ServiceCorrelationDescription.CreateFromNative((IntPtr)(nativeCorrelations + i));
                this.Correlations.Add(item);
            }
        }
Пример #4
0
 internal static void Validate(ServiceCorrelationDescription serviceCorrelationDescription)
 {
     Requires.Argument <ServiceCorrelationDescription>("serviceCorrelationDescription", serviceCorrelationDescription).NotNull();
     Requires.Argument <Uri>("serviceCorrelationDescription.Name", serviceCorrelationDescription.ServiceName).NotNullOrWhiteSpace();
 }
Пример #5
0
 internal ServiceCorrelationDescription(ServiceCorrelationDescription other)
 {
     this.ServiceName = other.ServiceName;
     this.Scheme      = other.Scheme;
 }