Esempio n. 1
0
 /// <summary>
 /// A stream to the local cache, or null if the file is not cached.
 /// </summary>
 /// <returns>A stream to access the file.</returns>
 public virtual ISharedStreamReader GetStream()
 {
     if (this.LocalCachePath != null && File.Exists(this.LocalCachePath))
     {
         CachedClusterResidentObject.Record(this);
         return(new FileSharedStreamReader(this.LocalCachePath));
     }
     return(null);
 }
Esempio n. 2
0
 /// <summary>
 /// Create a wrapper around a folder in the cache.
 /// </summary>
 ///
 /// <param name="folder">Folder to represent.</param>
 public FolderInCachedCluster(CachedClusterResidentObject folder)
     : base(folder.Config, folder.Job)
 {
     if (!folder.RepresentsAFolder)
     {
         throw new ArgumentException(folder + " is not a folder");
     }
     this.OriginalFolder = folder;
     // ReSharper disable once DoNotCallOverridableMethodsInConstructor
     this.RepresentsAFolder = true;
 }
Esempio n. 3
0
        /// <summary>
        /// Record the creation of this particular cluster resident object so it can be retrieved from the job summary.
        /// </summary>
        /// <param name="file">Object to record.</param>
        private static void Record(CachedClusterResidentObject file)
        {
            if (file.Job == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(file.LocalCachePath))
            {
                throw new ClusterException("Missing expected LocalCachePath");
            }

            CachedClusterResidentObject.RecordCachedFile(file.Job, file.LocalCachePath);
        }
Esempio n. 4
0
 /// <summary>
 /// This is closed when the cached file has been completely read.
 /// </summary>
 protected void OnClose()
 {
     // save the file to its proper place
     if (this.cacheWriter != null)
     {
         // this.cacheWriter.Close(); -- the callee should have done this already
         try
         {
             Utilities.EnsureDirectoryExistsForFile(this.LocalCachePath);
             Utilities.Move(this.tempFileName, this.LocalCachePath);
             Trace.TraceInformation("Writing to cache {0}", this.LocalCachePath);
             CachedClusterResidentObject.Record(this);
         }
         catch (Exception e)
         {
             Trace.TraceInformation("Exception {0} during move", e.Message);
         }
         this.tempFileName = null;
         this.cacheWriter  = null;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Create a wrapper around a folder in the cache.
 /// </summary>
 /// 
 /// <param name="folder">Folder to represent.</param>
 public FolderInCachedCluster(CachedClusterResidentObject folder)
     : base(folder.Config, folder.Job)
 {
     if (!folder.RepresentsAFolder)
         throw new ArgumentException(folder + " is not a folder");
     this.OriginalFolder = folder;
     // ReSharper disable once DoNotCallOverridableMethodsInConstructor
     this.RepresentsAFolder = true;
 }
Esempio n. 6
0
        /// <summary>
        /// Record the creation of this particular cluster resident object so it can be retrieved from the job summary.
        /// </summary>
        /// <param name="file">Object to record.</param>
        private static void Record(CachedClusterResidentObject file)
        {
            if (file.Job == null)
                return;
            if (string.IsNullOrEmpty(file.LocalCachePath))
                throw new ClusterException("Missing expected LocalCachePath");

            CachedClusterResidentObject.RecordCachedFile(file.Job, file.LocalCachePath);
        }