Exemple #1
0
        private void CreateNativeClient(IEnumerable <string> connectionStrings, bool isInternal, string workingDirectory, SecurityCredentials credentials)
        {
            Guid iid = typeof(NativeImageStore.IFabricNativeImageStoreClient).GetTypeInfo().GUID;

            if (connectionStrings == null)
            {
                using (var pinColl = new PinCollection())
                {
                    this.nativeClient = (NativeImageStore.IFabricNativeImageStoreClient3)NativeImageStore.FabricCreateLocalNativeImageStoreClient(
                        isInternal,
                        (workingDirectory == null ? IntPtr.Zero : pinColl.AddObject(workingDirectory)),
                        ref iid);
                }
            }
            else
            {
                using (var pinColl = new PinCollection())
                {
                    using (var pinArray = new PinArray(connectionStrings, PinBlittable.Create))
                    {
                        this.nativeClient = (NativeImageStore.IFabricNativeImageStoreClient3)NativeImageStore.FabricCreateNativeImageStoreClient(
                            isInternal,
                            (workingDirectory == null ? IntPtr.Zero : pinColl.AddObject(workingDirectory)),
                            (ushort)pinArray.Count,
                            pinArray.AddrOfPinnedObject(),
                            ref iid);
                    }
                }
            }

            if (credentials != null)
            {
                this.SetSecurityCredentialsWrapper(credentials);
            }
        }
Exemple #2
0
 internal void SetSecurityCredentialsWrapper(SecurityCredentials credentials)
 {
     using (var pin = new PinCollection())
     {
         this.nativeClient.SetSecurityCredentials(credentials.ToNative(pin));
     }
 }
        internal virtual IntPtr ToNative(PinCollection pinCollection)
        {
            var nativePolicy = new NativeTypes.FABRIC_ROLLING_UPGRADE_MONITORING_POLICY();

            switch (this.FailureAction)
            {
            case UpgradeFailureAction.Rollback:
            case UpgradeFailureAction.Manual:
                nativePolicy.FailureAction = (NativeTypes.FABRIC_MONITORED_UPGRADE_FAILURE_ACTION) this.FailureAction;
                break;

            default:
                // Allow this for modify upgrade
                //
                nativePolicy.FailureAction = (NativeTypes.FABRIC_MONITORED_UPGRADE_FAILURE_ACTION.FABRIC_MONITORED_UPGRADE_FAILURE_ACTION_INVALID);
                break;
            }

            nativePolicy.HealthCheckWaitDurationInSeconds = ToNativeTimeInSeconds(this.HealthCheckWaitDuration);
            nativePolicy.HealthCheckRetryTimeoutInSeconds = ToNativeTimeInSeconds(this.HealthCheckRetryTimeout);
            nativePolicy.UpgradeTimeoutInSeconds          = ToNativeTimeInSeconds(this.UpgradeTimeout);
            nativePolicy.UpgradeDomainTimeoutInSeconds    = ToNativeTimeInSeconds(this.UpgradeDomainTimeout);

            var ex1 = new NativeTypes.FABRIC_ROLLING_UPGRADE_MONITORING_POLICY_EX1();

            ex1.HealthCheckStableDurationInSeconds = ToNativeTimeInSeconds(this.HealthCheckStableDuration);

            nativePolicy.Reserved = pinCollection.AddBlittable(ex1);

            return(pinCollection.AddBlittable(nativePolicy));
        }
