Exemplo n.º 1
0
        internal new static unsafe AverageServiceLoadScalingTrigger CreateFromNative(NativeTypes.FABRIC_SCALING_TRIGGER policy)
        {
            if (policy.ScalingTriggerDescription != IntPtr.Zero)
            {
                var serviceAverageLoad = new AverageServiceLoadScalingTrigger();
                var nativeDescription  = (NativeTypes.FABRIC_SCALING_TRIGGER_AVERAGE_SERVICE_LOAD *)policy.ScalingTriggerDescription;

                serviceAverageLoad.MetricName             = NativeTypes.FromNativeString(nativeDescription->MetricName);
                serviceAverageLoad.UpperLoadThreshold     = nativeDescription->UpperLoadThreshold;
                serviceAverageLoad.LowerLoadThreshold     = nativeDescription->LowerLoadThreshold;
                serviceAverageLoad.ScaleIntervalInSeconds = (int)nativeDescription->ScaleIntervalInSeconds;

                if (nativeDescription->Reserved != IntPtr.Zero)
                {
                    NativeTypes.FABRIC_SCALING_TRIGGER_AVERAGE_SERVICE_LOAD_EX1 *ex1 = (NativeTypes.FABRIC_SCALING_TRIGGER_AVERAGE_SERVICE_LOAD_EX1 *)nativeDescription->Reserved;
                    if (ex1 == null)
                    {
                        throw new ArgumentException(StringResources.Error_UnknownReservedType);
                    }

                    serviceAverageLoad.UseOnlyPrimaryLoad = NativeTypes.FromBOOLEAN(ex1->UseOnlyPrimaryLoad);
                }

                return(serviceAverageLoad);
            }

            return(null);
        }
Exemplo n.º 2
0
 internal AverageServiceLoadScalingTrigger(AverageServiceLoadScalingTrigger other)
     : base(ScalingTriggerKind.AverageServiceLoadTrigger)
 {
     MetricName         = other.MetricName;
     LowerLoadThreshold = other.LowerLoadThreshold;
     UpperLoadThreshold = other.UpperLoadThreshold;
     ScaleInterval      = other.ScaleInterval;
     UseOnlyPrimaryLoad = other.UseOnlyPrimaryLoad;
 }
 internal static unsafe ScalingTriggerDescription CreateFromNative(NativeTypes.FABRIC_SCALING_TRIGGER trigger)
 {
     if (trigger.ScalingTriggerKind == NativeTypes.FABRIC_SCALING_TRIGGER_KIND.FABRIC_SCALING_TRIGGER_KIND_AVERAGE_PARTITION_LOAD)
     {
         return(AveragePartitionLoadScalingTrigger.CreateFromNative(trigger));
     }
     else if (trigger.ScalingTriggerKind == NativeTypes.FABRIC_SCALING_TRIGGER_KIND.FABRIC_SCALING_TRIGGER_KIND_AVERAGE_SERVICE_LOAD)
     {
         return(AverageServiceLoadScalingTrigger.CreateFromNative(trigger));
     }
     else
     {
         return(null);
     }
 }