cuboid 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +13 -13
  4. data/lib/cuboid/application.rb +10 -10
  5. data/lib/cuboid/option_groups/{dispatcher.rb → agent.rb} +9 -9
  6. data/lib/cuboid/option_groups/paths.rb +1 -1
  7. data/lib/cuboid/options.rb +1 -1
  8. data/lib/cuboid/processes/{dispatchers.rb → agents.rb} +25 -25
  9. data/lib/cuboid/processes/executables/agent.rb +5 -0
  10. data/lib/cuboid/processes/helpers/agents.rb +23 -0
  11. data/lib/cuboid/processes/helpers/instances.rb +4 -4
  12. data/lib/cuboid/processes/helpers.rb +1 -1
  13. data/lib/cuboid/processes/instances.rb +9 -9
  14. data/lib/cuboid/processes/schedulers.rb +2 -2
  15. data/lib/cuboid/processes.rb +2 -2
  16. data/lib/cuboid/rest/server/instance_helpers.rb +13 -13
  17. data/lib/cuboid/rest/server/routes/dispatcher.rb +11 -11
  18. data/lib/cuboid/rest/server/routes/grid.rb +8 -8
  19. data/lib/cuboid/rest/server/routes/instances.rb +1 -1
  20. data/lib/cuboid/rest/server.rb +5 -5
  21. data/lib/cuboid/rpc/client/{dispatcher.rb → agent.rb} +4 -4
  22. data/lib/cuboid/rpc/client/instance.rb +2 -2
  23. data/lib/cuboid/rpc/client.rb +1 -1
  24. data/lib/cuboid/rpc/server/agent/node.rb +247 -0
  25. data/lib/cuboid/rpc/server/{dispatcher → agent}/service.rb +13 -13
  26. data/lib/cuboid/rpc/server/{dispatcher.rb → agent.rb} +32 -31
  27. data/lib/cuboid/rpc/server/application_wrapper.rb +1 -1
  28. data/lib/cuboid/rpc/server/instance.rb +4 -4
  29. data/lib/cuboid/rpc/server/scheduler.rb +12 -12
  30. data/lib/version +1 -1
  31. data/spec/cuboid/option_groups/dispatcher_spec.rb +2 -2
  32. data/spec/cuboid/rest/server_spec.rb +45 -45
  33. data/spec/cuboid/rpc/client/dispatcher_spec.rb +2 -2
  34. data/spec/cuboid/rpc/server/dispatcher/node_spec.rb +65 -65
  35. data/spec/cuboid/rpc/server/dispatcher/service_spec.rb +16 -16
  36. data/spec/cuboid/rpc/server/dispatcher_spec.rb +95 -95
  37. data/spec/cuboid/rpc/server/scheduler_spec.rb +8 -8
  38. data/spec/support/fixtures/executables/node.rb +3 -3
  39. data/spec/support/fixtures/mock_app/test_service.rb +8 -8
  40. data/spec/support/fixtures/mock_app.rb +1 -1
  41. data/spec/support/fixtures/services/echo.rb +6 -6
  42. data/spec/support/helpers/resets.rb +1 -1
  43. data/spec/support/lib/web_server_client.rb +2 -2
  44. data/spec/support/lib/web_server_dispatcher.rb +1 -1
  45. metadata +10 -348
  46. data/lib/cuboid/processes/executables/dispatcher.rb +0 -5
  47. data/lib/cuboid/processes/helpers/dispatchers.rb +0 -23
  48. data/lib/cuboid/rpc/server/dispatcher/node.rb +0 -247
  49. data/spec/support/logs/Dispatcher - 1520492-37227.log +0 -6
  50. data/spec/support/logs/Dispatcher - 1520680-13689.log +0 -6
  51. data/spec/support/logs/Dispatcher - 1520682-24167.log +0 -6
  52. data/spec/support/logs/Dispatcher - 1520688-42731.log +0 -6
  53. data/spec/support/logs/Dispatcher - 1520690-5750.log +0 -10
  54. data/spec/support/logs/Dispatcher - 1520692-55183.log +0 -10
  55. data/spec/support/logs/Dispatcher - 1520695-39752.log +0 -10
  56. data/spec/support/logs/Dispatcher - 1520697-44327.log +0 -10
  57. data/spec/support/logs/Dispatcher - 1520699-58785.log +0 -10
  58. data/spec/support/logs/Dispatcher - 1520701-60952.log +0 -10
  59. data/spec/support/logs/Dispatcher - 1520796-50420.log +0 -6
  60. data/spec/support/logs/Dispatcher - 1520894-56883.log +0 -6
  61. data/spec/support/logs/Dispatcher - 1520896-21419.log +0 -6
  62. data/spec/support/logs/Dispatcher - 1520898-62584.log +0 -6
  63. data/spec/support/logs/Dispatcher - 1520900-59721.log +0 -6
  64. data/spec/support/logs/Dispatcher - 1520910-51632.log +0 -6
  65. data/spec/support/logs/Dispatcher - 1520920-21801.log +0 -6
  66. data/spec/support/logs/Dispatcher - 1520930-49223.log +0 -6
  67. data/spec/support/logs/Dispatcher - 1520933-34241.log +0 -6
  68. data/spec/support/logs/Dispatcher - 1520935-64571.log +0 -6
  69. data/spec/support/logs/Dispatcher - 1520937-50734.log +0 -6
  70. data/spec/support/logs/Dispatcher - 1520939-60841.log +0 -6
  71. data/spec/support/logs/Dispatcher - 1520944-8124.log +0 -6
  72. data/spec/support/logs/Dispatcher - 1520946-25192.log +0 -16
  73. data/spec/support/logs/Dispatcher - 1520948-9752.log +0 -14
  74. data/spec/support/logs/Dispatcher - 1520952-45543.log +0 -10
  75. data/spec/support/logs/Dispatcher - 1520958-36653.log +0 -16
  76. data/spec/support/logs/Dispatcher - 1520960-17456.log +0 -14
  77. data/spec/support/logs/Dispatcher - 1520964-5774.log +0 -10
  78. data/spec/support/logs/Dispatcher - 1520976-40848.log +0 -16
  79. data/spec/support/logs/Dispatcher - 1520978-29867.log +0 -14
  80. data/spec/support/logs/Dispatcher - 1520982-17715.log +0 -10
  81. data/spec/support/logs/Dispatcher - 1520987-8925.log +0 -16
  82. data/spec/support/logs/Dispatcher - 1520989-25480.log +0 -14
  83. data/spec/support/logs/Dispatcher - 1520993-5124.log +0 -10
  84. data/spec/support/logs/Dispatcher - 1520999-12901.log +0 -16
  85. data/spec/support/logs/Dispatcher - 1521004-32265.log +0 -14
  86. data/spec/support/logs/Dispatcher - 1521008-33455.log +0 -10
  87. data/spec/support/logs/Dispatcher - 1521014-13779.log +0 -6
  88. data/spec/support/logs/Dispatcher - 1521017-14755.log +0 -6
  89. data/spec/support/logs/Dispatcher - 1521022-48687.log +0 -6
  90. data/spec/support/logs/Dispatcher - 1521024-59097.log +0 -6
  91. data/spec/support/logs/Dispatcher - 1521034-12604.log +0 -6
  92. data/spec/support/logs/Dispatcher - 1521038-64272.log +0 -6
  93. data/spec/support/logs/Dispatcher - 1521043-8680.log +0 -6
  94. data/spec/support/logs/Dispatcher - 1521047-22949.log +0 -6
  95. data/spec/support/logs/Dispatcher - 1521051-3355.log +0 -6
  96. data/spec/support/logs/Dispatcher - 1521074-12332.log +0 -6
  97. data/spec/support/logs/Dispatcher - 1521118-53130.log +0 -16
  98. data/spec/support/logs/Dispatcher - 1521128-47137.log +0 -14
  99. data/spec/support/logs/Dispatcher - 1521136-30328.log +0 -10
  100. data/spec/support/logs/Dispatcher - 1521161-21329.log +0 -16
  101. data/spec/support/logs/Dispatcher - 1521172-19183.log +0 -14
  102. data/spec/support/logs/Dispatcher - 1521179-34902.log +0 -10
  103. data/spec/support/logs/Dispatcher - 1521190-20155.log +0 -16
  104. data/spec/support/logs/Dispatcher - 1521204-43843.log +0 -14
  105. data/spec/support/logs/Dispatcher - 1521211-23972.log +0 -10
  106. data/spec/support/logs/Dispatcher - 1521237-20879.log +0 -10
  107. data/spec/support/logs/Dispatcher - 1521239-61999.log +0 -10
  108. data/spec/support/logs/Dispatcher - 1521242-20975.log +0 -16
  109. data/spec/support/logs/Dispatcher - 1521246-28409.log +0 -14
  110. data/spec/support/logs/Dispatcher - 1521250-58505.log +0 -10
  111. data/spec/support/logs/Dispatcher - 1521262-53292.log +0 -6
  112. data/spec/support/logs/Dispatcher - 1521266-42758.log +0 -6
  113. data/spec/support/logs/Dispatcher - 1521277-4215.log +0 -6
  114. data/spec/support/logs/Dispatcher - 1521292-16086.log +0 -6
  115. data/spec/support/logs/Dispatcher - 1521301-42112.log +0 -6
  116. data/spec/support/logs/Dispatcher - 1521312-61196.log +0 -6
  117. data/spec/support/logs/Dispatcher - 1521316-23353.log +0 -6
  118. data/spec/support/logs/Dispatcher - 1521321-46361.log +0 -6
  119. data/spec/support/logs/Dispatcher - 1521438-46016.log +0 -6
  120. data/spec/support/logs/Dispatcher - 1521454-49862.log +0 -6
  121. data/spec/support/logs/Dispatcher - 1521470-54737.log +0 -6
  122. data/spec/support/logs/Instance - 1521353-26273.error.log +0 -105
  123. data/spec/support/logs/Instance - 1521355-56591.error.log +0 -105
  124. data/spec/support/logs/Instance - 1521363-26218.error.log +0 -105
  125. data/spec/support/logs/Scheduler - 1520469-35703.log +0 -3
  126. data/spec/support/logs/Scheduler - 1520473-60524.log +0 -6
  127. data/spec/support/logs/Scheduler - 1520509-34951.log +0 -3
  128. data/spec/support/logs/Scheduler - 1520517-31455.log +0 -6
  129. data/spec/support/logs/Scheduler - 1520529-43808.log +0 -4
  130. data/spec/support/logs/Scheduler - 1520536-23387.log +0 -1
  131. data/spec/support/logs/Scheduler - 1520549-48260.log +0 -3
  132. data/spec/support/logs/Scheduler - 1520563-45636.log +0 -6
  133. data/spec/support/logs/Scheduler - 1520599-40643.log +0 -3
  134. data/spec/support/logs/Scheduler - 1520608-54106.log +0 -6
  135. data/spec/support/logs/Scheduler - 1520629-24722.log +0 -3
  136. data/spec/support/logs/Scheduler - 1520637-61755.log +0 -6
  137. data/spec/support/logs/Scheduler - 1520663-17447.log +0 -4
  138. data/spec/support/logs/Scheduler - 1520671-38282.log +0 -6
  139. data/spec/support/logs/Scheduler - 1520703-33082.log +0 -1
  140. data/spec/support/logs/Scheduler - 1520706-22309.log +0 -1
  141. data/spec/support/logs/Scheduler - 1520709-1816.log +0 -1
  142. data/spec/support/logs/Scheduler - 1520711-19998.log +0 -1
  143. data/spec/support/logs/Scheduler - 1520714-47570.log +0 -1
  144. data/spec/support/logs/Scheduler - 1520723-18521.log +0 -1
  145. data/spec/support/logs/Scheduler - 1520725-40913.log +0 -3
  146. data/spec/support/logs/Scheduler - 1520749-45742.log +0 -6
  147. data/spec/support/logs/Scheduler - 1520759-44350.log +0 -4
  148. data/spec/support/logs/Scheduler - 1520770-53219.log +0 -1
  149. data/spec/support/logs/Scheduler - 1520773-54792.log +0 -1
  150. data/spec/support/logs/Scheduler - 1520777-19636.log +0 -1
  151. data/spec/support/logs/Scheduler - 1520780-51801.log +0 -1
  152. data/spec/support/logs/Scheduler - 1520782-9652.log +0 -3
  153. data/spec/support/logs/Scheduler - 1520786-59472.log +0 -1
  154. data/spec/support/logs/Scheduler - 1520789-1603.log +0 -1
  155. data/spec/support/logs/Scheduler - 1520792-35476.log +0 -1
  156. data/spec/support/logs/Scheduler - 1521410-47324.log +0 -16
  157. data/spec/support/logs/Scheduler - 1521422-33737.log +0 -6
  158. data/spec/support/logs/Scheduler - 1521433-36637.log +0 -6
  159. data/spec/support/logs/Scheduler - 1521440-15066.log +0 -6
  160. data/spec/support/logs/Scheduler - 1521456-48637.log +0 -3
  161. data/spec/support/logs/Scheduler - 1521472-54425.log +0 -5
  162. data/spec/support/logs/Scheduler - 1521496-12923.log +0 -1
  163. data/spec/support/logs/Scheduler - 1521518-46819.log +0 -1
  164. data/spec/support/logs/Scheduler - 1521522-21417.log +0 -1
  165. data/spec/support/logs/Scheduler - 1521525-35088.log +0 -1
  166. data/spec/support/logs/Scheduler - 1521528-13676.log +0 -1
  167. data/spec/support/logs/Scheduler - 1521530-48176.log +0 -1
  168. data/spec/support/logs/Scheduler - 1521532-13207.log +0 -1
  169. data/spec/support/logs/Scheduler - 1521535-5799.log +0 -3
  170. data/spec/support/logs/Scheduler - 1521543-62784.log +0 -3
  171. data/spec/support/logs/Scheduler - 1521551-10263.log +0 -3
  172. data/spec/support/logs/Scheduler - 1521556-56026.log +0 -3
  173. data/spec/support/logs/Scheduler - 1521560-14551.log +0 -4
  174. data/spec/support/logs/Scheduler - 1521573-47584.log +0 -1
  175. data/spec/support/logs/Scheduler - 1521578-14443.log +0 -4
  176. data/spec/support/logs/Scheduler - 1521580-60337.log +0 -1
  177. data/spec/support/logs/Scheduler - 1521583-52039.log +0 -1
  178. data/spec/support/logs/Scheduler - 1521586-1500.log +0 -16
  179. data/spec/support/logs/Scheduler - 1521598-61298.log +0 -4
  180. data/spec/support/logs/Scheduler - 1521602-61490.log +0 -1
  181. data/spec/support/logs/Scheduler - 1521604-29209.log +0 -1
  182. data/spec/support/logs/Scheduler - 1521606-47734.log +0 -1
  183. data/spec/support/logs/Scheduler - 1521612-63269.log +0 -1
  184. data/spec/support/logs/Scheduler - 1521614-47018.log +0 -3
  185. data/spec/support/logs/Scheduler - 1521619-32411.log +0 -1
  186. data/spec/support/logs/Scheduler - 1521621-42861.log +0 -1
  187. data/spec/support/logs/Scheduler - 1521623-56258.log +0 -1
  188. data/spec/support/logs/Scheduler - 1521627-9487.log +0 -1
  189. data/spec/support/logs/Scheduler - 1521630-3345.log +0 -1
  190. data/spec/support/logs/Scheduler - 1521632-47325.log +0 -1
  191. data/spec/support/logs/Scheduler - 1521635-22156.log +0 -2
  192. data/spec/support/logs/error-1520329.log +0 -797
  193. data/spec/support/logs/output_spec_1520329.log +0 -390
  194. data/spec/support/reports/003bed585153336c2548d1c60a026a3e.crf +0 -0
  195. data/spec/support/reports/30e3c7a8c13e9b40a0a443a5e5a4ff94.crf +0 -0
  196. data/spec/support/reports/31655751a9f0eee91e588bc796985b1e.crf +0 -0
  197. data/spec/support/reports/40801b7993c0ed919b73242a9c078dde.crf +0 -0
  198. data/spec/support/reports/4719b89667e92bb80102f4b0bb4c0c75.crf +0 -0
  199. data/spec/support/reports/4e765a3d2870d2763ea72167bd3db9d6.crf +0 -0
  200. data/spec/support/reports/61968f732d8ae715c104175e43679915.crf +0 -0
  201. data/spec/support/reports/63446a8ec637d9991b8c6a1151ae59a9.crf +0 -0
  202. data/spec/support/reports/737144b18305c7a115ad7964b9bbe41c.crf +0 -0
  203. data/spec/support/reports/73fe5f7adf905045c3fe4669bdf60d02.crf +0 -0
  204. data/spec/support/reports/86cd396db9ef97472876f32e57c44ce7.crf +0 -0
  205. data/spec/support/reports/8a031ac2b2730dfd07a1d1ca870299f2.crf +0 -0
  206. data/spec/support/reports/8e16ac74484ee5d8cf7073fe22adf787.crf +0 -0
  207. data/spec/support/reports/8eff857213ab6ff712a0b0e8582855c9.crf +0 -0
  208. data/spec/support/reports/9e0e6ed8718973b3d4e63bbb7dd1d1c6.crf +0 -0
  209. data/spec/support/reports/a9c88f967d09cb9c4e8e1180cfb24828.crf +0 -0
  210. data/spec/support/reports/ba32970a64686e45ec8caa5032f65c2e.crf +0 -0
  211. data/spec/support/reports/cceb7596659fd619ab4438953cbda78b.crf +0 -0
  212. data/spec/support/reports/d2e0f4558b605ffd1215e9226815b951.crf +0 -0
  213. data/spec/support/snapshots/Cuboid 2022-01-24 14_38_16 +0200 8238609e31cedaf1bcb89205f9d42121.csf +0 -0
  214. data/spec/support/snapshots/Cuboid 2022-01-24 14_38_30 +0200 68690b002e79c7bc9e3aabfcbc7ac5a7.csf +0 -0
  215. data/spec/support/snapshots/Cuboid 2022-01-24 14_46_39 +0200 6fd3c9491d3e784e18f9c3c0d9deddec.csf +0 -0
  216. data/spec/support/snapshots/Cuboid 2022-01-24 14_46_44 +0200 c3a012fba59210bc7c169afb0565d5a8.csf +0 -0
  217. data/spec/support/snapshots/Cuboid 2022-01-24 14_46_46 +0200 e4c1ce35d8e62e6a16f84eccd36b2283.csf +0 -0
