/// <summary> /// Builds the allocation chain following the GAM interval /// </summary> private async Task BuildAllocationChain(AllocationMap allocationMap, int databaseId, PageAddress pageAddress, int fileSize) { var allocationPage = await GetAllocationPage(databaseId, pageAddress); if (allocationPage.Header.PageType == PageType.Iam) { throw new ArgumentException(); } allocationMap.Pages.Add(allocationPage); var interval = AllocationMap.Interval; var pageCount = (int)Math.Ceiling(fileSize / (decimal)interval); if (pageCount > 1) { for (var i = 1; i < pageCount; i++) { var allocationAddress = new PageAddress(pageAddress.FileId, pageAddress.PageId + (i * interval)); allocationMap.Pages.Add(await GetAllocationPage(databaseId, allocationAddress)); } } }
public async Task <AllocationMap> GetAllocation(int databaseId, PageAddress pageAddress, int fileSize) { var allocation = new AllocationMap(); await BuildAllocationChain(allocation, databaseId, pageAddress, fileSize); return(allocation); }
public override void AssignExperiment() { var segment = GetSegment(); if (AllocationMap.ContainsKey(segment)) { var experimentName = AllocationMap[segment]; _assignExperimentObject(experimentName); } }
public override bool RemoveExperiment(string name) { if (!ActiveExperiments.ContainsKey(name)) { return(false); } var keysToRemove = (from segmentAllocation in AllocationMap where segmentAllocation.Value == name select segmentAllocation.Key).ToList(); foreach (var key in keysToRemove) { AllocationMap.Remove(key); AvailableSeqments.Add(key); } return(true); }