Implementation of comparator in FIFO Scheduler

Source: Internet
Author: User

  1. Class Jobqueuejobinprogresslistener extends Jobinprogresslistener, Where Jobqueuejobinprogresslistener has a static inner class Jobschedulinginfo
  2. int compare (object O1, Object O2) returns the integral type of a primitive type
    If you want to sort in ascending order,
    Then O1 is less than O2, returns 1 (negative number), equals returns 0,01 greater than 02 returns 1 (positive number)
    If you want to sort in descending order
    Then O1 is less than O2, returns 1 (positive), equals returns 0,01 greater than 02 returns-1 (negative number)
  3. Sort by jobschedulinginfo information in ascending order
  4. Static final comparator<jobschedulinginfo> Fifo_job_queue_comparator
    = new Comparator<jobschedulinginfo> () {
    public int Compare (Jobschedulinginfo O1, Jobschedulinginfo O2) {
    int res = o1.getpriority (). CompareTo (O2.getpriority ());
    if (res = = 0) {
    if (O1.getstarttime () < O2.getstarttime ()) {
    res =-1;
    } else {
    res = (O1.getstarttime () = = O2.getstarttime ()? 0:1);
    }
    }
    if (res = = 0) {
    res = O1.getjobid (). CompareTo (O2.getjobid ());
    }
    return res;
    }
    };

The specific implementation of the comparator in the FIFO scheduler

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.