public FileSystemErrorStatus LoadLeafSubGridSegment(IStorageProxy storageProxy, SubGridCellAddress cellAddress, bool loadLatestData, bool loadAllPasses, IServerLeafSubGrid subGrid, ISubGridCellPassesDataSegment segment) { //Log.LogInformation($"Segment load on {cellAddress}:{Segment.SegmentInfo.StartTime}-{Segment.SegmentInfo.EndTime} beginning, loadLatestData = {loadLatestData}, loadAllPasses = {loadAllPasses}"); var needToLoadLatestData = loadLatestData && !segment.HasLatestData; var needToLoadAllPasses = loadAllPasses && !segment.HasAllPasses; if (!needToLoadLatestData && !needToLoadAllPasses) { //Log.LogInformation($"Segment load on {cellAddress} exiting as neither latest nor all passes required"); return(FileSystemErrorStatus.OK); // Nothing more to do here } // Lock the segment briefly while its contents is being loaded lock (segment) { if (!(needToLoadLatestData ^ segment.HasLatestData) && !(needToLoadAllPasses ^ segment.HasAllPasses)) { //Log.LogInformation($"Segment load on {cellAddress} leaving quietly as a previous thread has performed the load"); return(FileSystemErrorStatus.OK); // The load operation was performed on another thread. Leave quietly } // Ensure the appropriate storage is allocated if (needToLoadLatestData) { segment.AllocateLatestPassGrid(); } if (needToLoadAllPasses) { segment.AllocateFullPassStacks(); } if (!segment.SegmentInfo.ExistsInPersistentStore) { //Log.LogInformation($"Segment load on {cellAddress} exiting as segment does not exist in persistent store"); return(FileSystemErrorStatus.OK); // Nothing more to do here } // Locate the segment file and load the data from it var fullFileName = GetLeafSubGridSegmentFullFileName(cellAddress, segment.SegmentInfo); // Load the cells into it from its file var fsError = subGrid.LoadSegmentFromStorage(storageProxy, fullFileName, segment, needToLoadLatestData, needToLoadAllPasses); if (fsError != FileSystemErrorStatus.OK) { //Log.LogInformation($"Segment load on {cellAddress} failed, performing allocation cleanup activities"); // Something bad happened. Remove the segment from the list. Return failure to the caller. if (loadAllPasses) { segment.DeAllocateFullPassStacks(); } if (loadLatestData) { segment.DeAllocateLatestPassGrid(); } return(fsError); } } //Log.LogInformation($"Segment load on {cellAddress} succeeded, AllPasses?={Segment.HasAllPasses}, Segment.PassesData?Null={Segment.PassesData==null} "); return(FileSystemErrorStatus.OK); }