@@ -15,7 +15,7 @@ describe Cuboid::Rest::Server do
15
15
  let(:id) { @id }
16
16
  let(:non_existent_id) { 'stuff' }
17
17
 
18
- let(:dispatcher) { Cuboid::Processes::Dispatchers.spawn }
18
+ let(:agent) { Cuboid::Processes::Agents.spawn }
19
19
  let(:scheduler) { Cuboid::Processes::Schedulers.spawn }
20
20
 
21
21
  def create_instance
@@ -235,17 +235,17 @@ describe Cuboid::Rest::Server do
235
235
  end
236
236
  end
237
237
 
238
- context 'when a Dispatcher has been set' do
238
+ context 'when a Agent has been set' do
239
239
 
240
240
  it 'uses it' do
241
- put '/dispatcher/url', dispatcher.url
241
+ put '/agent/url', agent.url
242
242
 
243
- get "/grid/#{dispatcher.url}"
243
+ get "/grid/#{agent.url}"
244
244
  expect(response_data['running_instances']).to be_empty
245
245
 
246
246
  create_instance
247
247
 
248
- get "/grid/#{dispatcher.url}"
248
+ get "/grid/#{agent.url}"
249
249
  expect(response_data['running_instances'].size).to eq 1
250
250
  end
251
251
  end