#pragma warning disable 618

        internal unsafe void ToNative(PinCollection pin, ref NativeTypes.FABRIC_SERVICE_LOAD_METRIC_DESCRIPTION native)
        {
            native.Name = pin.AddBlittable(this.Name);
            native.PrimaryDefaultLoad   = checked ((uint)this.PrimaryDefaultLoad);
            native.SecondaryDefaultLoad = checked ((uint)this.SecondaryDefaultLoad);

            switch (this.Weight)
            {
            case ServiceLoadMetricWeight.Zero:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_ZERO;
                break;

            case ServiceLoadMetricWeight.Low:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_LOW;
                break;

            case ServiceLoadMetricWeight.Medium:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_MEDIUM;
                break;

            case ServiceLoadMetricWeight.High:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_HIGH;
                break;

            default:
                ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_UnknownWeight_Formatted, this.Weight));
                break;
            }
        }
        private void CreateNativeClient(
            FabricTransportSettings transportSettings,
            string connectionAddress,
            IFabricTransportClientEventHandler eventHandler,
            IFabricTransportCallbackMessageHandler contract,
            NativeFabricTransport.IFabricTransportMessageDisposer messageMessageDisposer)
        {
            var iid = typeof(NativeFabricTransport.IFabricTransportClient).GetTypeInfo().GUID;

            using (var pin = new PinCollection())
            {
                var nativeTransportSettings = transportSettings.ToNativeV2(pin);
                var messageHandler          = new FabricTransportCallbackHandlerBroker(contract);
                var nativeConnectionAddress = pin.AddBlittable(connectionAddress);
                var nativeEventHandler      = new FabricTransportClientConnectionEventHandlerBroker(eventHandler);
                this.nativeClient =
                    NativeFabricTransport.CreateFabricTransportClient(
                        ref iid,
                        nativeTransportSettings,
                        nativeConnectionAddress,
                        messageHandler,
                        nativeEventHandler,
                        messageMessageDisposer);
            }
        }
Exemple #6
0
        CreateContainerBeginWrapper(
            string FullyQualifiedLogFilePath,
            Guid PhysicalLogId,
            Int64 PhysicalLogSize,
            UInt32 MaxAllowedStreams,
            UInt32 MaxRecordSize,
            LogManager.LogCreationFlags CreationFlags,
            NativeCommon.IFabricAsyncOperationCallback Callback)
        {
            NativeCommon.IFabricAsyncOperationContext context;

            using (var pin = new PinCollection())
            {
                this._NativeManager.BeginCreateLogContainer(
                    pin.AddBlittable(FullyQualifiedLogFilePath),
                    PhysicalLogId,
                    pin.AddBlittable(""),
                    PhysicalLogSize,
                    MaxAllowedStreams,
                    MaxRecordSize,
                    CreationFlags,
                    Callback,
                    out context);
            }

            return(context);
        }
        private bool OnTimerTick()
        {
            Task.Run(async() =>
            {
                Items.Clear();
                Items = await RefreshDataAsync();
                PinCollection.Clear();

                if (SelectedBus != null)
                {
                    var qw = Items.Where(n => n.BusNumber == SelectedBus);
                    foreach (var item in qw)
                    {
                        PinCollection.Add(new Pin()
                        {
                            Position = new Position(item.Latitude, item.Longitude), Type = PinType.Generic, Label = item.BusNumber
                        });
                    }
                }
                else
                {
                    foreach (var item in Items)
                    {
                        PinCollection.Add(new Pin()
                        {
                            Position = new Position(item.Latitude, item.Longitude), Type = PinType.Generic, Label = item.BusNumber
                        });
                    }
                }
            });

            return(true);
        }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeDescription = new NativeTypes.FABRIC_NODE_QUERY_DESCRIPTION();

            nativeDescription.NodeNameFilter = pinCollection.AddObject(this.NodeNameFilter);

            var ex1 = new NativeTypes.FABRIC_NODE_QUERY_DESCRIPTION_EX1();

            ex1.ContinuationToken = pinCollection.AddObject(this.ContinuationToken);

            var ex2 = new NativeTypes.FABRIC_NODE_QUERY_DESCRIPTION_EX2();

            ex2.NodeStatusFilter = (UInt32)this.NodeStatusFilter;

            var ex3 = new NativeTypes.FABRIC_NODE_QUERY_DESCRIPTION_EX3();

            if (this.MaxResults.HasValue)
            {
                ex3.MaxResults = this.MaxResults.Value;
            }

            ex3.Reserved = IntPtr.Zero;
            ex2.Reserved = pinCollection.AddBlittable(ex3);

            ex1.Reserved = pinCollection.AddBlittable(ex2);

            nativeDescription.Reserved = pinCollection.AddBlittable(ex1);
            return(pinCollection.AddBlittable(nativeDescription));
        }
