Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Download resource_locks.zip
  • Download resource_lock_consumer.zip
  • Extract the archives to the ./config/live folder of your JobScheduler installation.
  • The archive extracts the files to the folders  resource_locks and resource_lock_consumer respectively. 
  • You can store the resource_lock_consumer files in any folder as you like, however, if you move the resource_lock files to some other location then you will have to adjust settings in the resource_lock_consumer objects.

Pattern

Flowchart
jobresource_chainlock [label="Job Chain\ntriggered by File Orders\nor by Ad Hoc Ordersnof resource lock consumers",fillcolor="orange"]
job_manage_resource_lock [label="Job Manage Resource Lock",fillcolor="lightskyblue"]
 
resource_lock_consumer_1 [label="Job Chain\nrepresents a\nresource lock consumer",fillcolor="orange"]
job_sorter_request_resource_lock_1 [label="Job OrderRequest Resource SorterLock",fillcolor="lightskyblue"]
job_step_next_job1_1 [label="Job Step 1",fillcolor="lightskyblue"]
job_step_1_2 [label="NextJob Step Job2", fillcolor="lightskyblue"]

sorter_orders_completedresource_lock_available_1 [shape=diamond,label="listresourece oflock orders completedavailable?",fillcolor="white"]
order_suspend
resource_lock_consumer_2 [label="Suspend OrderJob Chain\ntrepresents a\nresource lock consumer",fillcolor="whiteorange"]
order_waitjob_request_resource_lock_2 [label="WaitJob forRequest nextResource OrderLock",fillcolor="whitelightskyblue"]
order_sortjob_step_2_1 [label="SortJob Step Orders1",fillcolor="whitelightskyblue"]
order_movejob_step_2_2 [label="Move Orders to Next JobJob Step 2",fillcolor="lightskyblue"]
resource_lock_available_2 [shape=diamond,label="resourece lock available?",fillcolor="white"]

order_C1A [shape="ellipse",label="Order 1A",fillcolor="violet"]
order_1B [shape="ellipse",label="Order C1B",fillcolor="violet"]
order_B2A [shape="ellipse",label="Order B2A",fillcolor="violet"]
order_A2B [shape="ellipse",label="Order A2B",fillcolor="violet"]

sortedshadow_order_A1A [shape="ellipse",label="Shadow Order A1A",fillcolor="violet"]
shadow_order_1B [shape="ellipse",label="Shadow Order 
sorted1B",fillcolor="violet"]
shadow_order_B2A [shape="ellipse",label="Shadow Order B2A",fillcolor="violet"]
sortedshadow_order_C2B [shape="ellipse",label="Shadow Order C2B",fillcolor="violet"]
 
order_A
order_suspend [label="Suspend Order",fillcolor="white"]
order_wait [label="Wait for next Order",fillcolor="white"]
order_move [label="Move Orders to Next Job",fillcolor="white"]

resource_lock_consumer_1 -> joborder_chain
order_B1A
resource_lock_consumer_1 -> joborder_chain1B
order_C1A -> job_chain
job_chain_request_resource_lock_1
order_1B -> job_sorter_request_resource_lock_1
job_sorterrequest_resource_lock_1 -> sorterresource_lock_ordersavailable_completed1
sorterresource_lock_ordersavailable_completed1 -> order_sortmove [label=" yes "]
sorterresource_lock_ordersavailable_completed1 -> order_suspend [label=" no "]
order_suspend
resource_lock -> shadow_order_1A
resource_lock -> shadow_order_1B
resource_lock -> shadow_order_wait2A
resource_lock -> job_sorter
order_sortshadow_order_2B
 
resource_lock_consumer_2 -> order_2A
resource_lock_consumer_2 -> order_2B

order_move1A -> sortedshadow_order_C1A
sorted_order_C1B -> sortedshadow_order_B1B
sorted_order_B2A -> sortedshadow_order_A2A
sorted_order_A2B -> jobshadow_nextorder_job2B
 

Implementation

Components

  • The solution implements a job named sorter that can be added at the start of any job chain.
    • This job implements a spooler_process() function that suspends all incoming orders.
    • This job is configured for a single task and with an idle timeout attribute. This means that it will execute incoming orders sequentially.
    • Having received the last available order this job will wait for the duration specified with the idle_timeout attribute for new orders. 
      • The idle timeout is configured using, for example <job idle_timeout="10"> with the sorter job definition.
      • Once the idle timeout has expired this job will execute its spooler_exit() function and then sort and move all orders that have previously been suspended.
        • Sorting is done in alphabetical order.
        • The orders are moved to the next job chain node that follows the sorter job in the job chain.
  • The download example uses a job chain named job_chain1 that includes the job nodes for the sorter job and a hello job. This job chain accepts ad hoc orders that are added by JOC and it can easily be modified to watch for incoming files and to create an order for each file.
  • Hint: to re-use the sorter job you can:
    • store the job in a central folder and reference the job in individual job chains.
    • move the job's JavaScript code to a central location and use an appropriate <include> element for individual job scripts.

...