@@ -623,32 +623,32 @@ describe Cuboid::Rest::Server do
623
623
  end
624
624
  end
625
625
 
626
- describe 'GET /dispatcher/url' do
627
- let(:tpl_url) { '/dispatcher/url' }
626
+ describe 'GET /agent/url' do
627
+ let(:tpl_url) { '/agent/url' }
628
628
 
629
- it 'returns the Dispatcher' do
630
- put url, dispatcher.url
629
+ it 'returns the Agent' do
630
+ put url, agent.url
631
631
  expect(response_code).to eq 200
632
632
 
633
633
  get url
634
634
  expect(response_code).to eq 200
635
- expect(response_data).to eq dispatcher.url
635
+ expect(response_data).to eq agent.url
636
636
  end
637
637
 
638
- context 'when no Dispatcher has been set' do
638
+ context 'when no Agent has been set' do
639
639
  it 'returns 501' do
640
640
  get url
641
641
  expect(response_code).to eq 501
642
- expect(response_data).to eq 'No Dispatcher has been set.'
642
+ expect(response_data).to eq 'No Agent has been set.'
643
643
  end
644
644
  end
645
645
  end
646
646
 
647
- describe 'PUT /dispatcher/url' do
648
- let(:tpl_url) { '/dispatcher/url' }
647
+ describe 'PUT /agent/url' do
648
+ let(:tpl_url) { '/agent/url' }
649
649
 
