internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeStartNodeTransitionDescription = new NativeTypes.FABRIC_START_NODE_TRANSITION_DESCRIPTION();

            nativeStartNodeTransitionDescription.OperationId        = this.OperationId;
            nativeStartNodeTransitionDescription.NodeTransitionType = (NativeTypes.FABRIC_NODE_TRANSITION_TYPE) this.NodeTransitionType;
            nativeStartNodeTransitionDescription.NodeName           = pinCollection.AddBlittable(this.NodeName);
            nativeStartNodeTransitionDescription.NodeInstanceId     = (ulong)this.NodeInstanceId;

            return(pinCollection.AddBlittable(nativeStartNodeTransitionDescription));
        }
예제 #2
0
 private static void ReplaceHelper(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors)
 {
     using (var pin = new PinCollection())
     {
         NativeCommon.FabricFileReplace(
             pin.AddBlittable(destinationFileName),
             pin.AddBlittable(sourceFileName),
             pin.AddBlittable(destinationBackupFileName),
             NativeTypes.ToBOOLEAN(ignoreMetadataErrors));
     }
 }
예제 #3
0
        private string GetVersionedClusterManifestFileHelper(string nodeName, string version)
        {
            using (var pin = new PinCollection())
            {
                var result = this.nativeFabricDeployment.GetVersionedClusterManifestFile(
                    pin.AddBlittable(nodeName),
                    pin.AddBlittable(version));

                return(StringResult.FromNative(result));
            }
        }
예제 #4
0
        internal IntPtr ToNative(PinCollection pin)
        {
            var desc = new NativeTypes.FABRIC_UNPROVISION_APPLICATION_TYPE_DESCRIPTION[1];

            desc[0].ApplicationTypeName    = pin.AddBlittable(this.ApplicationTypeName);
            desc[0].ApplicationTypeVersion = pin.AddBlittable(this.ApplicationTypeVersion);
            desc[0].Async    = NativeTypes.ToBOOLEAN(this.Async);
            desc[0].Reserved = IntPtr.Zero;

            return(pin.AddBlittable(desc));
        }
예제 #5
0
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeExecutorState = new NativeTypes.FABRIC_REPAIR_EXECUTOR_STATE()
            {
                Executor     = pinCollection.AddBlittable(this.Executor),
                ExecutorData = pinCollection.AddBlittable(this.ExecutorData),
            };

            var nativeResultDescription = new NativeTypes.FABRIC_REPAIR_RESULT_DESCRIPTION()
            {
                ResultStatus  = (NativeTypes.FABRIC_REPAIR_TASK_RESULT) this.ResultStatus,
                ResultCode    = this.ResultCode,
                ResultDetails = pinCollection.AddBlittable(this.ResultDetails),
            };

            var ex1 = new NativeTypes.FABRIC_REPAIR_TASK_EX1
            {
                PerformPreparingHealthCheck = NativeTypes.ToBOOLEAN(this.PerformPreparingHealthCheck),
                PerformRestoringHealthCheck = NativeTypes.ToBOOLEAN(this.PerformRestoringHealthCheck),
                PreparingHealthCheckState   = (NativeTypes.FABRIC_REPAIR_TASK_HEALTH_CHECK_STATE) this.PreparingHealthCheckState,
                RestoringHealthCheckState   = (NativeTypes.FABRIC_REPAIR_TASK_HEALTH_CHECK_STATE) this.RestoringHealthCheckState,
            };

            var nativeTask = new NativeTypes.FABRIC_REPAIR_TASK()
            {
                TaskId      = pinCollection.AddBlittable(this.TaskId),
                Version     = this.Version,
                Description = pinCollection.AddBlittable(this.Description),

                State = (NativeTypes.FABRIC_REPAIR_TASK_STATE) this.State,
                Flags = (UInt32)this.Flags,

                Action = pinCollection.AddBlittable(this.Action),

                ExecutorState = pinCollection.AddBlittable(nativeExecutorState),
                Result        = pinCollection.AddBlittable(nativeResultDescription),
                Reserved      = pinCollection.AddBlittable(ex1),
            };

            nativeTask.Scope = this.Scope.ToNative(pinCollection);

            if (this.Target != null)
            {
                nativeTask.Target = this.Target.ToNative(pinCollection);
            }

            if (this.Impact != null)
            {
                nativeTask.Impact = this.Impact.ToNative(pinCollection);
            }

            return(pinCollection.AddBlittable(nativeTask));
        }
