Class OpenWFE::YamlErrorJournal
In: lib/openwfe/expool/errorjournal.rb
Parent: ErrorJournal

A Journal that only keep track of error in process execution.

Methods

Attributes

workdir  [R] 

Public Class methods

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 329
329:         def initialize (service_name, application_context)
330: 
331:             require 'openwfe/storage/yamlcustom'
332:                 # making sure this file has been required at this point
333:                 # this yamlcustom thing prevents the whole OpenWFE ecosystem
334:                 # to get serialized :)
335: 
336:             super
337: 
338:             @workdir = get_work_directory + "/ejournal"
339: 
340:             FileUtils.makedirs(@workdir) unless File.exist?(@workdir)
341:         end

Public Instance methods

Copies the error log of a process instance to a give path (and filename).

Could be useful when one has to perform replay operations and wants to keep a copy of the original error[s].

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 366
366:         def copy_error_log_to (wfid, path)
367: 
368:             original_path = get_path wfid
369:             FileUtils.copy_file original_path, path
370:         end

Returns a list (older first) of the errors for a process instance identified by its fei or wfid.

Will return an empty list if there a no errors for the process instances.

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 350
350:         def get_error_log (wfid)
351: 
352:             path = get_path wfid
353: 
354:             return [] unless File.exist?(path)
355: 
356:             read_error_log_from path
357:         end

Reads all the error logs currently stored. Returns a hash wfid —> error list.

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 438
438:         def get_error_logs
439: 
440:             result = {}
441: 
442:             Find.find(@workdir) do |path|
443:                 next unless path.endswith(".ejournal")
444:                 wfid = path[0..-9]
445:                 log = read_error_log wfid
446:                 result[wfid] = log
447:             end
448: 
449:             result
450:         end

Reads an error log from a specific file (possibly as copied over via copy_error_log_to()).

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 376
376:         def read_error_log_from (path)
377: 
378:             raise "no error log file at #{path}" unless File.exist?(path)
379: 
380:             File.open(path) do |f|
381:                 s = YAML.load_stream f
382:                 s.documents
383:             end
384:         end

Removes the error log of a specific process instance. Could be a good idea after a succesful replay operation.

‘wfid’ may be either a workflow instance id (String) either a FlowExpressionId instance.

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 393
393:         def remove_error_log (wfid)
394: 
395:             path = get_path wfid
396: 
397:             File.delete(path) if File.exist?(path)
398:         end

Removes a list of errors from this error journal.

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 403
403:         def remove_errors (wfid, errors)
404: 
405:             errors = Array(errors)
406: 
407:             # load all errors
408: 
409:             log = get_error_log wfid
410: 
411:             # remove the given errors
412: 
413:             errors.each do |e|
414:                 log.delete e
415:             end
416: 
417:             # rewrite error file
418: 
419:             path = get_path wfid
420: 
421:             if log.size > 0
422: 
423:                 File.open(path, "w") do |f|
424:                     log.each do |e|
425:                         f.puts e.to_yaml
426:                     end
427:                 end
428:             else
429: 
430:                 File.delete path
431:             end
432:         end

Protected Instance methods

Returns the path to the error log file of a specific process instance.

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 471
471:             def get_path (fei_or_wfid)
472: 
473:                 @workdir + "/" + extract_wfid(fei_or_wfid, true) + ".ejournal"
474:             end

logs the error as a yaml string in an error log file (there is one error log file per workflow instance).

[Source]

     # File lib/openwfe/expool/errorjournal.rb, line 458
458:             def record_error (error)
459: 
460:                 path = get_path error.fei
461: 
462:                 File.open(path, "a+") do |f|
463:                     f.puts error.to_yaml
464:                 end
465:             end

[Validate]