650
- it 'sets the Dispatcher' do
651
- put url, dispatcher.url
650
+ it 'sets the Agent' do
651
+ put url, agent.url
652
652
  expect(response_code).to eq 200
653
653
  end
654
654
 
@@ -663,101 +663,101 @@ describe Cuboid::Rest::Server do
663
663
  end
664
664
  end
665
665
 
666
- describe 'DELETE /dispatcher/url' do
667
- let(:tpl_url) { '/dispatcher/url' }
666
+ describe 'DELETE /agent/url' do
667
+ let(:tpl_url) { '/agent/url' }
668
668
 
669
- it 'removes the the Dispatcher' do
670
- put url, dispatcher.url
669
+ it 'removes the the Agent' do
670
+ put url, agent.url
671
671
  expect(response_code).to eq 200
672
672
 
673
673
  delete url
674
674
  expect(response_code).to eq 200
675
675
 
676
- get url, dispatcher.url
676
+ get url, agent.url
677
677
  expect(response_code).to eq 501
678
678
  end
679
679
 
680
- context 'when no Dispatcher has been set' do
680
+ context 'when no Agent has been set' do
681
681
  it 'returns 501' do
682
682
  delete url
683
683
  expect(response_code).to eq 501
684
- expect(response_data).to eq 'No Dispatcher has been set.'
684
+ expect(response_data).to eq 'No Agent has been set.'
685
685
  end
