Permalink
Browse files

I think fixed segmentation fault and also logic to mark job as failur…

…e when there are errors. In addition able to capture partial successful outputs.
  • Loading branch information...
1 parent c4eea42 commit 339181d30417f3951dd827bcf55c98963d69223d @rdulepet committed Feb 15, 2010
Showing with 25 additions and 11 deletions.
  1. +1 −1 instrument_developer_script.rb
  2. +9 −1 job.rb
  3. +15 −8 processing_node.rb
  4. +0 −1 testing/test_instrumentation.r
@@ -106,7 +106,7 @@ def self.instrument_code orig_r_script
end
# automatically take care of FOOTER mandatory tag
- arr_instrumented[arr_instrumented.length] = "\nHTMLEndFile()\nsink()\n\n}, interrupt = function(ex) {\nprint (\"got exception\");\nprint(ex);\n}, error = function(ex) {\nprint (\"got error\");\nprint(ex);\n}, finally = {\n})\n"
+ arr_instrumented[arr_instrumented.length] = "\n}, interrupt = function(ex) {\nprint (\"got exception: Failed Job\");\n returnstatus=\"FAILED JOB, PLEASE CHECK LOG\"; \nHTML(returnstatus, file=crdata_target);\nprint(ex);\n}, error = function(ex) {\nprint (\"got error: Failed Job\");\n returnstatus=\"FAILED JOB, PLEASE CHECK LOG\"; \nHTML(returnstatus, file=crdata_target);\nprint(ex);\n}, finally = {\nHTMLEndFile()\nsink()\n\n})\n"
# now write instrumented array into the original R script
r_script_file_handle = File.open(orig_r_script, aModeString="w")
View
10 job.rb
@@ -26,13 +26,14 @@ class Job
VALUE_ENUMERATION = "Enumeration"
VALUE_STRING = "String"
- attr_reader :r_script_filename, :job_id, :curr_uuid, :r_call_interface
+ attr_reader :r_script_filename, :job_id, :curr_uuid, :r_call_interface, :job_status
def initialize(xml_response)
@r_call_interface = RSRuby.instance
@r_script_filename = nil
@job_id = 0
@curr_uuid = Global.rand_uuid
+ @job_status = Global::SUCCESSFUL_JOB
# log request
Global.logger.info(xml_response)
@@ -97,9 +98,16 @@ def run
# to capture HTML output as well as log stuff
InstrumentDeveloperScript::instrument_code "#{@curr_uuid}.r"
end
+
+ # assume that job will be successful by default
+ # let the R script will indicate if failure
+ @job_status = Global::SUCCESSFUL_JOB
# run the instrumented script
@r_call_interface.eval_R("source('#{@curr_uuid}.r')")
+
+ # fetch the r program execution status
+ File.open( Global::JOB_LOG ) {|io| io.grep(/#{Global::FAILED_JOB}/) { |s| @job_status = Global::FAILED_JOB }}
end
def get_id
View
@@ -58,15 +58,15 @@ def run
job.store_results_and_logs if !job.nil?
# STEP 8
- job_completed(job, true) if !job.nil?
+ job_completed(job) if !job.nil?
rescue => err
Global.logger.fatal(err)
# STEP 7
job.store_results_and_logs if !job.nil?
# STEP 8
- job_completed(job, false) if job.nil?
+ job_completed(job) if job.nil?
job = nil
end
rescue => err2
@@ -79,15 +79,22 @@ def run
def fetch_next_job
# issue command to fetch next job
- xml_response = @site['jobs_queues/run_next_job'].put '', {:content_length => '0', :content_type => 'text/xml'}
- job = Job.new(xml_response)
-
- job
+ begin
+ xml_response = @site['jobs_queues/run_next_job'].put '', {:content_length => '0', :content_type => 'text/xml'}
+ job = Job.new(xml_response)
+ return job
+ rescue Exception => exception_not_found
+ return_status = exception_not_found.to_s
+ # don't report too much stuff to log, unnecessary logging
+ # ResourceNotFound is reported when there are no new jobs
+ Global.logger.fatal(return_status) if !/ResourceNotFound/.match(return_status)
+ return nil
+ end
end
- def job_completed(job, successful)
+ def job_completed(job)
# mark status of the job on server
- if successful
+ if job.job_status == Global::SUCCESSFUL_JOB
#success_length = "success=true".length
#@site["jobs/#{job.get_id}/done.xml?success=true"].put '', {:content_length => '0', :content_type => 'text/plain'}
Global.logger.info('COMPLETED JOB, MARKING JOB SUCCESSFUL')
@@ -10,7 +10,6 @@ plot(tmp)
#<crdata_image caption="Second Graph">plot(tmp)
#</crdata_image>
-
#<crdata_image caption="Third Graph">plot(tmp)</crdata_image>
#<crdata_image>plot(tmp)</crdata_image>

0 comments on commit 339181d

Please sign in to comment.