private void DoAssertions(ReservationAllocation rAllocation, ReservationId reservationID
                           , ReservationDefinition rDef, IDictionary <ReservationInterval, ReservationRequest
                                                                      > allocations, int start, int[] alloc)
 {
     NUnit.Framework.Assert.AreEqual(reservationID, rAllocation.GetReservationId());
     NUnit.Framework.Assert.AreEqual(rDef, rAllocation.GetReservationDefinition());
     NUnit.Framework.Assert.AreEqual(allocations, rAllocation.GetAllocationRequests());
     NUnit.Framework.Assert.AreEqual(user, rAllocation.GetUser());
     NUnit.Framework.Assert.AreEqual(planName, rAllocation.GetPlanName());
     NUnit.Framework.Assert.AreEqual(start, rAllocation.GetStartTime());
     NUnit.Framework.Assert.AreEqual(start + alloc.Length + 1, rAllocation.GetEndTime(
                                         ));
 }
Exemplo n.º 2
0
        private void IncrementAllocation(ReservationAllocation reservation)
        {
            System.Diagnostics.Debug.Assert((readWriteLock.IsWriteLockedByCurrentThread()));
            IDictionary <ReservationInterval, ReservationRequest> allocationRequests = reservation
                                                                                       .GetAllocationRequests();
            // check if we have encountered the user earlier and if not add an entry
            string user = reservation.GetUser();
            RLESparseResourceAllocation resAlloc = userResourceAlloc[user];

            if (resAlloc == null)
            {
                resAlloc = new RLESparseResourceAllocation(resCalc, minAlloc);
                userResourceAlloc[user] = resAlloc;
            }
            foreach (KeyValuePair <ReservationInterval, ReservationRequest> r in allocationRequests)
            {
                resAlloc.AddInterval(r.Key, r.Value);
                rleSparseVector.AddInterval(r.Key, r.Value);
            }
        }
Exemplo n.º 3
0
        private void DecrementAllocation(ReservationAllocation reservation)
        {
            System.Diagnostics.Debug.Assert((readWriteLock.IsWriteLockedByCurrentThread()));
            IDictionary <ReservationInterval, ReservationRequest> allocationRequests = reservation
                                                                                       .GetAllocationRequests();
            string user = reservation.GetUser();
            RLESparseResourceAllocation resAlloc = userResourceAlloc[user];

            foreach (KeyValuePair <ReservationInterval, ReservationRequest> r in allocationRequests)
            {
                resAlloc.RemoveInterval(r.Key, r.Value);
                rleSparseVector.RemoveInterval(r.Key, r.Value);
            }
            if (resAlloc.IsEmpty())
            {
                Sharpen.Collections.Remove(userResourceAlloc, user);
            }
        }