rest-ftp-daemon 0.90.1 → 0.94.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,23 +76,16 @@ module RestFtpDaemon
76
76
  end
77
77
  end
78
78
 
79
- # def by_status status
80
- # return [] if status.nil?
81
-
82
- # # Select jobs from the queue if their status is (status)
83
- # all.select { |item| item.get(:status) == status.to_sym }
84
- # end
85
-
86
79
  def popped_reverse_sorted_by_status status
87
80
  return [] if status.nil?
88
81
 
89
82
  # Select jobs from the queue if their status is (status)
90
- ordered_popped.reverse.select { |item| item.get(:status) == status.to_sym }
83
+ ordered_popped.reverse.select { |item| item.status == status.to_sym }
91
84
  end
92
85
 
93
- def popped_counts_by_status
86
+ def counts_by_status
94
87
  statuses = {}
95
- @popped.group_by { |job| job.get(:status) }.map { |status, jobs| statuses[status] = jobs.size }
88
+ all.group_by { |job| job.status }.map { |status, jobs| statuses[status] = jobs.size }
96
89
  statuses
97
90
  end
98
91
 
@@ -114,12 +107,18 @@ module RestFtpDaemon
114
107
  @queued.select { |item| item.id == id }.last || @popped.select { |item| item.id == id }.last
115
108
  end
116
109
 
117
- def push obj
110
+ def push job
118
111
  # Check that item responds to "priorty" method
119
- raise "JobQueue.push: object should respond to priority method" unless obj.respond_to? :priority
112
+ raise "JobQueue.push: job should respond to priority method" unless job.respond_to? :priority
120
113
 
121
114
  @mutex.synchronize do
122
- @queued.push obj
115
+ # Push job into the queue
116
+ @queued.push job
117
+
118
+ # Tell the job it's been queued
119
+ job.set_queued if job.respond_to? :set_queued
120
+
121
+ # Try to wake a worker up
123
122
  begin
124
123
  t = @waiting.shift
125
124
  t.wakeup if t
@@ -165,7 +164,7 @@ module RestFtpDaemon
165
164
  end
166
165
 
167
166
  def ordered_popped
168
- @popped.sort_by { |item| [item.get(:updated_at)] }
167
+ @popped.sort_by { |item| [item.updated_at] }
169
168
  end
170
169
 
171
170
  protected
@@ -195,10 +194,10 @@ module RestFtpDaemon
195
194
  # Delete jobs from the queue if their status is (status)
196
195
  @popped.delete_if do |job|
197
196
  # Skip it if wrong status
198
- next unless job.get(:status) == status.to_sym
197
+ next unless job.status == status.to_sym
199
198
 
200
199
  # Skip it if updated_at invalid
201
- updated_at = job.get(:updated_at)
200
+ updated_at = job.updated_at
202
201
  next if updated_at.nil?
203
202
 
204
203
  # Skip it if not aged enough yet
@@ -37,8 +37,7 @@ module RestFtpDaemon
37
37
  error: params[:error],
38
38
  host: Settings['host'].to_s,
39
39
  }
40
- body[:status] = params[:status] if (params[:status].is_a? Enumerable)
41
- # && (!params[:status].empty?)
40
+ body[:status] = params[:status] if (params[:status].is_a? Enumerable) unless params[:status].nil?
42
41
 
43
42
  # Send message in a thread
44
43
  Thread.new do |thread|
@@ -4,14 +4,55 @@
4
4
 
5
5
  .transfer-method {
6
6
  display: inline-block;
7
- width: 35px;
8
- padding: 4px 1px;
7
+ /*width: 35px;*/
8
+ padding: 3px 3px;
9
9
  font-weight: normal;
10
10
  }
11
11
 
12
12
  .nobr {
13
13
  white-space: nowrap;
14
14
  }
