internal object GetPartition(IPartitionResolver partitionResolver, string id) {
            if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure))
                EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_START, HttpContext.Current.WorkerRequest, partitionResolver.GetType().FullName, id);
            
            string partitionString = null;
            string errorMessage = null;
            IPartitionInfo partitionInfo = null;
            try {
                try {
                    partitionString = partitionResolver.ResolvePartition(id);

                    if (partitionString == null) {
                        throw new HttpException(
                                SR.GetString(SR.Bad_partition_resolver_connection_string, partitionResolver.GetType().FullName));
                    }
                }
                catch (Exception e) {
                    errorMessage = e.Message;
                    throw;
                }

                try {
                    _lock.AcquireReaderLock(-1);
                    partitionInfo = (IPartitionInfo)_partitions[partitionString];
                    if (partitionInfo != null) {
                        Debug.Trace("PartitionManager", "id=" + id + "; partitionString=" + partitionString);
                        return partitionInfo;
                    }

                }
                finally {
                    if (_lock.IsReaderLockHeld) {
                        _lock.ReleaseReaderLock();
                    }
                }

                // Not found.  Has to add it.
                try {
                    _lock.AcquireWriterLock(-1);
                    // One more time
                    partitionInfo = (IPartitionInfo)_partitions[partitionString];
                    if (partitionInfo == null) {
                        partitionInfo = _createCallback(partitionString);

                        Debug.Trace("PartitionManager", "Add a new partition; id=" + id + "; partitionString=" + partitionString);
                        _partitions.Add(partitionString, partitionInfo);
                    }

                    Debug.Trace("PartitionManager", "id=" + id + "; partitionString=" + partitionString);
                    return partitionInfo;
                }
                finally {
                    if (_lock.IsWriterLockHeld) {
                        _lock.ReleaseWriterLock();
                    }
                }
            }
            finally {
                if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure)) {
                    string msg = errorMessage;
                    if (msg == null) {
                        if (partitionInfo != null) {
                            msg = partitionInfo.GetTracingPartitionString();
                        }
                        else {
                            msg = String.Empty;
                        }
                    }
                    EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_END, HttpContext.Current.WorkerRequest, msg);
                }
            }
        }
