public String toCumulativeString() { readLock.lock(); try { return rleSparseVector.toString(); } finally { readLock.unlock(); } }
public String toCumulativeString() { readLock.lock(); try { return rleSparseVector.toString(); } finally { readLock.unlock(); } }
public String toCumulativeString() { readLock.lock(); try { return rleSparseVector.toString() + "\n" + periodicRle.toString(); } finally { readLock.unlock(); } }
@Override public String toString() { StringBuilder ret = new StringBuilder(); ret.append("Period: ").append(timePeriod).append("\n") .append(super.toString()); if (super.isEmpty()) { ret.append(" no allocations\n"); } return ret.toString(); }
@Override public String toString() { StringBuilder sBuf = new StringBuilder(); sBuf.append(getReservationId()).append(" user:").append(getUser()) .append(" startTime: ").append(getStartTime()).append(" endTime: ") .append(getEndTime()).append(" Periodiciy: ").append(periodicity) .append(" alloc:\n[").append(resourcesOverTime.toString()).append("] "); return sBuf.toString(); }
@Override public String toString() { StringBuilder sBuf = new StringBuilder(); sBuf.append(getReservationId()).append(" user:").append(getUser()) .append(" startTime: ").append(getStartTime()).append(" endTime: ") .append(getEndTime()).append(" alloc:[") .append(resourcesOverTime.toString()).append("] "); return sBuf.toString(); }
@Override public String toString() { StringBuilder sBuf = new StringBuilder(); sBuf.append(getReservationId()).append(" user:").append(getUser()) .append(" startTime: ").append(getStartTime()).append(" endTime: ") .append(getEndTime()).append(" alloc:[") .append(resourcesOverTime.toString()).append("] "); return sBuf.toString(); }
@Test public void testZeroAllocation() { ResourceCalculator resCalc = new DefaultResourceCalculator(); RLESparseResourceAllocation rleSparseVector = new RLESparseResourceAllocation(resCalc); rleSparseVector.addInterval(new ReservationInterval(0, Long.MAX_VALUE), Resource.newInstance(0, 0)); LOG.info(rleSparseVector.toString()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(new Random().nextLong())); Assert.assertTrue(rleSparseVector.isEmpty()); }
@Test public void testZeroAlloaction() { ResourceCalculator resCalc = new DefaultResourceCalculator(); Resource minAlloc = Resource.newInstance(1, 1); RLESparseResourceAllocation rleSparseVector = new RLESparseResourceAllocation(resCalc, minAlloc); rleSparseVector.addInterval(new ReservationInterval(0, Long.MAX_VALUE), ReservationRequest.newInstance(Resource.newInstance(0, 0), (0))); LOG.info(rleSparseVector.toString()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(new Random().nextLong())); Assert.assertTrue(rleSparseVector.isEmpty()); }
rleSparseVector.addInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); Assert.assertFalse(rleSparseVector.isEmpty()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.removeInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0),
rleSparseVector.addInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); Assert.assertFalse(rleSparseVector.isEmpty()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.removeInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0),
rleSparseVector.addInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); Assert.assertFalse(rleSparseVector.isEmpty()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.removeInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0),
rleSparseVector.addInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); Assert.assertFalse(rleSparseVector.isEmpty()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.removeInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0),
rleSparseVector.addInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); Assert.assertFalse(rleSparseVector.isEmpty()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.removeInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0),
rleSparseVector.addInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); Assert.assertFalse(rleSparseVector.isEmpty()); Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.removeInterval(ip.getKey(), ip.getValue()); LOG.info(rleSparseVector.toString()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0),
@Test public void testGetMinimumCapacityInInterval() { long[] timeSteps = { 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L }; int[] alloc = { 2, 5, 7, 10, 3, 4, 0, 8 }; RLESparseResourceAllocation rleSparseVector = ReservationSystemTestUtil .generateRLESparseResourceAllocation(alloc, timeSteps); LOG.info(rleSparseVector.toString()); Assert.assertEquals(rleSparseVector.getMinimumCapacityInInterval( new ReservationInterval(1L, 3L)), Resource.newInstance(5, 5)); Assert.assertEquals(rleSparseVector.getMinimumCapacityInInterval( new ReservationInterval(2L, 5L)), Resource.newInstance(3, 3)); Assert.assertEquals(rleSparseVector.getMinimumCapacityInInterval( new ReservationInterval(1L, 7L)), Resource.newInstance(0, 0)); }
@Test public void testMaxPeriodicCapacity() { long[] timeSteps = { 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L }; int[] alloc = { 2, 5, 7, 10, 3, 4, 6, 8 }; RLESparseResourceAllocation rleSparseVector = ReservationSystemTestUtil .generateRLESparseResourceAllocation(alloc, timeSteps); LOG.info(rleSparseVector.toString()); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(0, 1), Resource.newInstance(10, 10)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(0, 2), Resource.newInstance(7, 7)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(0, 3), Resource.newInstance(10, 10)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(0, 4), Resource.newInstance(3, 3)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(0, 5), Resource.newInstance(4, 4)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(0, 5), Resource.newInstance(4, 4)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(7, 5), Resource.newInstance(8, 8)); Assert.assertEquals(rleSparseVector.getMaximumPeriodicCapacity(10, 3), Resource.newInstance(0, 0)); }