Пример #1
0
        private NativeBlockStream GetStream(int idx, FileAccess access)
        {
            DryadLinqFileBlockStream fileStream = null;

            string[] pathAlternatives = this.m_srcList[idx];

            for (int i = 0; i < pathAlternatives.Length; i++)
            {
                bool   bLastIter  = (i == pathAlternatives.Length - 1);
                string curSrcPath = pathAlternatives[i];
                try
                {
                    fileStream = new DryadLinqFileBlockStream(curSrcPath, access, this.m_compressionScheme);
                }
                catch (Exception e)
                {
                    // if we have more path alternatives to try we will continue,
                    // otherwise we'll propagate the exception from this last attempt
                    if (bLastIter)
                    {
                        // if we caught the DryadLinqException thrown by DryadLinqFileStream.Initialize,
                        // we want to propagate its inner exception (which contains the actual IO error)
                        // otherwise we'll attach the exception we caught as is
                        Exception innerException = (e is DryadLinqException) ? e.InnerException : e;
                        throw new DryadLinqException(DryadLinqErrorCode.MultiBlockCannotAccesFilePath,
                                                     String.Format(SR.MultiBlockCannotAccesFilePath,
                                                                   curSrcPath, m_associatedDscStreamName),
                                                     innerException);
                    }
                }

                // if the attempt to initialize an DryadLinqFileStream with this path succeeded we'll return the object
                if (fileStream != null)
                {
                    break;
                }
            }

            return(fileStream);
        }
Пример #2
0
        private NativeBlockStream GetStream(int idx, FileAccess access)
        {
            DryadLinqFileBlockStream fileStream = null;
            string[] pathAlternatives = this.m_srcList[idx];

            for (int i = 0; i < pathAlternatives.Length; i++)
            {
                bool bLastIter = (i == pathAlternatives.Length - 1);
                string curSrcPath = pathAlternatives[i];
                try
                {
                    fileStream = new DryadLinqFileBlockStream(curSrcPath, access, this.m_compressionScheme);
                }
                catch(Exception e)
                {
                    // if we have more path alternatives to try we will continue,
                    // otherwise we'll propagate the exception from this last attempt
                    if (bLastIter)
                    {
                        // if we caught the DryadLinqException thrown by DryadLinqFileStream.Initialize,
                        // we want to propagate its inner exception (which contains the actual IO error)
                        // otherwise we'll attach the exception we caught as is
                        Exception innerException = (e is DryadLinqException) ? e.InnerException : e;
                        throw new DryadLinqException(DryadLinqErrorCode.MultiBlockCannotAccesFilePath,
                                                   String.Format(SR.MultiBlockCannotAccesFilePath,
                                                                 curSrcPath, m_associatedDscStreamName),
                                                   innerException);
                    }
                }

                // if the attempt to initialize an DryadLinqFileStream with this path succeeded we'll return the object
                if (fileStream != null) break;
            }
            
            return fileStream;
        }