686
686
  end
687
687
  end
688
688
 
689
689
  describe 'GET /grid' do
690
- let(:dispatcher) { Cuboid::Processes::Dispatchers.grid_spawn }
690
+ let(:agent) { Cuboid::Processes::Agents.grid_spawn }
691
691
  let(:tpl_url) { '/grid' }
692
692
 
693
693
  it 'returns Grid info' do
694
- put '/dispatcher/url', dispatcher.url
694
+ put '/agent/url', agent.url
695
695
  expect(response_code).to eq 200
696
696
 
697
697
  get url
698
698
  expect(response_code).to eq 200
699
- expect(response_data.sort).to eq ([dispatcher.url] + dispatcher.node.neighbours).sort
699
+ expect(response_data.sort).to eq ([agent.url] + agent.node.peers).sort
700
700
  end
701
701
 
702
- context 'when no Dispatcher has been set' do
702
+ context 'when no Agent has been set' do
703
703
  it 'returns 501' do
704
704
  get url
705
705
  expect(response_code).to eq 501
706
- expect(response_data).to eq 'No Dispatcher has been set.'
706
+ expect(response_data).to eq 'No Agent has been set.'
707
707
  end
708
708
  end
709
709
  end
710
710
 
711
- describe 'GET /grid/:dispatcher' do
712
- let(:dispatcher) { Cuboid::Processes::Dispatchers.grid_spawn }
711
+ describe 'GET /grid/:agent' do
712
+ let(:agent) { Cuboid::Processes::Agents.grid_spawn }
713
713
  let(:tpl_url) { '/grid/%s' }
714
714
 
715
- it 'returns Dispatcher info' do
716
- put '/dispatcher/url', dispatcher.url
715
+ it 'returns Agent info' do
716
+ put '/agent/url', agent.url
717
717
  expect(response_code).to eq 200
718
718
 
719
- @id = dispatcher.url
719
+ @id = agent.url
720
720
 
721
721
  get url
722
722
  expect(response_code).to eq 200
723
- expect(response_data).to eq dispatcher.statistics
723
+ expect(response_data).to eq agent.statistics
724
724
  end
725
725
 
726
- context 'when no Dispatcher has been set' do
726
+ context 'when no Agent has been set' do
727
727
  it 'returns 501' do
728
728
  @id = 'localhost:2222'
729
729
 
730
730
  get url
731
731
  expect(response_code).to eq 501
732
- expect(response_data).to eq 'No Dispatcher has been set.'
732
+ expect(response_data).to eq 'No Agent has been set.'
733
733
  end
734
734
  end
735
735
  end
736
736
 
737
- describe 'DELETE /grid/:dispatcher' do
738
- let(:dispatcher) { Cuboid::Processes::Dispatchers.grid_spawn }
737
+ describe 'DELETE /grid/:agent' do
738
+ let(:agent) { Cuboid::Processes::Agents.grid_spawn }
739
739
  let(:tpl_url) { '/grid/%s' }
740
740
 
741
- it 'unplugs the Dispatcher from the Grid' do
742
- put '/dispatcher/url', dispatcher.url
741
+ it 'unplugs the Agent from the Grid' do
742
+ put '/agent/url', agent.url
743
743
  expect(response_code).to eq 200
744
744
 
745
- @id = dispatcher.url
745
+ @id = agent.url
746
746
 
747
- expect(dispatcher.node.grid_member?).to be_truthy
747
+ expect(agent.node.grid_member?).to be_truthy
748
748
 