예제 #6
0
 private static bool CreateHardLinkHelper(string fileName, string existingFileName)
 {
     using (var pin = new PinCollection())
     {
         BOOLEAN succeeded;
         NativeCommon.FabricFileCreateHardLink(
             pin.AddBlittable(fileName),
             pin.AddBlittable(existingFileName),
             out succeeded);
         return(NativeTypes.FromBOOLEAN(succeeded));
     }
 }
예제 #7
0
 public static void GenerateSelfSignedCertAndSaveAsPFX(string subName, string fileName, string password, string DNS, DateTime expirationDate)
 {
     using (var pin = new PinCollection())
     {
         NativeCommon.GenerateSelfSignedCertAndSaveAsPFX(
             pin.AddBlittable(subName),
             pin.AddBlittable(fileName),
             pin.AddBlittable(password),
             pin.AddBlittable(DNS),
             NativeTypes.ToNativeFILETIME(expirationDate));
     }
 }
예제 #8
0
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeDescription = new NativeTypes.FABRIC_REPAIR_TASK_QUERY_DESCRIPTION()
            {
                Scope          = (this.Scope == null ? IntPtr.Zero : this.Scope.ToNative(pinCollection)),
                TaskIdFilter   = pinCollection.AddBlittable(this.TaskIdFilter),
                StateFilter    = (uint)this.StateFilter,
                ExecutorFilter = pinCollection.AddBlittable(this.ExecutorFilter),
            };

            return(pinCollection.AddBlittable(nativeDescription));
        }
        internal override void ToNative(PinCollection pinCollection, ref NativeTypes.FABRIC_SCALING_TRIGGER scalingTrigger)
        {
            scalingTrigger.ScalingTriggerKind = NativeTypes.FABRIC_SCALING_TRIGGER_KIND.FABRIC_SCALING_TRIGGER_KIND_AVERAGE_PARTITION_LOAD;
            var partitionAverageLoad = new NativeTypes.FABRIC_SCALING_TRIGGER_AVERAGE_PARTITION_LOAD();

            partitionAverageLoad.MetricName             = pinCollection.AddBlittable(MetricName);
            partitionAverageLoad.UpperLoadThreshold     = UpperLoadThreshold;
            partitionAverageLoad.LowerLoadThreshold     = LowerLoadThreshold;
            partitionAverageLoad.ScaleIntervalInSeconds = (uint)ScaleIntervalInSeconds;

            scalingTrigger.ScalingTriggerDescription = pinCollection.AddBlittable(partitionAverageLoad);
        }
예제 #10
0
        private string GetApplicationPackageFileHelper(
            string applicationId,
            string applicationRolloutVersion)
        {
            using (var pin = new PinCollection())
            {
                var result = this.nativeRunLayout.GetApplicationPackageFile(
                    pin.AddBlittable(applicationId),
                    pin.AddBlittable(applicationRolloutVersion));

                return(StringResult.FromNative(result));
            }
        }
        private string GetConfigPackageFolderHelper(
            string serviceManifestName,
            string configPackageName)
        {
            using (var pin = new PinCollection())
            {
                var result = this.nativeBuildLayout.GetConfigPackageFolder(
                    pin.AddBlittable(serviceManifestName),
                    pin.AddBlittable(configPackageName));

                return(StringResult.FromNative(result));
            }
        }
        private string GetDataPackageChecksumFileHelper(
            string serviceManifestName,
            string dataPackageName)
        {
            using (var pin = new PinCollection())
            {
                var result = this.nativeBuildLayout.GetDataPackageChecksumFile(
                    pin.AddBlittable(serviceManifestName),
                    pin.AddBlittable(dataPackageName));

                return(StringResult.FromNative(result));
            }
        }
 private static string EncryptValueHelper(
     string text,
     string certFilePath,
     string algorithmOid)
 {
     using (var pin = new PinCollection())
     {
         return(StringResult.FromNative(NativeCommon.FabricEncryptText2(
                                            pin.AddBlittable(text),
                                            pin.AddBlittable(certFilePath),
                                            pin.AddBlittable(algorithmOid))));
     }
 }
