omf_web 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. data/.gitignore +0 -1
  2. data/README.md +8 -2
  3. data/doc/screenshot.png +0 -0
  4. data/example/{basic → NOT_WORKING/basic}/hello-world-wired.rb +0 -0
  5. data/example/{basic → NOT_WORKING/basic}/visualisation.yml +0 -0
  6. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklynDemo.sq3 +0 -0
  7. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_gps.dat +0 -0
  8. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_server.rb +0 -0
  9. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_wimax.dat +0 -0
  10. data/example/{brooklyn → NOT_WORKING/brooklyn}/sql_source.rb +0 -0
  11. data/example/{code → NOT_WORKING/code}/code_server.rb +0 -0
  12. data/example/{frisbee → NOT_WORKING/frisbee}/data_sources/parse_log.rb +0 -0
  13. data/example/{frisbee → NOT_WORKING/frisbee}/data_sources/pxe_slice-2012-06-02t02.25.00-04.00.log +0 -0
  14. data/example/{frisbee → NOT_WORKING/frisbee}/progress_chart.yaml +0 -0
  15. data/example/{frisbee → NOT_WORKING/frisbee}/progress_tab.yaml +0 -0
  16. data/example/{frisbee → NOT_WORKING/frisbee}/progress_table.yaml +0 -0
  17. data/example/{frisbee → NOT_WORKING/frisbee}/viz_server.rb +0 -0
  18. data/example/{gec12 → NOT_WORKING/gec12}/gec12-53.rb +0 -0
  19. data/example/{gec12 → NOT_WORKING/gec12}/gec12_demo.sq3 +0 -0
  20. data/example/{gec12 → NOT_WORKING/gec12}/gec12_demo_server.rb +0 -0
  21. data/example/{gec12 → NOT_WORKING/gec12}/visualization.rb +0 -0
  22. data/example/{incoming → NOT_WORKING/incoming}/ofpu_barchart_widget.yaml +0 -0
  23. data/example/{log → NOT_WORKING/log}/log_config.xml +0 -0
  24. data/example/{log → NOT_WORKING/log}/log_server.rb +0 -0
  25. data/example/{network → NOT_WORKING/network}/flow_tab.yaml +0 -0
  26. data/example/{network → NOT_WORKING/network}/network_server.rb +0 -0
  27. data/example/{text → NOT_WORKING/text}/test.md +0 -0
  28. data/example/{text → NOT_WORKING/text}/test.rb +0 -0
  29. data/example/{wimax → NOT_WORKING/wimax}/downlink.yaml +0 -0
  30. data/example/{wimax → NOT_WORKING/wimax}/power.yaml +0 -0
  31. data/example/{wimax → NOT_WORKING/wimax}/snapshot.db +0 -0
  32. data/example/{wimax → NOT_WORKING/wimax}/snapshot.sql +0 -0
  33. data/example/{wimax → NOT_WORKING/wimax}/test.rb +0 -0
  34. data/example/{wimax → NOT_WORKING/wimax}/uplink.yaml +0 -0
  35. data/example/{wimax → NOT_WORKING/wimax}/viz_server.rb +0 -0
  36. data/example/demo/data_sources/mobile_network.rb +3 -0
  37. data/example/demo/data_sources/static_network.rb +54 -0
  38. data/example/demo/widgets/charts_tab.yaml +21 -16
  39. data/example/demo/widgets/linked_graphs_tab.yaml +95 -0
  40. data/example/demo/widgets/mobile_network_widget.yaml +1 -1
  41. data/example/demo/widgets/pie_chart_widget.yaml +1 -1
  42. data/lib/omf-web/config.ru +2 -2
  43. data/lib/omf-web/data_source_proxy.rb +81 -19
  44. data/lib/omf-web/rack/websocket_handler.rb +77 -23
  45. data/lib/omf-web/theme/abstract_page.rb +43 -26
  46. data/lib/omf-web/theme/bright/code_renderer.rb +1 -1
  47. data/lib/omf-web/theme/bright/page.rb +1 -0
  48. data/lib/omf-web/theme/bright/tabbed_renderer.rb +7 -0
  49. data/lib/omf-web/version.rb +7 -0
  50. data/lib/omf-web/widget/data_widget.rb +38 -46
  51. data/lib/omf-web/widget/layout/stacked_layout.rb +2 -1
  52. data/lib/omf-web/widget/layout/tabbed_layout.rb +1 -2
  53. data/{MARUKU-LICENSE → lib/omf-web/widget/text/maruku/MARUKU-LICENSE} +0 -0
  54. data/lib/{maruku → omf-web/widget/text/maruku}/helpers.rb +0 -0
  55. data/lib/{maruku → omf-web/widget/text/maruku}/input/parse_block.rb +0 -0
  56. data/lib/{maruku → omf-web/widget/text/maruku}/output/to_html.rb +26 -21
  57. data/lib/omf-web/widget/text/maruku.rb +5 -0
  58. data/omf_web.gemspec +2 -1
  59. data/share/htdocs/{js → UNUSED}/log/table.js +0 -0
  60. data/share/htdocs/{css → graph/css}/graph.css +0 -0
  61. data/share/htdocs/{image/graph → graph/img}/bar_chart.png +0 -0
  62. data/share/htdocs/{image/graph → graph/img}/donut_chart.png +0 -0
  63. data/share/htdocs/{image/graph → graph/img}/funnel.png +0 -0
  64. data/share/htdocs/{image/graph → graph/img}/info.png +0 -0
  65. data/share/htdocs/{image/graph → graph/img}/line_chart.png +0 -0
  66. data/share/htdocs/{image/graph → graph/img}/line_chart_fill.png +0 -0
  67. data/share/htdocs/{image/graph → graph/img}/misc.png +0 -0
  68. data/share/htdocs/{image/graph → graph/img}/overview.png +0 -0
  69. data/share/htdocs/{image/graph → graph/img}/pie_chart.png +0 -0
  70. data/share/htdocs/{image/graph → graph/img}/scatter_plot.png +0 -0
  71. data/share/htdocs/{image/graph → graph/img}/stacked_bar_chart.png +0 -0
  72. data/share/htdocs/{image/graph → graph/img}/stacked_line_chart.png +0 -0
  73. data/share/htdocs/{image/graph → graph/img}/table.png +0 -0
  74. data/share/htdocs/{js/graph → graph/js}/abstract_chart.js +1 -1
  75. data/share/htdocs/{js/graph → graph/js}/abstract_nv_chart.js +8 -13
  76. data/share/htdocs/{js/graph → graph/js}/abstract_widget.js +9 -16
  77. data/share/htdocs/{js/graph → graph/js}/axis.js +1 -1
  78. data/share/htdocs/{js/graph → graph/js}/barchart.js +2 -2
  79. data/share/htdocs/{js/graph → graph/js}/code_mirror.js +1 -5
  80. data/share/htdocs/{js/graph → graph/js}/discrete_bar_chart.js +1 -1
  81. data/share/htdocs/{js/graph → graph/js}/histogram2.js +1 -1
  82. data/share/htdocs/{js/graph → graph/js}/holt_winters_chart.js +1 -1
  83. data/share/htdocs/{js/graph → graph/js}/line_chart3.js +1 -1
  84. data/share/htdocs/{js/graph → graph/js}/line_chart_with_focus.js +1 -1
  85. data/share/htdocs/{js/graph → graph/js}/map2.js +1 -1
  86. data/share/htdocs/{js/graph → graph/js}/multi_barchart.js +1 -1
  87. data/share/htdocs/graph/js/network2.js +412 -0
  88. data/share/htdocs/{js/graph → graph/js}/pie_chart2.js +1 -1
  89. data/share/htdocs/{js/graph → graph/js}/scatter_plot.js +1 -1
  90. data/share/htdocs/{js/graph → graph/js}/table2.js +17 -20
  91. data/share/htdocs/js/data_source2.js +187 -60
  92. data/share/htdocs/js/require3.js +38 -57
  93. data/share/htdocs/theme/bright/css/bright.css +4 -4
  94. data/share/htdocs/vendor/jquery/jquery.js +9404 -0
  95. data/share/htdocs/vendor/osa/LICENSE.txt +11 -0
  96. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_arrow_green_left.svg +0 -0
  97. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_arrow_yellow_right.svg +0 -0
  98. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_awareness.svg +0 -0
  99. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_camera-web.svg +0 -0
  100. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_cloud.svg +0 -0
  101. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_contract.svg +0 -0
  102. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_database.svg +0 -0
  103. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_desktop.svg +0 -0
  104. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_desktop_imac.svg +0 -0
  105. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-music.svg +0 -0
  106. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-scanner.svg +0 -0
  107. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-usb-wifi.svg +0 -0
  108. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-usb.svg +0 -0
  109. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-wireless-router.svg +0 -0
  110. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_disposal.svg +0 -0
  111. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_drive-harddisk.svg +0 -0
  112. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_drive-optical.svg +0 -0
  113. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_firewall.svg +0 -0
  114. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_home.svg +0 -0
  115. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_hub.svg +0 -0
  116. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_iPhone.svg +0 -0
  117. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_drive.svg +0 -0
  118. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_plc.svg +0 -0
  119. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_thermometer.svg +0 -0
  120. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_id_card.svg +0 -0
  121. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_image-generic.svg +0 -0
  122. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_laptop.svg +0 -0
  123. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_lifecycle.svg +0 -0
  124. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_lightning.svg +0 -0
  125. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-flash.svg +0 -0
  126. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-optical.svg +0 -0
  127. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-tape.svg +0 -0
  128. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_mobile_pda.svg +0 -0
  129. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_padlock.svg +0 -0
  130. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_printer.svg +0 -0
  131. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server.svg +0 -0
  132. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_application.svg +0 -0
  133. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_database.svg +0 -0
  134. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_directory.svg +0 -0
  135. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_distribution.svg +0 -0
  136. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_file.svg +0 -0
  137. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_gateway.svg +0 -0
  138. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_identity.svg +0 -0
  139. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_mail.svg +0 -0
  140. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_media.svg +0 -0
  141. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_monitor.svg +0 -0
  142. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_proxy.svg +0 -0
  143. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_terminal.svg +0 -0
  144. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_web.svg +0 -0
  145. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-branch.svg +0 -0
  146. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-factory.svg +0 -0
  147. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-head-office.svg +0 -0
  148. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-neighbourhood.svg +0 -0
  149. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_audit.svg +0 -0
  150. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_black_hat.svg +0 -0
  151. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue.svg +0 -0
  152. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_security_specialist.svg +0 -0
  153. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_sysadmin.svg +0 -0
  154. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_tester.svg +0 -0
  155. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_tie.svg +0 -0
  156. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green.svg +0 -0
  157. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_architect.svg +0 -0
  158. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_business_manager.svg +0 -0
  159. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_developer.svg +0 -0
  160. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_operations.svg +0 -0
  161. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_project_manager.svg +0 -0
  162. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_service_manager.svg +0 -0
  163. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_warning.svg +0 -0
  164. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_large_group.svg +0 -0
  165. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_users_blue_green.svg +0 -0
  166. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_vpn.svg +0 -0
  167. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_warning.svg +0 -0
  168. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_wireless_network.svg +0 -0
  169. data/share/htdocs/{image → vendor/unknown/image}/.DS_Store +0 -0
  170. data/share/htdocs/{image → vendor/unknown/image}/add_icon.gif +0 -0
  171. data/share/htdocs/{image → vendor/unknown/image}/alertbad_icon.gif +0 -0
  172. data/share/htdocs/{image → vendor/unknown/image}/alertgood_icon.gif +0 -0
  173. data/share/htdocs/{image → vendor/unknown/image}/back_disabled.jpg +0 -0
  174. data/share/htdocs/{image → vendor/unknown/image}/back_disabled.png +0 -0
  175. data/share/htdocs/{image → vendor/unknown/image}/back_enabled.jpg +0 -0
  176. data/share/htdocs/{image → vendor/unknown/image}/back_enabled.png +0 -0
  177. data/share/htdocs/{image → vendor/unknown/image}/back_enabled_hover.jpg +0 -0
  178. data/share/htdocs/{image → vendor/unknown/image}/back_enabled_hover.png +0 -0
  179. data/share/htdocs/{image → vendor/unknown/image}/bottom-bg.gif +0 -0
  180. data/share/htdocs/{image → vendor/unknown/image}/forward_disabled.jpg +0 -0
  181. data/share/htdocs/{image → vendor/unknown/image}/forward_disabled.png +0 -0
  182. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled.jpg +0 -0
  183. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled.png +0 -0
  184. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled_hover.jpg +0 -0
  185. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled_hover.png +0 -0
  186. data/share/htdocs/{image → vendor/unknown/image}/icon-remove.gif +0 -0
  187. data/share/htdocs/{image → vendor/unknown/image}/indicator.gif +0 -0
  188. data/share/htdocs/{image → vendor/unknown/image}/laptop.png +0 -0
  189. data/share/htdocs/{image → vendor/unknown/image}/logo-bottom.gif +0 -0
  190. data/share/htdocs/{image → vendor/unknown/image}/nav-tab-arrow.gif +0 -0
  191. data/share/htdocs/{image → vendor/unknown/image}/norbit_big.gif +0 -0
  192. data/share/htdocs/{image → vendor/unknown/image}/norbit_clipart.png +0 -0
  193. data/share/htdocs/{image → vendor/unknown/image}/progress_bar.gif +0 -0
  194. data/share/htdocs/{image → vendor/unknown/image}/right-bg.gif +0 -0
  195. data/share/htdocs/{image → vendor/unknown/image}/sort_asc.png +0 -0
  196. data/share/htdocs/{image → vendor/unknown/image}/sort_asc_disabled.png +0 -0
  197. data/share/htdocs/{image → vendor/unknown/image}/sort_both.png +0 -0
  198. data/share/htdocs/{image → vendor/unknown/image}/sort_desc.png +0 -0
  199. data/share/htdocs/{image → vendor/unknown/image}/sort_desc_disabled.png +0 -0
  200. data/share/htdocs/{image → vendor/unknown/image}/spinner.gif +0 -0
  201. data/share/htdocs/{svg → vendor/unknown/svg}/ap.svg +0 -0
  202. data/share/htdocs/{svg → vendor/unknown/svg}/router.svg +0 -0
  203. metadata +198 -216
  204. data/example/demo/widgets/dashboard_tab.yaml +0 -28
  205. data/example/demo/widgets/download_tab.yaml +0 -42
  206. data/example/demo/widgets/edit_tab.yaml +0 -20
  207. data/example/demo/widgets/generator_tab.yaml +0 -12
  208. data/lib/omf-oml/endpoint.rb +0 -175
  209. data/lib/omf-oml/indexed_table.rb +0 -57
  210. data/lib/omf-oml/network.rb +0 -413
  211. data/lib/omf-oml/oml_tuple.rb +0 -62
  212. data/lib/omf-oml/schema.rb +0 -191
  213. data/lib/omf-oml/sequel/sequel_server.rb +0 -412
  214. data/lib/omf-oml/sql_row.rb +0 -302
  215. data/lib/omf-oml/sql_source.rb +0 -131
  216. data/lib/omf-oml/table.rb +0 -131
  217. data/lib/omf-oml/tuple.rb +0 -97
  218. data/lib/omf_oml.rb +0 -4
  219. data/share/htdocs/css/coderay.css +0 -127
  220. data/share/htdocs/css/ie.css +0 -40
  221. data/share/htdocs/css/lightbox.css +0 -62
  222. data/share/htdocs/css/scaffold.css +0 -74
  223. data/share/htdocs/css/screen.css +0 -1313
  224. data/share/htdocs/css/search.css +0 -102
  225. data/share/htdocs/css/table.css +0 -538
  226. data/share/htdocs/css/table2.css +0 -191
  227. data/share/htdocs/css/welcome.css +0 -103
  228. data/share/htdocs/css/wfob.css +0 -171
  229. data/share/htdocs/css/wshow.css +0 -69
  230. data/share/htdocs/gec9_demo.html +0 -39
  231. data/share/htdocs/images +0 -1
  232. data/share/htdocs/js/graph/histogram.js +0 -229
  233. data/share/htdocs/js/graph/line_chart.js +0 -342
  234. data/share/htdocs/js/graph/line_chart2.js +0 -232
  235. data/share/htdocs/js/graph/line_chart_fc.js +0 -94
  236. data/share/htdocs/js/graph/map.js +0 -85
  237. data/share/htdocs/js/graph/network.js +0 -591
  238. data/share/htdocs/js/graph/network2.js +0 -318
  239. data/share/htdocs/js/graph/pie_chart.js +0 -130
  240. data/share/htdocs/js/graph/table.js +0 -94
  241. data/share/htdocs/js/require2.js +0 -1998
  242. data/share/htdocs/js/timelines.js +0 -101
  243. data/share/htdocs/stylesheet/grid.css +0 -31