749
749
  delete url
750
750
  expect(response_code).to eq 200
751
- expect(dispatcher.node.grid_member?).to be_falsey
751
+ expect(agent.node.grid_member?).to be_falsey
752
752
  end
753
753
 
754
- context 'when no Dispatcher has been set' do
754
+ context 'when no Agent has been set' do
755
755
  it 'returns 501' do
756
756
  @id = 'localhost:2222'
757
757
 
758
758
  delete url
759
759
  expect(response_code).to eq 501
760
- expect(response_data).to eq 'No Dispatcher has been set.'
760
+ expect(response_data).to eq 'No Agent has been set.'
761
761
  end
762
762
  end
763
763
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'fileutils'
3
3
 
4
- describe Cuboid::RPC::Client::Dispatcher do
5
- subject { dispatcher_spawn application: "#{fixtures_path}/mock_app.rb" }
4
+ describe Cuboid::RPC::Client::Agent do
5
+ subject { agent_spawn application: "#{fixtures_path}/mock_app.rb" }
6
6
 
7
7
  describe '#node' do
8
8
  it 'provides access to the node data' do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
- require "#{Cuboid::Options.paths.lib}/rpc/server/dispatcher"
2
+ require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
3
3
 
4
- describe Cuboid::RPC::Server::Dispatcher::Node do
4
+ describe Cuboid::RPC::Server::Agent::Node do
5
5
 
6
6
  def get_node( port = available_port )
7
7
  Cuboid::Options.rpc.server_port = port
@@ -25,7 +25,7 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
25
25
 
26
26
  before( :each ) do
27
27
  options.paths.executables = "#{fixtures_path}executables/"
28
- options.dispatcher.ping_interval = 0.5
28
+ options.agent.ping_interval = 0.5
29
29
  end
30
30
  after( :each ) do
31
31
  Cuboid::Processes::Manager.killall
@@ -35,9 +35,9 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
35
35
  let(:options) { Cuboid::Options }
36
36
 
37
37
  describe '#grid_member?' do
38
- context 'when the dispatcher is a grid member' do
38
+ context 'when the agent is a grid member' do
39
39
  it 'should return true' do
40
- options.dispatcher.neighbour = subject.url
40
+ options.agent.peer = subject.url
41
41
 
42
42
  c = get_node
43
43
  sleep 0.5
@@ -46,68 +46,68 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
46
46
  end
47
47
  end
48
48
 
49
- context 'when the dispatcher is not a grid member' do
49
+ context 'when the agent is not a grid member' do
50
50
  it 'should return false' do
51
51
  expect(subject.grid_member?).to be_falsey
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
- context 'when a previously unreachable neighbour comes back to life' do
57
- it 'gets re-added to the neighbours list' do
56
+ context 'when a previously unreachable peer comes back to life' do
57
+ it 'gets re-added to the peers list' do
58
58
  port = available_port
59
- subject.add_neighbour( '127.0.0.1:' + port.to_s )
59
+ subject.add_peer( '127.0.0.1:' + port.to_s )
60
60
 
61
61
  sleep 3
62
- expect(subject.neighbours).to be_empty
62
+ expect(subject.peers).to be_empty
63
63
 
64
64
  c = get_node( port )
65
65
 
66
66
  sleep 0.5
67
- expect(subject.neighbours).to eq([c.url])
68
- expect(c.neighbours).to eq([subject.url])
67
+ expect(subject.peers).to eq([c.url])
68
+ expect(c.peers).to eq([subject.url])
69
69
  end
70
70
  end
71
71
 
72
- context 'when a neighbour becomes unreachable' do
72
+ context 'when a peer becomes unreachable' do
73
73
  it 'is removed' do
74
74
  c = get_node
75
75
 
76
- subject.add_neighbour( c.url )
76
+ subject.add_peer( c.url )
77
77
  sleep 0.5
78
78
 
79
- expect(c.neighbours).to eq([subject.url])
80
- expect(subject.neighbours).to eq([c.url])
79
+ expect(c.peers).to eq([subject.url])
80
+ expect(subject.peers).to eq([c.url])
81
81
 
82
82
  subject.shutdown rescue break while sleep 0.1
83
83
  sleep 0.5
84
84
 
85
- expect(c.neighbours).to be_empty
85
+ expect(c.peers).to be_empty
86
86
  end
87
87
  end
88
88
 
89
- context 'when initialised with a neighbour' do
90
- it 'adds that neighbour and reach convergence' do
91
- options.dispatcher.neighbour = subject.url
89
+ context 'when initialised with a peer' do
90
+ it 'adds that peer and reach convergence' do
91
+ options.agent.peer = subject.url
92
92
 
93
93
  c = get_node
94
94
  sleep 0.5
95
- expect(c.neighbours).to eq([subject.url])
96
- expect(subject.neighbours).to eq([c.url])
95
+ expect(c.peers).to eq([subject.url])
96
+ expect(subject.peers).to eq([c.url])
97
97
 
98
98
  d = get_node
99
99
  sleep 0.5