예제 #14
0
        private string GetApplicationManifestFileHelper(
            string applicationTypeName,
            string applicationTypeVersion)
        {
            using (var pin = new PinCollection())
            {
                var result = this.nativeStoreLayout.GetApplicationManifestFile(
                    pin.AddBlittable(applicationTypeName),
                    pin.AddBlittable(applicationTypeVersion));

                return(StringResult.FromNative(result));
            }
        }
예제 #15
0
        internal override IntPtr ToNative(PinCollection pin, out NativeTypes.FABRIC_NODE_TRANSITION_TYPE nodeTransitionType)
        {
            var nativeDescription = new NativeTypes.FABRIC_NODE_START_DESCRIPTION();

            nativeDescription.OperationId    = this.OperationId;
            nativeDescription.NodeName       = pin.AddBlittable(this.NodeName);
            nativeDescription.NodeInstanceId = (ulong)this.NodeInstanceId;

            nativeDescription.Reserved = IntPtr.Zero;

            nodeTransitionType = NativeTypes.FABRIC_NODE_TRANSITION_TYPE.FABRIC_NODE_TRANSITION_TYPE_START;
            return(pin.AddBlittable(nativeDescription));
        }
예제 #16
0
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeContextMap = new NativeTypes.FABRIC_EVENT_CONTEXT_MAP();

            if (this.Context != null && this.Context.Any())
            {
                int count = this.Context.ContainsKey(ChaosConstants.KeyForDummyContextEntry) ? this.Context.Count - 1 : this.Context.Count;
                var nativeContextArray = new NativeTypes.FABRIC_EVENT_CONTEXT_MAP_ITEM[count];

                for (int i = 0, j = 0; i < this.Context.Count; ++i)
                {
                    if (!this.Context.ElementAt(i).Key.Equals(ChaosConstants.KeyForDummyContextEntry, StringComparison.OrdinalIgnoreCase))
                    {
                        nativeContextArray[j].Key   = pinCollection.AddObject(this.Context.ElementAt(i).Key);
                        nativeContextArray[j].Value = pinCollection.AddObject(this.Context.ElementAt(i).Value);

                        ++j;
                    }
                }

                nativeContextMap.Count = (uint)nativeContextArray.Length;
                nativeContextMap.Items = pinCollection.AddBlittable(nativeContextArray);
            }

            var ex1 = new NativeTypes.FABRIC_CHAOS_PARAMETERS_EX1
            {
                ClusterHealthPolicy = this.ClusterHealthPolicy.ToNative(pinCollection)
            };

            var ex2 = new NativeTypes.FABRIC_CHAOS_PARAMETERS_EX2
            {
                ChaosTargetFilter = this.ChaosTargetFilter == null ? IntPtr.Zero : this.ChaosTargetFilter.ToNative(pinCollection)
            };

            ex1.Reserved = pinCollection.AddBlittable(ex2);

            var nativeChaosParameters = new NativeTypes.FABRIC_CHAOS_PARAMETERS
            {
                MaxClusterStabilizationTimeoutInSeconds = Convert.ToUInt32(this.MaxClusterStabilizationTimeout.TotalSeconds),
                MaxConcurrentFaults                = Convert.ToUInt32(this.MaxConcurrentFaults),
                EnableMoveReplicaFaults            = NativeTypes.ToBOOLEAN(this.EnableMoveReplicaFaults),
                WaitTimeBetweenIterationsInSeconds = Convert.ToUInt32(this.WaitTimeBetweenIterations.TotalSeconds),
                WaitTimeBetweenFaultsInSeconds     = Convert.ToUInt32(this.WaitTimeBetweenFaults.TotalSeconds),
                TimeToRunInSeconds = Convert.ToUInt32(this.TimeToRun.TotalSeconds),
                Context            = nativeContextMap.Count > 0 ? pinCollection.AddBlittable(nativeContextMap) : IntPtr.Zero,
                Reserved           = pinCollection.AddBlittable(ex1)
            };

            return(pinCollection.AddBlittable(nativeChaosParameters));
        }
