From 428516e88d393145874343af508b831d1aa9c2f2 Mon Sep 17 00:00:00 2001 From: Heiko Bernloehr Date: Wed, 25 May 2016 19:37:28 +0200 Subject: Adjust resource fetching to redirected ECS URL. Evaluationserver (ev) is now able to process resource URLs contained in an EvaluationJob which differ from the configured ECS-URL in appcfg.yml, i.e. the URL its a redirected one. Nonetheless ev communicates to the configured ECS directly further on. --- lib/job_event.rb | 10 +++++++--- lib/main_loop.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/job_event.rb b/lib/job_event.rb index 85ebdbf..f07491d 100644 --- a/lib/job_event.rb +++ b/lib/job_event.rb @@ -34,7 +34,9 @@ class JobEvent # Fetch an exercise from ECS. def fetch_exercise(job) # URI#path returns the path with leading "/" - path= URI(job["EvaluationJob"]["resources"]["exercise"]).path[1..-1] + /#{APP_CONFIG["resources"]["exercises"]["name"]}.*$/ =~ URI(job["EvaluationJob"]["resources"]["exercise"]).path[1..-1] + path = $~.to_s + Rails.logger.info "***** JobEvent#fetch_exercise: exercise path #{path}" exercise= @ecs.connection[path].delete exercise = unpack(exercise.body) if packed?(exercise.body) Rails.logger.info "***** JobEvent#fetch_exercise: #{path} = #{exercise}" @@ -45,7 +47,8 @@ class JobEvent # Fetch an evaluation from ECS. def fetch_evaluation(job) # URI#path returns the path with leading "/" - path= URI(job["EvaluationJob"]["resources"]["evaluation"]).path[1..-1] + /#{APP_CONFIG["resources"]["evaluations"]["name"]}.*$/ =~ URI(job["EvaluationJob"]["resources"]["evaluation"]).path[1..-1] + path = $~.to_s evaluation= @ecs.connection[path].delete evaluation = unpack(evaluation.body) if packed?(evaluation.body) Rails.logger.info "***** JobEvent#fetch_evaluation: #{path} = #{evaluation}" @@ -56,7 +59,8 @@ class JobEvent # Fetch a solution from ECS. def fetch_solution(job) # URI#path returns the path with leading "/" - path= URI(job["EvaluationJob"]["resources"]["solution"]).path[1..-1] + /#{APP_CONFIG["resources"]["solutions"]["name"]}.*$/ =~ URI(job["EvaluationJob"]["resources"]["solution"]).path[1..-1] + path = $~.to_s solution= @ecs.connection[path].delete solution = unpack(solution.body) if packed?(solution.body) Rails.logger.info "***** JobEvent#fetch_solution: #{path} = #{solution}" diff --git a/lib/main_loop.rb b/lib/main_loop.rb index b85d232..571e058 100644 --- a/lib/main_loop.rb +++ b/lib/main_loop.rb @@ -56,7 +56,7 @@ class MainLoop end def read_event - @ecs.connection["sys/events/fifo"].post "" + @ecs.connection[APP_CONFIG["resources"]["sys_events"]["name"]+"/fifo"].post "" end -- cgit v1.2.3