public double adjustWeight(FSAppAttempt app, double curWeight) { long start = app.getStartTime(); long now = System.currentTimeMillis(); if (now - start < duration) { return curWeight * factor; } else { return curWeight; } } }
public double adjustWeight(FSAppAttempt app, double curWeight) { long start = app.getStartTime(); long now = System.currentTimeMillis(); if (now - start < duration) { return curWeight * factor; } else { return curWeight; } } }
@Override public FSAppAttempt next() { IndexAndTime indexAndTime = appListsByCurStartTime.remove(); int nextListIndex = indexAndTime.index; FSAppAttempt next = appLists[nextListIndex] .get(curPositionsInAppLists[nextListIndex]); curPositionsInAppLists[nextListIndex]++; if (curPositionsInAppLists[nextListIndex] < appLists[nextListIndex].size()) { indexAndTime.time = appLists[nextListIndex] .get(curPositionsInAppLists[nextListIndex]).getStartTime(); } else { indexAndTime.time = Long.MAX_VALUE; } appListsByCurStartTime.add(indexAndTime); return next; }
@SuppressWarnings("unchecked") public MultiListStartTimeIterator(List<List<FSAppAttempt>> appListList) { appLists = appListList.toArray(new List[appListList.size()]); curPositionsInAppLists = new int[appLists.length]; appListsByCurStartTime = new PriorityQueue<IndexAndTime>(); for (int i = 0; i < appLists.length; i++) { long time = appLists[i].isEmpty() ? Long.MAX_VALUE : appLists[i].get(0) .getStartTime(); appListsByCurStartTime.add(new IndexAndTime(i, time)); } }
@Override public FSAppAttempt next() { IndexAndTime indexAndTime = appListsByCurStartTime.remove(); int nextListIndex = indexAndTime.index; FSAppAttempt next = appLists[nextListIndex] .get(curPositionsInAppLists[nextListIndex]); curPositionsInAppLists[nextListIndex]++; if (curPositionsInAppLists[nextListIndex] < appLists[nextListIndex].size()) { indexAndTime.time = appLists[nextListIndex] .get(curPositionsInAppLists[nextListIndex]).getStartTime(); } else { indexAndTime.time = Long.MAX_VALUE; } appListsByCurStartTime.add(indexAndTime); return next; }
@Override public FSAppAttempt next() { IndexAndTime indexAndTime = appListsByCurStartTime.remove(); int nextListIndex = indexAndTime.index; FSAppAttempt next = appLists[nextListIndex] .get(curPositionsInAppLists[nextListIndex]); curPositionsInAppLists[nextListIndex]++; if (curPositionsInAppLists[nextListIndex] < appLists[nextListIndex].size()) { indexAndTime.time = appLists[nextListIndex] .get(curPositionsInAppLists[nextListIndex]).getStartTime(); } else { indexAndTime.time = Long.MAX_VALUE; } appListsByCurStartTime.add(indexAndTime); return next; }
@SuppressWarnings("unchecked") public MultiListStartTimeIterator(List<List<FSAppAttempt>> appListList) { appLists = appListList.toArray(new List[appListList.size()]); curPositionsInAppLists = new int[appLists.length]; appListsByCurStartTime = new PriorityQueue<IndexAndTime>(); for (int i = 0; i < appLists.length; i++) { long time = appLists[i].isEmpty() ? Long.MAX_VALUE : appLists[i].get(0) .getStartTime(); appListsByCurStartTime.add(new IndexAndTime(i, time)); } }
@SuppressWarnings("unchecked") public MultiListStartTimeIterator(List<List<FSAppAttempt>> appListList) { appLists = appListList.toArray(new List[appListList.size()]); curPositionsInAppLists = new int[appLists.length]; appListsByCurStartTime = new PriorityQueue<IndexAndTime>(); for (int i = 0; i < appLists.length; i++) { long time = appLists[i].isEmpty() ? Long.MAX_VALUE : appLists[i].get(0) .getStartTime(); appListsByCurStartTime.add(new IndexAndTime(i, time)); } }
public int compare(FSAppAttempt a1, FSAppAttempt a2) { int res = a1.getPriority().compareTo(a2.getPriority()); if (res == 0) { if (a1.getStartTime() < a2.getStartTime()) { res = -1; } else { res = (a1.getStartTime() == a2.getStartTime() ? 0 : 1); } } if (res == 0) { // If there is a tie, break it by app ID to get a deterministic order res = a1.getApplicationId().compareTo(a2.getApplicationId()); } return res; } }
public int compare(FSAppAttempt a1, FSAppAttempt a2) { int res = a1.getPriority().compareTo(a2.getPriority()); if (res == 0) { if (a1.getStartTime() < a2.getStartTime()) { res = -1; } else { res = (a1.getStartTime() == a2.getStartTime() ? 0 : 1); } } if (res == 0) { // If there is a tie, break it by app ID to get a deterministic order res = a1.getApplicationId().compareTo(a2.getApplicationId()); } return res; } }
public int compare(FSAppAttempt a1, FSAppAttempt a2) { int res = a1.getPriority().compareTo(a2.getPriority()); if (res == 0) { if (a1.getStartTime() < a2.getStartTime()) { res = -1; } else { res = (a1.getStartTime() == a2.getStartTime() ? 0 : 1); } } if (res == 0) { // If there is a tie, break it by app ID to get a deterministic order res = a1.getApplicationId().compareTo(a2.getApplicationId()); } return res; } }
private FSAppAttempt mockAppAttempt(long startTime) { FSAppAttempt schedApp = mock(FSAppAttempt.class); when(schedApp.getStartTime()).thenReturn(startTime); return schedApp; } }
private FSAppAttempt mockAppAttempt(long startTime) { FSAppAttempt schedApp = mock(FSAppAttempt.class); when(schedApp.getStartTime()).thenReturn(startTime); return schedApp; } }
waitTime -= lastScheduledContainer.get(priority); } else { waitTime -= getStartTime();
waitTime -= lastScheduledContainer.get(priority); } else { waitTime -= getStartTime();
waitTime -= lastScheduledContainer.get(schedulerKey); } else{ waitTime -= getStartTime();
@Test public void testMultiListStartTimeIteratorEmptyAppLists() { List<List<FSAppAttempt>> lists = new ArrayList<List<FSAppAttempt>>(); lists.add(Arrays.asList(mockAppAttempt(1))); lists.add(Arrays.asList(mockAppAttempt(2))); Iterator<FSAppAttempt> iter = new MaxRunningAppsEnforcer.MultiListStartTimeIterator(lists); assertEquals(1, iter.next().getStartTime()); assertEquals(2, iter.next().getStartTime()); }
@Test public void testMultiListStartTimeIteratorEmptyAppLists() { List<List<FSAppAttempt>> lists = new ArrayList<List<FSAppAttempt>>(); lists.add(Arrays.asList(mockAppAttempt(1))); lists.add(Arrays.asList(mockAppAttempt(2))); Iterator<FSAppAttempt> iter = new MaxRunningAppsEnforcer.MultiListStartTimeIterator(lists); assertEquals(1, iter.next().getStartTime()); assertEquals(2, iter.next().getStartTime()); }