Exemple #9
0
        private static void SetLastWriteTimeHelper(string path, long lastWriteTime)
        {
#if DotNetCoreClrLinux
            throw new NotSupportedException("This operation is not supported on Linux. Please use File.SetLastWriteTime API");
#else
            using (var pin = new PinCollection())
            {
                // Default values indicate "no change". Use defaults.
                var basicInfo = new Kernel32Types.FILE_BASIC_INFO
                {
                    CreationTime   = -1,
                    LastAccessTime = -1,
                    LastWriteTime  = lastWriteTime,
                    ChangeTime     = -1,
                    FileAttributes = 0
                };

                // To update the file last written time, it needs to be opened up with Write access.
                using (FileStream file = FabricFile.Open(path, FileMode.Open, FileAccess.ReadWrite))
                {
                    var success = SetFileInformationByHandle(
                        file.SafeFileHandle,
                        Kernel32Types.FILE_INFO_BY_HANDLE_CLASS.FileBasicInfo,
                        ref basicInfo,
                        Marshal.SizeOf(typeof(Kernel32Types.FILE_BASIC_INFO)));

                    if (!success)
                    {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }
                }
            }
#endif
        }
Exemple #10
0
 private static string GetVersionInfoHelper(string path)
 {
     using (var pin = new PinCollection())
     {
         return(StringResult.FromNative(NativeCommon.FabricFileGetVersionInfo(pin.AddBlittable(path))));
     }
 }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeRestartNodeDescriptionUsingNodeName = new NativeTypes.FABRIC_RESTART_NODE_DESCRIPTION_USING_NODE_NAME();

            nativeRestartNodeDescriptionUsingNodeName.NodeName = pinCollection.AddObject(this.NodeName);

            // make it Utility.To...
            nativeRestartNodeDescriptionUsingNodeName.NodeInstance = (ulong)this.NodeInstance;

            nativeRestartNodeDescriptionUsingNodeName.ShouldCreateFabricDump =
                NativeTypes.ToBOOLEAN(this.ShouldCreateFabricDump);

            switch (this.CompletionMode)
            {
            case CompletionMode.DoNotVerify:
                nativeRestartNodeDescriptionUsingNodeName.CompletionMode = NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_DO_NOT_VERIFY;
                break;

            case CompletionMode.Verify:
                nativeRestartNodeDescriptionUsingNodeName.CompletionMode = NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_VERIFY;
                break;

            default:
                nativeRestartNodeDescriptionUsingNodeName.CompletionMode = NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_INVALID;
                break;
            }

            return(pinCollection.AddBlittable(nativeRestartNodeDescriptionUsingNodeName));
        }
Exemple #12
0
        protected override void OnInit()
        {
            PinCollection.AddInput("A", typeof(bool));
            PinCollection.AddInput("B", typeof(bool));

            PinCollection.AddOutput("Result", typeof(bool));
        }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeMovePrimaryDescription2 = new NativeTypes.FABRIC_MOVE_PRIMARY_DESCRIPTION2();

            switch (this.DescriptionKind)
            {
            case MovePrimaryDescriptionKind.UsingNodeName:
                nativeMovePrimaryDescription2.Kind  = NativeTypes.FABRIC_MOVE_PRIMARY_DESCRIPTION_KIND.FABRIC_MOVE_PRIMARY_DESCRIPTION_KIND_USING_NODE_NAME;
                nativeMovePrimaryDescription2.Value =
                    ((MovePrimaryDescriptionUsingNodeName)this.Value).ToNative(pinCollection);
                break;

            case MovePrimaryDescriptionKind.UsingReplicaSelector:
                nativeMovePrimaryDescription2.Kind = NativeTypes.FABRIC_MOVE_PRIMARY_DESCRIPTION_KIND.FABRIC_MOVE_PRIMARY_DESCRIPTION_KIND_USING_REPLICA_SELECTOR;
                // not implemented now
                nativeMovePrimaryDescription2.Value = IntPtr.Zero;
                break;

            default:
                nativeMovePrimaryDescription2.Kind  = NativeTypes.FABRIC_MOVE_PRIMARY_DESCRIPTION_KIND.FABRIC_MOVE_PRIMARY_DESCRIPTION_KIND_INVALID;
                nativeMovePrimaryDescription2.Value = IntPtr.Zero;
                break;
            }

            return(pinCollection.AddBlittable(nativeMovePrimaryDescription2));
        }