100
- expect(d.neighbours.sort).to eq([subject.url, c.url].sort)
101
- expect(c.neighbours.sort).to eq([subject.url, d.url].sort)
102
- expect(subject.neighbours.sort).to eq([c.url, d.url].sort)
100
+ expect(d.peers.sort).to eq([subject.url, c.url].sort)
101
+ expect(c.peers.sort).to eq([subject.url, d.url].sort)
102
+ expect(subject.peers.sort).to eq([c.url, d.url].sort)
103
103
 
104
- options.dispatcher.neighbour = d.url
104
+ options.agent.peer = d.url
105
105
  e = get_node
106
106
  sleep 0.5
107
- expect(e.neighbours.sort).to eq([subject.url, c.url, d.url].sort)
108
- expect(d.neighbours.sort).to eq([subject.url, c.url, e.url].sort)
109
- expect(c.neighbours.sort).to eq([subject.url, d.url, e.url].sort)
110
- expect(subject.neighbours.sort).to eq([c.url, d.url, e.url].sort)
107
+ expect(e.peers.sort).to eq([subject.url, c.url, d.url].sort)
108
+ expect(d.peers.sort).to eq([subject.url, c.url, e.url].sort)
109
+ expect(c.peers.sort).to eq([subject.url, d.url, e.url].sort)
110
+ expect(subject.peers.sort).to eq([c.url, d.url, e.url].sort)
111
111
  end
112
112
  end
113
113
 
@@ -115,75 +115,75 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
115
115
  it 'removes itself from the Grid' do
116
116
  c = get_node
117
117
 
118
- subject.add_neighbour( c.url )
118
+ subject.add_peer( c.url )
119
119
  sleep 0.5
120
- expect(c.neighbours).to eq([subject.url])
120
+ expect(c.peers).to eq([subject.url])
121
121
 
122
122
  c.unplug
123
123
 
124
- expect(c.neighbours).to be_empty
124
+ expect(c.peers).to be_empty
125
125
  expect(c.grid_member?).to be_falsey
126
126
  end
127
127
  end
128
128
 
129
- describe '#add_neighbour' do
129
+ describe '#add_peer' do
130
130
  before(:each) do
131
- subject.add_neighbour( other.url )
131
+ subject.add_peer( other.url )
132
132
  sleep 0.5
133
133
  end
134
134
 
135
135
  let( :other ) { get_node }
136
136
 
137
- it 'adds a neighbour' do
138
- expect(subject.neighbours).to eq([other.url])
139
- expect(other.neighbours).to eq([subject.url])
137
+ it 'adds a peer' do
138
+ expect(subject.peers).to eq([other.url])
139
+ expect(other.peers).to eq([subject.url])
140
140
  end
141
141
 
142
142
  context 'when propagate is set to true' do
143
- it 'announces the new neighbour to the existing neighbours' do
143
+ it 'announces the new peer to the existing peers' do
144
144
  n = get_node
145
- subject.add_neighbour( n.url, true )
145
+ subject.add_peer( n.url, true )
146
146
  sleep 0.5
147
147
 
148
- expect(subject.neighbours.sort).to eq([other.url, n.url].sort)
149
- expect(other.neighbours.sort).to eq([subject.url, n.url].sort)
148
+ expect(subject.peers.sort).to eq([other.url, n.url].sort)
149
+ expect(other.peers.sort).to eq([subject.url, n.url].sort)
150
150
 
151
151
  c = get_node
152
- n.add_neighbour( c.url, true )
152
+ n.add_peer( c.url, true )
153
153
  sleep 0.5
154
154
 
155
- expect(subject.neighbours.sort).to eq([other.url, n.url, c.url].sort)
156
- expect(other.neighbours.sort).to eq([subject.url, n.url, c.url].sort)
157
- expect(c.neighbours.sort).to eq([subject.url, n.url, other.url].sort)
155
+ expect(subject.peers.sort).to eq([other.url, n.url, c.url].sort)
156
+ expect(other.peers.sort).to eq([subject.url, n.url, c.url].sort)
157
+ expect(c.peers.sort).to eq([subject.url, n.url, other.url].sort)
158
158
 
159
159
  d = get_node
160
- d.add_neighbour( c.url, true )
160
+ d.add_peer( c.url, true )
161
161
  sleep 0.5
162
162
 
163
- expect(subject.neighbours.sort).to eq([d.url, other.url, n.url, c.url].sort)
164
- expect(other.neighbours.sort).to eq([d.url, subject.url, n.url, c.url].sort)
165
- expect(c.neighbours.sort).to eq([d.url, subject.url, n.url, other.url].sort)
166
- expect(d.neighbours.sort).to eq([c.url, subject.url, n.url, other.url].sort)
163
+ expect(subject.peers.sort).to eq([d.url, other.url, n.url, c.url].sort)
164
+ expect(other.peers.sort).to eq([d.url, subject.url, n.url, c.url].sort)
165
+ expect(c.peers.sort).to eq([d.url, subject.url, n.url, other.url].sort)
166
+ expect(d.peers.sort).to eq([c.url, subject.url, n.url, other.url].sort)
167
167
  end
168
168
  end
169
169
  end
170
170
 
171
- describe '#neighbours' do
172
- it 'returns an array of neighbours' do
173
- expect(subject.neighbours.is_a?( Array )).to be_truthy
171
+ describe '#peers' do
172
+ it 'returns an array of peers' do
173
+ expect(subject.peers.is_a?( Array )).to be_truthy
174
174
  end
175
175
  end
176
176
 