예제 #17
0
 private static void SetLogRootHelper(string logRoot, string machineName)
 {
     using (var pin = new PinCollection())
     {
         if (string.IsNullOrEmpty(machineName))
         {
             NativeCommon.FabricSetLogRoot(pin.AddBlittable(logRoot));
         }
         else
         {
             NativeCommon.FabricSetLogRoot2(pin.AddBlittable(logRoot), pin.AddBlittable(machineName));
         }
     }
 }
예제 #18
0
 private static void SetFabricCodePathHelper(string codePath, string machineName)
 {
     using (var pin = new PinCollection())
     {
         if (string.IsNullOrEmpty(machineName))
         {
             NativeCommon.FabricSetCodePath(pin.AddBlittable(codePath));
         }
         else
         {
             NativeCommon.FabricSetCodePath2(pin.AddBlittable(codePath), pin.AddBlittable(machineName));
         }
     }
 }
예제 #19
0
        internal IntPtr ToNative(PinCollection pin)
        {
            var nativeSettings = new NativeTypes.FABRIC_KEY_VALUE_STORE_RESTORE_SETTINGS[1];

            nativeSettings[0].InlineReopen = NativeTypes.ToBOOLEAN(this.inlineReopen);

            var ex1Settings = new NativeTypes.FABRIC_KEY_VALUE_STORE_RESTORE_SETTINGS_EX1[1];

            ex1Settings[0].EnableLsnCheck = NativeTypes.ToBOOLEAN(this.enableLsnCheck);

            nativeSettings[0].Reserved = pin.AddBlittable(ex1Settings);

            return(pin.AddBlittable(nativeSettings));
        }
예제 #20
0
        internal override unsafe IntPtr ToNative(PinCollection pin, out NativeTypes.FABRIC_PROPERTY_BATCH_OPERATION_KIND nativeOperationType)
        {
            Requires.Argument <object>("PropertyValue", this.PropertyValue).NotNull();

            var nativePutCustomOperation = new NativeTypes.FABRIC_PUT_CUSTOM_PROPERTY_OPERATION[1];

            nativePutCustomOperation[0].PropertyName = pin.AddBlittable(this.PropertyName);

            switch (this.PropertyType)
            {
            case PropertyTypeId.Binary:
                nativePutCustomOperation[0].PropertyTypeId = NativeTypes.FABRIC_PROPERTY_TYPE_ID.FABRIC_PROPERTY_TYPE_BINARY;

                // Create FABRIC_OPERATION_DATA_BUFFER from the byte[]
                var valueAsArray          = this.PropertyValue as byte[];
                var nativeOperationBuffer = new NativeTypes.FABRIC_OPERATION_DATA_BUFFER[1];
                nativeOperationBuffer[0].BufferSize = (uint)valueAsArray.Length;
                nativeOperationBuffer[0].Buffer     = pin.AddBlittable(valueAsArray);

                nativePutCustomOperation[0].PropertyValue = pin.AddBlittable(nativeOperationBuffer);
                break;

            case PropertyTypeId.Double:
                nativePutCustomOperation[0].PropertyTypeId = NativeTypes.FABRIC_PROPERTY_TYPE_ID.FABRIC_PROPERTY_TYPE_DOUBLE;
                var valueAsDouble = new double[1];
                valueAsDouble[0] = (double)this.PropertyValue;
                nativePutCustomOperation[0].PropertyValue = pin.AddBlittable(valueAsDouble);
                break;

            case PropertyTypeId.Guid:
                nativePutCustomOperation[0].PropertyTypeId = NativeTypes.FABRIC_PROPERTY_TYPE_ID.FABRIC_PROPERTY_TYPE_GUID;
                nativePutCustomOperation[0].PropertyValue  = pin.AddBlittable((Guid)this.PropertyValue);
                break;

            case PropertyTypeId.Int64:
                nativePutCustomOperation[0].PropertyTypeId = NativeTypes.FABRIC_PROPERTY_TYPE_ID.FABRIC_PROPERTY_TYPE_INT64;
                var valueAsLong = new long[1];
                valueAsLong[0] = (long)this.PropertyValue;
                nativePutCustomOperation[0].PropertyValue = pin.AddBlittable(valueAsLong);
                break;

            case PropertyTypeId.String:
                nativePutCustomOperation[0].PropertyTypeId = NativeTypes.FABRIC_PROPERTY_TYPE_ID.FABRIC_PROPERTY_TYPE_WSTRING;
                nativePutCustomOperation[0].PropertyValue  = pin.AddBlittable((string)this.PropertyValue);
                break;

            default:
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.Error_TypeNotSupported_Formatted, this.PropertyType));
            }

            nativePutCustomOperation[0].PropertyCustomTypeId = pin.AddBlittable(this.CustomTypeId);

            nativeOperationType = NativeTypes.FABRIC_PROPERTY_BATCH_OPERATION_KIND.FABRIC_PROPERTY_BATCH_OPERATION_KIND_PUT_CUSTOM;
            return(pin.AddBlittable(nativePutCustomOperation));
        }