Exemple #14
0
        private NativeCommon.IFabricAsyncOperationContext PartitionBackupOperationBeginWrapper(
            Uri serviceName,
            Guid partitionId,
            Guid operationId,
            BackupNowConfiguration configuration,
            TimeSpan timeout,
            NativeCommon.IFabricAsyncOperationCallback callback)
        {
            var timeoutMilliseconds = Utility.ToMilliseconds(timeout, "timeout");
            var partitionInfo       = new BackupPartitionInfo
            {
                PartitionId = partitionId,
                ServiceName = serviceName.ToString(),
            };

            using (var pin = new PinCollection())
            {
                return(this._nativeAgent.BeginPartitionBackupOperation(
                           partitionInfo.ToNative(pin),
                           operationId,
                           configuration.ToNative(pin),
                           timeoutMilliseconds,
                           callback));
            }
        }
        private long ReplicateBeginWrapper(OperationData operationData, NativeCommon.IFabricAsyncOperationCallback callback, out NativeCommon.IFabricAsyncOperationContext context)
        {
            long sequenceNumber = 0;

            using (var pin = new PinCollection())
            {
                var nativeOperationBuffer = new NativeTypes.FABRIC_OPERATION_DATA_BUFFER_EX1[operationData.Count];

                var buffersAddress = pin.AddBlittable(nativeOperationBuffer);

                for (int i = 0; i < operationData.Count; i++)
                {
                    nativeOperationBuffer[i].Offset = (uint)operationData[i].Offset;
                    nativeOperationBuffer[i].Count  = (uint)operationData[i].Count;
                    nativeOperationBuffer[i].Buffer = pin.AddBlittable(operationData[i].Array);
                }

                context = this.replicatorUsingOperationEx1.BeginReplicate2(
                    operationData.Count,
                    buffersAddress,
                    callback,
                    out sequenceNumber);
            }

            return(sequenceNumber);
        }
 /// <summary>
 /// <para>Encrypt text string with an installed X509 certificate.</para>
 /// </summary>
 /// <param name="textToEncrypt">
 /// <para>The text to encrypt.</para>
 /// </param>
 /// <param name="thumbprint">
 /// <para>The thumbprint of encryption certificate.</para>
 /// </param>
 /// <param name="storeName">
 /// <para>The name of certificate store, from which encryption certificate is retrieved.</para>
 /// </param>
 /// <param name="storeLocation">
 /// <para>The certificate store location to retrieve encryption certificate.</para>
 /// </param>
 /// <param name="algorithmOid">
 /// <para>The encryption algorithm object identifier (OID).</para>
 /// </param>
 /// <returns>
 /// <para>The encrypted text as <see cref="System.String" />.</para>
 /// </returns>
 public static string EncryptText(
     string textToEncrypt,
     string thumbprint,
     string storeName,
     StoreLocation storeLocation,
     string algorithmOid)
 {
     using (PinCollection pin = new PinCollection())
     {
         try
         {
             return(NativeTypes.FromNativeString(NativeCommon.FabricEncryptText(
                                                     pin.AddObject(textToEncrypt),
                                                     pin.AddObject(thumbprint),
                                                     pin.AddObject(storeName),
                                                     (NativeTypes.FABRIC_X509_STORE_LOCATION)storeLocation,
                                                     pin.AddObject(algorithmOid))));
         }
         catch (Exception ex)
         {
             COMException comEx = Utility.TryTranslateExceptionToCOM(ex);
             if (comEx != null)
             {
                 throw comEx;
             }
             throw;
         }
     }
 }
        private void UpdateReplicatorSettingsHelper(ReplicatorSettings replicatorSettings)
        {
            // Initialize replicator
            if (replicatorSettings == null)
            {
                AppTrace.TraceSource.WriteNoise("FabricReplicator.UpdateReplicatorSettings", "Using default replicator settings");
            }
            else
            {
                AppTrace.TraceSource.WriteNoise("FabricReplicator.UpdateReplicatorSettings", "Replicator Settings - address {0}, listenAddress {1}, publishAddress {2}, retyrInterval {3}, ackInterval {4}, credentials provided {5}", replicatorSettings.ReplicatorAddress, replicatorSettings.ReplicatorListenAddress, replicatorSettings.ReplicatorPublishAddress, replicatorSettings.RetryInterval, replicatorSettings.BatchAcknowledgementInterval, replicatorSettings.SecurityCredentials != null);
            }

            using (var pin = new PinCollection())
            {
                unsafe
                {
                    if (replicatorSettings == null)
                    {
                        this.nativeStateReplicator.UpdateReplicatorSettings(IntPtr.Zero);
                    }
                    else
                    {
                        IntPtr nativeReplicatorSettings = replicatorSettings.ToNative(pin);
                        this.nativeStateReplicator.UpdateReplicatorSettings(nativeReplicatorSettings);
                    }
                }
            }
        }
