content_server 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/bin/backup_server +8 -20
  2. data/bin/content_server +8 -20
  3. data/bin/testing_memory +60 -0
  4. data/bin/testing_server +57 -0
  5. data/ext/run_in_background/mkrf_conf.rb +34 -0
  6. data/lib/content_data/content_data.rb +613 -0
  7. data/lib/content_data/version.rb +3 -0
  8. data/lib/content_data.rb +6 -0
  9. data/lib/content_server/backup_server.rb +65 -86
  10. data/lib/content_server/content_server.rb +47 -77
  11. data/lib/content_server/file_streamer.rb +27 -33
  12. data/lib/content_server/queue_copy.rb +154 -49
  13. data/lib/content_server/queue_indexer.rb +19 -11
  14. data/lib/content_server/remote_content.rb +41 -23
  15. data/lib/content_server/server.rb +91 -0
  16. data/lib/content_server/version.rb +1 -1
  17. data/lib/content_server.rb +0 -15
  18. data/lib/email/email.rb +87 -0
  19. data/lib/email/version.rb +3 -0
  20. data/lib/email.rb +4 -0
  21. data/lib/file_copy/copy.rb +68 -0
  22. data/lib/file_copy/version.rb +4 -0
  23. data/lib/file_copy.rb +4 -0
  24. data/lib/file_indexing/index_agent.rb +170 -0
  25. data/lib/file_indexing/indexer_patterns.rb +72 -0
  26. data/lib/file_indexing/version.rb +3 -0
  27. data/lib/file_indexing.rb +9 -0
  28. data/lib/file_monitoring/file_monitoring.rb +105 -0
  29. data/lib/file_monitoring/monitor_path.rb +304 -0
  30. data/lib/file_monitoring/version.rb +3 -0
  31. data/lib/file_monitoring.rb +29 -0
  32. data/lib/file_utils/file_generator/README +97 -0
  33. data/lib/file_utils/file_generator/file_generator.rb +156 -0
  34. data/lib/file_utils/file_utils.rb +260 -0
  35. data/lib/file_utils/version.rb +3 -0
  36. data/lib/file_utils.rb +4 -0
  37. data/lib/log/version.rb +3 -0
  38. data/lib/log.rb +188 -0
  39. data/lib/networking/tcp.rb +213 -0
  40. data/lib/networking/version.rb +3 -0
  41. data/lib/networking.rb +4 -0
  42. data/lib/params/version.rb +3 -0
  43. data/lib/params.rb +419 -0
  44. data/lib/process_monitoring/monitoring.rb +85 -0
  45. data/lib/process_monitoring/monitoring_info.rb +79 -0
  46. data/lib/process_monitoring/send_email.rb +40 -0
  47. data/lib/process_monitoring/thread_safe_hash.rb +77 -0
  48. data/lib/process_monitoring/version.rb +3 -0
  49. data/lib/process_monitoring.rb +6 -0
  50. data/lib/run_in_background/version.rb +3 -0
  51. data/lib/run_in_background.rb +432 -0
  52. data/lib/testing_memory/testing_memory.rb +187 -0
  53. data/lib/testing_server/testing_server.rb +236 -0
  54. data/lib/testing_server/version.rb +3 -0
  55. data/lib/testing_server.rb +12 -0
  56. data/lib/validations/index_validations.rb +106 -0
  57. data/lib/validations/version.rb +3 -0
  58. data/lib/validations.rb +4 -0
  59. data/spec/content_data/validations_spec.rb +113 -0
  60. data/spec/file_copy/copy_spec.rb +54 -0
  61. data/spec/file_indexing/index_agent_spec.rb +53 -0
  62. data/spec/networking/tcp_spec.rb +95 -0
  63. data/spec/validations/index_validations_spec.rb +77 -0
  64. data/test/content_data/content_data_test.rb +290 -0
  65. data/test/file_generator/file_generator_spec.rb +84 -0
  66. data/test/file_indexing/index_agent_test/New.txt +0 -0
  67. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libexslt.dll +0 -0
  68. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/libxslt.dll +0 -0
  69. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/bin/xsltproc.exe +0 -0
  70. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exslt.h +102 -0
  71. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltconfig.h +73 -0
  72. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/exsltexports.h +140 -0
  73. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libexslt/libexslt.h +29 -0
  74. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/attributes.h +38 -0
  75. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/documents.h +93 -0
  76. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extensions.h +262 -0
  77. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/extra.h +80 -0
  78. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/functions.h +78 -0
  79. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/imports.h +75 -0
  80. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/keys.h +53 -0
  81. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/libxslt.h +30 -0
  82. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/namespaces.h +68 -0
  83. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/numbersInternals.h +69 -0
  84. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/pattern.h +81 -0
  85. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/preproc.h +43 -0
  86. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/security.h +104 -0
  87. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/templates.h +77 -0
  88. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/transform.h +207 -0
  89. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/trio.h +216 -0
  90. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/triodef.h +220 -0
  91. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/variables.h +91 -0
  92. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/win32config.h +101 -0
  93. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xslt.h +103 -0
  94. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltInternals.h +1967 -0
  95. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltconfig.h +172 -0
  96. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltexports.h +142 -0
  97. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltlocale.h +57 -0
  98. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltutils.h +309 -0
  99. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/include/libxslt/xsltwin32config.h +105 -0
  100. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt.lib +0 -0
  101. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libexslt_a.lib +0 -0
  102. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt.lib +0 -0
  103. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/lib/libxslt_a.lib +0 -0
  104. data/test/file_indexing/index_agent_test/libxslt-1.1.26.win32/readme.txt +22 -0
  105. data/test/file_indexing/index_agent_test/patterns.input +3 -0
  106. data/test/file_indexing/index_agent_test.rb +51 -0
  107. data/test/file_monitoring/file_monitoring_test/conf.yml +4 -0
  108. data/test/file_monitoring/file_monitoring_test/conf_win32.yml +5 -0
  109. data/test/file_monitoring/file_monitoring_test/log +56 -0
  110. data/test/file_monitoring/file_monitoring_test.rb +0 -0
  111. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000 +1000 -0
  112. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000.0 +1000 -0
  113. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000.1 +1000 -0
  114. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500 +1500 -0
  115. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500.0 +1500 -0
  116. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500.1 +1500 -0
  117. data/test/file_monitoring/monitor_path_test/test_file.500 +500 -0
  118. data/test/file_monitoring/monitor_path_test/test_file.500.0 +500 -0
  119. data/test/file_monitoring/monitor_path_test/test_file.500.1 +500 -0
  120. data/test/file_monitoring/monitor_path_test.rb +153 -0
  121. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500 +1500 -0
  122. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.0 +1500 -0
  123. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.1 +1500 -0
  124. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000 +1000 -0
  125. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.0 +1000 -0
  126. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.1 +1000 -0
  127. data/test/file_utils/fileutil_mksymlink_test/test_file.500 +500 -0
  128. data/test/file_utils/fileutil_mksymlink_test/test_file.500.0 +500 -0
  129. data/test/file_utils/fileutil_mksymlink_test/test_file.500.1 +500 -0
  130. data/test/file_utils/fileutil_mksymlink_test.rb +125 -0
  131. data/test/file_utils/time_modification_test.rb +132 -0
  132. data/test/params/params_spec.rb +280 -0
  133. data/test/params/params_test.rb +43 -0
  134. data/test/run_in_background/run_in_background_test.rb +122 -0
  135. data/test/run_in_background/test_app +57 -0
  136. metadata +272 -132
  137. data/lib/content_server/globals.rb +0 -10
