Class: JIJI::Service::OutputService
- Inherits:
-
Object
- Object
- JIJI::Service::OutputService
- Defined in:
- lib/jiji/service/output_service.rb
Instance Attribute Summary collapse
-
#output_manager ⇒ Object
Returns the value of attribute output_manager.
-
#process_dir ⇒ Object
Returns the value of attribute process_dir.
-
#process_manager ⇒ Object
Returns the value of attribute process_manager.
Instance Method Summary collapse
-
#delete_output(process_id, agent_id) ⇒ Object
プロセスの出力を削除する.
-
#get_log(process_id) ⇒ Object
プロセスのログを取得する.
-
#list_datas(process_id, names, scale, start_time, end_time) ⇒ Object
指定範囲の出力データを取得する。.
-
#list_outputs(process_id) ⇒ Object
プロセスの出力一覧を取得する.
-
#set_properties(process_id, agent_id, output_name, properties) ⇒ Object
アウトプットのプロパティを設定.
Instance Attribute Details
#output_manager ⇒ Object
Returns the value of attribute output_manager.
73 74 75 |
# File 'lib/jiji/service/output_service.rb', line 73 def output_manager @output_manager end |
#process_dir ⇒ Object
Returns the value of attribute process_dir.
71 72 73 |
# File 'lib/jiji/service/output_service.rb', line 71 def process_dir @process_dir end |
#process_manager ⇒ Object
Returns the value of attribute process_manager.
72 73 74 |
# File 'lib/jiji/service/output_service.rb', line 72 def process_manager @process_manager end |
Instance Method Details
#delete_output(process_id, agent_id) ⇒ Object
プロセスの出力を削除する
44 45 46 47 |
# File 'lib/jiji/service/output_service.rb', line 44 def delete_output( process_id, agent_id ) output_manager.delete( process_id, agent_id ) :success end |
#get_log(process_id) ⇒ Object
プロセスのログを取得する
61 62 63 64 65 66 67 68 69 |
# File 'lib/jiji/service/output_service.rb', line 61 def get_log( process_id ) process_manager.get( process_id ) # プロセスの存在確認 file = "#{@process_dir}/#{process_id}/log.txt" # TODO 古いものも連結するか? サイズが大きくなってしまうので微妙。 if ( File.exist?( file ) ) return IO.read( file ) else return "" end end |
#list_datas(process_id, names, scale, start_time, end_time) ⇒ Object
指定範囲の出力データを取得する。
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jiji/service/output_service.rb', line 6 def list_datas( process_id, names, scale, start_time, end_time ) map = output_manager.get_process_map( process_id ) list = {} names.each {|n| buff = [] outputs = map[n[0]] next unless outputs outputs.get(n[1]).each( scale, Time.at(start_time), Time.at(end_time) ) {|data| buff << data } list[n[0]] ||= {} list[n[0]][n[1]] = buff } return list end |
#list_outputs(process_id) ⇒ Object
プロセスの出力一覧を取得する
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jiji/service/output_service.rb', line 24 def list_outputs( process_id ) buff = {} rmt_process = nil rmt_process = process_manager.get( process_id ) if ( process_id == "rmt" ) output_manager.each( process_id ) {|outputs| buff[outputs.agent_id] = { "agent_id"=>outputs.agent_id, "agent_name"=>outputs.agent_name, "outputs"=>outputs.inject({}) {|r,v| r[v[0]] = v[1]. r }, "alive"=> process_id == "rmt" && is_live_agent( rmt_process["agents"], outputs.agent_id ) } } buff end |
#set_properties(process_id, agent_id, output_name, properties) ⇒ Object
アウトプットのプロパティを設定
50 51 52 53 54 55 56 57 58 |
# File 'lib/jiji/service/output_service.rb', line 50 def set_properties( process_id, agent_id, output_name, properties ) outputs = output_manager.get( process_id, agent_id ) unless outputs.exist? output_name raise UserError.new( JIJI::ERROR_NOT_FOUND, "output not found. name=#{agent_id}:#{output_name}") end out = outputs.get(output_name) out.set_properties( properties ) return :success end |