Esempio n. 1
0
        internal static async Task <string> GetFabricUriFromPartitionId(string partitionId, TimeSpan timeout, CancellationToken cancellationToken)
        {
            string serviceNameUri = await FabricClientHelper.GetFabricServiceUriFromPartitionId(partitionId, timeout, cancellationToken);

            string applicationNameUri = await FabricClientHelper.GetFabricApplicationUriFromServiceUri(serviceNameUri, timeout, cancellationToken);

            string applicationName = GetNameFromUri(applicationNameUri);
            string serviceName     = RemoveApplicationNameUriFromServiceNameUri(applicationNameUri, serviceNameUri);

            return(string.Format("{0}/{1}",
                                 CreateUriFromApplicationAndServiceName(applicationName, serviceName), partitionId));
        }
Esempio n. 2
0
        internal static async Task <string> GetFabricUriFromRequstHeaderForPartitions(string fabricRequestHeader, TimeSpan timeout, CancellationToken cancellationToken)
        {
            string fabricUri;

            try
            {
                string[] segments = fabricRequestHeader.Split('/');
                string   type     = segments[0];

                switch (type)
                {
                case "Partitions":
                    if (segments.Length != 2 || string.IsNullOrEmpty(segments[1]))
                    {
                        throw new ArgumentException(StringResources.InvalidArguments);
                    }
                    string serviceNameUri = await FabricClientHelper.GetFabricServiceUriFromPartitionId(segments[1], timeout, cancellationToken);

                    string applicationNameUri = await FabricClientHelper.GetFabricApplicationUriFromServiceUri(serviceNameUri, timeout, cancellationToken);

                    string applicationName = GetNameFromUri(applicationNameUri);
                    string serviceName     = RemoveApplicationNameUriFromServiceNameUri(applicationNameUri, serviceNameUri);
                    fabricUri = string.Format("{0}/{1}",
                                              CreateUriFromApplicationAndServiceName(applicationName, serviceName), segments[1]);
                    break;

                default:
                    throw new ArgumentException(StringResources.InvalidArguments);
                }
            }
            catch (Exception exception)
            {
                LogException(TraceType, exception);
                FabricException fabricException = exception as FabricException;
                if (fabricException != null)
                {
                    throw;
                }

                throw new ArgumentException(StringResources.InvalidArguments);
            }
            return(fabricUri);
        }