pampa 2.0.15 → 2.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pampa.rb +15 -40
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8fec0d0fcba61ab662150060b8ce14185a9d3c3d2d4a74a3c255da0ae3e8e6
|
4
|
+
data.tar.gz: d290f6eb64265a7a16451ea4b6e9be99f6e3ca4f86493703894b44fc8f57c275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49ccc2d9c1440d65ffd0b137425807ff0e34133363d7308f3a9d4fea050d24d078a319f608f0bb3a0f68622154603af4f3ec6f858ea83f743789d0d3b6cd1a2f
|
7
|
+
data.tar.gz: 49b313fa4e0ef847643e632249cf529dfdc0ecc357de0fac1f226694895f3959dc5e777002c9481ecff4946d6638e46184b64f919fae97f7ed5bb49785269bfe
|
data/lib/pampa.rb
CHANGED
@@ -23,6 +23,11 @@ module BlackStack
|
|
23
23
|
# Connection string to the database. Example: mysql2://user:password@localhost:3306/database
|
24
24
|
@@connection_string = nil
|
25
25
|
|
26
|
+
def self.now()
|
27
|
+
tz = 'America/Argentina/Buenos_Aires' #DB["SELECT current_setting('TIMEZONE') AS tz"].first[:tz]
|
28
|
+
DB["SELECT current_timestamp() at TIME ZONE '#{tz}' AS now"].first[:now]
|
29
|
+
end
|
30
|
+
|
26
31
|
# @@integrate_with_blackstack_deployer
|
27
32
|
def self.integrate_with_blackstack_deployer()
|
28
33
|
@@integrate_with_blackstack_deployer
|
@@ -138,34 +143,6 @@ module BlackStack
|
|
138
143
|
@@jobs
|
139
144
|
end
|
140
145
|
|
141
|
-
=begin
|
142
|
-
# return a hash descriptor of the whole configuration of the cluster.
|
143
|
-
def self.to_hash()
|
144
|
-
ret = {
|
145
|
-
:log_filename => self.log_filename,
|
146
|
-
:connection_string => self.connection_string,
|
147
|
-
}
|
148
|
-
#ret[:workers] = []
|
149
|
-
#@@workers.each do |w|
|
150
|
-
# ret[:workers] << w.to_hash
|
151
|
-
#end
|
152
|
-
ret[:nodes] = []
|
153
|
-
@@nodes.each do |n|
|
154
|
-
ret[:nodes] << n.to_hash
|
155
|
-
end
|
156
|
-
ret[:jobs] = []
|
157
|
-
@@jobs.each do |j|
|
158
|
-
ret[:jobs] << j.to_hash
|
159
|
-
end
|
160
|
-
ret
|
161
|
-
end # def self.to_hash()
|
162
|
-
|
163
|
-
# setup from a whole hash descriptor
|
164
|
-
def self.initialize(h)
|
165
|
-
# TODO
|
166
|
-
end
|
167
|
-
=end
|
168
|
-
|
169
146
|
# get attached and unassigned workers.
|
170
147
|
# assign and unassign workers to jobs.
|
171
148
|
#
|
@@ -199,6 +176,7 @@ module BlackStack
|
|
199
176
|
l.logf("done (#{assigned.size.to_s})")
|
200
177
|
|
201
178
|
l.logs("Getting total pending tasks... ")
|
179
|
+
|
202
180
|
pendings = job.selecting(job.max_pending_tasks)
|
203
181
|
l.logf("done (#{pendings.size.to_s})")
|
204
182
|
|
@@ -804,14 +782,11 @@ module BlackStack
|
|
804
782
|
|
805
783
|
# returns an array of failed tasks for restarting.
|
806
784
|
def relaunching_dataset(n)
|
807
|
-
#ds = DB[self.table.to_sym].where("#{self.field_time.to_s} < CURRENT_TIMESTAMP() - INTERVAL '#{self.max_job_duration_minutes.to_i} minutes'")
|
808
|
-
#ds = ds.filter("#{self.field_end_time.to_s} IS NULL") if !self.field_end_time.nil?
|
809
|
-
#ds.limit(n).all
|
810
785
|
q = "
|
811
786
|
SELECT *
|
812
787
|
FROM #{self.table.to_s}
|
813
788
|
WHERE #{self.field_time.to_s} IS NOT NULL
|
814
|
-
AND #{self.field_time.to_s} <
|
789
|
+
AND #{self.field_time.to_s} < CAST('#{BlackStack::Pampa.now}' AS TIMESTAMP) - INTERVAL '#{self.max_job_duration_minutes.to_i} minutes'
|
815
790
|
AND #{self.field_id.to_s} IS NOT NULL
|
816
791
|
AND #{self.field_end_time.to_s} IS NULL
|
817
792
|
AND COALESCE(#{self.field_times.to_s},0) < #{self.max_try_times.to_i}
|
@@ -835,14 +810,14 @@ module BlackStack
|
|
835
810
|
o[self.field_time.to_sym] = nil
|
836
811
|
o[self.field_start_time.to_sym] = nil if !self.field_start_time.nil?
|
837
812
|
o[self.field_end_time.to_sym] = nil if !self.field_end_time.nil?
|
838
|
-
|
813
|
+
o.save
|
839
814
|
end
|
840
815
|
|
841
816
|
def start(o)
|
842
817
|
if self.starter_function.nil?
|
843
|
-
o[self.field_start_time.to_sym] = DB["SELECT
|
818
|
+
o[self.field_start_time.to_sym] = DB["SELECT CAST('#{BlackStack::Pampa.now}' AS TIMESTAMP) AS dt"].first[:dt] if !self.field_start_time.nil? # IMPORTANT: use DB location to get current time.
|
844
819
|
o[self.field_times.to_sym] = o[self.field_times.to_sym].to_i + 1
|
845
|
-
|
820
|
+
o.save
|
846
821
|
else
|
847
822
|
self.starter_function.call(o, self)
|
848
823
|
end
|
@@ -850,10 +825,10 @@ module BlackStack
|
|
850
825
|
|
851
826
|
def finish(o, e=nil)
|
852
827
|
if self.finisher_function.nil?
|
853
|
-
o[self.field_end_time.to_sym] = DB["SELECT
|
828
|
+
o[self.field_end_time.to_sym] = DB["SELECT CAST('#{BlackStack::Pampa.now}' AS TIMESTAMP) AS dt"].first[:dt] if !self.field_end_time.nil? && e.nil? # IMPORTANT: use DB location to get current time.
|
854
829
|
o[self.field_success.to_sym] = e.nil?
|
855
830
|
o[self.field_error_description.to_sym] = e.to_console if !e.nil?
|
856
|
-
|
831
|
+
o.save
|
857
832
|
else
|
858
833
|
self.finisher_function.call(o, e, self)
|
859
834
|
end
|
@@ -886,12 +861,12 @@ module BlackStack
|
|
886
861
|
self.selecting(n).each { |o|
|
887
862
|
# count the # of dispatched
|
888
863
|
i += 1
|
889
|
-
# dispatch
|
864
|
+
# dispatch
|
890
865
|
o[self.field_id.to_sym] = worker.id
|
891
|
-
o[self.field_time.to_sym] = DB["SELECT
|
866
|
+
o[self.field_time.to_sym] = DB["SELECT CAST('#{BlackStack::Pampa.now}' AS TIMESTAMP) AS dt"].first[:dt] # IMPORTANT: use DB location to get current time.
|
892
867
|
o[self.field_start_time.to_sym] = nil if !self.field_start_time.nil?
|
893
868
|
o[self.field_end_time.to_sym] = nil if !self.field_end_time.nil?
|
894
|
-
|
869
|
+
o.save
|
895
870
|
# release resources
|
896
871
|
DB.disconnect
|
897
872
|
GC.start
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pampa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|