unageanu-jiji 1.1.4 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +24 -1
- data/README +0 -0
- data/base/shared_lib/moving_average.rb +34 -33
- data/base/shared_lib/system/cross.rb +76 -0
- data/base/shared_lib/system/position_manager.rb +160 -0
- data/base/shared_lib/system/signal.rb +347 -0
- data/html/css/datatable.css +4 -4
- data/html/css/default.css +57 -5
- data/html/css/treeview.css +205 -0
- data/html/img/bin_closed.png +0 -0
- data/html/img/bin_empty.png +0 -0
- data/html/img/button_add_small.gif +0 -0
- data/html/img/button_add_small_gray.gif +0 -0
- data/html/img/button_add_small_over.gif +0 -0
- data/html/img/button_mkcol.gif +0 -0
- data/html/img/button_mkcol_gray.gif +0 -0
- data/html/img/button_mkcol_over.gif +0 -0
- data/html/img/button_remove_small.gif +0 -0
- data/html/img/button_remove_small_gray.gif +0 -0
- data/html/img/button_remove_small_over.gif +0 -0
- data/html/img/button_rename.gif +0 -0
- data/html/img/button_rename_gray.gif +0 -0
- data/html/img/button_rename_over.gif +0 -0
- data/html/img/control_play.png +0 -0
- data/html/img/control_play_blue.png +0 -0
- data/html/img/folder.png +0 -0
- data/html/img/folder_brick.png +0 -0
- data/html/img/folder_user.png +0 -0
- data/html/{js/codepress/images → img}/line-numbers.png +0 -0
- data/html/img/page_white_ruby.png +0 -0
- data/html/img/sidebar_agent_edit.png +0 -0
- data/html/img/sidebar_agent_edit_over.png +0 -0
- data/html/img/sidebar_agent_edit_s.png +0 -0
- data/html/img/yui/treeview-sprite.gif +0 -0
- data/html/index.html +34 -18
- data/html/js/agent-editor/agent-editor-page.js +324 -0
- data/html/js/agent-editor/agent-editor.js +363 -0
- data/html/js/agent-editor/agent-list-tree.js +251 -0
- data/html/js/agent-selector.js +23 -28
- data/html/js/app.js +63 -91
- data/html/js/bt-create-page.js +25 -19
- data/html/js/container-min.js +1 -1
- data/html/js/container.js +944 -0
- data/html/js/edit_area/autocompletion.js +11 -13
- data/html/js/edit_area/edit_area.css +79 -40
- data/html/js/edit_area/edit_area.js +255 -226
- data/html/js/edit_area/edit_area_compressor.php +4 -4
- data/html/js/edit_area/edit_area_full.gz +0 -0
- data/html/js/edit_area/edit_area_full.js +31 -31
- data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
- data/html/js/edit_area/edit_area_full_with_plugins.js +31 -31
- data/html/js/edit_area/edit_area_functions.js +448 -341
- data/html/js/edit_area/edit_area_loader.js +409 -397
- data/html/js/edit_area/elements_functions.js +120 -123
- data/html/js/edit_area/highlight.js +305 -197
- data/html/js/edit_area/images/goto.png +0 -0
- data/html/js/edit_area/images/help.png +0 -0
- data/html/js/edit_area/images/redo.png +0 -0
- data/html/js/edit_area/images/save.png +0 -0
- data/html/js/edit_area/images/search.png +0 -0
- data/html/js/edit_area/images/undo.png +0 -0
- data/html/js/edit_area/images/word_wrap.gif +0 -0
- data/html/js/edit_area/keyboard.js +5 -5
- data/html/js/edit_area/langs/bg.js +73 -0
- data/html/js/edit_area/langs/cs.js +2 -0
- data/html/js/edit_area/langs/de.js +2 -0
- data/html/js/edit_area/langs/dk.js +2 -0
- data/html/js/edit_area/langs/en.js +2 -0
- data/html/js/edit_area/langs/eo.js +2 -0
- data/html/js/edit_area/langs/es.js +2 -0
- data/html/js/edit_area/langs/fi.js +67 -0
- data/html/js/edit_area/langs/fr.js +2 -0
- data/html/js/edit_area/langs/hr.js +2 -0
- data/html/js/edit_area/langs/it.js +2 -0
- data/html/js/edit_area/langs/ja.js +2 -0
- data/html/js/edit_area/langs/mk.js +2 -0
- data/html/js/edit_area/langs/nl.js +2 -0
- data/html/js/edit_area/langs/pl.js +2 -0
- data/html/js/edit_area/langs/pt.js +2 -0
- data/html/js/edit_area/langs/ru.js +2 -0
- data/html/js/edit_area/langs/sk.js +2 -0
- data/html/js/edit_area/langs/zh.js +67 -0
- data/html/js/edit_area/manage_area.js +362 -205
- data/html/js/edit_area/plugins/charmap/langs/bg.js +12 -0
- data/html/js/edit_area/plugins/charmap/langs/zh.js +6 -0
- data/html/js/edit_area/plugins/test/langs/bg.js +10 -0
- data/html/js/edit_area/plugins/test/langs/zh.js +4 -0
- data/html/js/edit_area/reg_syntax/java.js +56 -0
- data/html/js/edit_area/reg_syntax/ruby.js +9 -9
- data/html/js/edit_area/reg_syntax.js +15 -13
- data/html/js/edit_area/regexp.js +36 -32
- data/html/js/edit_area/resize_area.js +43 -47
- data/html/js/edit_area/search_replace.js +29 -29
- data/html/js/edit_area/template.html +6 -4
- data/html/js/json-broker-client.js +23 -17
- data/html/js/result-page.js +107 -57
- data/html/js/rt-setting-page.js +38 -15
- data/html/js/sidebar.js +41 -27
- data/html/js/templates.js +167 -32
- data/html/js/utils.js +143 -7
- data/html/js/yui/treeview.js +3671 -0
- data/html/swf/chart.swf +0 -0
- data/html/test/agent_editor_spec.js +815 -0
- data/html/test/index.html +40 -0
- data/html/test/jsspec/JSSpec.css +224 -0
- data/html/test/jsspec/JSSpec.js +1549 -0
- data/html/test/jsspec/diff_match_patch.js +1 -0
- data/html/test/utils_spec.js +111 -0
- data/lib/jiji/agent/agent.rb +69 -12
- data/lib/jiji/agent/agent_manager.rb +18 -12
- data/lib/jiji/agent/agent_registry.rb +35 -121
- data/lib/jiji/collector.rb +16 -6
- data/lib/jiji/command.rb +46 -5
- data/lib/jiji/dao/file_system_dao.rb +158 -0
- data/lib/jiji/dao/timed_data_dao.rb +2 -0
- data/lib/jiji/dao/trade_result_dao.rb +1 -1
- data/lib/jiji/error.rb +24 -8
- data/lib/jiji/migration/migrator1_2_0.rb +67 -0
- data/lib/jiji/models.rb +82 -24
- data/lib/jiji/operator.rb +55 -51
- data/lib/jiji/output.rb +85 -29
- data/lib/jiji/output_manager.rb +84 -0
- data/lib/jiji/plugin/embedded/single_click_client.rb +2 -2
- data/lib/jiji/plugin/securities_plugin.rb +0 -1
- data/lib/jiji/process.rb +229 -208
- data/lib/jiji/process_manager.rb +190 -96
- data/lib/jiji/registry.rb +87 -19
- data/lib/jiji/server.rb +1 -0
- data/lib/jiji/service/agent_service.rb +147 -48
- data/lib/jiji/service/output_service.rb +37 -17
- data/lib/jiji/service/process_service.rb +3 -5
- data/lib/jiji/service/trade_result_service.rb +4 -5
- data/lib/jiji/util/file_lock.rb +4 -4
- data/lib/jiji/util/include_proxy.rb +17 -0
- data/lib/jiji/util/json_broker.rb +6 -4
- data/lib/jiji/util/util.rb +1 -1
- data/swf/chart/fx/chart/Chart.as +7 -0
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +15 -2
- data/test/ProcessTest/agents/foo.rb +10 -0
- data/test/ProcessTest/conf/configuration.yaml +3 -0
- data/test/agent/agent_tests.rb +10 -0
- data/test/agent/test_AgentManager.rb +28 -12
- data/test/agent/test_AgentRegistry.rb +194 -99
- data/test/agent/test_PeriodicallyAgent.rb +1 -2
- data/test/agent/test_Permitter.rb +1 -2
- data/test/all_tests.rb +7 -19
- data/test/dao/dao_tests.rb +9 -0
- data/test/dao/test_FileSystemDao.rb +431 -0
- data/test/dao/test_RateDao.rb +5 -7
- data/test/dao/test_TradeResultDao.rb +1 -2
- data/test/migration/migration_tests.rb +10 -0
- data/test/migration/migrator1_2_0test_data/basic/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/basic/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/props.yaml +1 -0
- data/test/migration/migrator1_2_0test_data/no_outs/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/test_Migrator.rb +1 -1
- data/test/migration/test_Migrator1_0_3.rb +1 -1
- data/test/migration/test_Migrator1_1_0.rb +1 -1
- data/test/migration/test_Migrator1_2_0.rb +94 -0
- data/test/plugin/embedded/test_SingleClickClient.rb +1 -2
- data/test/plugin/plugin_tests.rb +8 -0
- data/test/plugin/test_Loader.rb +1 -1
- data/test/shared/rate.csv +144 -0
- data/test/shared/shared_tests.rb +9 -0
- data/test/shared/test_Cross.rb +144 -0
- data/test/shared/test_PositionManager.rb +285 -0
- data/test/shared/test_Signal.rb +65 -0
- data/test/test_Output.rb +28 -21
- data/test/test_OutputManager.rb +162 -0
- data/test/test_Output_registry.rb +6 -17
- data/test/test_Process.rb +434 -222
- data/test/test_ProcessManager.rb +458 -101
- data/test/test_utils.rb +71 -8
- data/test/util/test_BlockToSession.rb +1 -2
- data/test/util/test_CSV.rb +1 -2
- data/test/util/test_SynchronizeInterceptor.rb +1 -2
- data/test/util/util_tests.rb +9 -0
- metadata +127 -47
- data/html/js/agent-editor-page.js +0 -440
- data/html/js/codepress/codepress.css +0 -21
- data/html/js/codepress/codepress.html +0 -35
- data/html/js/codepress/codepress.js +0 -138
- data/html/js/codepress/engines/gecko.js +0 -293
- data/html/js/codepress/engines/khtml.js +0 -0
- data/html/js/codepress/engines/msie.js +0 -304
- data/html/js/codepress/engines/older.js +0 -0
- data/html/js/codepress/engines/opera.js +0 -260
- data/html/js/codepress/images/line-numbers.gif +0 -0
- data/html/js/codepress/index.html +0 -443
- data/html/js/codepress/languages/asp.css +0 -71
- data/html/js/codepress/languages/asp.js +0 -117
- data/html/js/codepress/languages/autoit.css +0 -13
- data/html/js/codepress/languages/autoit.js +0 -32
- data/html/js/codepress/languages/csharp.css +0 -9
- data/html/js/codepress/languages/csharp.js +0 -25
- data/html/js/codepress/languages/css.css +0 -10
- data/html/js/codepress/languages/css.js +0 -23
- data/html/js/codepress/languages/generic.css +0 -9
- data/html/js/codepress/languages/generic.js +0 -25
- data/html/js/codepress/languages/html.css +0 -13
- data/html/js/codepress/languages/html.js +0 -59
- data/html/js/codepress/languages/java.css +0 -7
- data/html/js/codepress/languages/java.js +0 -24
- data/html/js/codepress/languages/javascript.css +0 -8
- data/html/js/codepress/languages/javascript.js +0 -30
- data/html/js/codepress/languages/perl.css +0 -11
- data/html/js/codepress/languages/perl.js +0 -27
- data/html/js/codepress/languages/php.css +0 -12
- data/html/js/codepress/languages/php.js +0 -61
- data/html/js/codepress/languages/ruby.css +0 -10
- data/html/js/codepress/languages/ruby.js +0 -26
- data/html/js/codepress/languages/sql.css +0 -10
- data/html/js/codepress/languages/sql.js +0 -30
- data/html/js/codepress/languages/text.css +0 -5
- data/html/js/codepress/languages/text.js +0 -9
- data/html/js/codepress/languages/vbscript.css +0 -71
- data/html/js/codepress/languages/vbscript.js +0 -117
- data/html/js/codepress/languages/xsl.css +0 -15
- data/html/js/codepress/languages/xsl.js +0 -103
- data/html/js/codepress/license.txt +0 -458
- data/html/js/edit_area/images/Thumbs.db +0 -0
- data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +0 -6
@@ -14,14 +14,15 @@ module JIJI
|
|
14
14
|
include JIJI::AgentUtil
|
15
15
|
|
16
16
|
# ファイルの一覧を取得する
|
17
|
-
def list_files(
|
18
|
-
|
17
|
+
def list_files( path )
|
18
|
+
check_path path
|
19
|
+
@dao.list( path )
|
19
20
|
end
|
20
21
|
|
21
22
|
# ファイルの内容を取得する
|
22
|
-
def get_file(
|
23
|
-
|
24
|
-
@
|
23
|
+
def get_file( path )
|
24
|
+
check_path path
|
25
|
+
@dao.get( path )
|
25
26
|
end
|
26
27
|
|
27
28
|
|
@@ -30,32 +31,141 @@ module JIJI
|
|
30
31
|
@agent_registry.inject([]) {|list,name|
|
31
32
|
next unless name =~ /([^@]+)@([^@]+)/
|
32
33
|
list << {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
:class_name=>$1,
|
35
|
+
:file_name=>$2,
|
36
|
+
:properties=>@agent_registry.get_property_infos(name),
|
37
|
+
:description=>@agent_registry.get_description(name)
|
37
38
|
}
|
38
39
|
list
|
39
40
|
}
|
40
41
|
end
|
41
42
|
|
42
43
|
# ファイルを追加/更新する
|
43
|
-
def put_file(
|
44
|
-
|
45
|
-
@
|
44
|
+
def put_file( path, body )
|
45
|
+
check_path path
|
46
|
+
@dao.put( path, body )
|
47
|
+
@agent_registry.load( path )
|
48
|
+
:success
|
49
|
+
end
|
50
|
+
|
51
|
+
# ファイルを追加する
|
52
|
+
def add_file( path, body )
|
53
|
+
check_path path
|
54
|
+
@dao.add( path, body )
|
55
|
+
@agent_registry.load( path )
|
56
|
+
:success
|
46
57
|
end
|
47
58
|
|
48
59
|
# ファイルを削除する
|
49
|
-
def
|
50
|
-
|
51
|
-
|
60
|
+
def remove( paths )
|
61
|
+
result = {:success=>{},:failed=>{}}
|
62
|
+
targets = {}
|
63
|
+
paths.each {|path|
|
64
|
+
begin
|
65
|
+
check_path path
|
66
|
+
# agents, sharedは削除できない
|
67
|
+
if path =~ /^(#{@agent_dir}|#{@shared_lib_dir})$/
|
68
|
+
raise JIJI::UserError.new( ERROR_ILLEGAL_NAME, "illegal path. path=#{path}" )
|
69
|
+
end
|
70
|
+
targets[path] = @dao.directory?(path) \
|
71
|
+
? targets[path] = @dao.list( path, true ).map{|item| item[:path]} \
|
72
|
+
: [path]
|
73
|
+
rescue Exception
|
74
|
+
result[:failed][path] = mk_error_info(path,$!)
|
75
|
+
end
|
76
|
+
}
|
77
|
+
targets.each_pair {|path, files|
|
78
|
+
begin
|
79
|
+
@dao.delete( path )
|
80
|
+
result[:success][path] = {:path=>path}
|
81
|
+
rescue Exception
|
82
|
+
result[:failed][path] = mk_error_info(path,$!)
|
83
|
+
next
|
84
|
+
end
|
85
|
+
begin
|
86
|
+
files.each {|f|
|
87
|
+
@agent_registry.unload(f)
|
88
|
+
}
|
89
|
+
rescue Exception
|
90
|
+
#ロードで発生したエラーはログ出力のみして握る
|
91
|
+
server_logger.error $!
|
92
|
+
end
|
93
|
+
}
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
97
|
+
# ファイルを移動する
|
98
|
+
def move( files, to )
|
99
|
+
check_path to
|
100
|
+
result = {:success=>{},:failed=>{}}
|
101
|
+
targets = {}
|
102
|
+
files.each {|path|
|
103
|
+
begin
|
104
|
+
check_path path
|
105
|
+
targets[path] = @dao.directory?(path) \
|
106
|
+
? targets[path] = @dao.list( path, true ).map{|item| item[:path]} \
|
107
|
+
: [path]
|
108
|
+
rescue Exception
|
109
|
+
result[:failed][path] = mk_error_info(path,$!)
|
110
|
+
end
|
52
111
|
}
|
53
|
-
|
54
|
-
|
112
|
+
targets.each_pair {|path,files|
|
113
|
+
begin
|
114
|
+
@dao.move( from, to )
|
115
|
+
result[:success][path] = {:path=>path}
|
116
|
+
rescue Exception
|
117
|
+
result[:failed][path] = mk_error_info(path,$!)
|
118
|
+
next
|
119
|
+
end
|
120
|
+
begin
|
121
|
+
files.each {|f|
|
122
|
+
@agent_registry.unload(f)
|
123
|
+
}
|
124
|
+
@dao.list( "#{to}/#{File.basename(from)}", true ) {|f|
|
125
|
+
@agent_registry.load(f)
|
126
|
+
}
|
127
|
+
rescue Exception
|
128
|
+
#ロードで発生したエラーはログ出力のみして握る
|
129
|
+
server_logger.error $!
|
130
|
+
end
|
55
131
|
}
|
132
|
+
result
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
# ファイルを移動する
|
137
|
+
def rename( path, new_name )
|
138
|
+
check_path path
|
139
|
+
# agents, sharedはリネームできない
|
140
|
+
if path =~ /^(#{@agent_dir}|#{@shared_lib_dir})$/
|
141
|
+
raise JIJI::UserError.new( ERROR_ILLEGAL_NAME, "illegal path. path=#{path}" )
|
142
|
+
end
|
143
|
+
new_path = "#{File.dirname(path)}/#{new_name}"
|
144
|
+
files = @dao.directory?(path) ? @dao.list( path, true ).reject{|item|
|
145
|
+
item[:type] == :directory
|
146
|
+
}.map {|item|
|
147
|
+
item[:path]
|
148
|
+
} : [path]
|
149
|
+
@dao.rename( path, new_path )
|
150
|
+
begin
|
151
|
+
files.each {|f|
|
152
|
+
server_logger.info f
|
153
|
+
@agent_registry.unload(f)
|
154
|
+
@agent_registry.load( f.sub( path, new_path ))
|
155
|
+
}
|
156
|
+
rescue Exception
|
157
|
+
#ロードで発生したエラーはログ出力のみして握る
|
158
|
+
server_logger.error $!
|
159
|
+
end
|
56
160
|
:success
|
57
161
|
end
|
58
162
|
|
163
|
+
# フォルダを作成する
|
164
|
+
def mkcol( path )
|
165
|
+
check_path path
|
166
|
+
@dao.mkcol( path )
|
167
|
+
:success
|
168
|
+
end
|
59
169
|
|
60
170
|
# プロセスに登録されているエージェントの一覧を得る
|
61
171
|
def list_agent( process_id )
|
@@ -64,39 +174,18 @@ module JIJI
|
|
64
174
|
p.agent_manager.collect.map! {|entry|
|
65
175
|
props = entry[1].agent.properties
|
66
176
|
{
|
67
|
-
|
68
|
-
|
177
|
+
:name=>entry[0],
|
178
|
+
:properties=>entry[1].agent.property_infos.map! {|info|
|
69
179
|
prop = props.find() {|e| e[0] == info.id.to_s }
|
70
|
-
{
|
180
|
+
{ :id=>info.id.to_s, :info=>info, :value=> prop ? prop[1] : nil }
|
71
181
|
},
|
72
|
-
|
73
|
-
|
182
|
+
:description=>entry[1].agent.description,
|
183
|
+
:active=>entry[1].active
|
74
184
|
}
|
75
185
|
}
|
76
186
|
}
|
77
187
|
end
|
78
188
|
|
79
|
-
# プロセスにエージェントを追加する
|
80
|
-
def add_agent( process_id, name, class_name, properties )
|
81
|
-
p = process_manager.get( process_id )
|
82
|
-
agent = agent_registry.create( class_name, properties )
|
83
|
-
p.agent_manager.add( name, agent )
|
84
|
-
:success
|
85
|
-
end
|
86
|
-
|
87
|
-
# プロセスのエージェントを削除する
|
88
|
-
def remove_agent( process_id, name )
|
89
|
-
p = process_manager.get( process_id )
|
90
|
-
p.agent_manager.remove( name )
|
91
|
-
:success
|
92
|
-
end
|
93
|
-
|
94
|
-
# # エージェントのプロパティを更新する
|
95
|
-
# def set_agent_properties( process_id, name, properties )
|
96
|
-
# p = process_manager.get( process_id )
|
97
|
-
# p.agent_manager.get( name ).properties = properties
|
98
|
-
# end
|
99
|
-
|
100
189
|
# プロセスのエージェントを一時的に無効化する
|
101
190
|
def off( process_id, name )
|
102
191
|
p = process_manager.get( process_id )
|
@@ -116,14 +205,24 @@ module JIJI
|
|
116
205
|
end
|
117
206
|
attr :agent_registry, true
|
118
207
|
attr :process_manager, true
|
119
|
-
|
208
|
+
attr :agent_dir, true
|
209
|
+
attr :shared_lib_dir, true
|
210
|
+
attr :dao, true
|
211
|
+
attr :server_logger, true
|
120
212
|
private
|
121
|
-
def
|
122
|
-
unless
|
123
|
-
raise JIJI::UserError.new( ERROR_ILLEGAL_NAME, "illegal
|
213
|
+
def check_path(path)
|
214
|
+
unless path =~ /^(#{@agent_dir}|#{@shared_lib_dir})(\/.*)?/
|
215
|
+
raise JIJI::UserError.new( ERROR_ILLEGAL_NAME, "illegal path. path=#{path}" )
|
124
216
|
end
|
125
217
|
end
|
126
|
-
|
218
|
+
|
219
|
+
def mk_error_info( path, error )
|
220
|
+
return {
|
221
|
+
:path=>path,
|
222
|
+
:code=>error.respond_to?(:code) ? error.code : "",
|
223
|
+
:msg=>error.to_s
|
224
|
+
}
|
225
|
+
end
|
127
226
|
|
128
227
|
end
|
129
228
|
|
@@ -4,17 +4,17 @@ module JIJI
|
|
4
4
|
|
5
5
|
# 指定範囲の出力データを取得する。
|
6
6
|
def list_datas( process_id, names, scale, start_time, end_time )
|
7
|
-
|
7
|
+
map = output_manager.get_process_map( process_id )
|
8
8
|
list = {}
|
9
9
|
names.each {|n|
|
10
10
|
buff = []
|
11
|
-
outputs =
|
11
|
+
outputs = map[n[0]]
|
12
12
|
next unless outputs
|
13
13
|
outputs.get(n[1]).each( scale,
|
14
14
|
Time.at(start_time), Time.at(end_time) ) {|data|
|
15
15
|
buff << data
|
16
16
|
}
|
17
|
-
list[n[0]]
|
17
|
+
list[n[0]] ||= {}
|
18
18
|
list[n[0]][n[1]] = buff
|
19
19
|
}
|
20
20
|
return list
|
@@ -22,23 +22,37 @@ module JIJI
|
|
22
22
|
|
23
23
|
# プロセスの出力一覧を取得する
|
24
24
|
def list_outputs( process_id )
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
buff = {}
|
26
|
+
rmt_process = nil
|
27
|
+
rmt_process = process_manager.get( process_id ) if ( process_id == "rmt" )
|
28
|
+
output_manager.each( process_id ) {|outputs|
|
29
|
+
buff[outputs.agent_id] = {
|
30
|
+
"agent_id"=>outputs.agent_id,
|
31
|
+
"agent_name"=>outputs.agent_name,
|
32
|
+
"outputs"=>outputs.inject({}) {|r,v|
|
33
|
+
r[v[0]] = v[1].options
|
34
|
+
r
|
35
|
+
},
|
36
|
+
"alive"=> process_id == "rmt" &&
|
37
|
+
is_live_agent( rmt_process["agents"], outputs.agent_id )
|
30
38
|
}
|
31
|
-
buff
|
32
39
|
}
|
40
|
+
buff
|
41
|
+
end
|
42
|
+
|
43
|
+
# プロセスの出力を削除する
|
44
|
+
def delete_output( process_id, agent_id )
|
45
|
+
output_manager.delete( process_id, agent_id )
|
46
|
+
:success
|
33
47
|
end
|
34
48
|
|
35
49
|
# アウトプットのプロパティを設定
|
36
|
-
def set_properties( process_id,
|
37
|
-
|
38
|
-
outputs
|
39
|
-
|
40
|
-
|
41
|
-
|
50
|
+
def set_properties( process_id, agent_id, output_name, properties )
|
51
|
+
outputs = output_manager.get( process_id, agent_id )
|
52
|
+
unless outputs.exist? output_name
|
53
|
+
raise UserError.new( JIJI::ERROR_NOT_FOUND, "output not found. name=#{agent_id}:#{output_name}")
|
54
|
+
end
|
55
|
+
out = outputs.get(output_name)
|
42
56
|
out.set_properties( properties )
|
43
57
|
return :success
|
44
58
|
end
|
@@ -47,15 +61,21 @@ module JIJI
|
|
47
61
|
def get_log( process_id )
|
48
62
|
process_manager.get( process_id ) # プロセスの存在確認
|
49
63
|
file = "#{@process_dir}/#{process_id}/log.txt" # TODO 古いものも連結するか? サイズが大きくなってしまうので微妙。
|
50
|
-
if ( File.exist?( file ) )
|
64
|
+
if ( File.exist?( file ) )
|
51
65
|
return IO.read( file )
|
52
66
|
else
|
53
67
|
return ""
|
54
68
|
end
|
55
69
|
end
|
56
|
-
|
70
|
+
|
57
71
|
attr :process_dir, true
|
58
72
|
attr :process_manager, true
|
73
|
+
attr :output_manager, true
|
74
|
+
private
|
75
|
+
def is_live_agent( agents, agent_id )
|
76
|
+
return false if !agents
|
77
|
+
return agents.find {|i| i["id"] == agent_id } != nil
|
78
|
+
end
|
59
79
|
end
|
60
80
|
|
61
81
|
end
|
@@ -22,7 +22,6 @@ module JIJI
|
|
22
22
|
# プロセスの設定を更新する。
|
23
23
|
def set( process_id, setting )
|
24
24
|
@process_manager.set( process_id, setting )
|
25
|
-
:success
|
26
25
|
end
|
27
26
|
|
28
27
|
|
@@ -54,7 +53,6 @@ module JIJI
|
|
54
53
|
# テストを再実行する
|
55
54
|
def restart( process_id, agent_properties )
|
56
55
|
@process_manager.restart_test(process_id, agent_properties)
|
57
|
-
:success
|
58
56
|
end
|
59
57
|
|
60
58
|
attr :process_manager, true
|
@@ -68,11 +66,11 @@ module JIJI
|
|
68
66
|
"end_date"=>process["end_date"],
|
69
67
|
"create_date"=>process["create_date"],
|
70
68
|
"trade_enable"=>process["trade_enable"],
|
71
|
-
"state"=>process
|
72
|
-
"progress"=>process.progress
|
69
|
+
"state"=>process["state"],
|
70
|
+
"progress"=>process.progress
|
73
71
|
}
|
74
72
|
end
|
75
73
|
end
|
76
|
-
|
74
|
+
|
77
75
|
end
|
78
76
|
end
|
@@ -4,11 +4,10 @@ module JIJI
|
|
4
4
|
|
5
5
|
# 指定範囲のトレード結果を取得する。
|
6
6
|
def list( process_id, scale, start_time, end_time )
|
7
|
-
|
8
|
-
dao = p.agent_manager.trade_result_dao
|
7
|
+
dao = registry.trade_result_dao(process_id)
|
9
8
|
result = dao.list_positions( scale, start_time ? Time.at(start_time) : nil, end_time ? Time.at(end_time) : nil )
|
10
9
|
# 現在進行中の建て玉はoperatorから取得する
|
11
|
-
op =
|
10
|
+
op = (process_id == "rmt") ? registry.rmt_process.agent_manager.operator : nil
|
12
11
|
return result.map {|e|
|
13
12
|
op && op.positions.key?(e[0]) ? op.positions[e[0]].values : e[1]
|
14
13
|
}
|
@@ -16,8 +15,7 @@ module JIJI
|
|
16
15
|
|
17
16
|
# 指定範囲の損益を取得する。
|
18
17
|
def list_profit_or_loss( process_id, scale, start_time, end_time )
|
19
|
-
|
20
|
-
dao = p.agent_manager.trade_result_dao
|
18
|
+
dao = registry.trade_result_dao(process_id)
|
21
19
|
buff = []
|
22
20
|
dao.each( scale, start_time ? Time.at(start_time) : nil, end_time ? Time.at(end_time) : nil ) {|data|
|
23
21
|
buff << data
|
@@ -26,6 +24,7 @@ module JIJI
|
|
26
24
|
end
|
27
25
|
|
28
26
|
attr :process_manager, true
|
27
|
+
attr :registry, true
|
29
28
|
end
|
30
29
|
|
31
30
|
end
|
data/lib/jiji/util/file_lock.rb
CHANGED
@@ -13,7 +13,7 @@ class FileLock
|
|
13
13
|
File.open( @lockfile, "r" ) { |f|
|
14
14
|
f.flock(File::LOCK_SH)
|
15
15
|
begin
|
16
|
-
|
16
|
+
block.call(f)
|
17
17
|
ensure
|
18
18
|
f.flock(File::LOCK_UN)
|
19
19
|
end
|
@@ -26,7 +26,7 @@ class FileLock
|
|
26
26
|
File.open( @lockfile, "w" ) { |f|
|
27
27
|
f.flock(File::LOCK_EX)
|
28
28
|
begin
|
29
|
-
|
29
|
+
block.call(f)
|
30
30
|
ensure
|
31
31
|
f.flock(File::LOCK_UN)
|
32
32
|
end
|
@@ -48,7 +48,7 @@ class DirLock
|
|
48
48
|
File.open( @lockfile, "r" ) { |f|
|
49
49
|
f.flock(File::LOCK_SH)
|
50
50
|
begin
|
51
|
-
|
51
|
+
block.call
|
52
52
|
ensure
|
53
53
|
f.flock(File::LOCK_UN)
|
54
54
|
end
|
@@ -62,7 +62,7 @@ class DirLock
|
|
62
62
|
File.open( @lockfile, "w" ) { |f|
|
63
63
|
f.flock(File::LOCK_EX)
|
64
64
|
begin
|
65
|
-
|
65
|
+
block.call
|
66
66
|
ensure
|
67
67
|
f.flock(File::LOCK_UN)
|
68
68
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Module
|
2
|
+
#プロキシモジュールをincludeする。
|
3
|
+
def include_proxy( mod )
|
4
|
+
include mod
|
5
|
+
class << self
|
6
|
+
def const_missing(id)
|
7
|
+
self.included_modules.each {|m|
|
8
|
+
begin
|
9
|
+
return m.const_get(id)
|
10
|
+
rescue NameError
|
11
|
+
end
|
12
|
+
}
|
13
|
+
raise NameError.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -40,10 +40,12 @@ class Broker
|
|
40
40
|
args = json["params"]
|
41
41
|
|
42
42
|
result = @service.send( method.to_sym, *args )
|
43
|
-
return '[{"error":null, "result":' << result.to_json << "}]"
|
44
|
-
rescue
|
45
|
-
error = $!.to_s
|
46
|
-
|
43
|
+
return '[{"error":null, "detail":null,"result":' << result.to_json << "}]"
|
44
|
+
rescue Exception
|
45
|
+
error = $!.to_s.gsub(/'/, "")
|
46
|
+
detail = $!.respond_to?(:detail) ? $!.detail : {}
|
47
|
+
detail[:backtrace] = $!.backtrace.join("\n").gsub(/'/, "")
|
48
|
+
return '[{"error":' << error.to_json << ', "detail":' + detail.to_json + ', "result":null}]'
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
data/lib/jiji/util/util.rb
CHANGED
data/swf/chart/fx/chart/Chart.as
CHANGED
@@ -112,6 +112,7 @@ package fx.chart {
|
|
112
112
|
} );
|
113
113
|
ExternalInterface.addCallback("setGraphVisible", this.setGraphVisible );
|
114
114
|
ExternalInterface.addCallback("setGraphColors", this.setGraphColors );
|
115
|
+
ExternalInterface.addCallback("removeGraph", this.removeGraph );
|
115
116
|
}
|
116
117
|
/**
|
117
118
|
* グラフを初期化する
|
@@ -156,5 +157,11 @@ package fx.chart {
|
|
156
157
|
private function setGraphColors( name:Array, colors:Array ):void {
|
157
158
|
this.graphManager.setGraphColors( name, colors );
|
158
159
|
}
|
160
|
+
/**
|
161
|
+
* グラフの表示/非表示を設定
|
162
|
+
*/
|
163
|
+
private function removeGraph( agentId:String ):void {
|
164
|
+
this.graphManager.removeGraph( agentId );
|
165
|
+
}
|
159
166
|
}
|
160
167
|
}
|
@@ -45,7 +45,8 @@ package fx.chart.ui.graph {
|
|
45
45
|
// グラフ一覧を作成
|
46
46
|
for ( var graph:* in model.graphs ) {
|
47
47
|
infos[graph] = {};
|
48
|
-
var x:* = model.graphs[graph];
|
48
|
+
var x:* = model.graphs[graph]["outputs"];
|
49
|
+
x ||= {};
|
49
50
|
for ( var g:* in x ) {
|
50
51
|
infos[graph][g] = new GraphInfo( x[g], null, model, ctrl, rc );
|
51
52
|
}
|
@@ -106,7 +107,19 @@ package fx.chart.ui.graph {
|
|
106
107
|
target.setColors( colors );
|
107
108
|
target.draw(); // グラフを再描画
|
108
109
|
}
|
109
|
-
|
110
|
+
}
|
111
|
+
|
112
|
+
/**
|
113
|
+
* グラフを削除する
|
114
|
+
*/
|
115
|
+
public function removeGraph( agentId:String ):void {
|
116
|
+
// レイヤーを非表示。
|
117
|
+
if ( infos && infos[agentId] ) {
|
118
|
+
for ( var j:* in infos[agentId] ) {
|
119
|
+
off( [agentId, j] );
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
110
123
|
|
111
124
|
/**
|
112
125
|
* グラフデータを再取得して更新する。
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
$: << "
|
4
|
-
$: << "../"
|
3
|
+
$: << "../lib"
|
5
4
|
|
6
5
|
require 'rubygems'
|
7
6
|
require 'runit/testcase'
|
@@ -13,7 +12,10 @@ require 'jiji/agent/permitter'
|
|
13
12
|
require 'jiji/agent/util'
|
14
13
|
require 'jiji/configuration'
|
15
14
|
require 'jiji/collector'
|
15
|
+
require 'jiji/output'
|
16
|
+
require 'jiji/output_manager'
|
16
17
|
require 'jiji/dao/trade_result_dao'
|
18
|
+
require 'jiji/dao/file_system_dao'
|
17
19
|
require 'fileutils'
|
18
20
|
require 'test_utils'
|
19
21
|
require 'logger'
|
@@ -28,15 +30,24 @@ class AgentManagerTest < RUNIT::TestCase
|
|
28
30
|
@dir = File.dirname(__FILE__) + "/agents"
|
29
31
|
FileUtils.mkdir_p @dir
|
30
32
|
|
31
|
-
@
|
32
|
-
@
|
33
|
+
@dao = JIJI::Dao::FileSystemDao.new( @dir )
|
34
|
+
@dao.mkcol "agents"
|
35
|
+
@dao.mkcol "shared"
|
33
36
|
|
34
37
|
@permitter = JIJI::Permitter.new( 5, 0 )
|
35
38
|
logger = Logger.new STDOUT
|
36
39
|
logger = @permitter.proxy( logger, [/^(info|debug|warn|error|fatal)$/] )
|
37
|
-
|
40
|
+
|
41
|
+
@registry = JIJI::AgentRegistry.new( "agents", "shared" )
|
42
|
+
@registry.conf = CONF
|
43
|
+
@registry.file_dao = @dao
|
44
|
+
@registry.server_logger = logger
|
45
|
+
|
38
46
|
@registry_mock = Object.new
|
39
47
|
class << @registry_mock
|
48
|
+
def output_dir( id )
|
49
|
+
"#{@dir}/#{id}/out"
|
50
|
+
end
|
40
51
|
def output( agent_name, dir )
|
41
52
|
output = JIJI::Output.new( agent_name, "#{@dir}/#{dir}/out" )
|
42
53
|
output = @permitter.proxy( output, [/^(get|each|put|<<)$/], [/^get$/] )
|
@@ -52,16 +63,16 @@ class AgentManagerTest < RUNIT::TestCase
|
|
52
63
|
operator = JIJI::Operator.new( trade_result_dao )
|
53
64
|
operator.conf = CONF
|
54
65
|
operator = @permitter.proxy( operator, [/^(sell|buy|commit)$/],[/^(sell|buy)$/])
|
55
|
-
|
66
|
+
|
56
67
|
@m = JIJI::AgentManager.new( "test_agentManager", @registry, logger)
|
57
68
|
@m.operator = operator
|
58
69
|
@m.conf = CONF
|
59
70
|
@m.trade_result_dao = trade_result_dao
|
60
|
-
@m.
|
71
|
+
@m.output_manager = JIJI::OutputManager.new(@registry_mock)
|
61
72
|
end
|
62
73
|
|
63
74
|
def teardown
|
64
|
-
@permitter.close
|
75
|
+
@permitter.close if @permitter
|
65
76
|
FileUtils.rm_rf @dir
|
66
77
|
end
|
67
78
|
|
@@ -79,7 +90,8 @@ class AgentManagerTest < RUNIT::TestCase
|
|
79
90
|
attr :log, true
|
80
91
|
end
|
81
92
|
AGENT_STR
|
82
|
-
@
|
93
|
+
@dao.put( "agents/foo.rb", str )
|
94
|
+
@registry.load( "agents/foo.rb" )
|
83
95
|
|
84
96
|
agent1 = @registry.create( "Foo@foo.rb" )
|
85
97
|
agent2 = @registry.create( "Foo@foo.rb" )
|
@@ -222,7 +234,8 @@ class AgentManagerTest < RUNIT::TestCase
|
|
222
234
|
attr :log, true
|
223
235
|
end
|
224
236
|
AGENT_STR
|
225
|
-
@
|
237
|
+
@dao.put( "agents/foo.rb", str )
|
238
|
+
@registry.load( "agents/foo.rb" )
|
226
239
|
|
227
240
|
agent = @registry.create( "Foo@foo.rb" )
|
228
241
|
@m.add( "test", agent )
|
@@ -241,8 +254,11 @@ class AgentManagerTest < RUNIT::TestCase
|
|
241
254
|
|
242
255
|
# 循環参照のテスト
|
243
256
|
def test_recursive
|
244
|
-
@
|
245
|
-
@registry.
|
257
|
+
@dao.put( "agents/AgentServiceTest_1.rb", BODY_O1 )
|
258
|
+
@registry.load( "agents/AgentServiceTest_1.rb" )
|
259
|
+
@dao.put( "agents/AgentServiceTest_2.rb", BODY_O2 )
|
260
|
+
@registry.load( "agents/AgentServiceTest_2.rb" )
|
261
|
+
|
246
262
|
@m.each {|a|}
|
247
263
|
@registry.inject([]) {|list,name|
|
248
264
|
list << {
|