예제 #21
0
        internal override IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeBackupPolicy = GetNativeBackupPolicy(pinCollection);
            var nativeSchedulePolicyDescription = new NativeBackupRestoreTypes.FABRIC_SCHEDULE_BASED_BACKUP_POLICY
            {
                RunScheduleType = (NativeBackupRestoreTypes.FABRIC_BACKUP_POLICY_RUN_SCHEDULE_MODE)RunSchedule,
                RunTimesList    = ToNativeRunTimes(pinCollection, RunTimes),
                RunDays         = ToRunDaysByte(RunDays),
            };

            nativeBackupPolicy.PolicyDescription = pinCollection.AddBlittable(nativeSchedulePolicyDescription);

            return(pinCollection.AddBlittable(nativeBackupPolicy));
        }
 private string ReadStringHelper(string sectionName, string keyName, out bool isEncrypted)
 {
     using (var pin = new PinCollection())
     {
         BOOLEAN isEncryptedValue;
         string  value = StringResult.FromNative(
             this.nativeConfigStore.ReadString(
                 pin.AddBlittable(sectionName),
                 pin.AddBlittable(keyName),
                 out isEncryptedValue));
         isEncrypted = NativeTypes.FromBOOLEAN(isEncryptedValue);
         return(value);
     }
 }
        internal override IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeStoreInformation = GetNativeBackupStoreInformation(pinCollection);

            var nativeAzureStorageBackupStore = new NativeBackupRestoreTypes.FABRIC_BACKUP_STORE_DSMS_AZURE_STORAGE_INFORMATION()
            {
                StorageCredentialsSourceLocation = pinCollection.AddObject(this.StorageCredentialsSourceLocation),
                ContainerName = pinCollection.AddObject(this.ContainerName),
                FolderPath    = pinCollection.AddObject(this.FolderPath),
            };

            nativeStoreInformation.StoreAccessInformation = pinCollection.AddBlittable(nativeAzureStorageBackupStore);
            return(pinCollection.AddBlittable(nativeStoreInformation));
        }
        internal override IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeBackupPolicy = GetNativeBackupPolicy(pinCollection);

            var nativeFrquencyPolicyDescription = new NativeBackupRestoreTypes.FABRIC_FREQUENCY_BASED_BACKUP_POLICY
            {
                RunFrequencyType = (NativeBackupRestoreTypes.FABRIC_BACKUP_POLICY_RUN_FREQUENCY_MODE)RunFrequencyType,
                Value            = RunFrequency,
            };

            nativeBackupPolicy.PolicyDescription = pinCollection.AddBlittable(nativeFrquencyPolicyDescription);


            return(pinCollection.AddBlittable(nativeBackupPolicy));
        }
