Description:
[web] updated grader monitoring
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@222 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r105:0ea7f18fc18a - - 14 files changed: 149 inserted, 20 deleted
@@ -0,0 +1,22 | |||
|
1 | + %h1= "Submission: #{@submission.id}" | |
|
2 | + | |
|
3 | + %p | |
|
4 | + User: | |
|
5 | + = "#{@submission.user.login}" | |
|
6 | + %br/ | |
|
7 | + Problem: | |
|
8 | + - if @submission.problem!=nil | |
|
9 | + = "#{@submission.problem.full_name}" | |
|
10 | + - else | |
|
11 | + = "(n/a)" | |
|
12 | + %br/ | |
|
13 | + = "Number: #{@submission.number}" | |
|
14 | + %br/ | |
|
15 | + = "Submitted at: #{format_short_time(@submission.submitted_at)}" | |
|
16 | + | |
|
17 | + %b Source code (first 10kb) | |
|
18 | + %div{:style => "border: 1px solid black; background: lightgrey"} | |
|
19 | + - if @submission.source | |
|
20 | + %pre | |
|
21 | + = truncate(@submission.source,10240) | |
|
22 | + |
@@ -0,0 +1,15 | |||
|
1 | + %h1= "Task: #{@task.id}" | |
|
2 | + | |
|
3 | + %p | |
|
4 | + User: | |
|
5 | + = "#{@task.submission.user.login}" | |
|
6 | + %br/ | |
|
7 | + Status: | |
|
8 | + = "#{@task.status_str} (at #{format_short_time(@task.updated_at)})" | |
|
9 | + %br/ | |
|
10 | + = "Submission: #{@task.submission_id}" | |
|
11 | + - if @task.submission !=nil | |
|
12 | + = link_to '[view submission]', :action => 'submission', :id => @task.submission.id | |
|
13 | + %br/ | |
|
14 | + = "Submitted at: #{format_short_time(@task.created_at)}" | |
|
15 | + %br/ |
@@ -0,0 +1,40 | |||
|
1 | + %h1= "Test Request: #{@test_request.id}" | |
|
2 | + | |
|
3 | + %p | |
|
4 | + User: | |
|
5 | + = "#{@test_request.user.login}" | |
|
6 | + %br/ | |
|
7 | + Problem: | |
|
8 | + - if @test_request.problem!=nil | |
|
9 | + = "#{@test_request.problem.full_name}" | |
|
10 | + - else | |
|
11 | + = "(n/a)" | |
|
12 | + %br/ | |
|
13 | + = "Submission: #{@test_request.submission.number}" | |
|
14 | + = link_to '[view submission]', :action => 'submission', :id => @test_request.submission.id | |
|
15 | + %br/ | |
|
16 | + = "Test submitted at: #{format_short_time(@test_request.submitted_at)}" | |
|
17 | + %br/ | |
|
18 | + = "Execution time: #{@test_request.running_time} s." | |
|
19 | + %br/ | |
|
20 | + = "Memory usage: #{@test_request.memory_usage}kb" | |
|
21 | + %br/ | |
|
22 | + %b= @test_request.exit_status | |
|
23 | + %br/ | |
|
24 | + | |
|
25 | + - if @test_request.compiler_message!=nil and @test_request.compiler_message!='' | |
|
26 | + %b Compiler Message | |
|
27 | + %div{:style => "border: 1px solid black; background: lightgrey"} | |
|
28 | + = simple_format(truncate((@test_request.compiler_message or ''),200)) | |
|
29 | + | |
|
30 | + %b Input (first 2kb) | |
|
31 | + %div{:style => "border: 1px solid black; background: lightgrey"} | |
|
32 | + - if @test_request.input_file_name!=nil | |
|
33 | + = simple_format(read_textfile(@test_request.input_file_name,2048)) | |
|
34 | + | |
|
35 | + %b Output (first 2kb) | |
|
36 | + %div{:style => "border: 1px solid black; background: lightgrey"} | |
|
37 | + - if @test_request.output_file_name!=nil | |
|
38 | + = simple_format(read_textfile(@test_request.output_file_name,2048)) | |
|
39 | + - else | |
|
40 | + (no output) |
@@ -0,0 +1,9 | |||
|
1 | + class AddTaskTypeToGraderProcesses < ActiveRecord::Migration | |
|
2 | + def self.up | |
|
3 | + add_column 'grader_processes', 'task_type', :string | |
|
4 | + end | |
|
5 | + | |
|
6 | + def self.down | |
|
7 | + remove_column 'grader_processes', 'task_type' | |
|
8 | + end | |
|
9 | + end |
@@ -1,10 +1,16 | |||
|
1 | 1 | class GradersController < ApplicationController |
|
2 | 2 | |
|
3 | - | |
|
4 | - before_filter :authorization | |
|
3 | + before_filter :admin_authorization | |
|
4 | + | |
|
5 | + verify :method => :post, :only => ['clear_all'], | |
|
6 | + :redirect_to => {:action => 'index'} | |
|
7 | + | |
|
8 | + def index | |
|
9 | + redirect_to :action => 'list' | |
|
10 | + end | |
|
5 | 11 | |
|
6 | 12 | def list |
|
7 | 13 | @grader_processes = GraderProcess.find(:all, |
|
8 | 14 | :order => 'updated_at desc') |
|
9 | 15 | @stalled_processes = GraderProcess.find_stalled_process |
|
10 | 16 | end |
@@ -12,7 +18,34 | |||
|
12 | 18 | def clear |
|
13 | 19 | grader_proc = GraderProcess.find(params[:id]) |
|
14 | 20 | grader_proc.destroy if grader_proc!=nil |
|
15 | 21 | redirect_to :action => 'list' |
|
16 | 22 | end |
|
17 | 23 | |
|
24 | + def clear_all | |
|
25 | + GraderProcess.find(:all).each do |p| | |
|
26 | + p.destroy | |
|
27 | + end | |
|
28 | + redirect_to :action => 'list' | |
|
29 | + end | |
|
30 | + | |
|
31 | + def view | |
|
32 | + if params[:type]=='Task' | |
|
33 | + redirect_to :action => 'task', :id => params[:id] | |
|
34 | + else | |
|
35 | + redirect_to :action => 'test_request', :id => params[:id] | |
|
36 | + end | |
|
37 | + end | |
|
38 | + | |
|
39 | + def test_request | |
|
40 | + @test_request = TestRequest.find(params[:id]) | |
|
41 | + end | |
|
42 | + | |
|
43 | + def task | |
|
44 | + @task = Task.find(params[:id]) | |
|
45 | + end | |
|
46 | + | |
|
47 | + def submission | |
|
48 | + @submission = Submission.find(params[:id]) | |
|
49 | + end | |
|
50 | + | |
|
18 | 51 | end |
@@ -1,9 +1,9 | |||
|
1 | 1 | class UserAdminController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_filter :a |
|
|
3 | + before_filter :admin_authorization | |
|
4 | 4 | |
|
5 | 5 | def index |
|
6 | 6 | list |
|
7 | 7 | render :action => 'list' |
|
8 | 8 | end |
|
9 | 9 |
@@ -10,13 +10,13 | |||
|
10 | 10 | menu_items << "<b>Administrative task:</b> " |
|
11 | 11 | append_to menu_items, '[Announcements]', 'announcements', 'index' |
|
12 | 12 | append_to menu_items, '[Msg console]', 'messages', 'console' |
|
13 | 13 | append_to menu_items, '[Problem admin]', 'problems', 'index' |
|
14 | 14 | append_to menu_items, '[User admin]', 'user_admin', 'index' |
|
15 | 15 | append_to menu_items, '[User stat]', 'user_admin', 'user_stat' |
|
16 |
- |
|
|
16 | + append_to menu_items, '[Graders]', 'graders', 'list' | |
|
17 | 17 | append_to menu_items, '[Site config]', 'configurations', 'index' |
|
18 | 18 | menu_items << "<br/>" |
|
19 | 19 | end |
|
20 | 20 | |
|
21 | 21 | # main page |
|
22 | 22 | append_to menu_items, '[Main]', 'main', 'list' |
@@ -69,7 +69,15 | |||
|
69 | 69 | </tr> |
|
70 | 70 | </table> |
|
71 | 71 | </div> |
|
72 | 72 | TITLEBAR |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | + def read_textfile(fname,max_size=2048) | |
|
76 | + begin | |
|
77 | + File.open(fname).read(max_size) | |
|
78 | + rescue | |
|
79 | + nil | |
|
80 | + end | |
|
81 | + end | |
|
82 | + | |
|
75 | 83 | end |
@@ -1,11 +1,2 | |||
|
1 | 1 | module TestHelper |
|
2 | - | |
|
3 | - def read_textfile(fname,max_size=2048) | |
|
4 | - begin | |
|
5 | - File.open(fname).read(max_size) | |
|
6 | - rescue | |
|
7 | - nil | |
|
8 | - end | |
|
9 | - end | |
|
10 | - | |
|
11 | 2 | end |
@@ -1,10 +1,8 | |||
|
1 | 1 | class GraderProcess < ActiveRecord::Base |
|
2 | 2 | |
|
3 | - belongs_to :task | |
|
4 | - | |
|
5 | 3 | def self.find_by_host_and_pid(host,pid) |
|
6 | 4 | return GraderProcess.find(:first, |
|
7 | 5 | :conditions => { |
|
8 | 6 | :host => host, |
|
9 | 7 | :pid => pid |
|
10 | 8 | }) |
@@ -13,12 +11,13 | |||
|
13 | 11 | def self.register(host,pid,mode) |
|
14 | 12 | grader = GraderProcess.find_by_host_and_pid(host,pid) |
|
15 | 13 | if grader |
|
16 | 14 | grader.mode = mode |
|
17 | 15 | grader.active = nil |
|
18 | 16 | grader.task_id = nil |
|
17 | + grader.task_type = nil | |
|
19 | 18 | grader.save |
|
20 | 19 | else |
|
21 | 20 | grader = GraderProcess.create(:host => host, |
|
22 | 21 | :pid => pid, |
|
23 | 22 | :mode => mode) |
|
24 | 23 | end |
@@ -30,19 +29,21 | |||
|
30 | 29 | :conditions => ["active AND updated_at < ?", |
|
31 | 30 | Time.now.gmtime - GraderProcess.stalled_time]) |
|
32 | 31 | end |
|
33 | 32 | |
|
34 | 33 | def report_active(task=nil) |
|
35 | 34 | self.active = true |
|
36 | - self.task = task | |
|
35 | + self.task_id = task.id | |
|
36 | + self.task_type = task.class.to_s | |
|
37 | 37 | self.save |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | def report_inactive() |
|
41 | 41 | self.active = false |
|
42 | - self.task = nil | |
|
42 | + self.task_id = nil | |
|
43 | + self.task_type = nil | |
|
43 | 44 | self.save |
|
44 | 45 | end |
|
45 | 46 | |
|
46 | 47 | protected |
|
47 | 48 | |
|
48 | 49 | def self.stalled_time() |
@@ -1,8 +1,10 | |||
|
1 | 1 | class Task < ActiveRecord::Base |
|
2 | 2 | |
|
3 | + belongs_to :submission | |
|
4 | + | |
|
3 | 5 | STATUS_GRADING = 0 |
|
4 | 6 | STATUS_INQUEUE = 1 |
|
5 | 7 | STATUS_COMPLETE = 2 |
|
6 | 8 | |
|
7 | 9 | def status_inqueue |
|
8 | 10 | self.status = Task::STATUS_INQUEUE |
@@ -1,9 +1,11 | |||
|
1 | 1 | |
|
2 | 2 | %td= grader.host |
|
3 | 3 | %td= grader.pid |
|
4 | + %td= grader.mode | |
|
4 | 5 | %td= grader.updated_at.strftime("%H:%M:%S") if grader.updated_at!=nil |
|
6 | + %td= grader.task_type | |
|
5 | 7 | %td |
|
6 | 8 | - if grader.task_id==nil |
|
7 | - \- | |
|
9 | + idle | |
|
8 | 10 | - else |
|
9 | - = grader.task_id | |
|
11 | + = link_to "#{grader.task_id}", :action => 'view', :id => grader.task_id, :type => grader.task_type |
@@ -1,12 +1,14 | |||
|
1 | 1 | |
|
2 | 2 | %table.graders |
|
3 | 3 | %tr |
|
4 | 4 | %th host |
|
5 | 5 | %th pid |
|
6 | + %th mode | |
|
6 | 7 | %th last updated |
|
8 | + %th type | |
|
7 | 9 | %th task |
|
8 | 10 | - grader_list.each do |grader| |
|
9 | 11 | - if grader.active |
|
10 | 12 | - c = 'active' |
|
11 | 13 | - else |
|
12 | 14 | - c = 'inactive' |
@@ -1,11 +1,14 | |||
|
1 | 1 | - content_for :head do |
|
2 | 2 | = stylesheet_link_tag 'graders' |
|
3 | 3 | |
|
4 | 4 | %h2 (Under Experiments) |
|
5 | 5 | |
|
6 | + - form_for :clear, nil, :url => {:action => 'clear_all'} do |f| | |
|
7 | + = submit_tag 'Clear all data' | |
|
8 | + | |
|
6 | 9 | %h3 Current graders |
|
7 | 10 | |
|
8 | 11 | = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes} |
|
9 | 12 | |
|
10 | 13 | %h3 Stalled graders |
|
11 | 14 |
@@ -6,13 +6,13 | |||
|
6 | 6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
7 | 7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
8 | 8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
9 | 9 | # |
|
10 | 10 | # It's strongly recommended to check this file into your version control system. |
|
11 | 11 | |
|
12 |
- ActiveRecord::Schema.define(:version => 3 |
|
|
12 | + ActiveRecord::Schema.define(:version => 33) do | |
|
13 | 13 | |
|
14 | 14 | create_table "announcements", :force => true do |t| |
|
15 | 15 | t.string "author" |
|
16 | 16 | t.text "body" |
|
17 | 17 | t.boolean "published" |
|
18 | 18 | t.datetime "created_at" |
@@ -39,12 +39,13 | |||
|
39 | 39 | t.integer "pid" |
|
40 | 40 | t.string "mode" |
|
41 | 41 | t.boolean "active" |
|
42 | 42 | t.datetime "created_at" |
|
43 | 43 | t.datetime "updated_at" |
|
44 | 44 | t.integer "task_id" |
|
45 | + t.string "task_type" | |
|
45 | 46 | end |
|
46 | 47 | |
|
47 | 48 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
48 | 49 | |
|
49 | 50 | create_table "languages", :force => true do |t| |
|
50 | 51 | t.string "name", :limit => 10 |
You need to be logged in to leave comments.
Login now