177
- describe '#neighbours_with_info' do
178
- it 'returns all neighbours accompanied by their node info' do
179
- subject.add_neighbour( get_node.url )
177
+ describe '#peers_with_info' do
178
+ it 'returns all peers accompanied by their node info' do
179
+ subject.add_peer( get_node.url )
180
180
  sleep 0.5
181
181
 
182
- expect(subject.neighbours).to be_any
183
- expect(subject.neighbours_with_info.size).to eq (subject.neighbours.size)
182
+ expect(subject.peers).to be_any
183
+ expect(subject.peers_with_info.size).to eq (subject.peers.size)
184
184
 
185
185
  keys = subject.info.keys.sort
186
- subject.neighbours_with_info.each do |i|
186
+ subject.peers_with_info.each do |i|
187
187
  expect(i.keys.sort).to eq(keys)
188
188
  end
189
189
  end
@@ -191,18 +191,18 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
191
191
 
192
192
  describe '#info' do
193
193
  it 'returns node info' do
194
- options.dispatcher.name = 'blah'
194
+ options.agent.name = 'blah'
195
195
 
196
196
  c = get_node
197
- subject.add_neighbour( c.url )
197
+ subject.add_peer( c.url )
198
198
  sleep 0.5
199
199
 
200
200
  info = subject.info
201
201
 
202
202
  expect(info['url']).to eq(subject.url)
203
- expect(info['neighbours']).to eq(subject.neighbours)
204
- expect(info['unreachable_neighbours']).to be_empty
205
- expect(info['name']).to eq(options.dispatcher.name)
203
+ expect(info['peers']).to eq(subject.peers)
204
+ expect(info['unreachable_peers']).to be_empty
205
+ expect(info['name']).to eq(options.agent.name)
206
206
  end
207
207
 
208
208
  context 'when OptionGroups::RPC#server_external_address has been set' do
@@ -1,36 +1,36 @@
1
1
  require 'spec_helper'
2
- require "#{Cuboid::Options.paths.lib}/rpc/server/dispatcher"
2
+ require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
3
3
 
4
- describe Cuboid::RPC::Server::Dispatcher::Service do
4
+ describe Cuboid::RPC::Server::Agent::Service do
5
5
  before( :each ) do
6
6
  Cuboid::Options.paths.services = "#{fixtures_path}services/"
7
7
  Cuboid::Options.system.max_slots = 10
8
8
  end
9
9
  let(:instance_count) { 3 }
10
- let(:dispatcher) { dispatcher_spawn application: "#{fixtures_path}/mock_app.rb" }
11
- let(:subject) { dispatcher.test_service }
10
+ let(:agent) { agent_spawn application: "#{fixtures_path}/mock_app.rb" }
11
+ let(:subject) { agent.test_service }
12
12
 
13
- describe '#dispatcher' do
14
- it 'provides access to the parent Dispatcher' do
15
- expect(subject.test_dispatcher).to be_truthy
13
+ describe '#agent' do
14
+ it 'provides access to the parent Agent' do
15
+ expect(subject.test_agent).to be_truthy
16
16
  end
17
17
  end
18
18
 
19
19
  describe '#opts' do
20
- it 'provides access to the Dispatcher\'s options' do
20
+ it 'provides access to the Agent\'s options' do
21
21
  expect(subject.test_opts).to be_truthy
22
22
  end
23
23
  end
24
24
 
25
25
  describe '#node' do
26
- it 'provides access to the Dispatcher\'s node' do
26
+ it 'provides access to the Agent\'s node' do
27
27
  expect(subject.test_node).to be_truthy
28
28
  end
29
29
  end
30
30
 
31
31
  describe '#instances' do
32
32
  before(:each) do
33
- instance_count.times { dispatcher.dispatch }
33
+ instance_count.times { agent.spawn }
34
34
  end
35
35
 
36
36
  it 'provides access to the running instances' do
@@ -40,7 +40,7 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
40
40
 
41
41
  describe '#map_instances' do
42
42
  before(:each) do
43
- instance_count.times { dispatcher.dispatch }
43
+ instance_count.times { agent.spawn }
44
44
  end
45
45
 
46
46
  it 'asynchronously maps all running instances' do
@@ -52,7 +52,7 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
52
52
 
53
53
  describe '#each_instance' do
54
54
  before(:each) do
55
- instance_count.times { dispatcher.dispatch }
55
+ instance_count.times { agent.spawn }
56
56
  end
57
57
 
58
58
  it 'asynchronously iterates over all running instances' do
@@ -92,15 +92,15 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
92
92
  end
93
93
  end
94
94
 
95
- describe '#connect_to_dispatcher' do
96
- it 'connects to the a dispatcher by url' do
97
- expect(subject.test_connect_to_dispatcher( dispatcher.url )).to be_truthy
95
+ describe '#connect_to_agent' do
96
+ it 'connects to the a agent by url' do
97
+ expect(subject.test_connect_to_agent( agent.url )).to be_truthy
98
98
  end
99
99
  end
100
100
 
101
101
  describe '#connect_to_instance' do
102
102
  it 'connects to an instance' do
103
- dispatcher.dispatch
103
+ agent.spawn
104
104
  instance = subject.instances.first
105
105
 
106
106
  expect(subject.test_connect_to_instance( instance )).to be_falsey