Exemple #18
0
 internal unsafe void ToNative(PinCollection pin, out NativeTypes.FABRIC_TOKEN_SERVICE_METADATA serviceMetadata)
 {
     serviceMetadata.Metadata       = pin.AddObject(this.Metadata);
     serviceMetadata.ServiceName    = pin.AddObject(this.ServiceName);
     serviceMetadata.ServiceDnsName = pin.AddObject(this.ServiceDnsName);
     serviceMetadata.Reserved       = IntPtr.Zero;
 }
 /// <summary>
 /// <para>Encrypt text string with an X509 certificate in a file.</para>
 /// </summary>
 /// <param name="textToEncrypt">
 /// <para>The text to encrypt.</para>
 /// </param>
 /// <param name="certFileName">
 /// <para>The encryption certificate file path.</para>
 /// </param>
 /// <param name="algorithmOid">
 /// <para>The encryption algorithm object identifier (OID).</para>
 /// </param>
 /// <returns>
 /// <para>The encrypted text as <see cref="System.String" />.</para>
 /// </returns>
 public static string EncryptTextByCertFile(
     string textToEncrypt,
     string certFileName,
     string algorithmOid)
 {
     using (PinCollection pin = new PinCollection())
     {
         try
         {
             return(NativeTypes.FromNativeString(NativeCommon.FabricEncryptText2(
                                                     pin.AddObject(textToEncrypt),
                                                     pin.AddObject(certFileName),
                                                     pin.AddObject(algorithmOid))));
         }
         catch (Exception ex)
         {
             COMException comEx = Utility.TryTranslateExceptionToCOM(ex);
             if (comEx != null)
             {
                 throw comEx;
             }
             throw;
         }
     }
 }
        internal override IntPtr ToNative(PinCollection pinCollection)
        {
            string reasonToSendBack = null;

            if (ChaosUtility.DisableOptimizationForValidationFailedEvent)
            {
                reasonToSendBack = ChaosUtility.Decompress(this.reason);
                if (reasonToSendBack.Length > ChaosConstants.StringLengthLimit)
                {
                    reasonToSendBack = reasonToSendBack.Substring(0, ChaosConstants.StringLengthLimit);
                }
            }
            else
            {
                reasonToSendBack = this.reason;
            }

            var nativeValidationFailedEvent = new NativeTypes.FABRIC_VALIDATION_FAILED_EVENT
            {
                TimeStampUtc = NativeTypes.ToNativeFILETIME(this.TimeStampUtc),
                Reason       = pinCollection.AddObject(reasonToSendBack)
            };

            return(pinCollection.AddBlittable(nativeValidationFailedEvent));
        }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeDeployedServicePackageHealthQueryDescription = new NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_QUERY_DESCRIPTION();

            nativeDeployedServicePackageHealthQueryDescription.ApplicationName     = pinCollection.AddObject(this.ApplicationName);
            nativeDeployedServicePackageHealthQueryDescription.NodeName            = pinCollection.AddBlittable(this.NodeName);
            nativeDeployedServicePackageHealthQueryDescription.ServiceManifestName = pinCollection.AddBlittable(this.ServiceManifestName);
            if (this.HealthPolicy != null)
            {
                nativeDeployedServicePackageHealthQueryDescription.HealthPolicy = this.HealthPolicy.ToNative(pinCollection);
            }
            if (this.EventsFilter != null)
            {
                nativeDeployedServicePackageHealthQueryDescription.EventsFilter = this.EventsFilter.ToNative(pinCollection);
            }

            if (!string.IsNullOrWhiteSpace(this.ServicePackageActivationId))
            {
                var ex1 = new NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_QUERY_DESCRIPTION_EX1();
                ex1.ServicePackageActivationId = pinCollection.AddBlittable(this.ServicePackageActivationId);

                nativeDeployedServicePackageHealthQueryDescription.Reserved = pinCollection.AddBlittable(ex1);
            }

            return(pinCollection.AddBlittable(nativeDeployedServicePackageHealthQueryDescription));
        }
        internal static IntPtr ToNativeList(PinCollection pinCollection, IList <DeployedServicePackageHealthStateFilter> deployedServicePackageList)
        {
            if (deployedServicePackageList == null || deployedServicePackageList.Count == 0)
            {
                return(IntPtr.Zero);
            }

            var nativeArray = new NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_STATE_FILTER[deployedServicePackageList.Count];

            for (int i = 0; i < deployedServicePackageList.Count; i++)
            {
                nativeArray[i].HealthStateFilter         = (UInt32)deployedServicePackageList[i].HealthStateFilter;
                nativeArray[i].ServiceManifestNameFilter = pinCollection.AddObject(deployedServicePackageList[i].ServiceManifestNameFilter);

                if (deployedServicePackageList[i].ServicePackageActivationIdFilter != null)
                {
                    var ex1 = new NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_STATE_FILTER_EX1();
                    ex1.ServicePackageActivationIdFilter = pinCollection.AddBlittable(deployedServicePackageList[i].ServicePackageActivationIdFilter);
                    nativeArray[i].Reserved = pinCollection.AddBlittable(ex1);
                }
            }

            var nativeList = new NativeTypes.FABRIC_DEPLOYED_SERVICE_PACKAGE_HEALTH_STATE_FILTER_LIST();

            nativeList.Count = (uint)deployedServicePackageList.Count;
            nativeList.Items = pinCollection.AddBlittable(nativeArray);

            return(pinCollection.AddBlittable(nativeList));
        }