예제 #25
0
        internal override IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeStoreInformation = GetNativeBackupStoreInformation(pinCollection);

            var nativeAzureStorageBackupStore = new NativeBackupRestoreTypes.FABRIC_BACKUP_STORE_AZURE_STORAGE_INFORMATION()
            {
                ConnectionString            = pinCollection.AddObject(this.ConnectionString),
                ContainerName               = pinCollection.AddObject(this.ContainerName),
                FolderPath                  = pinCollection.AddObject(this.FolderPath),
                IsConnectionStringEncrypted = NativeTypes.ToBOOLEAN(this.IsAccountKeyEncrypted),
            };

            nativeStoreInformation.StoreAccessInformation = pinCollection.AddBlittable(nativeAzureStorageBackupStore);
            return(pinCollection.AddBlittable(nativeStoreInformation));
        }
예제 #26
0
        private static SecurityCredentials LoadFromPrivate(CodePackageActivationContext codePackageActivationContext, string configPackageName, string sectionName)
        {
            using (var pin = new PinCollection())
            {
                var nativeSectionName       = pin.AddBlittable(sectionName);
                var nativeConfigPackageName = pin.AddBlittable(configPackageName);
                NativeRuntime.IFabricSecurityCredentialsResult securityCredentialsResult =
                    NativeRuntime.FabricLoadSecurityCredentials(
                        codePackageActivationContext.NativeActivationContext,
                        nativeConfigPackageName,
                        nativeSectionName);

                return(SecurityCredentials.CreateFromNative(securityCredentialsResult));
            }
        }
예제 #27
0
        private static LocalEseStoreSettings InternalLoadFrom(
            CodePackageActivationContext codePackageActivationContext,
            string configPackageName,
            string sectionName)
        {
            using (var pin = new PinCollection())
            {
                NativeRuntime.IFabricEseLocalStoreSettingsResult nativeResult = NativeRuntime.FabricLoadEseLocalStoreSettings(
                    codePackageActivationContext.NativeActivationContext,
                    pin.AddBlittable(configPackageName),
                    pin.AddBlittable(sectionName));

                return(LocalEseStoreSettings.CreateFromNative(nativeResult));
            }
        }
        internal IntPtr ToNative(PinCollection pin)
        {
            var nativeResponseBody = NativeTypes.ToNativeBytes(pin, this.ResponseBody);

            var nativeExecutionResponse = new NativeTypes.FABRIC_CONTAINER_API_EXECUTION_RESPONSE
            {
                StatusCode = this.StatusCode,
                ContentType = pin.AddBlittable(this.ContentType),
                ContentEncoding = pin.AddBlittable(this.ContentEncoding),
                ResponseBodyBufferSize = nativeResponseBody.Item1,
                ResponseBody = nativeResponseBody.Item2
            };

            return pin.AddBlittable(nativeExecutionResponse);
        }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            var nativeGetChaosReportDescription = new NativeTypes.FABRIC_GET_CHAOS_REPORT_DESCRIPTION();

            nativeGetChaosReportDescription.Filter            = this.Filter.ToNative(pinCollection);
            nativeGetChaosReportDescription.ContinuationToken = pinCollection.AddObject(this.ContinuationToken);
            var clientType = new NativeTypes.FABRIC_CHAOS_CLIENT_TYPE
            {
                ClientType = pinCollection.AddObject(ChaosConstants.ManagedClientTypeName)
            };

            nativeGetChaosReportDescription.Reserved = pinCollection.AddBlittable(clientType);

            return(pinCollection.AddBlittable(nativeGetChaosReportDescription));
        }
        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));
        }