예제 #1
0
        public WinFabricPropertyEnumerationResult(int identifier, PropertyEnumerationResult result)
        {
            ThrowIf.Null(result, "result");

            this.Identifier = identifier;
            this.Result     = result;
        }
예제 #2
0
        public PropertyEnumerationResult Convert(WinFabricPropertyEnumerationResult previousResult)
        {
            PropertyEnumerationResult result = null;

            if (previousResult != null)
            {
                result = this.EnumerationHolder.RetrieveObject(previousResult.Identifier).RetrieveEnumeration <PropertyEnumerationResult>();
            }

            return(result);
        }
예제 #3
0
        public WinFabricPropertyEnumerationResult Convert(PropertyEnumerationResult result)
        {
            WinFabricPropertyEnumerationResult actualResult = null;

            if (result != null)
            {
                int id = this.EnumerationHolder.StoreObject(new EnumerationWrapper(result));
                actualResult = new WinFabricPropertyEnumerationResult(id, result);
            }

            return(actualResult);
        }
예제 #4
0
        public static int GetNamingStoreContents(string[] args)
        {
            var hostEndPoint = args[1]; // e.g. "paralleljobs2-bn-cs.cloudapp.net:19000"

            // e.g. "Fabric:/__FabricSystem_App4294967295" or "Fabric:/__FabricSystem_App4294967295/InfrastructureService" (for multi-tenant store)
            var storeName = args[2];

            var pm       = new FabricClient(new FabricClientSettings(), hostEndPoint).PropertyManager;
            var storeUri = new Uri(storeName);
            PropertyEnumerationResult properties = null; // TODO use this in a loop

            properties = pm.EnumeratePropertiesAsync(storeUri, true, properties).GetAwaiter().GetResult();
            foreach (var property in properties)
            {
                Console.WriteLine("{0}, {1}, {2:o}, {3}", property.Metadata.PropertyName, GetValue(property),
                                  property.Metadata.LastModifiedUtc, property.Metadata.TypeId);
            }

            return(0);
        }
        /// <summary>
        /// Enumerates all Service Fabric properties under a given name.
        /// Also takes in timeout interval, which is the maximum of time the system will allow this operation to continue before returning.
        /// </summary>
        public async Task <IDictionary <string, string> > EnumeratePropertiesAsync(Uri parentName, TimeSpan timeout, CancellationToken cancellationToken)
        {
            var namedProperties = new Dictionary <string, string>(StringComparer.Ordinal);
            PropertyEnumerationResult previousResult = null;

            // Set up the counter that record the time lapse.
            var stopWatch = Stopwatch.StartNew();

            do
            {
                cancellationToken.ThrowIfCancellationRequested();
                var remaining = timeout - stopWatch.Elapsed;
                if (remaining.Ticks < 0)
                {
                    // If the passing time is longer than the timeout duration.
                    throw new TimeoutException($"Unable to enumerate all property pages in the allotted time budget of {timeout.TotalSeconds} seconds");
                }

                previousResult = await ExceptionsHelper.TranslateCancellations(
                    () => _propertyManagementClient.EnumeratePropertiesAsync(
                        name: parentName,
                        includeValues: true,
                        previousResult: previousResult,
                        timeout: remaining,
                        cancellationToken: cancellationToken),
                    cancellationToken);

                foreach (var p in previousResult)
                {
                    if (!namedProperties.TryAdd(p.Metadata.PropertyName, p.GetValue <string>()))
                    {
                        // TODO: Add warning message such as "$PropertyName already exist"
                    }
                }
            }while (previousResult.HasMoreData);
            return(namedProperties);
        }
예제 #6
0
        public EnumerationWrapper(PropertyEnumerationResult enumerationResult)
        {
            ThrowIf.Null(enumerationResult, "enumerationResult");

            this.enumerationResult = enumerationResult;
        }
예제 #7
0
        public OperationResult <WinFabricPropertyEnumerationResult> ConvertToWinFabricPropertyEnumerationResult(PropertyEnumerationResult enumerationResult, uint errorCode)
        {
            OperationResult <WinFabricPropertyEnumerationResult> actualResult = new OperationResult <WinFabricPropertyEnumerationResult>(errorCode);

            if (enumerationResult != null)
            {
                WinFabricPropertyEnumerationResult testProperty = this.Convert(enumerationResult);
                actualResult = FabricClientState.CreateOperationResultFromNativeErrorCode <WinFabricPropertyEnumerationResult>(testProperty);
            }

            return(actualResult);
        }