@@ -1,175 +0,0 @@
1
-
2
- require 'omf_common/lobject'
3
- require 'omf_oml'
4
-
5
- require 'omf-oml/oml_tuple'
6
-
7
- module OMF::OML
8
-
9
- # This class parses an OML network stream and creates various OML mstreams which can
10
- # be visualized. After creating the object, the @run@ method needs to be called to
11
- # start processing the stream.
12
- #
13
- class OmlEndpoint < OMF::Common::LObject
14
-
15
- # Register a proc to be called when a new stream was
16
- # discovered on this endpoint.
17
- #
18
- def on_new_stream(key = :_, &proc)
19
- if proc
20
- @on_new_stream_procs[key] = proc
21
- else
22
- @on_new_stream_procs.delete key
23
- end
24
- end
25
-
26
- def initialize(port = 3000, host = "127.0.0.1")
27
- require 'socket'
28
- @serv = TCPServer.new(host, port)
29
- @running = false
30
- @on_new_stream_procs = {}
31
- end
32
-
33
- def report_new_stream(stream)
34
- @on_new_stream_procs.each_value do |proc|
35
- proc.call(stream)
36
- end
37
- end
38
-
39
- def run(in_thread = true)
40
- if in_thread
41
- Thread.new do
42
- _run
43
- end
44
- else
45
- _run
46
- end
47
- end
48
-
49
- private
50
-
51
- def _run
52
- @running = true
53
- while @running do
54
- sock = @serv.accept
55
- debug "OML client connected: #{sock}"
56
-
57
- Thread.new do
58
- begin
59
- conn = OmlConnection.new(self)
60
- conn.run(sock)
61
- debug "OML client disconnected: #{sock}"
62
- rescue Exception => ex
63
- error "Exception in OmlConnection: #{ex}"
64
- debug "Exception in OmlConnection: #{ex.backtrace.join("\n\t")}"
65
- ensure
66
- sock.close
67
- end
68
- end
69
-
70
- end
71
- end
72
- end
73
-
74
- # PRIVATE
75
- # An instance of this class is created by +OmlEndpoint+ to deal with
76
- # and individual client connection (socket). An EndPoint is creating
77
- # and instance and then immediately calls the +run+ methods.
78
- #
79
- #
80
- class OmlSession < OMF::Common::LObject # :nodoc
81
-
82
- # Return the value for the respective @key@ in the protocol header.
83
- #
84
- def [](key)
85
- @header[key]
86
- end
87
-
88
- def initialize(endpoint)
89
- @endpoint = endpoint
90
- @header = {}
91
- @streams = []
92
- @on_new_stream_procs = {}
93
- end
94
-
95
- # This methods blocks until the peer disconnects. Each new stream is reported
96
- # to the @reportProc@
97
- #
98
- def run(socket)
99
- parse_header(socket)
100
- parse_rows(socket)
101
- end
102
-
103
- private
104
- def parse_header(socket, &reportStreamProc)
105
- while (l = socket.gets.strip)
106
- return if l.length == 0
107
-
108
- key, *value = l.split(':')
109
- if (key == 'schema')
110
- parse_schema(value.join(':'))
111
- else
112
- @header[key] = value[0].strip
113
- debug "HEADER: #{key}: #{@header[key]}"
114
- end
115
- end
116
- end
117
-
118
- def parse_schema(desc)
119
- debug "SCHEMA: #{desc}"
120
- els = desc.split(' ')
121
- #puts "ELS: #{els.inspect}"
122
- index = els.shift.to_i - 1
123
-
124
- sname = els.shift
125
- schema = els.collect do |el|
126
- name, type = el.split(':')
127
- {:name => name.to_sym, :type => type.to_sym}
128
- end
129
-
130
- @streams[index] = row = OmlTuple.new(schema, sname)
131
- @endpoint.report_new_stream(row)
132
- end
133
-
134
- def parse_rows(socket)
135
- while (l = socket.gets)
136
- return if l.length == 0
137
-
138
- els = l.split("\t")
139
- index = els.delete_at(1).to_i - 1
140
- row = @streams[index].parse_row(els)
141
- end
142
- end
143
-
144
- # def parse_row(els, sindex)
145
- # ts, index, *rest = els
146
- # row = {:oml_sname => @name, :oml_ts => ts.to_f, :oml_seq_no => index.to_i}
147
- # rest.each_index do |i|
148
- # name, unused, typeProc = @schema[i]
149
- # value = rest[i]
150
- # row[name] = typeProc.call(value)
151
- # end
152
- # add_row(row)
153
- # end
154
-
155
- end # OMLEndpoint
156
-
157
-
158
- end
159
-
160
- if $0 == __FILE__
161
-
162
- require 'omf-oml/table'
163
- ep = OMF::OML::OmlEndpoint.new(3000)
164
- toml = OMF::OML::OmlTable.new('oml', [[:x], [:y]], :max_size => 20)
165
- ep.on_new_stream() do |s|
166
- puts "New stream: #{s}"
167
- s.on_new_vector() do |v|
168
- puts "New vector: #{v.select(:oml_ts, :value).join('|')}"
169
- toml.add_row(v.select(:oml_ts, :value))
170
- end
171
- end
172
- ep.run(false)
173
-
174
- end
175
-
@@ -1,57 +0,0 @@
1
-
2
- require 'monitor'
3
-
4
- require 'omf_oml'
5
- require 'omf-oml/schema'
6
-
7
-
8
- module OMF::OML
9
-
10
- # This table shadows an other table but keeps only the most recently added
11
- # row with a unique entry in the +index+ column. It will have the same
12
- # +schema+ as the shadowed table.
13
- #
14
- # NOTE: THe current implementation does not remove rows when they are removed
15
- # in the source table.
16
- #
17
- class OmlIndexedTable < OmlTable
18
-
19
- attr_reader :index_col
20
- attr_reader :source_table
21
-
22
- #
23
- # index_col - Name of column to indexName of table
24
- # source_table - Table to shadow
25
- #
26
- def initialize(index_col, source_table)
27
- @index_col = index_col
28
- @source_table = source_table
29
- name = "#{source_table.name}+#{index_col}"
30
- super name, source_table.schema, {}
31
-
32
- @index2row = {}
33
- index = schema.index_for_col(index_col)
34
- @source_table.on_row_added(self) do |r|
35
- key = r[index]
36
- row_id = @index2row[key]
37
- unless row_id
38
- row_id = @rows.length
39
- @index2row[key] = row_id
40
- end
41
- @rows[row_id] = r
42
- _notify_row_added r
43
- end
44
- end
45
-
46
-
47
- # NOTE: +on_row_added+ callbacks are done within the monitor.
48
- #
49
- def add_row(row)
50
- throw "Do not use"
51
- end
52
-
53
-
54
-
55
- end # OMLTable
56
-
57
- end
@@ -1,413 +0,0 @@
1
- require 'monitor'
2
- require 'json'
3
- require 'set'
4
- require 'omf_common/lobject'
5
- require 'omf_oml'
6
-
7
-
8
-
9
- module OMF::OML
10
-
11
- class OmlNetworkAlreadyExistException < Exception; end
12
- class OmlNodeAlreadyExistException < Exception; end
13
- class OmlLinkAlreadyExistException < Exception; end
14
-
15
- class UnknownOmlNodeException < Exception; end
16
-
17
- class SameNameOnUpdateException < Exception; end
18
-
19
- # This class represents a network consisting of nodes and links with their respective
20
- # attributes.
21
- #
22
- class OmlNetwork < OMF::Common::LObject
23
- include MonitorMixin
24
-
25
- @@name2network = {}
26
-
27
- # Return a named network
28
- #
29
- def self.[](name)
30
- @@name2network[name]
31
- end
32
-
33
- attr_reader :name
34
-
35
- #
36
- # name - Name of table
37
- # opts -
38
- #
39
- def initialize(name = nil, attributes = {})
40
- super name
41
- @name = name
42
- @attributes = attributes
43
- @nodes = {}
44
- @name2node = {}
45
- @links = {}
46
- @name2link = {}
47
- @epoch = 0 # increment whenever an element is being updated
48
- @updateListeners = {}
49
- if name
50
- synchronize do
51
- if @@name2network[name]
52
- raise OmlNetworkAlreadyExistException.new(name)
53
- end
54
- @@name2network[name] = self
55
- end
56
- end
57
- end
58
-
59
- def nodes()
60
- @nodes.values
61
- end
62
-
63
- # Return the node named +name+. If the node doesn't exist and
64
- # +new_opts+ is a Hash, create a new one and return that.
65
- #
66
- def node(name, new_opts = nil)
67
- return name if name.kind_of? NetworkNode
68
- node = @name2node[name.to_sym]
69
- if node.nil? && !new_opts.nil?
70
- node = create_node(name, new_opts)
71
- end
72
- node
73
- end
74
-
75
- def links()
76
- @links.values
77
- end
78
-
79
- # Return the link named +name+. If the link doesn't exist and
80
- # +new_opts+ is a Hash, create a new one and return that.
81
- #
82
- def link(name, new_opts = nil)
83
- return name if name.kind_of? NetworkLink
84
- link = @name2link[name.to_sym]
85
- if link.nil? && !new_opts.nil?
86
- link = create_link(name, nil, nil, new_opts)
87
- end
88
- link
89
- end
90
-
91
-
92
- # Register a callback to be called every time network elements change
93
- # The callback is provided with an arrach of changed elements.
94
- #
95
- def on_update(name = :_, &callback)
96
- if (callback)
97
- if @updateListeners[name]
98
- throw SameNameOnUpdateException.new(name)
99
- end
100
- @updateListeners[name] = callback
101
- else
102
- @updateListeners.delete(name)
103
- end
104
- end
105
-
106
- # NOTE: May need a monitor if used in multi-threaded environments
107
- #
108
- def create_node(name = nil, attributes = {})
109
- name = name.to_sym if name
110
- synchronize do
111
- if name && @name2node[name]
112
- raise OmlNodeAlreadyExistException.new(name)
113
- end
114
- node = NetworkNode.new(name, attributes, self)
115
- @nodes[node.el_id] = node
116
- @name2node[name] = node if name
117
- node
118
- end
119
- end
120
-
121
- #
122
- # opts
123
- # :from - fromNode if +fromNode+ is nil
124
- # :to - toNode if +toNode+ is nil
125
- # ... - rest of options passed on to +NetworkLink+ constructor
126
- #
127
- def create_link(name = nil, fromNode = nil, toNode = nil, attributes = {})
128
- name = name.to_sym if name
129
- fromNode = attributes.delete(:from) unless fromNode
130
- toNode = attributes.delete(:to) unless toNode
131
-
132
- synchronize do
133
- if name && @name2link[name]
134
- raise OmlLinkAlreadyExistException.new(name)
135
- end
136
- if fromNode
137
- fromNode = node(fromNode) || (raise UnknownOmlNodeException.new(fromNode))
138
- end
139
- if toNode
140
- toNode = node(toNode) || (raise UnknownOmlNodeException.new(toNode))
141
- end
142
- link = NetworkLink.new(name, fromNode, toNode, attributes, self)
143
- @links[link.el_id] = link
144
- @name2link[name] = link if name
145
- link
146
- end
147
- end
148
-
149
- # To have the update listeners only called once when multiple elements are changed at once, perform the
150
- # changes within a +transaction+ block. The listeners are then called once with an array containing
151
- # all updated elements.
152
- #
153
- def transaction(&block)
154
- updated = UpdateSet.new
155
- synchronize do
156
- @updated = updated
157
-
158
- @in_transaction = true
159
- block.call
160
- @in_transaction = true
161
- end
162
- unless updated.empty?
163
- @updateListeners.values.each do |l|
164
- l.call(updated)
165
- end
166
- end
167
- end
168
-
169
- def node_schema(schema = null)
170
- if schema
171
- @node_schema = OmlSchema.create(schema)
172
- @node_schema.insert_column_at(0, :id)
173
- @node_schema.insert_column_at(1, :name)
174
- end
175
- @node_schema
176
- end
177
-
178
- def link_schema(schema = null)
179
- if schema
180
- @link_schema = OmlSchema.create(schema)
181
- @link_schema.insert_column_at(0, :id)
182
- @link_schema.insert_column_at(1, :name)
183
- @link_schema.insert_column_at(2, :from_id)
184
- @link_schema.insert_column_at(3, :to_id)
185
- end
186
- @link_schema
187
- end
188
-
189
-
190
- def describe
191
- nh = {}
192
- @nodes.each do |id, node| nh[id] = node.describe end
193
- lh = {}
194
- @links.each do |id, link| lh[id] = link.describe end
195
- {:nodes => nh, :links => lh}
196
- end
197
-
198
- # Creates two tables, one capturing the link state and one for the node state.
199
- # Returns the two tables in a hash with keys 'nodes' and 'links'.
200
- #
201
- def to_tables(table_opts = {})
202
- node_table = OmlTable.new 'nodes', @node_schema, table_opts
203
- @nodes.each do |id, n|
204
- node_table.add_row @node_schema.hash_to_row(n.attributes)
205
- end
206
-
207
- link_table = OmlTable.new 'links', @link_schema, table_opts
208
- @links.each do |id, l|
209
- link_table.add_row @link_schema.hash_to_row(l.attributes)
210
- end
211
-
212
- on_update "__to_tables_#{node_table.object_id}" do |a|
213
- a.each do |e|
214
- if e.kind_of? NetworkNode
215
- node_table.add_row @node_schema.hash_to_row(e.attributes)
216
- else
217
- link_table.add_row @link_schema.hash_to_row(e.attributes)
218
- end
219
- end
220
- end
221
- {:nodes => node_table, :links => link_table}
222
- end
223
-
224
- def to_json
225
- describe.to_json
226
- end
227
-
228
-
229
-
230
- def updated(element)
231
- synchronize do
232
- if @in_transaction
233
- @updated << element
234
- return
235
- end
236
- end
237
- uset = UpdateSet.new
238
- uset << element
239
- @updateListeners.each do |l|
240
- l.call(uset)
241
- end
242
- end
243
-
244
- end # OMLNetwork
245
-
246
- class NetworkElementAttributeException < Exception; end
247
-
248
-
249
- # This class represents an abstract network element and shouldn't be used directly.
250
- #
251
- class NetworkElement < OMF::Common::LObject
252
-
253
- attr_reader :name
254
- attr_reader :el_id
255
- attr_reader :attributes
256
-
257
- def initialize(name, attributes, network)
258
- super name
259
- @attributes = attributes.dup
260
- if @name = name
261
- @attributes[:name] = name
262
- end
263
- if attributes.key?(:id) || attributes.key?(:name)
264
- raise NetworkElementAttributeException.new("Attributes 'id' and 'name' are reserved attributes")
265
- end
266
- @el_id = @attributes[:id] = "e#{self.object_id}"
267
- @attributes[:name] = name || @el_id
268
-
269
- @network = network
270
- end
271
-
272
- def [](name)
273
- @attributes[name]
274
- end
275
-
276
- def []=(name, value)
277
- @attributes[name] = _set(value, @attributes[name])
278
- end
279
-
280
- # Update the element's attributes. The +attributes+ argument
281
- # is expected to be a hash with the key identifying the attribute
282
- # name and the value being the new value to set that attribute to.
283
- #
284
- def update(attributes)
285
- attributes.each do |name, value|
286
- self[name] = value
287
- end
288
- end
289
-
290
- # Return the current state of the network element as hash
291
- #
292
- def describe
293
- @attributes
294
- end
295
-
296
- def node?
297
- false
298
- end
299
-
300
- def link?
301
- false
302
- end
303
-
304
- protected
305
-
306
- def _set(value, old_value)
307
- if value != old_value
308
- @network.updated(self)
309
- end
310
- value
311
- end
312
-
313
- end # NetworkElement
314
-
315
- # This class represents a network node. Should NOT be created directly, but only through
316
- # +OmlNetwork#create_node+ method
317
- #
318
- class NetworkNode < NetworkElement
319
-
320
- def initialize(name, attributes, network)
321
- super
322
- end
323
-
324
- def node?
325
- true
326
- end
327
- end # NetworkNode
328
-
329
- # This class represents a network link between two nodes.
330
- # Should NOT be created directly, but only through
331
- # +OmlNetwork#create_node+ method
332
- #
333
- class NetworkLink < NetworkElement
334
- attr_reader :from # node
335
- attr_reader :to # node
336
-
337
- def initialize(name, fromNode, toNode, attributes, network)
338
- super name, attributes, network
339
- if fromNode
340
- @fromNode = fromNode
341
- #puts ">>>> NODE: #{fromNode.inspect}"
342
- @attributes[:from_id] = fromNode.el_id
343
- end
344
- if toNode
345
- @toNode = toNode
346
- @attributes[:to_id] = toNode.el_id
347
- end
348
- end
349
-
350
- def from=(node)
351
- @attributes[:from_id] = node.el_id if node
352
- @fromNode = _set(node, @fromNode)
353
- end
354
-
355
- def to=(node)
356
- @attributes[:to_id] = node.el_id if node
357
- @toNode = _set(node, @toNode)
358
- end
359
-
360
- def link?
361
- true
362
- end
363
- end # NetworkLink
364
-
365
- # This set may hold a set of nodes and links which have been
366
- # updated during a transaction. It supports the +describe+
367
- # function which returns a domain-specific combine of all the
368
- # included network elements.
369
- #
370
- class UpdateSet < Set
371
- def describe()
372
- nh = {}
373
- lh = {}
374
-
375
- self.each do |el|
376
- d = el.describe
377
- if el.kind_of? NetworkNode
378
- nh[el.el_id] = d
379
- else
380
- lh[el.el_id] = d
381
- end
382
- end
383
- {:nodes => nh, :links => lh}
384
- end
385
- end
386
- end
387
-
388
- if $0 == __FILE__
389
- require 'json'
390
- include OMF::Common::OML
391
-
392
- nw = OmlNetwork.new
393
-
394
- cnt = 3
395
- cnt.times do |i|
396
- nw.create_node "n#{i}", :x => i
397
- end
398
- cnt.times do |i|
399
- nw.create_link "l#{i}", "n#{i}", "n#{(i + 1) % cnt}", :y => i
400
- end
401
-
402
- puts nw.describe.to_json
403
-
404
- nw.on_update do |els|
405
- puts "UPDATED: #{els}"
406
- end
407
- nw.nodes.first[:x] = 20
408
-
409
- nw.transaction do
410
- nw.nodes.first[:x] = 30
411
- nw.links.first[:y] = 20
412
- end
413
- end
@@ -1,62 +0,0 @@
1
-
2
- require 'omf_oml'
3
- require 'omf-oml/schema'
4
- require 'omf-oml/tuple'
5
-
6
- module OMF::OML
7
-
8
- # This class represents a single vector from an OML measurement stream.
9
- # It provides various methods to access the vectors elements.
10
- #
11
- # NOTE: Do not store the vector itself, but make a copy as the instance may be
12
- # reused over various rows by the sender.
13
- #
14
- class OmlTuple < Tuple
15
-
16
- # Return the elements of the vector as an array
17
- def to_a(include_index_ts = false)
18
- res = []
19
- r = @raw
20
- if include_index_ts
21
- res << @vprocs[:oml_ts].call(r)
22
- res << @vprocs[:oml_seq_no].call(r)
23
- end
24
- @schema.each do |col|
25
- res << @vprocs[col[:name]].call(r)
26
- end
27
- res
28
- end
29
-
30
- def ts
31
- @raw[0].to_f
32
- end
33
-
34
- def seq_no
35
- @raw[1].to_i
36
- end
37
-
38
- # Note: This method assumes that the first two elements in each OML tuple,
39
- # 'oml_ts' and 'oml_seq_no' are not defined in the associated schema.
40
- #
41
- def process_schema(schema)
42
- i = 0
43
- @vprocs = {}
44
- schema.each_column do |col| #
45
- name = col[:name] || raise("Ill-formed schema '#{schema}'")
46
- type = col[:type] || raise("Ill-formed schema '#{schema}'")
47
- j = i + 2; # need to create a locally scoped variable for the following lambdas
48
- @vprocs[name] = @vprocs[i] = case type
49
- when :string
50
- lambda do |r| r[j] end
51
- when :double
52
- lambda do |r| r[j].to_f end
53
- else raise "Unrecognized OML type '#{type}'"
54
- end
55
- i += 1
56
- end
57
- @vprocs[:oml_ts] = lambda do |r| r[0].to_f end
58
- @vprocs[:oml_seq_no] = lambda do |r| r[1].to_i end
59
- end
60
-
61
- end # OmlTuple
62
- end # OMF::OML