data/bin/backup_server CHANGED
@@ -7,13 +7,16 @@
7
7
 
8
8
  # NOTE this file mainly is a copy of content_server
9
9
 
10
+ require 'content_server' #todo: yarondbb need it?
11
+ require 'content_server/backup_server' # specific backup server impl
12
+ require 'content_server/server' # shared file between content\backup
10
13
  require 'log'
11
14
  require 'params'
12
15
  require 'run_in_background'
13
- require 'content_server'
14
16
 
15
17
  Params.init ARGV
16
18
  Log.init
19
+ ContentServer.init_globals
17
20
 
18
21
  Thread.abort_on_exception = true # TODO (genadyp) should be treated globally? by param for example.
19
22
 
@@ -21,28 +24,13 @@ retries = 0 # number of retries to run a server
21
24
 
22
25
  begin
23
26
  RunInBackground.run { ContentServer.run_backup_server }
24
- rescue SystemExit, SignalException => exc
27
+ rescue SystemExit, SignalException => exception
25
28
  # TODO (genadyp) do we need to trap signals by types?
26
- puts("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
27
- "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
28
- puts("Force writing local content data to #{Params['local_content_data_path']}.")
29
- ContentServer::local_dynamic_content_data.last_content_data.to_file(ContentServer::tmp_content_data_file)
30
- sleep(0.1) # Added to prevent mv access issue
31
- ::FileUtils.mv(ContentServer::tmp_content_data_file, Params['local_content_data_path'])
32
-
33
-
34
- Log.error("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
35
- "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
29
+ ContentServer.handle_program_termination(exception)
36
30
  Log.flush
37
31
  exit
38
- rescue Exception => exc
39
- puts("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n#{exc.backtrace.join("\n")}")
40
- puts("Force writing local content data to #{Params['local_content_data_path']}.")
41
- ContentServer::local_dynamic_content_data.last_content_data.to_file(ContentServer::tmp_content_data_file)
42
- sleep(0.1) # Added to prevent mv access issue
43
- ::FileUtils.mv(ContentServer::tmp_content_data_file, Params['local_content_data_path'])
44
-
45
- Log.error("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n#{exc.backtrace.join("\n")}")
32
+ rescue Exception => exception
33
+ ContentServer.handle_program_termination(exception)
46
34
  if retries > 0
47
35
  Log.debug1("Restarting (retries:#{retries}).")
48
36
  else
data/bin/content_server CHANGED
@@ -4,13 +4,16 @@
4
4
  # The files in those directories are indexed (calculating their SHA1).
5
5
  # Each unique content is backed up to the remote (backup) server.
6
6
 
7
+ require 'content_server' #todo: yarondbb need it?
8
+ require 'content_server/content_server' # specific content server impl
9
+ require 'content_server/server' # shared file between content\backup
7
10
  require 'log'
8
11
  require 'params'
9
12
  require 'run_in_background'
10
- require 'content_server'
11
13
 
12
14
  Params.init ARGV
13
15
  Log.init
16
+ ContentServer.init_globals
14
17
 
15
18
  Thread.abort_on_exception = true # TODO (genadyp) should be treated globally? by param for example.
16
19
 
@@ -18,28 +21,13 @@ retries = 0 # number of retries to run a server
18
21
 
19
22
  begin
20
23
  RunInBackground.run { ContentServer.run_content_server }
21
- rescue SystemExit, SignalException => exc
24
+ rescue SystemExit, SignalException => exception
22
25
  # TODO (genadyp) do we need to trap signals by types?
23
- #force dump of content data to file
24
- puts("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
25
- "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
26
- puts("Force writing local content data to #{Params['local_content_data_path']}.")
27
- ContentServer::local_dynamic_content_data.last_content_data.to_file(ContentServer::tmp_content_data_file)
28
- sleep(0.1) # Added to prevent mv access issue
29
- ::FileUtils.mv(ContentServer::tmp_content_data_file, Params['local_content_data_path'])
30
-
31
- Log.error("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
32
- "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
26
+ ContentServer.handle_program_termination(exception)
33
27
  Log.flush
34
28
  exit
35
- rescue Exception => exc
36
- puts("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n#{exc.backtrace.join("\n")}")
37
- puts("Force writing local content data to #{Params['local_content_data_path']}.")
38
- ContentServer::local_dynamic_content_data.last_content_data.to_file(ContentServer::tmp_content_data_file)
39
- sleep(0.1) # Added to prevent mv access issue
40
- ::FileUtils.mv(ContentServer::tmp_content_data_file, Params['local_content_data_path'])
41
-
42
- Log.error("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n#{exc.backtrace.join("\n")}")
29
+ rescue Exception => exception
30
+ ContentServer.handle_program_termination(exception)
43
31
  if retries > 0
44
32
  Log.debug1("Restarting (retries:#{retries}).")
45
33
  else
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Runs a memory test:
4
+ # 1. Run content server or backup server
5
+ # 2. Generate files.
6
+ # 3. Monitor files.
7
+ # 4. Index files.
8
+ # 5. Report memory of process at different phases\times
9
+ # Examples:
10
+ # testing_server --conf_file=~/.bbfs/etc/backup_testing_memory.yml --server_to_test=backup
11
+ # testing_server --conf_file=~/.bbfs/etc/content_testing_memory.yml --server_to_test=content
12
+
13
+ # TODO add command line help/usage
14
+
15
+ require 'params'
16
+ require 'run_in_background'
17
+ require 'testing_memory/testing_memory'
18
+
19
+ Params.string('server_to_test', nil, 'Server that will be run under test_server. Values are: content, backup')
20
+
21
+ Params.init ARGV
22
+ Log.init
23
+ ContentServer.init_globals
24
+
25
+ Thread.abort_on_exception = true
26
+
27
+ retries = 0 # number of retries to run a server
28
+
29
+ begin
30
+ case Params['server_to_test']
31
+ when 'content'
32
+ RunInBackground.run { TestingMemory.run_content_memory_server }
33
+ when 'backup'
34
+ RunInBackground.run { TestingMemory.run_backup_memory_server }
35
+ else
36
+ raise ArgumentError.new "Incorrect server_to_test parameter value: #{Params['server_to_test']}"
37
+ end
38
+ retries -=1
39
+
40
+ rescue SystemExit, SignalException => exc
41
+ # TODO (genadyp) do we need to trap signals by types?
42
+ puts("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
43
+ "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
44
+ Log.error("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
45
+ "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
46
+ Log.flush
47
+ exit
48
+ rescue Exception => exc
49
+ puts("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n" +
50
+ "#{exc.backtrace.join("\n")}")
51
+ Log.error("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n" +
52
+ "#{exc.backtrace.join("\n")}")
53
+ if retries > 0
54
+ Log.debug1("Restarting (retries:#{retries}).")
55
+ else
56
+ Log.debug1("Exiting...")
57
+ Log.flush
58
+ end
59
+ retries -= 1
60
+ end while retries >= 0
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Runs content server. This server monitors a set of directories (blobs/patterns).
4
+ # The files in those directories are indexed (calculating their SHA1).
5
+ # Each unique content is backed up to the remote (backup) server.
6
+ # How to run on content side:
7
+ # testing_server --conf_file=~/.bbfs/etc/content_testing_server.yml --server_to_test=content
8
+ # How to run on backup side:
9
+ # testing_server --conf_file=~/.bbfs/etc/backup_testing_server.yml --server_to_test=backup
10
+
11
+ # TODO add command line help/usage
12
+
13
+ require 'params'
14
+ require 'run_in_background'
15
+ require 'testing_server'
16
+
17
+ Params.string('server_to_test', nil, 'Server that will be run under test_server. Values are: content, backup')
18
+
19
+ Params.init ARGV
20
+ Log.init
21
+ ContentServer.init_globals
22
+
23
+ Thread.abort_on_exception = true
24
+
25
+ retries = 0 # number of retries to run a server
26
+
27
+ begin
28
+ case Params['server_to_test']
29
+ when 'content'
30
+ RunInBackground.run { TestingServer.run_content_testing_server }
31
+ when 'backup'
32
+ RunInBackground.run { TestingServer.run_backup_testing_server }
33
+ else
34
+ raise ArgumentError.new "Incorrect server_to_test parameter value: #{Params['server_to_test']}"
35
+ end
36
+
37
+ rescue SystemExit, SignalException => exc
38
+ # TODO (genadyp) do we need to trap signals by types?
39
+ puts("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
40
+ "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
41
+ Log.error("Interrupt or Exit happened in #{Params['service_name']} server: #{exc.class}, " +
42
+ "stopping process.\nBacktrace:\n#{exc.backtrace.join("\n")}")
43
+ Log.flush
44
+ exit
45
+ rescue Exception => exc
46
+ puts("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n" +
47
+ "#{exc.backtrace.join("\n")}")
48
+ Log.error("Exception happened in #{Params['service_name']} server: #{exc.class}:#{exc.message}\nBacktrace:\n" +
49
+ "#{exc.backtrace.join("\n")}")
50
+ if retries > 0
51
+ Log.debug1("Restarting (retries:#{retries}).")
52
+ else
53
+ Log.debug1("Exiting...")
54
+ Log.flush
55
+ end
56
+ retries -= 1
57
+ end while retries >= 0
@@ -0,0 +1,34 @@
1
+ # This extension used to install platform specific gem dependencies
2
+ # for more information:
3
+ # http://stackoverflow.com/questions/4596606/rubygems-how-do-i-add-platform-specific-dependency/10249133#10249133
4
+ # https://github.com/openshift/os-client-tools/blob/master/express/ext/mkrf_conf.rb
5
+
6
+ require 'rubygems'
7
+ require 'rubygems/command.rb'
8
+ require 'rubygems/dependency_installer.rb'
9
+ #begin
10
+ #Gem::Command.build_args = ARGV
11
+ #rescue NoMethodError
12
+ #end
13
+ inst = Gem::DependencyInstaller.new
14
+ begin
15
+ if Gem::win_platform?
16
+ if Gem::Specification.find_all_by_name('sys-uname').empty?
17
+ inst.install 'sys-uname'
18
+ end
19
+ if Gem::Specification.find_all_by_name('win32-service').empty?
20
+ inst.install 'win32-service'
21
+ end
22
+ else
23
+ if Gem::Specification.find_all_by_name('daemons').empty?
24
+ inst.install 'daemons'
25
+ end
26
+ end
27
+ rescue Exception => e
28
+ puts e.to_s
29
+ exit(1)
30
+ end
31
+
32
+ f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
33
+ f.write("task :default\n")
34
+ f.close