Implement match phase

See sch.mod.matchexample.c for details.

  1. Define resource criteria type, handler-specific data, and user specific pending reason, as required.
  2. Implement handler functions.
  3. Implement initialization functions.

Step 1.

Define resource criteria type, handler-specific data, and user specific pending reason.

The criteria type indicates the kind of resource requirement the handler is handling. Usually, the external plugin handler only handles external resource requirement (string) which is specified through bsub command using the ‑extsched option.

In order to use -extsched, you must set LSF_ENABLE_EXTSCHEDULER=y in lsf.conf.

New() function parses the external resource requirement string, and stores the parsed resource to handler-specific data.

handler-specific data is a container used to store any data which is needed by the handler.

If the plugin needs to set a user specific pending reason, a pending reason ID needs to be defined. See lsb_reason_set() in sched_api.h for more information.

Step 2.

Implement handler functions: New(), Free(), Match(), and Sort().

  1. New():
    1. Get external resource requirement message (lsb_resreq_getextresreq()).
    2. Find my message, and parse it.
    3. Create handler-specific data, and store parsing result in it.
    4. Create a key, (in example, just use external message as a key).
    5. Attach the handler-specific data (lsb_resreq_setobject()).
  2. Free():

    Free whatever in handler-specific data.

  3. Match(): (handler-specific data is passed in)
    1. Go through all candidate host groups.(lsb_cand_getnextgroup())
    2. Look at candidate host in each group. If a host is not eligible, remove it from group and set pending reason (lsb_cand_removehost(), lsb_reason_set()).
  4. Sort(): (handler-specific data is passed in)
    1. Go through all candidate host groups (lsb_cand_getnextgroup()).
    2. Sort the candidate hosts in the group.

Step 3.

  1. Implement sched_init().

    This function is the plugin initialization function, which is called when the plugin is loaded.

  2. Create handler, and register it to scheduler framework (lsb_resreq_registerhandler).