jobmaster 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/job_master/gen_methods.rb +7 -0
- data/lib/job_master/stealth.rb +1 -4
- data/lib/job_master.rb +0 -118
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ba10006ad5958002049e49b7493e4a33e75d1b7
|
4
|
+
data.tar.gz: 959fdef93a1f534139d207ecc384d0550f22574d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca906eb1d84569a70c2c419d614db1ad92459f9fae6a4baaf128f73718f6408bc9e600b5448b34fe9b034e998f9e0b5f4f990a968fd0a823ab234b2f3a67256b
|
7
|
+
data.tar.gz: 8e99588ac3b62b249d52627977ecabd665fc907cda2347acf19eb0d6f0809ef590146c47156d8d8d42507a3727c62c582cf42d8dcb30f6568e511722b536865c
|
@@ -8,6 +8,13 @@ end
|
|
8
8
|
|
9
9
|
class JobMaster
|
10
10
|
|
11
|
+
def single_mapping (args)
|
12
|
+
args = args.first
|
13
|
+
eval(args[1]).map { |item|
|
14
|
+
{args[0] => item}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
11
18
|
def date_gen (args)
|
12
19
|
min = Date.parse(args[:earliest]).jd
|
13
20
|
max = args[:latest] == 'none' ? Date.today.jd : Date.parse(args[:latest]).jd
|
data/lib/job_master/stealth.rb
CHANGED
@@ -3,10 +3,7 @@ require 'tunnel_blick'
|
|
3
3
|
class JobMaster
|
4
4
|
def stealth(max_requests, args, *websites)
|
5
5
|
@tunnel = TunnelBlick.new(database)
|
6
|
-
|
7
|
-
database[:websites][domain_url: ws.home_url.scan(/[^\/]+/)[1]][:id]
|
8
|
-
}
|
9
|
-
@tunnel.connect_smart(max_requests, args, dom_ids)
|
6
|
+
@tunnel.connect_smart(max_requests, args, *websites)
|
10
7
|
@tunnel.add_websites(*websites)
|
11
8
|
@tunnel
|
12
9
|
end
|
data/lib/job_master.rb
CHANGED
@@ -17,122 +17,4 @@ class JobMaster
|
|
17
17
|
@websites = websites
|
18
18
|
end
|
19
19
|
|
20
|
-
class << self
|
21
|
-
|
22
|
-
LEGEND = {
|
23
|
-
date_range_gen: [:earliest, :latest],
|
24
|
-
from_csv: ['file', '*labels']
|
25
|
-
}
|
26
|
-
|
27
|
-
def date_range_gen
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def start_single (prog_name , minutes = 10, sleep = 3)
|
34
|
-
|
35
|
-
@start_time = Time.now
|
36
|
-
set_up_job(prog_name)
|
37
|
-
|
38
|
-
unit_time = 0.0
|
39
|
-
|
40
|
-
while (Time.now - @start_time) / 60 < minutes
|
41
|
-
|
42
|
-
unless unit_time == 0.0
|
43
|
-
update_job(unit_time)
|
44
|
-
end
|
45
|
-
|
46
|
-
unit_start = Time.now
|
47
|
-
unit = next_unit
|
48
|
-
|
49
|
-
break if unit.nil?
|
50
|
-
|
51
|
-
@websites.first.send(prog_name.to_sym, unit)
|
52
|
-
|
53
|
-
puts unit_time = (Time.now - unit_start) / 60
|
54
|
-
sleep(sleep)
|
55
|
-
unit_time += sleep / 60
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def step_single (prog_name)
|
61
|
-
|
62
|
-
@start_time = Time.now
|
63
|
-
set_up_job(prog_name)
|
64
|
-
unit = next_unit
|
65
|
-
return false if unit.nil?
|
66
|
-
|
67
|
-
@websites.first.send(prog_name.to_sym, unit)
|
68
|
-
puts unit_time = (Time.now - @start_time) / 60
|
69
|
-
update_job(unit_time)
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
def set_up_job (program)
|
74
|
-
last_matching = programs_db.where(program: program, @myself => Sequel.pg_array_op(:machines).any).order(:id).last
|
75
|
-
|
76
|
-
@program_id = last_matching[:id]
|
77
|
-
the_job = jobs_db.where(program: program, constraints: @program_id).order(:id).last
|
78
|
-
|
79
|
-
if the_job.nil?
|
80
|
-
units = self.send(last_matching[:method].to_sym, last_matching[:constraints].merge(program: program))
|
81
|
-
insert_job_details(program, units, last_matching[:machines])
|
82
|
-
end
|
83
|
-
|
84
|
-
@job_id = the_job[:id]
|
85
|
-
end
|
86
|
-
|
87
|
-
def insert_job_details (program, units, machines)
|
88
|
-
|
89
|
-
time_share = machines.inject({}) { |acc, m|
|
90
|
-
acc.store(m, 0)
|
91
|
-
acc
|
92
|
-
}
|
93
|
-
|
94
|
-
details = {
|
95
|
-
program: program,
|
96
|
-
created: Time.now,
|
97
|
-
constraints: @program_id,
|
98
|
-
units: Sequel.pg_array(units),
|
99
|
-
size: units.size,
|
100
|
-
total_minutes: 0.0,
|
101
|
-
time_share: Sequel.hstore(time_share),
|
102
|
-
unit_checkout: Sequel.hstore({:apples => :bananas})
|
103
|
-
}
|
104
|
-
jobs_db.insert(details)
|
105
|
-
end
|
106
|
-
|
107
|
-
def next_unit
|
108
|
-
checkout = jobs_db[id: @job_id][:unit_checkout].to_hash
|
109
|
-
|
110
|
-
if checkout.keys.include?(@myself)
|
111
|
-
checkout[@myself]
|
112
|
-
else
|
113
|
-
units = jobs_db[id: @job_id][:units]
|
114
|
-
return false if units.empty?
|
115
|
-
next_unit = units.pop
|
116
|
-
jobs_db.where(id: @job_id).update(
|
117
|
-
:units => units,
|
118
|
-
:unit_checkout => Sequel.hstore(Sequel.expr(:unit_checkout)).merge(@myself => next_unit))
|
119
|
-
next_unit
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def update_job (unit_time)
|
124
|
-
|
125
|
-
time_share = jobs_db[id: @job_id][:time_share].to_hash
|
126
|
-
time_share.find_add!(@myself, unit_time)
|
127
|
-
|
128
|
-
unit_checkout = jobs_db[id: @job_id][:unit_checkout].to_hash
|
129
|
-
unit_checkout.delete!(@myself)
|
130
|
-
|
131
|
-
jobs_db.where(id: @job_id).update(
|
132
|
-
:total_minutes => Sequel.expr(:total_minutes) + unit_time,
|
133
|
-
:time_share => Sequel.hstore(time_share),
|
134
|
-
:unit_checkout => Sequel.hstore(unit_checkout)
|
135
|
-
)
|
136
|
-
end
|
137
|
-
|
138
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobmaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Lai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flex_core
|