Exemple #23
0
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeFilter = new NativeTypes.FABRIC_PARTITION_HEALTH_STATISTICS_FILTER();

            nativeFilter.ExcludeHealthStatistics = NativeTypes.ToBOOLEAN(this.ExcludeHealthStatistics);
            return(pinCollection.AddBlittable(nativeFilter));
        }
Exemple #24
0
 IntPtr NativeTokenValidationService.IFabricTokenClaimResult.get_Result()
 {
     using (PinCollection pin = new PinCollection())
     {
         return(claimsResult.ToNative(pin));
     }
 }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeDescription = new NativeTypes.FABRIC_APPLICATION_UPGRADE_DESCRIPTION();

            nativeDescription.ApplicationName = pinCollection.AddObject(this.ApplicationName);
            nativeDescription.TargetApplicationTypeVersion = pinCollection.AddBlittable(this.TargetApplicationTypeVersion);

            if (this.ApplicationParameters.Count != 0)
            {
                var applicationParameterList = new ApplicationParameterList(this.ApplicationParameters);
                nativeDescription.ApplicationParameters = applicationParameterList.ToNative(pinCollection);
            }
            else
            {
                nativeDescription.ApplicationParameters = IntPtr.Zero;
            }

            var rollingUpgradePolicyDescription = this.UpgradePolicyDescription as RollingUpgradePolicyDescription;

            if (rollingUpgradePolicyDescription != null)
            {
                nativeDescription.UpgradeKind = NativeTypes.FABRIC_APPLICATION_UPGRADE_KIND.FABRIC_APPLICATION_UPGRADE_KIND_ROLLING;
                nativeDescription.UpgradePolicyDescription = rollingUpgradePolicyDescription.ToNative(pinCollection);
            }
            else
            {
                throw new ArgumentException("description.UpgradePolicyDescription");
            }

            return(pinCollection.AddBlittable(nativeDescription));
        }