Beispiel #2
0
        internal object GetPartition(IPartitionResolver partitionResolver, string id)
        {
            if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure))
            {
                EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_START, HttpContext.Current.WorkerRequest, partitionResolver.GetType().FullName, id);
            }

            string         partitionString = null;
            string         errorMessage    = null;
            IPartitionInfo partitionInfo   = null;

            try {
                try {
                    partitionString = partitionResolver.ResolvePartition(id);

                    if (partitionString == null)
                    {
                        throw new HttpException(
                                  SR.GetString(SR.Bad_partition_resolver_connection_string, partitionResolver.GetType().FullName));
                    }
                }
                catch (Exception e) {
                    errorMessage = e.Message;
                    throw;
                }

                try {
                    _lock.AcquireReaderLock(-1);
                    partitionInfo = (IPartitionInfo)_partitions[partitionString];
                    if (partitionInfo != null)
                    {
                        Debug.Trace("PartitionManager", "id=" + id + "; partitionString=" + partitionString);
                        return(partitionInfo);
                    }
                }
                finally {
                    if (_lock.IsReaderLockHeld)
                    {
                        _lock.ReleaseReaderLock();
                    }
                }

                // Not found.  Has to add it.
                try {
                    _lock.AcquireWriterLock(-1);
                    // One more time
                    partitionInfo = (IPartitionInfo)_partitions[partitionString];
                    if (partitionInfo == null)
                    {
                        partitionInfo = _createCallback(partitionString);

                        Debug.Trace("PartitionManager", "Add a new partition; id=" + id + "; partitionString=" + partitionString);
                        _partitions.Add(partitionString, partitionInfo);
                    }

                    Debug.Trace("PartitionManager", "id=" + id + "; partitionString=" + partitionString);
                    return(partitionInfo);
                }
                finally {
                    if (_lock.IsWriterLockHeld)
                    {
                        _lock.ReleaseWriterLock();
                    }
                }
            }
            finally {
                if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure))
                {
                    string msg = errorMessage;
                    if (msg == null)
                    {
                        if (partitionInfo != null)
                        {
                            msg = partitionInfo.GetTracingPartitionString();
                        }
                        else
                        {
                            msg = String.Empty;
                        }
                    }
                    EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_END, HttpContext.Current.WorkerRequest, msg);
                }
            }
        }
 internal object GetPartition(IPartitionResolver partitionResolver, string id)
 {
     object obj2;
     if (EtwTrace.IsTraceEnabled(5, 1))
     {
         EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_START, HttpContext.Current.WorkerRequest, partitionResolver.GetType().FullName, id);
     }
     string connectionString = null;
     string message = null;
     IPartitionInfo info = null;
     try
     {
         try
         {
             connectionString = partitionResolver.ResolvePartition(id);
             if (connectionString == null)
             {
                 throw new HttpException(System.Web.SR.GetString("Bad_partition_resolver_connection_string", new object[] { partitionResolver.GetType().FullName }));
             }
         }
         catch (Exception exception)
         {
             message = exception.Message;
             throw;
         }
         try
         {
             this._lock.AcquireReaderLock(-1);
             info = (IPartitionInfo) this._partitions[connectionString];
             if (info != null)
             {
                 return info;
             }
         }
         finally
         {
             if (this._lock.IsReaderLockHeld)
             {
                 this._lock.ReleaseReaderLock();
             }
         }
         try
         {
             this._lock.AcquireWriterLock(-1);
             info = (IPartitionInfo) this._partitions[connectionString];
             if (info == null)
             {
                 info = this._createCallback(connectionString);
                 this._partitions.Add(connectionString, info);
             }
             return info;
         }
         finally
         {
             if (this._lock.IsWriterLockHeld)
             {
                 this._lock.ReleaseWriterLock();
             }
         }
     }
     finally
     {
         if (EtwTrace.IsTraceEnabled(5, 1))
         {
             string tracingPartitionString = message;
             if (tracingPartitionString == null)
             {
                 if (info != null)
                 {
                     tracingPartitionString = info.GetTracingPartitionString();
                 }
                 else
                 {
                     tracingPartitionString = string.Empty;
                 }
             }
             EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_END, HttpContext.Current.WorkerRequest, tracingPartitionString);
         }
     }
     return obj2;
 }
Beispiel #4
0
        internal object GetPartition(IPartitionResolver partitionResolver, string id)
        {
            object obj2;

            if (EtwTrace.IsTraceEnabled(5, 1))
            {
                EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_START, HttpContext.Current.WorkerRequest, partitionResolver.GetType().FullName, id);
            }
            string         connectionString = null;
            string         message          = null;
            IPartitionInfo info             = null;

            try
            {
                try
                {
                    connectionString = partitionResolver.ResolvePartition(id);
                    if (connectionString == null)
                    {
                        throw new HttpException(System.Web.SR.GetString("Bad_partition_resolver_connection_string", new object[] { partitionResolver.GetType().FullName }));
                    }
                }
                catch (Exception exception)
                {
                    message = exception.Message;
                    throw;
                }
                try
                {
                    this._lock.AcquireReaderLock(-1);
                    info = (IPartitionInfo)this._partitions[connectionString];
                    if (info != null)
                    {
                        return(info);
                    }
                }
                finally
                {
                    if (this._lock.IsReaderLockHeld)
                    {
                        this._lock.ReleaseReaderLock();
                    }
                }
                try
                {
                    this._lock.AcquireWriterLock(-1);
                    info = (IPartitionInfo)this._partitions[connectionString];
                    if (info == null)
                    {
                        info = this._createCallback(connectionString);
                        this._partitions.Add(connectionString, info);
                    }
                    return(info);
                }
                finally
                {
                    if (this._lock.IsWriterLockHeld)
                    {
                        this._lock.ReleaseWriterLock();
                    }
                }
            }
            finally
            {
                if (EtwTrace.IsTraceEnabled(5, 1))
                {
                    string tracingPartitionString = message;
                    if (tracingPartitionString == null)
                    {
                        if (info != null)
                        {
                            tracingPartitionString = info.GetTracingPartitionString();
                        }
                        else
                        {
                            tracingPartitionString = string.Empty;
                        }
                    }
                    EtwTrace.Trace(EtwTraceType.ETW_TYPE_SESSIONSTATE_PARTITION_END, HttpContext.Current.WorkerRequest, tracingPartitionString);
                }
            }
            return(obj2);
        }