@Test public void testCompare() { assertEquals(FCFSSchedulerGroup.compare(null, null), 0); FCFSSchedulerGroup lhs = new FCFSSchedulerGroup("one"); FCFSSchedulerGroup rhs = new FCFSSchedulerGroup("two"); assertEquals(FCFSSchedulerGroup.compare(lhs, lhs), 0); assertNull(lhs.peekFirst()); assertNull(rhs.peekFirst()); assertEquals(lhs.compareTo(rhs), 0); assertEquals(rhs.compareTo(lhs), 0); SchedulerQueryContext firstRequest = createQueryRequest("groupOne", metrics, 2000); lhs.addLast(firstRequest); assertEquals(lhs.compareTo(rhs), 1); assertEquals(rhs.compareTo(lhs), -1); SchedulerQueryContext secondRequest = createQueryRequest("groupTwo", metrics, 3000); rhs.addLast(secondRequest); assertEquals(lhs.compareTo(rhs), 1); assertEquals(rhs.compareTo(lhs), -1); }
public static int compare(SchedulerGroup lhs, SchedulerGroup rhs) { if (lhs == rhs) { return 0; } if (rhs == null) { return 1; } SchedulerQueryContext lhsFirst = lhs.peekFirst(); SchedulerQueryContext rhsFirst = rhs.peekFirst(); if (lhsFirst != null && rhsFirst != null) { return Long.compare(rhsFirst.getArrivalTimeMs(), lhsFirst.getArrivalTimeMs()); } else if (lhsFirst != null) { return 1; } else if (rhsFirst != null) { return -1; } else { return 0; } }
FCFSSchedulerGroup extends AbstractSchedulerGroup { public static int compare(SchedulerGroup lhs, SchedulerGroup rhs) { if (lhs == rhs) { return 0; } if (rhs == null) { return 1; } SchedulerQueryContext lhsFirst = lhs.peekFirst(); SchedulerQueryContext rhsFirst = rhs.peekFirst(); if (lhsFirst != null && rhsFirst != null) { return Long.compare(rhsFirst.getArrivalTimeMs(), lhsFirst.getArrivalTimeMs()); } else if (lhsFirst != null) { return 1; } else if (rhsFirst != null) { return -1; } else { return 0; } } }
FCFSSchedulerGroup extends AbstractSchedulerGroup { public static int compare(SchedulerGroup lhs, SchedulerGroup rhs) { if (lhs == rhs) { return 0; } if (rhs == null) { return 1; } SchedulerQueryContext lhsFirst = lhs.peekFirst(); SchedulerQueryContext rhsFirst = rhs.peekFirst(); if (lhsFirst != null && rhsFirst != null) { return Long.compare(rhsFirst.getArrivalTimeMs(), lhsFirst.getArrivalTimeMs()); } else if (lhsFirst != null) { return 1; } else if (rhsFirst != null) { return -1; } else { return 0; } } FCFSSchedulerGroup(@Nonnull String group); }
FCFSSchedulerGroup extends AbstractSchedulerGroup { public static int compare(SchedulerGroup lhs, SchedulerGroup rhs) { if (lhs == rhs) { return 0; } if (rhs == null) { return 1; } SchedulerQueryContext lhsFirst = lhs.peekFirst(); SchedulerQueryContext rhsFirst = rhs.peekFirst(); if (lhsFirst != null && rhsFirst != null) { return Long.compare(rhsFirst.getArrivalTimeMs(), lhsFirst.getArrivalTimeMs()); } else if (lhsFirst != null) { return 1; } else if (rhsFirst != null) { return -1; } else { return 0; } } FCFSSchedulerGroup(@Nonnull String group); @Override int compareTo(SchedulerGroupAccountant rhs); static int compare(SchedulerGroup lhs, SchedulerGroup rhs); }
FCFSSchedulerGroup extends AbstractSchedulerGroup { public static int compare(SchedulerGroup lhs, SchedulerGroup rhs) { if (lhs == rhs) { return 0; } if (rhs == null) { return 1; } SchedulerQueryContext lhsFirst = lhs.peekFirst(); SchedulerQueryContext rhsFirst = rhs.peekFirst(); if (lhsFirst != null && rhsFirst != null) { return Long.compare(rhsFirst.getArrivalTimeMs(), lhsFirst.getArrivalTimeMs()); } else if (lhsFirst != null) { return 1; } else if (rhsFirst != null) { return -1; } else { return 0; } } FCFSSchedulerGroup(@Nonnull String group); @Override int compareTo(SchedulerGroupAccountant rhs); static int compare(SchedulerGroup lhs, SchedulerGroup rhs);  }