Exemple #26
0
        public static IntPtr CreateCounterSet(FabricPerformanceCounterSetDefinition counterSetDefinition,
                                              IEnumerable <FabricPerformanceCounterDefinition> counters)

        {
            IntPtr counterSetHandle = IntPtr.Zero;

#if !DotNetCoreClrLinux
            NativeTypes.FABRIC_COUNTER_SET_INITIALIZER nativeCounterSet = new NativeTypes.FABRIC_COUNTER_SET_INITIALIZER();
            using (var pin = new PinCollection())
            {
                nativeCounterSet.CounterSetId           = pin.AddBlittable(counterSetDefinition.Guid.ToString());
                nativeCounterSet.CounterSetName         = pin.AddBlittable(counterSetDefinition.Name);
                nativeCounterSet.CounterSetDescription  = pin.AddBlittable(counterSetDefinition.Description);
                nativeCounterSet.CounterSetInstanceType = (UInt32)counterSetDefinition.CategoryType;
                nativeCounterSet.NumCountersInSet       = (UInt32)counters.Count();

                var nativeCounters = new NativeTypes.FABRIC_COUNTER_INITIALIZER[counters.Count()];
                int index          = 0;
                foreach (FabricPerformanceCounterDefinition ctr in counters)
                {
                    nativeCounters[index].CounterId          = (UInt32)ctr.Id;
                    nativeCounters[index].BaseCounterId      = (UInt32)ctr.BaseId;
                    nativeCounters[index].CounterType        = (UInt32)ctr.CounterType;
                    nativeCounters[index].CounterName        = pin.AddBlittable(ctr.Name);
                    nativeCounters[index].CounterDescription = pin.AddBlittable(ctr.Description);
                    index++;
                }
                nativeCounterSet.Counters = pin.AddBlittable(nativeCounters);
                Utility.WrapNativeSyncInvokeInMTA(() => { NativeCommon.FabricPerfCounterCreateCounterSet(pin.AddBlittable(nativeCounterSet), out counterSetHandle); }, "PerformanceCountersInterop.CreateCounterSet");
            }
#endif
            return(counterSetHandle);
        }
Exemple #27
0
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeStopNodeDescriptionUsingNodeName = new NativeTypes.FABRIC_STOP_NODE_DESCRIPTION_USING_NODE_NAME();

            nativeStopNodeDescriptionUsingNodeName.NodeName = pinCollection.AddObject(this.NodeName);

            // make it Utility.To...
            nativeStopNodeDescriptionUsingNodeName.NodeInstance = (ulong)this.NodeInstance;

            switch (this.CompletionMode)
            {
            case CompletionMode.DoNotVerify:
                nativeStopNodeDescriptionUsingNodeName.CompletionMode = NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_DO_NOT_VERIFY;
                break;

            case CompletionMode.Verify:
                nativeStopNodeDescriptionUsingNodeName.CompletionMode = NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_VERIFY;
                break;

            default:
                nativeStopNodeDescriptionUsingNodeName.CompletionMode = NativeTypes.FABRIC_COMPLETION_MODE.FABRIC_COMPLETION_MODE_INVALID;
                break;
            }

            var raw = pinCollection.AddBlittable(nativeStopNodeDescriptionUsingNodeName);

            var recreated = CreateFromNative(raw);

            return(raw);
        }
