cosmos 5.0.3 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cosmos +1 -1
- data/lib/cosmos/api/api.rb +1 -25
- data/lib/cosmos/api/cmd_api.rb +6 -6
- data/lib/cosmos/api/config_api.rb +10 -4
- data/lib/cosmos/api/limits_api.rb +1 -1
- data/lib/cosmos/api/settings_api.rb +19 -7
- data/lib/cosmos/api/target_api.rb +2 -2
- data/lib/cosmos/api/tlm_api.rb +8 -8
- data/lib/cosmos/config/config_parser.rb +2 -2
- data/lib/cosmos/config/meta_config_parser.rb +1 -1
- data/lib/cosmos/logs/log_writer.rb +2 -2
- data/lib/cosmos/microservices/decom_microservice.rb +1 -1
- data/lib/cosmos/microservices/interface_microservice.rb +0 -1
- data/lib/cosmos/microservices/microservice.rb +2 -2
- data/lib/cosmos/microservices/reducer_microservice.rb +12 -10
- data/lib/cosmos/models/cvt_model.rb +6 -6
- data/lib/cosmos/models/gem_model.rb +2 -2
- data/lib/cosmos/models/info_model.rb +1 -1
- data/lib/cosmos/models/interface_status_model.rb +1 -1
- data/lib/cosmos/models/metadata_model.rb +42 -216
- data/lib/cosmos/models/metric_model.rb +2 -2
- data/lib/cosmos/models/microservice_model.rb +1 -1
- data/lib/cosmos/models/microservice_status_model.rb +1 -1
- data/lib/cosmos/models/model.rb +16 -16
- data/lib/cosmos/models/note_model.rb +124 -0
- data/lib/cosmos/models/ping_model.rb +2 -1
- data/lib/cosmos/models/plugin_model.rb +1 -1
- data/lib/cosmos/models/process_status_model.rb +1 -1
- data/lib/cosmos/models/scope_model.rb +9 -6
- data/lib/cosmos/models/settings_model.rb +55 -0
- data/lib/cosmos/models/sorted_model.rb +165 -0
- data/lib/cosmos/models/target_model.rb +20 -20
- data/lib/cosmos/models/tool_config_model.rb +38 -0
- data/lib/cosmos/models/tool_model.rb +1 -1
- data/lib/cosmos/models/widget_model.rb +1 -1
- data/lib/cosmos/operators/microservice_operator.rb +2 -1
- data/lib/cosmos/script/calendar.rb +26 -15
- data/lib/cosmos/system/system.rb +2 -1
- data/lib/cosmos/top_level.rb +5 -1
- data/lib/cosmos/topics/autonomic_topic.rb +2 -2
- data/lib/cosmos/topics/calendar_topic.rb +1 -1
- data/lib/cosmos/topics/command_decom_topic.rb +31 -1
- data/lib/cosmos/topics/command_topic.rb +6 -4
- data/lib/cosmos/topics/interface_topic.rb +8 -8
- data/lib/cosmos/topics/limits_event_topic.rb +5 -3
- data/lib/cosmos/topics/notifications_topic.rb +1 -1
- data/lib/cosmos/topics/router_topic.rb +9 -9
- data/lib/cosmos/topics/telemetry_decom_topic.rb +1 -1
- data/lib/cosmos/topics/telemetry_topic.rb +1 -1
- data/lib/cosmos/topics/timeline_topic.rb +1 -1
- data/lib/cosmos/topics/topic.rb +21 -16
- data/lib/cosmos/utilities/logger.rb +3 -3
- data/lib/cosmos/utilities/metric.rb +32 -26
- data/lib/cosmos/utilities/s3.rb +1 -1
- data/lib/cosmos/utilities/s3_file_cache.rb +12 -6
- data/lib/cosmos/utilities/store.rb +1 -0
- data/lib/cosmos/utilities/store_autoload.rb +27 -126
- data/lib/cosmos/version.rb +5 -5
- metadata +7 -4
- data/lib/cosmos/models/narrative_model.rb +0 -280
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a561fd5492c1b282759d45170da4e687b4e53eea086804bde1c549a75a8bdd5
|
4
|
+
data.tar.gz: c88407b16125e7ef2fb9764dd14338f6508e2fbde1567ff3b7d23b24f1b7dd2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f80a81b27f8c00611a730ef329b4c4afc01e572419ee03d1c7621295e2670a1e829d41511ee4a82af5874d43d32f7b51280281c26310ee8f1e79e767e987c542
|
7
|
+
data.tar.gz: 14f36f225ac641ca74dac4eca580ffad8e6ffea7d69bed1c685d387db0ff6d3977c6ad8b148b8a8117914bd7752914423d2691aa899b0ec902fde5c25f4e931a
|
data/bin/cosmos
CHANGED
@@ -99,7 +99,7 @@ def generate(args)
|
|
99
99
|
end
|
100
100
|
base_name.sub!("target.rb", target_lib_filename)
|
101
101
|
base_name.sub!("plugin.gemspec", "#{plugin_name}.gemspec")
|
102
|
-
output = ERB.new(File.read(file)).result(b)
|
102
|
+
output = ERB.new(File.read(file), trim_mode: "-").result(b)
|
103
103
|
File.open(base_name, 'w') do |file|
|
104
104
|
file.write output
|
105
105
|
end
|
data/lib/cosmos/api/api.rb
CHANGED
@@ -28,36 +28,12 @@ require 'cosmos/api/settings_api'
|
|
28
28
|
require 'cosmos/api/target_api'
|
29
29
|
require 'cosmos/api/tlm_api'
|
30
30
|
require 'cosmos/utilities/authorization'
|
31
|
+
require 'cosmos/topics/topic'
|
31
32
|
|
32
33
|
module Cosmos
|
33
34
|
module Api
|
34
35
|
include Extract
|
35
36
|
include Authorization
|
36
37
|
include ApiShared
|
37
|
-
|
38
|
-
# PRIVATE - Shared by cmd_api and tlm_api
|
39
|
-
|
40
|
-
def _get_cnt(topic)
|
41
|
-
_, packet = Store.instance.read_topic_last(topic)
|
42
|
-
packet ? packet["received_count"].to_i : 0
|
43
|
-
end
|
44
|
-
|
45
|
-
def get_all_cmd_tlm_info(type, scope:, token:)
|
46
|
-
authorize(permission: 'system', scope: scope, token: token)
|
47
|
-
result = []
|
48
|
-
keys = []
|
49
|
-
count = 0
|
50
|
-
loop do
|
51
|
-
count, part = Store.scan(0, :match => "#{scope}__#{type}__*", :count => 1000)
|
52
|
-
keys.concat(part)
|
53
|
-
break if count.to_i == 0
|
54
|
-
end
|
55
|
-
keys.each do |key|
|
56
|
-
_, _, target, packet = key.gsub(/{|}/, '').split('__') # split off scope and type
|
57
|
-
result << [target, packet, _get_cnt(key)]
|
58
|
-
end
|
59
|
-
# Return the results sorted by target, packet
|
60
|
-
result.sort_by { |a| [a[0], a[1]] }
|
61
|
-
end
|
62
38
|
end
|
63
39
|
end
|
data/lib/cosmos/api/cmd_api.rb
CHANGED
@@ -195,7 +195,7 @@ module Cosmos
|
|
195
195
|
authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, scope: scope, token: token)
|
196
196
|
TargetModel.packet(target_name, command_name, type: :CMD, scope: scope)
|
197
197
|
topic = "#{scope}__COMMAND__{#{target_name}}__#{command_name}"
|
198
|
-
msg_id, msg_hash =
|
198
|
+
msg_id, msg_hash = Topic.get_newest_message(topic)
|
199
199
|
if msg_id
|
200
200
|
msg_hash['buffer'] = msg_hash['buffer'].b
|
201
201
|
return msg_hash
|
@@ -302,7 +302,7 @@ module Cosmos
|
|
302
302
|
# @return [Varies] value
|
303
303
|
def get_cmd_value(target_name, command_name, parameter_name, value_type = :CONVERTED, scope: $cosmos_scope, token: $cosmos_token)
|
304
304
|
authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, scope: scope, token: token)
|
305
|
-
|
305
|
+
CommandDecomTopic.get_cmd_item(target_name, command_name, parameter_name, type: value_type, scope: scope)
|
306
306
|
end
|
307
307
|
|
308
308
|
# Returns the time the most recent command was sent
|
@@ -315,7 +315,7 @@ module Cosmos
|
|
315
315
|
def get_cmd_time(target_name = nil, command_name = nil, scope: $cosmos_scope, token: $cosmos_token)
|
316
316
|
authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, scope: scope, token: token)
|
317
317
|
if target_name and command_name
|
318
|
-
time =
|
318
|
+
time = CommandDecomTopic.get_cmd_item(target_name, command_name, 'RECEIVED_TIMESECONDS', type: :CONVERTED, scope: scope)
|
319
319
|
[target_name, command_name, time.to_i, ((time.to_f - time.to_i) * 1_000_000).to_i]
|
320
320
|
else
|
321
321
|
if target_name.nil?
|
@@ -327,7 +327,7 @@ module Cosmos
|
|
327
327
|
time = 0
|
328
328
|
command_name = nil
|
329
329
|
TargetModel.packets(target_name, type: :CMD, scope: scope).each do |packet|
|
330
|
-
cur_time =
|
330
|
+
cur_time = CommandDecomTopic.get_cmd_item(target_name, packet["packet_name"], 'RECEIVED_TIMESECONDS', type: :CONVERTED, scope: scope)
|
331
331
|
next unless cur_time
|
332
332
|
|
333
333
|
if cur_time > time
|
@@ -349,7 +349,7 @@ module Cosmos
|
|
349
349
|
def get_cmd_cnt(target_name, command_name, scope: $cosmos_scope, token: $cosmos_token)
|
350
350
|
authorize(permission: 'system', target_name: target_name, packet_name: command_name, scope: scope, token: token)
|
351
351
|
TargetModel.packet(target_name, command_name, type: :CMD, scope: scope)
|
352
|
-
|
352
|
+
Topic.get_cnt("#{scope}__COMMAND__{#{target_name}}__#{command_name}")
|
353
353
|
end
|
354
354
|
|
355
355
|
# Get information on all command packets
|
@@ -362,7 +362,7 @@ module Cosmos
|
|
362
362
|
TargetModel.packets(target_name, type: :CMD, scope: scope).each do | packet |
|
363
363
|
command_name = packet['packet_name']
|
364
364
|
key = "#{scope}__COMMAND__{#{target_name}}__#{command_name}"
|
365
|
-
result << [target_name, command_name,
|
365
|
+
result << [target_name, command_name, Topic.get_cnt(key)]
|
366
366
|
end
|
367
367
|
end
|
368
368
|
# Return the results sorted by target, packet
|
@@ -17,6 +17,8 @@
|
|
17
17
|
# enterprise edition license of COSMOS if purchased from the
|
18
18
|
# copyright holder
|
19
19
|
|
20
|
+
require 'cosmos/models/tool_config_model'
|
21
|
+
|
20
22
|
module Cosmos
|
21
23
|
module Api
|
22
24
|
WHITELIST ||= []
|
@@ -34,19 +36,23 @@ module Cosmos
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def list_configs(tool, scope: $cosmos_scope, token: $cosmos_token)
|
37
|
-
|
39
|
+
authorize(permission: 'system', scope: scope, token: token)
|
40
|
+
ToolConfigModel.list_configs(tool, scope: scope)
|
38
41
|
end
|
39
42
|
|
40
43
|
def load_config(tool, name, scope: $cosmos_scope, token: $cosmos_token)
|
41
|
-
|
44
|
+
authorize(permission: 'system', scope: scope, token: token)
|
45
|
+
ToolConfigModel.load_config(tool, name, scope: scope)
|
42
46
|
end
|
43
47
|
|
44
48
|
def save_config(tool, name, data, scope: $cosmos_scope, token: $cosmos_token)
|
45
|
-
|
49
|
+
authorize(permission: 'system_set', scope: scope, token: token)
|
50
|
+
ToolConfigModel.save_config(tool, name, data, scope: scope)
|
46
51
|
end
|
47
52
|
|
48
53
|
def delete_config(tool, name, scope: $cosmos_scope, token: $cosmos_token)
|
49
|
-
|
54
|
+
authorize(permission: 'system_set', scope: scope, token: token)
|
55
|
+
ToolConfigModel.delete_config(tool, name, scope: scope)
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
@@ -64,7 +64,7 @@ module Cosmos
|
|
64
64
|
targets.each do |target_name|
|
65
65
|
get_all_telemetry(target_name, scope: scope).each do |packet|
|
66
66
|
topic = "#{scope}__TELEMETRY__{#{target_name}}__#{packet['packet_name']}"
|
67
|
-
_, msg_hash =
|
67
|
+
_, msg_hash = Topic.get_newest_message(topic)
|
68
68
|
unless msg_hash && msg_hash['time'].to_i > stale_time
|
69
69
|
next if with_limits_only && packet['items'].find { |item| item['limits'] }.nil?
|
70
70
|
|
@@ -19,8 +19,6 @@
|
|
19
19
|
|
20
20
|
module Cosmos
|
21
21
|
module Api
|
22
|
-
SETTINGS_KEY = "cosmos__settings"
|
23
|
-
|
24
22
|
WHITELIST ||= []
|
25
23
|
WHITELIST.concat([
|
26
24
|
'list_settings',
|
@@ -31,28 +29,42 @@ module Cosmos
|
|
31
29
|
])
|
32
30
|
|
33
31
|
def list_settings(scope: $cosmos_scope, token: $cosmos_token)
|
34
|
-
|
32
|
+
authorize(permission: 'system', scope: scope, token: token)
|
33
|
+
SettingsModel.names(scope: scope)
|
35
34
|
end
|
36
35
|
|
37
36
|
def get_all_settings(scope: $cosmos_scope, token: $cosmos_token)
|
38
|
-
|
37
|
+
authorize(permission: 'system', scope: scope, token: token)
|
38
|
+
SettingsModel.all(scope: scope)
|
39
39
|
end
|
40
40
|
|
41
41
|
def get_setting(name, scope: $cosmos_scope, token: $cosmos_token)
|
42
|
-
|
42
|
+
authorize(permission: 'system', scope: scope, token: token)
|
43
|
+
setting = SettingsModel.get(name: name, scope: scope)
|
44
|
+
if setting
|
45
|
+
return setting["data"]
|
46
|
+
else
|
47
|
+
return nil
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
51
|
def get_settings(*args, scope: $cosmos_scope, token: $cosmos_token)
|
52
|
+
authorize(permission: 'system', scope: scope, token: token)
|
46
53
|
ret = []
|
47
54
|
args.each do |name|
|
48
|
-
|
55
|
+
setting = SettingsModel.get(name: name, scope: scope)
|
56
|
+
if setting
|
57
|
+
ret << setting["data"]
|
58
|
+
else
|
59
|
+
ret << nil
|
60
|
+
end
|
49
61
|
end
|
50
62
|
return ret
|
51
63
|
end
|
52
64
|
|
53
65
|
def save_setting(name, data, scope: $cosmos_scope, token: $cosmos_token)
|
54
66
|
authorize(permission: 'admin', scope: scope, token: token)
|
55
|
-
|
67
|
+
SettingsModel.set({ name: name, data: data }, scope: scope)
|
56
68
|
end
|
57
69
|
end
|
58
70
|
end
|
@@ -56,12 +56,12 @@ module Cosmos
|
|
56
56
|
cmd_cnt = 0
|
57
57
|
packets = TargetModel.packets(target_name, type: :CMD, scope: scope)
|
58
58
|
packets.each do |packet|
|
59
|
-
cmd_cnt +=
|
59
|
+
cmd_cnt += Topic.get_cnt("#{scope}__COMMAND__{#{target_name}}__#{packet['packet_name']}")
|
60
60
|
end
|
61
61
|
tlm_cnt = 0
|
62
62
|
packets = TargetModel.packets(target_name, type: :TLM, scope: scope)
|
63
63
|
packets.each do |packet|
|
64
|
-
tlm_cnt +=
|
64
|
+
tlm_cnt += Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet['packet_name']}")
|
65
65
|
end
|
66
66
|
interface_name = ''
|
67
67
|
InterfaceModel.all(scope: scope).each do |name, interface|
|
data/lib/cosmos/api/tlm_api.rb
CHANGED
@@ -190,7 +190,7 @@ module Cosmos
|
|
190
190
|
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
191
191
|
TargetModel.packet(target_name, packet_name, scope: scope)
|
192
192
|
topic = "#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
|
193
|
-
msg_id, msg_hash =
|
193
|
+
msg_id, msg_hash = Topic.get_newest_message(topic)
|
194
194
|
if msg_id
|
195
195
|
msg_hash['buffer'] = msg_hash['buffer'].b
|
196
196
|
return msg_hash
|
@@ -300,7 +300,7 @@ module Cosmos
|
|
300
300
|
packets.each do |target_name, packet_name|
|
301
301
|
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
302
302
|
topic = "#{scope}__DECOM__{#{target_name}}__#{packet_name}"
|
303
|
-
id, _ =
|
303
|
+
id, _ = Topic.get_newest_message(topic)
|
304
304
|
result[topic] = id ? id : '0-0'
|
305
305
|
end
|
306
306
|
result.to_a.join(SUBSCRIPTION_DELIMITER)
|
@@ -317,13 +317,13 @@ module Cosmos
|
|
317
317
|
authorize(permission: 'tlm', scope: scope, token: token)
|
318
318
|
# Split the list of topic, ID values and turn it into a hash for easy updates
|
319
319
|
lookup = Hash[*id.split(SUBSCRIPTION_DELIMITER)]
|
320
|
-
xread =
|
320
|
+
xread = Topic.read_topics(lookup.keys, lookup.values, block, count)
|
321
321
|
# Return the original ID and nil if we didn't get anything
|
322
322
|
return [id, nil] if xread.empty?
|
323
323
|
packets = []
|
324
324
|
xread.each do |topic, data|
|
325
325
|
data.each do |id, msg_hash|
|
326
|
-
lookup[topic] = id #
|
326
|
+
lookup[topic] = id # save the new ID
|
327
327
|
json_hash = JSON.parse(msg_hash['json_data'])
|
328
328
|
msg_hash.delete('json_data')
|
329
329
|
packets << msg_hash.merge(json_hash)
|
@@ -340,7 +340,7 @@ module Cosmos
|
|
340
340
|
def get_tlm_cnt(target_name, packet_name, scope: $cosmos_scope, token: $cosmos_token)
|
341
341
|
authorize(permission: 'system', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
342
342
|
TargetModel.packet(target_name, packet_name, scope: scope)
|
343
|
-
|
343
|
+
Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}")
|
344
344
|
end
|
345
345
|
|
346
346
|
# Get information on all telemetry packets
|
@@ -353,12 +353,12 @@ module Cosmos
|
|
353
353
|
TargetModel.packets(target_name, scope: scope).each do | packet |
|
354
354
|
packet_name = packet['packet_name']
|
355
355
|
key = "#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
|
356
|
-
result << [target_name, packet_name,
|
356
|
+
result << [target_name, packet_name, Topic.get_cnt(key)]
|
357
357
|
end
|
358
358
|
end
|
359
359
|
['UNKNOWN'].each do | x |
|
360
360
|
key = "#{scope}__TELEMETRY__{#{x}}__#{x}"
|
361
|
-
result << [x, x,
|
361
|
+
result << [x, x, Topic.get_cnt(key)]
|
362
362
|
end
|
363
363
|
# Return the result sorted by target, packet
|
364
364
|
result.sort_by { |a| [a[0], a[1]] }
|
@@ -425,7 +425,7 @@ module Cosmos
|
|
425
425
|
TargetModel.packets(target_name, scope: scope).each do |packet|
|
426
426
|
item = packet['items'].find { |item| item['name'] == item_name }
|
427
427
|
if item
|
428
|
-
_, msg_hash =
|
428
|
+
_, msg_hash = Topic.get_oldest_message("#{scope}__DECOM__{#{target_name}}__#{packet['packet_name']}")
|
429
429
|
if msg_hash && msg_hash['time'] && msg_hash['time'].to_i > latest
|
430
430
|
packet_name = packet['packet_name']
|
431
431
|
latest = msg_hash['time'].to_i
|
@@ -168,7 +168,7 @@ module Cosmos
|
|
168
168
|
path = File.join(File.dirname(@filename), template_name)
|
169
169
|
end
|
170
170
|
Cosmos.set_working_dir(File.dirname(path)) do
|
171
|
-
return ERB.new(File.read(path)).result(b)
|
171
|
+
return ERB.new(File.read(path), trim_mode: "-").result(b)
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -377,7 +377,7 @@ module Cosmos
|
|
377
377
|
output = nil
|
378
378
|
if run_erb
|
379
379
|
Cosmos.set_working_dir(File.dirname(filename)) do
|
380
|
-
output = ERB.new(File.read(filename)).result(binding.set_variables(variables))
|
380
|
+
output = ERB.new(File.read(filename), trim_mode: "-").result(binding.set_variables(variables))
|
381
381
|
end
|
382
382
|
else
|
383
383
|
output = File.read(filename)
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
require 'thread'
|
21
21
|
require 'cosmos/config/config_parser'
|
22
|
-
require 'cosmos/
|
22
|
+
require 'cosmos/topics/topic'
|
23
23
|
require 'cosmos/utilities/s3'
|
24
24
|
|
25
25
|
module Cosmos
|
@@ -211,7 +211,7 @@ module Cosmos
|
|
211
211
|
S3Utilities.move_log_file_to_s3(@filename, s3_key)
|
212
212
|
# Now that the file is in S3, trim the Redis stream up until the previous file.
|
213
213
|
# This keeps one file worth of data in Redis as a safety buffer
|
214
|
-
|
214
|
+
Topic.trim_topic(@redis_topic, @previous_file_redis_offset) if @redis_topic and @previous_file_redis_offset
|
215
215
|
@previous_file_redis_offset = @last_offset
|
216
216
|
rescue Exception => err
|
217
217
|
Logger.instance.error "Error closing #{@filename} : #{err.formatted}"
|
@@ -143,7 +143,6 @@ module Cosmos
|
|
143
143
|
hazardous, hazardous_description = System.commands.cmd_pkt_hazardous?(command)
|
144
144
|
# Return back the error, description, and the formatted command
|
145
145
|
# This allows the error handler to simply re-send the command
|
146
|
-
# TODO: Should we set target_name, cmd_name, and cmd_params instead?
|
147
146
|
next "HazardousError\n#{hazardous_description}\n#{System.commands.format(command)}" if hazardous
|
148
147
|
end
|
149
148
|
|
@@ -40,7 +40,7 @@ module Cosmos
|
|
40
40
|
attr_accessor :scope
|
41
41
|
|
42
42
|
def self.run
|
43
|
-
microservice = self.new(
|
43
|
+
microservice = self.new(ENV['COSMOS_MICROSERVICE_NAME'])
|
44
44
|
begin
|
45
45
|
MicroserviceStatusModel.set(microservice.as_json, scope: microservice.scope)
|
46
46
|
microservice.state = 'RUNNING'
|
@@ -52,7 +52,7 @@ module Cosmos
|
|
52
52
|
else
|
53
53
|
microservice.error = err
|
54
54
|
microservice.state = 'DIED_ERROR'
|
55
|
-
Logger.fatal("Microservice #{
|
55
|
+
Logger.fatal("Microservice #{ENV['COSMOS_MICROSERVICE_NAME']} dying from exception\n#{err.formatted}")
|
56
56
|
end
|
57
57
|
ensure
|
58
58
|
MicroserviceStatusModel.set(microservice.as_json, scope: microservice.scope)
|
@@ -96,9 +96,8 @@ module Cosmos
|
|
96
96
|
ReducerModel
|
97
97
|
.all_files(type: :DECOM, target: @target_name, scope: @scope)
|
98
98
|
.each do |file|
|
99
|
-
|
100
|
-
|
101
|
-
end
|
99
|
+
process_file(file, 'minute', MINUTE_ENTRY_SECS, MINUTE_FILE_SECS)
|
100
|
+
ReducerModel.rm_file(file)
|
102
101
|
end
|
103
102
|
end
|
104
103
|
end
|
@@ -108,9 +107,8 @@ module Cosmos
|
|
108
107
|
ReducerModel
|
109
108
|
.all_files(type: :MINUTE, target: @target_name, scope: @scope)
|
110
109
|
.each do |file|
|
111
|
-
|
112
|
-
|
113
|
-
end
|
110
|
+
process_file(file, 'hour', HOUR_ENTRY_SECS, HOUR_FILE_SECS)
|
111
|
+
ReducerModel.rm_file(file)
|
114
112
|
end
|
115
113
|
end
|
116
114
|
end
|
@@ -120,9 +118,8 @@ module Cosmos
|
|
120
118
|
ReducerModel
|
121
119
|
.all_files(type: :HOUR, target: @target_name, scope: @scope)
|
122
120
|
.each do |file|
|
123
|
-
|
124
|
-
|
125
|
-
end
|
121
|
+
process_file(file, 'day', DAY_ENTRY_SECS, DAY_FILE_SECS)
|
122
|
+
ReducerModel.rm_file(file)
|
126
123
|
end
|
127
124
|
end
|
128
125
|
end
|
@@ -250,7 +247,12 @@ module Cosmos
|
|
250
247
|
)
|
251
248
|
true
|
252
249
|
rescue => e
|
253
|
-
|
250
|
+
if file.local_path and File.exist?(file.local_path)
|
251
|
+
Logger.error("Reducer Error: #{filename}:#{File.size(file.local_path)} bytes: \n#{e.formatted}")
|
252
|
+
else
|
253
|
+
Logger.error("Reducer Error: #{filename}:(Not Retrieved): \n#{e.formatted}")
|
254
|
+
end
|
255
|
+
false
|
254
256
|
end
|
255
257
|
|
256
258
|
def reduce(type, data_keys, reduced)
|
@@ -40,12 +40,12 @@ module Cosmos
|
|
40
40
|
|
41
41
|
# Delete the current value table for a target
|
42
42
|
def self.del(target_name:, packet_name:, scope:)
|
43
|
-
|
43
|
+
EphemeralStore.hdel("#{scope}__tlm__#{target_name}", packet_name)
|
44
44
|
end
|
45
45
|
|
46
46
|
# Set the current value table for a target, packet
|
47
47
|
def self.set(hash, target_name:, packet_name:, scope:)
|
48
|
-
|
48
|
+
EphemeralStore.hset("#{scope}__tlm__#{target_name}", packet_name, JSON.generate(hash.as_json))
|
49
49
|
end
|
50
50
|
|
51
51
|
# Set an item in the current value table
|
@@ -62,9 +62,9 @@ module Cosmos
|
|
62
62
|
else
|
63
63
|
raise "Unknown type '#{type}' for #{target_name} #{packet_name} #{item_name}"
|
64
64
|
end
|
65
|
-
hash = JSON.parse(
|
65
|
+
hash = JSON.parse(EphemeralStore.hget("#{scope}__tlm__#{target_name}", packet_name))
|
66
66
|
hash[field] = value
|
67
|
-
|
67
|
+
EphemeralStore.hset("#{scope}__tlm__#{target_name}", packet_name, JSON.generate(hash.as_json))
|
68
68
|
end
|
69
69
|
|
70
70
|
# Get an item from the current value table
|
@@ -86,7 +86,7 @@ module Cosmos
|
|
86
86
|
else
|
87
87
|
raise "Unknown type '#{type}' for #{target_name} #{packet_name} #{item_name}"
|
88
88
|
end
|
89
|
-
hash = JSON.parse(
|
89
|
+
hash = JSON.parse(EphemeralStore.hget("#{scope}__tlm__#{target_name}", packet_name))
|
90
90
|
hash.values_at(*types).each do |result|
|
91
91
|
return result if result
|
92
92
|
end
|
@@ -106,7 +106,7 @@ module Cosmos
|
|
106
106
|
|
107
107
|
lookups.each do |target_packet_key, target_name, packet_name, packet_values|
|
108
108
|
unless packet_lookup[target_packet_key]
|
109
|
-
packet =
|
109
|
+
packet = EphemeralStore.hget("#{scope}__tlm__#{target_name}", packet_name)
|
110
110
|
raise "Packet '#{target_name} #{packet_name}' does not exist" unless packet
|
111
111
|
packet_lookup[target_packet_key] = JSON.parse(packet)
|
112
112
|
end
|
@@ -73,7 +73,7 @@ module Cosmos
|
|
73
73
|
return nil
|
74
74
|
end
|
75
75
|
|
76
|
-
def self.install(name_or_path)
|
76
|
+
def self.install(name_or_path, scope:)
|
77
77
|
temp_dir = Dir.mktmpdir
|
78
78
|
begin
|
79
79
|
if File.exist?(name_or_path)
|
@@ -81,7 +81,7 @@ module Cosmos
|
|
81
81
|
else
|
82
82
|
gem_file_path = get(temp_dir, name_or_path)
|
83
83
|
end
|
84
|
-
rubygems_url = get_setting('rubygems_url')
|
84
|
+
rubygems_url = get_setting('rubygems_url', scope: scope)
|
85
85
|
Gem.sources = [rubygems_url] if rubygems_url
|
86
86
|
Gem.done_installing_hooks.clear
|
87
87
|
Gem.install(gem_file_path, "> 0.pre", :build_args => ['--no-document'], :prerelease => true)
|
@@ -23,7 +23,7 @@ module Cosmos
|
|
23
23
|
# Stores the status about an interface. This class also implements logic
|
24
24
|
# to handle status for a router since the functionality is identical
|
25
25
|
# (only difference is the Redis key used).
|
26
|
-
class InterfaceStatusModel <
|
26
|
+
class InterfaceStatusModel < EphemeralModel
|
27
27
|
INTERFACES_PRIMARY_KEY = 'cosmos_interface_status'
|
28
28
|
ROUTERS_PRIMARY_KEY = 'cosmos_router_status'
|
29
29
|
|