Skip to content

Commit

Permalink
I think fixed segmentation fault and also logic to mark job as failur…
Browse files Browse the repository at this point in the history
…e when there are errors. In addition able to capture partial successful outputs.
  • Loading branch information
rdulepet committed Feb 15, 2010
1 parent c4eea42 commit 339181d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion instrument_developer_script.rb
Expand Up @@ -106,7 +106,7 @@ def self.instrument_code orig_r_script
end end


# automatically take care of FOOTER mandatory tag # 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 # now write instrumented array into the original R script
r_script_file_handle = File.open(orig_r_script, aModeString="w") r_script_file_handle = File.open(orig_r_script, aModeString="w")
Expand Down
10 changes: 9 additions & 1 deletion job.rb
Expand Up @@ -26,13 +26,14 @@ class Job
VALUE_ENUMERATION = "Enumeration" VALUE_ENUMERATION = "Enumeration"
VALUE_STRING = "String" 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) def initialize(xml_response)
@r_call_interface = RSRuby.instance @r_call_interface = RSRuby.instance
@r_script_filename = nil @r_script_filename = nil
@job_id = 0 @job_id = 0
@curr_uuid = Global.rand_uuid @curr_uuid = Global.rand_uuid
@job_status = Global::SUCCESSFUL_JOB
# log request # log request
Global.logger.info(xml_response) Global.logger.info(xml_response)


Expand Down Expand Up @@ -97,9 +98,16 @@ def run
# to capture HTML output as well as log stuff # to capture HTML output as well as log stuff
InstrumentDeveloperScript::instrument_code "#{@curr_uuid}.r" InstrumentDeveloperScript::instrument_code "#{@curr_uuid}.r"
end 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 # run the instrumented script
@r_call_interface.eval_R("source('#{@curr_uuid}.r')") @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 end


def get_id def get_id
Expand Down
23 changes: 15 additions & 8 deletions processing_node.rb
Expand Up @@ -58,15 +58,15 @@ def run
job.store_results_and_logs if !job.nil? job.store_results_and_logs if !job.nil?


# STEP 8 # STEP 8
job_completed(job, true) if !job.nil? job_completed(job) if !job.nil?
rescue => err rescue => err
Global.logger.fatal(err) Global.logger.fatal(err)


# STEP 7 # STEP 7
job.store_results_and_logs if !job.nil? job.store_results_and_logs if !job.nil?


# STEP 8 # STEP 8
job_completed(job, false) if job.nil? job_completed(job) if job.nil?
job = nil job = nil
end end
rescue => err2 rescue => err2
Expand All @@ -79,15 +79,22 @@ def run


def fetch_next_job def fetch_next_job
# issue command to 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'} begin
job = Job.new(xml_response) xml_response = @site['jobs_queues/run_next_job'].put '', {:content_length => '0', :content_type => 'text/xml'}

job = Job.new(xml_response)
job 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 end


def job_completed(job, successful) def job_completed(job)
# mark status of the job on server # mark status of the job on server
if successful if job.job_status == Global::SUCCESSFUL_JOB
#success_length = "success=true".length #success_length = "success=true".length
#@site["jobs/#{job.get_id}/done.xml?success=true"].put '', {:content_length => '0', :content_type => 'text/plain'} #@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') Global.logger.info('COMPLETED JOB, MARKING JOB SUCCESSFUL')
Expand Down
1 change: 0 additions & 1 deletion testing/test_instrumentation.r
Expand Up @@ -10,7 +10,6 @@ plot(tmp)


#<crdata_image caption="Second Graph">plot(tmp) #<crdata_image caption="Second Graph">plot(tmp)
#</crdata_image> #</crdata_image>

#<crdata_image caption="Third Graph">plot(tmp)</crdata_image> #<crdata_image caption="Third Graph">plot(tmp)</crdata_image>


#<crdata_image>plot(tmp)</crdata_image> #<crdata_image>plot(tmp)</crdata_image>

0 comments on commit 339181d

Please sign in to comment.