Exemple #28
0
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeDescription = new NativeTypes.FABRIC_APPLICATION_TYPE_PAGED_QUERY_DESCRIPTION();

            nativeDescription.ApplicationTypeNameFilter = pinCollection.AddObject(this.ApplicationTypeNameFilter);

            // bools are not blittable (directly readable in native)
            nativeDescription.ExcludeApplicationParameters = NativeTypes.ToBOOLEAN(this.ExcludeApplicationParameters);
            nativeDescription.ContinuationToken            = pinCollection.AddObject(this.ContinuationToken);
            nativeDescription.MaxResults = this.MaxResults;

            var ex1 = new NativeTypes.FABRIC_APPLICATION_TYPE_PAGED_QUERY_DESCRIPTION_EX1();

            ex1.ApplicationTypeVersionFilter = pinCollection.AddObject(this.ApplicationTypeVersionFilter);

            var ex2 = new NativeTypes.FABRIC_APPLICATION_TYPE_PAGED_QUERY_DESCRIPTION_EX2();

            ex2.ApplicationTypeDefinitionKindFilter = (UInt32)this.ApplicationTypeDefinitionKindFilter;
            ex2.Reserved = IntPtr.Zero;

            ex1.Reserved = pinCollection.AddBlittable(ex2);

            nativeDescription.Reserved = pinCollection.AddBlittable(ex1);

            return(pinCollection.AddBlittable(nativeDescription));
        }
Exemple #29
0
 internal void ToNative(PinCollection pinCollection, out NativeTypes.FABRIC_SECURITY_ACE nativeAce)
 {
     nativeAce.AccessMask = (uint)this.AccessMask;
     nativeAce.AceType    = (NativeTypes.FABRIC_SECURITY_ACE_TYPE) this.AceType;
     nativeAce.Principal  = this.Principal.ToNative(pinCollection);
     nativeAce.Reserved   = IntPtr.Zero;
 }
Exemple #30
0
        internal unsafe IntPtr ToNative(PinCollection pin)
        {
            if (this.Count > 0)
            {
                var nativeApplicationTypeHealthPolicyMap = new NativeTypes.FABRIC_APPLICATION_TYPE_HEALTH_POLICY_MAP();

                var nativeArray = new NativeTypes.FABRIC_APPLICATION_TYPE_HEALTH_POLICY_MAP_ITEM[this.Count];

                int ix = 0;
                foreach (var pair in this)
                {
                    nativeArray[ix].ApplicationTypeName             = pin.AddObject(pair.Key);
                    nativeArray[ix].MaxPercentUnhealthyApplications = pair.Value;
                    ++ix;
                }

                nativeApplicationTypeHealthPolicyMap.Count = (uint)nativeArray.Length;
                nativeApplicationTypeHealthPolicyMap.Items = pin.AddBlittable(nativeArray);

                return(pin.AddBlittable(nativeApplicationTypeHealthPolicyMap));
            }
            else
            {
                return(IntPtr.Zero);
            }
        }
Exemple #31
0
        /// <summary>
        /// Inicializa un objeto de tipo ChartElement. Este constructor establece los pines de entrada y salida del elemento
        /// utilizando los valores de las propiedades NumberOfValidInputs y NumberOfValidOutputs.
        /// </summary>
        public ChartElement()
        {
            /// Se crea la coleccion de pines de entrada.
             ValidInputs = new PinCollection(this, NumberOfValidInputs, PinType.Input);
             /// Se crea la coleccion de pines de salida.
             ValidOutputs = new PinCollection(this, NumberOfValidOutputs, PinType.Output);

             ShowInputPins = false;
             ShowOutputPins = false;

             Display = new Rectangle(0, 0, 100, 20);
        }