15
- .fixed {
16
- font-family:monospace;
15
+
16
+ table tr td, .fixed {
17
+ font-family: 'Inconsolata', sans-serif;
18
+ font-size: 1em;
19
+ }
20
+
21
+ .token {
22
+ display: inline-block;
23
+ background-color: #f8f8f8;
24
+ padding: 0 2px;
25
+ /*font-weight: bold;*/
17
26
  }
27
+
28
+ /*
29
+ .label-outline.badge-success {
30
+ border-color: #468847;
31
+ }
32
+ */
33
+ .label-outline {
34
+ color: black;
35
+ border: 1px solid #999;
36
+ background-color: transparent;
37
+ }
38
+
39
+ .flag {
40
+ margin-right: 3px;
41
+ }
42
+
43
+ h2 {
44
+ font-size: 1.5em;
45
+ margin-top: 2em;
46
+ }
47
+
48
+ #header {
49
+ padding: 20px auto;
50
+ border-bottom: 1px solid silver;
51
+ background-color: #eee;
52
+ }
53
+
54
+ .progress {
55
+ margin-bottom: 0;
56
+ }
57
+
58
+
@@ -4,26 +4,9 @@
4
4
  %meta{:charset => "utf-8"}/
5
5
  %link{ href:"/css/bootstrap.css" , rel: "stylesheet"}
6
6
  %link{ href:"/css/main.css" , rel: "stylesheet"}
7
-
7
+ %link{ href:"http://fonts.googleapis.com/css?family=Inconsolata:400,700" , rel: "stylesheet"}
8
8
  %title="#{Settings['host']} [#{Settings.namespace}] #{APP_NAME}"
9
9
 
10
- :css
11
-
12
- h2 {
13
- font-size: 1.5em;
14
- margin-top: 2em;
15
- }
16
-
17
- #header {
18
- padding: 20px auto;
19
- border-bottom: 1px solid silver;
20
- background-color: #eee;
21
- }
22
-
23
- .progress {
24
- margin-bottom: 0;
25
- }
26
-
27
10
  %body
28
11
 
29
12
  .navbar.navbar-default.navbar-fixed
@@ -39,38 +22,10 @@
39
22
 
40
23
  .container
41
24
 
42
- - trans = $queue.counter_get :transferred
43
- .btn-group.btn-group-sm
44
- .btn.btn-default.btn-success Processors
45
- .btn.btn-default= @info_procs
46
-
47
- .btn-group.btn-group-sm
48
- .btn.btn-default.btn-success IP
49
- .btn.btn-default= @info_ipaddr
50
-
51
- .btn-group.btn-group-sm
52
- .btn.btn-default.btn-success Host
53
- .btn.btn-default= Settings['host']
54
-
55
- .btn-group.btn-group-sm
56
- .btn.btn-default.btn-warning Load
57
- .btn.btn-default= @info_load.round(1)
58
-
59
- .btn-group.btn-group-sm
60
- .btn.btn-default.btn-warning CPU
61
- .btn.btn-default= "#{@info_norm} %"
62
-
63
- .btn-group.btn-group-sm
64
- .btn.btn-default.btn-warning Free
65
- .btn.btn-default= @info_memfree
66
-
67
- .btn-group.btn-group-sm
68
- .btn.btn-default.btn-info Transferred
69
- .btn.btn-default= Helpers.format_bytes(trans, "B")
70
-
25
+ = render :dashboard_headers
71
26
 
72
27
  .row
73
- .col-md-10
28
+ .col-md-12
74
29
 
75
30
  %h2
76
31
  Jobs  
@@ -88,13 +43,14 @@
88
43
  %table.table.table-striped.table-hover.table-condensed
89
44
  %tr
90
45
  %th JID
91
- %th prio
92
- %th worker
46
+ %th P
47
+ %th W
93
48
  %th source
94
49
  %th target
50
+ %th started
95
51
  %th status
96
- %th error
97
52
  %th progress
53
+ %th error
98
54
  %th.text-right size
99
55
  %th.text-right bitrate
100
56
 
@@ -106,10 +62,15 @@
106
62
  = render :dashboard_jobs, {jobs: @jobs_popped, counts: @counts}
