Beispiel #1
0
 /// <summary>
 /// Releases all resources used by the HpcLinqContext.
 /// </summary>
 public void Dispose()
 {
     _configuration = null;
     if (_runtime != null)
     {
         _runtime.Dispose();
         _runtime = null;
     }
     if (_dscService != null)
     {
         _dscService.Close();
         _dscService = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the HpcLinqConfiguration class.
        /// </summary>
        /// <param name="configuration">Configuration information.</param>
        /// <remarks>
        /// Connections will be opened to DSC and HPC Server using configuration.HeadNode.
        /// The connections will be opened regardless of whether DSC is used and/or whether
        /// configuration.LocalDebug is true
        /// </remarks>
        public HpcLinqContext(HpcLinqConfiguration configuration)
        {
            // Verify that the head node is set
            if (configuration.HeadNode == null)
            {
                throw new DryadLinqException(HpcLinqErrorCode.ClusterNameMustBeSpecified,
                                             SR.ClusterNameMustBeSpecified);
            }

            _configuration   = configuration.MakeImmutableCopy();
            _runtime         = new HpcQueryRuntime(_configuration.HeadNode);
            _dscService      = new DscService(_configuration.HeadNode);
            _hdfsServiceNode = _configuration.HdfsNameNode;
        }
Beispiel #3
0
        public DscIOStream(string streamName, FileAccess access, FileMode createMode, DscCompressionScheme compressionScheme)
        {
            if (String.IsNullOrEmpty(streamName))
            {
                throw new ArgumentNullException("streamName");
            }

            Uri streamUri = new Uri(streamName);
            this.m_dscClient = new DscService(streamUri.Host);
            this.m_fileSetName = streamUri.LocalPath.TrimStart('/');
            this.m_mode = access;
            this.m_compressionScheme = compressionScheme;

            bool streamExists = this.m_dscClient.FileSetExists(this.m_fileSetName);

            if (access == FileAccess.Read)
            {
                switch (createMode)
                {
                    case FileMode.Open:
                    case FileMode.OpenOrCreate:
                        if (!streamExists)
                        {
                            throw new FileNotFoundException(String.Format( SR.StreamDoesNotExist , streamName));
                        }
                        break;

                    case FileMode.Append:
                    case FileMode.Create:
                    case FileMode.CreateNew:
                    case FileMode.Truncate:
                        throw new NotSupportedException();
                }

                this.m_dscFileSet = this.m_dscClient.GetFileSet(streamName);
                this.m_dscFileEnumerator = this.m_dscFileSet.GetFiles().GetEnumerator();
            }
            else if (access == FileAccess.Write)
            {
                switch (createMode)
                {
                    case FileMode.Append:
                        if (!streamExists)
                        {
                            this.m_dscFileSet = this.m_dscClient.CreateFileSet(this.m_fileSetName, this.m_compressionScheme);
                        }
                        break;
                    case FileMode.Create:
                        if (streamExists)
                        {
                            this.m_dscClient.DeleteFileSet(this.m_fileSetName);
                        }
                        this.m_dscFileSet = this.m_dscClient.CreateFileSet(this.m_fileSetName, this.m_compressionScheme);
                        break;
                    case FileMode.CreateNew:
                        if (streamExists)
                        {
                            throw new IOException(String.Format(SR.StreamAlreadyExists, streamName));
                        }
                        break;
                    case FileMode.Truncate:
                        if (streamExists)
                        {
                            this.m_dscClient.DeleteFileSet(this.m_fileSetName);
                        }
                        this.m_dscFileSet = this.m_dscClient.CreateFileSet(this.m_fileSetName, this.m_compressionScheme);
                        break;
                    case FileMode.Open:
                    case FileMode.OpenOrCreate: // TODO: this should be dealt with correctly,
                                                // although it's not obvious what open should do
                        throw new NotSupportedException();
                }
            }
            else
            {
                throw new ArgumentException(SR.ReadWriteNotSupported, "access");
            }

            this.m_fstream = null;
            this.m_atEOF = false;
        }
Beispiel #4
0
        public DscIOStream(string streamName, FileAccess access, DscCompressionScheme compressionScheme)
        {
            if (String.IsNullOrEmpty(streamName))
            {
                throw new ArgumentNullException("streamName");
            }

            Uri streamUri = new Uri(streamName);
            this.m_dscClient = new DscService(streamUri.Host);
            this.m_fileSetName = streamUri.LocalPath;
            this.m_mode = access;
            this.m_fstream = null;
            this.m_atEOF = false;
            this.m_compressionScheme = compressionScheme;

            if (access == FileAccess.Read)
            {
                this.m_dscFileSet = this.m_dscClient.GetFileSet(streamName);
                this.m_dscFileEnumerator = this.m_dscFileSet.GetFiles().GetEnumerator();
            }
            else if (access == FileAccess.Write)
            {
                this.m_dscFileSet = this.m_dscClient.CreateFileSet(streamName, compressionScheme);
            }
            else
            {
                throw new ArgumentException(SR.ReadWriteNotSupported, "access");
            }
        }
Beispiel #5
0
 internal static string MakeDscStreamUri(DscService dsc, string streamName)
 {
     string serviceNodeName = dsc.HostName;
     return MakeDscStreamUri(serviceNodeName, streamName);
 }
Beispiel #6
0
        internal static string MakeDscStreamUri(DscService dsc, string streamName)
        {
            string serviceNodeName = dsc.HostName;

            return(MakeDscStreamUri(serviceNodeName, streamName));
        }