Versions Compared

Key

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

...

  • JobScheduler's aquire_lock job matches files using regular expressions and determines the file's category - for example, Berlin or Munich.
    No Format
     The regular expressions are also defined in the "File Order Sources" area shown in the screenshot.
     Note that for simplicity the regular expressions match the prefixes "a" and "b" in the file names and not directly "Berlin" or "Munich".
     The {{aquire_lock}} job uses a Rhino JavaScript to try to aquire the lock and wait if the lock is not available. This script is listed below.
    

...

  • Once aquire_lock finds the matching category it will try to set a semaphore (flag) using JobScheduler's inbuilt LOCK mechanism
  • Only one instance of each LOCK is allowed as can be seen in the screenshot below. Once a LOCK has been assigned to a file from a category (either Berlin or Munich), all subsequent files for this category haves to wait with a setback until the LOCK has been freed.
  • The same mechanism will be repeated for files from other categories. As long as a file of any given category is not being processed and therefore the corresponding LOCK not been set, the way will be free for the file from the other category to be allowed to be processed.
    No Format
     This can be seen in the following screenshot of JobScheduler's JOE interface showing the progression of file orders along the {{load_files}} job chain.
    

Image RemovedImage Added

  • Once process is finished depending upon success or error, JobScheduler will move the file from the in folder to either the done (on success) or failed (on error) folders.
  • After moving input file to correct target directory JobScheduler, the release_lock job will be called, which will remove the lock/semaphore from JobScheduler and allow the next file from same category to be processed.

The following screenshot from the JobScheduler's JOE interface show Image Removed

Image Added

Code Block
languagejavascript
function spooler_process() \{

  try \{

     var parameters = spooler_task.order().params();
    
     var filePath = "" + String(parameters.value("scheduler_file_path"));
     spooler_log.info( " scheduler_file_path : " + filePath );
     var lockName = "" + String(parameters.value( "lock_name" ));
     spooler_log.info( "  lock_name : " +  lockName );

/*
     var fileParts = filePath.split("\\");
     var fileName  = fileParts[fileParts.length-1];
     spooler_log.info( "fileName : " + fileName );

     if(fileName.match("^a[A-Za-z0-9_]*\.csv$")) \{
        var lockName = "BERLIN_PROC";
        var lock_name = "BERLIN_PROC";
        spooler_log.info( "File matched with berlin lock_name : "+ lockName  );
     \}
    
     if(fileName.match("^b[A-Za-z0-9_]*\.csv$")) \{
        var lockName = "MUNICH_PROC";
        spooler_log.info( "File matched with berlin lock_name : "+ lockName  );
     \}
*/
     if (spooler.locks().lock_or_null( lockName )) \{
        spooler.locks().lock( lockName ).remove();
     \}
     return true;

  \} catch (e) \{

    spooler_log.warn("error occurred: " + String(e));
    return false;

  \}

\}

...