107
63
 
108
64
 
109
- .col-md-2
110
- = render :dashboard_workers, {}
111
65
 
112
- = render :dashboard_tokens, {tokens: Settings.endpoints || {}}
66
+ .row
67
+ .col-md-7
68
+ = render :dashboard_tokens, {tokens: Settings.endpoints || {}}
69
+
70
+ .col-md-3
71
+ = render :dashboard_workers
72
+
73
+ .col-md-2
74
+ = render :dashboard_counters
113
75
 
114
- %br
115
76
  %br
@@ -0,0 +1,14 @@
1
+ %h2 Counters
2
+
3
+ %table.table.table-striped.table-hover.table-condensed
4
+
5
+ %tr
6
+ %th counter
7
+ %th.text-right value
8
+
9
+ - $queue.counters.each do |name, value|
10
+
11
+ %tr
12
+ %td= name
13
+ %td.text-right= value
14
+
@@ -0,0 +1,29 @@
1
+ - trans = $queue.counter_get :transferred
2
+ .btn-group.btn-group-sm
3
+ .btn.btn-default.btn-success Processors
4
+ .btn.btn-default= @info_procs
5
+
6
+ .btn-group.btn-group-sm
7
+ .btn.btn-default.btn-success IP
8
+ .btn.btn-default= @info_ipaddr
9
+
10
+ .btn-group.btn-group-sm
11
+ .btn.btn-default.btn-success Host
12
+ .btn.btn-default= Settings['host']
13
+
14
+ .btn-group.btn-group-sm
15
+ .btn.btn-default.btn-warning Load
16
+ .btn.btn-default= @info_load.round(1)
17
+
18
+ .btn-group.btn-group-sm
19
+ .btn.btn-default.btn-warning CPU
20
+ .btn.btn-default= "#{@info_norm} %"
21
+
22
+ .btn-group.btn-group-sm
23
+ .btn.btn-default.btn-warning Free
24
+ .btn.btn-default= @info_memfree
25
+
26
+ .btn-group.btn-group-sm
27
+ .btn.btn-default.btn-info Transferred
28
+ .btn.btn-default= Helpers.format_bytes(trans, "B")
29
+
@@ -1,45 +1,51 @@
1
1
  - jobs.each do |job|
2
- - error = job.get :error
3
- - status = job.get :status
4
2
  - size = job.get :transfer_total
5
3
  - progress = job.get :progress
6
- - transfer_source_count = job.get(:transfer_source_count) || 0
7
- - transfer_source_done = job.get(:transfer_source_done) || 0
4
+ - source_count = job.get(:source_count) || 0
5
+ - source_processed = job.get(:source_processed) || 0
6
+ - source_processing = job.get(:source_processing)
7
+ - presented = present job, :with => RestFtpDaemon::API::Entities::JobPresenter, hide_params: true
8
8
 
9
- - if error!=0 && !error.nil?
9
+ - if !job.error.nil?
10
10
  - trclass = "danger"
11
- - elsif status == :uploading
11
+ - elsif job.status == :uploading
12
12
  - trclass = "info"
13
- - elsif status == :finished
13
+ - elsif job.status == :finished
14
14
  - trclass = "success"
15
15
  - else
16
16
  - trclass = "warning"
17
17
 
18
+
18
19
  %tr{class: trclass}
19
20
 
20
- %td= job.id
21
+ %td{title: presented.to_json}= job.id
22
+
23
+ %td
24
+ - unless job.priority.nil?
25
+ = job.priority
26
+
27
+ %td
21
28
 
22
- %td= job.get :priority
23
29
 
24
- %td= job.wid
30
+ - unless job.wid.nil?
31
+ .label.label-warning.flag= "w#{job.wid}"
25
32
 
26
- %td.fixed{title: job.get(:source_path)}
27
- = Helpers.job_method_label job.get(:source_method)
28
- = job.get :source
33
+ %td{title: job.get(:source_path)}
34
+ =# Helpers.job_method_label job.get(:source_method)
35
+ = Helpers.highlight_tokens job.source
29
36
 
30
- %td.fixed{title: job.get(:target_url)}
37
+ %td{title: job.get(:target_url)}
31
38
  = Helpers.job_method_label job.get(:target_method)
32
- = job.get :target
39
+ =# job.target
40
+ = Helpers.highlight_tokens job.target
33
41
 
34
42
  %td
35
- = status
36
- - if (transfer_source_count > 0) #&& (transfer_source_done < transfer_source_count)
37
- %small= " #{transfer_source_done}/#{transfer_source_count}"
43
+ = Helpers.datetime_short(job.started_at)
38
44
 
39
45
  %td
40
- = error
41
- - unless progress.nil? || status == :finished
42
- %small= "#{progress}%"
46
+ = job.status
47
+ - if (source_count > 1) && (source_processed < source_count)
48
+ %small= " #{source_processed}/#{source_count}"
43
49
 
44
50
  %td
45
51
  - unless progress.nil?
@@ -47,6 +53,15 @@
47
53
  .progress-bar{style:"width: #{progress}%;"}
48
54
  = Helpers.format_bytes job.get(:transfer_sent), "B"
49
55
 
56
+ %td
57
+ - unless job.error || job.status == :finished
58
+ - unless progress.nil?
59
+ = "#{progress}%"
60
+ - unless source_processing.nil?
61
+ %small= " (#{source_processing})"
62
+ - else
63
+ = Helpers.text_or_empty(job.error)
64
+
50
65
  %td.nobr.text-right
51
66
  = Helpers.format_bytes(size, "B")
52
67
 
@@ -54,3 +69,4 @@
54
69
  - if (bitrate = job.get :transfer_bitrate)
55
70
  = Helpers.format_bytes(bitrate, "bps")
56
71
 
72
+
@@ -1,9 +1,14 @@
1
1
  %h2 Endpoint tokens
2
2
 
3
3
  %table.table.table-striped.table-hover.table-condensed
4
+
5
+ %tr
6
+ %th token
7
+ %th value
8
+
4
9
  - tokens.each do |token, value|
5
10
  %tr
6
11
  %td
7
- %b= Helpers.tokenize(token)
12
+ = Helpers.tokenize(token)
8
13
  %td
9
14
  = value
@@ -1,45 +1,29 @@
1
1
  - styles = {waiting: :success, processing: :info, crashed: :error, done: :success }
2
2
 
3
- %h2
4
- Workers
5
- = "&nbsp;"
6
-
7
- .btn-group.btn-group-md
8
- .btn.btn-default
9
- = Settings.workers
10
-
3
+ %h2 Workers
11
4
 
12
5
  %table.table.table-striped.table-hover.table-condensed
13
6
 
14
7
  %tr
15
- %th= "WID"
16
- %th= "status"
17
- %th= "job"
18
- %th= "time"
8
+ %th ID
9
+ %th status
10
+ %th job
11
+ %th.text-right idle
19
12
 
20
13
  - @gworker_statuses.each do |wid, infos|
21
14
  - status = infos[:status]
15
+ - style = styles[status] || ""
16
+
22
17
  - if infos[:active_at].is_a? Time
23
18
  - no_news_for = (Time.now - infos[:active_at]).round(0)
24
19
  - else
25
20
  - no_news_for = "?"
26
21
 
27
- -# status = :waiting
28
- - style = styles[status] || ""
29
- -# style = "success"
30
-
31
22
  %tr{class: style.to_s}
32
-
33
23
  %td= wid
34
24
  %td= infos[:status]
35
25
  %td= infos[:jobid]
36
- %td
26
+ %td.text-right
37
27
  = no_news_for
38
-
39
- %h2 Counters
40
- - $queue.counters.each do |name, value|
41
- %b= "#{name}"
42
- = value
43
- %br
44
-
28
+ s
45
29