cuboid 0.0.0 → 0.0.1alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -0
- data/Gemfile +20 -5
- data/LICENSE.md +22 -0
- data/README.md +158 -19
- data/Rakefile +56 -3
- data/config/paths.yml +15 -0
- data/cuboid.gemspec +61 -23
- data/lib/cuboid.rb +96 -4
- data/lib/cuboid/application.rb +326 -0
- data/lib/cuboid/application/parts/data.rb +18 -0
- data/lib/cuboid/application/parts/report.rb +29 -0
- data/lib/cuboid/application/parts/state.rb +274 -0
- data/lib/cuboid/application/runtime.rb +25 -0
- data/lib/cuboid/banner.rb +13 -0
- data/lib/cuboid/data.rb +86 -0
- data/lib/cuboid/data/application.rb +52 -0
- data/lib/cuboid/error.rb +9 -0
- data/lib/cuboid/option_group.rb +129 -0
- data/lib/cuboid/option_groups.rb +8 -0
- data/lib/cuboid/option_groups/datastore.rb +23 -0
- data/lib/cuboid/option_groups/dispatcher.rb +38 -0
- data/lib/cuboid/option_groups/output.rb +14 -0
- data/lib/cuboid/option_groups/paths.rb +184 -0
- data/lib/cuboid/option_groups/report.rb +39 -0
- data/lib/cuboid/option_groups/rpc.rb +105 -0
- data/lib/cuboid/option_groups/scheduler.rb +27 -0
- data/lib/cuboid/option_groups/snapshot.rb +13 -0
- data/lib/cuboid/option_groups/system.rb +10 -0
- data/lib/cuboid/options.rb +254 -0
- data/lib/cuboid/processes.rb +13 -0
- data/lib/cuboid/processes/dispatchers.rb +140 -0
- data/lib/cuboid/processes/executables/base.rb +54 -0
- data/lib/cuboid/processes/executables/dispatcher.rb +5 -0
- data/lib/cuboid/processes/executables/instance.rb +12 -0
- data/lib/cuboid/processes/executables/rest_service.rb +13 -0
- data/lib/cuboid/processes/executables/scheduler.rb +5 -0
- data/lib/cuboid/processes/helpers.rb +4 -0
- data/lib/cuboid/processes/helpers/dispatchers.rb +23 -0
- data/lib/cuboid/processes/helpers/instances.rb +39 -0
- data/lib/cuboid/processes/helpers/processes.rb +23 -0
- data/lib/cuboid/processes/helpers/schedulers.rb +23 -0
- data/lib/cuboid/processes/instances.rb +203 -0
- data/lib/cuboid/processes/manager.rb +262 -0
- data/lib/cuboid/processes/schedulers.rb +128 -0
- data/lib/cuboid/report.rb +220 -0
- data/lib/cuboid/rest/server.rb +165 -0
- data/lib/cuboid/rest/server/instance_helpers.rb +99 -0
- data/lib/cuboid/rest/server/routes/dispatcher.rb +41 -0
- data/lib/cuboid/rest/server/routes/grid.rb +41 -0
- data/lib/cuboid/rest/server/routes/instances.rb +131 -0
- data/lib/cuboid/rest/server/routes/scheduler.rb +140 -0
- data/lib/cuboid/rpc/client.rb +3 -0
- data/lib/cuboid/rpc/client/base.rb +58 -0
- data/lib/cuboid/rpc/client/dispatcher.rb +58 -0
- data/lib/cuboid/rpc/client/instance.rb +100 -0
- data/lib/cuboid/rpc/client/instance/service.rb +37 -0
- data/lib/cuboid/rpc/client/scheduler.rb +46 -0
- data/lib/cuboid/rpc/serializer.rb +92 -0
- data/lib/cuboid/rpc/server/active_options.rb +38 -0
- data/lib/cuboid/rpc/server/application_wrapper.rb +138 -0
- data/lib/cuboid/rpc/server/base.rb +63 -0
- data/lib/cuboid/rpc/server/dispatcher.rb +317 -0
- data/lib/cuboid/rpc/server/dispatcher/node.rb +247 -0
- data/lib/cuboid/rpc/server/dispatcher/service.rb +145 -0
- data/lib/cuboid/rpc/server/instance.rb +338 -0
- data/lib/cuboid/rpc/server/output.rb +92 -0
- data/lib/cuboid/rpc/server/scheduler.rb +482 -0
- data/lib/cuboid/ruby.rb +4 -0
- data/lib/cuboid/ruby/array.rb +17 -0
- data/lib/cuboid/ruby/hash.rb +41 -0
- data/lib/cuboid/ruby/object.rb +32 -0
- data/lib/cuboid/snapshot.rb +186 -0
- data/lib/cuboid/state.rb +94 -0
- data/lib/cuboid/state/application.rb +309 -0
- data/lib/cuboid/state/options.rb +27 -0
- data/lib/cuboid/support.rb +11 -0
- data/lib/cuboid/support/buffer.rb +3 -0
- data/lib/cuboid/support/buffer/autoflush.rb +61 -0
- data/lib/cuboid/support/buffer/base.rb +91 -0
- data/lib/cuboid/support/cache.rb +7 -0
- data/lib/cuboid/support/cache/base.rb +226 -0
- data/lib/cuboid/support/cache/least_cost_replacement.rb +77 -0
- data/lib/cuboid/support/cache/least_recently_pushed.rb +21 -0
- data/lib/cuboid/support/cache/least_recently_used.rb +31 -0
- data/lib/cuboid/support/cache/preference.rb +31 -0
- data/lib/cuboid/support/cache/random_replacement.rb +20 -0
- data/lib/cuboid/support/crypto.rb +2 -0
- data/lib/cuboid/support/crypto/rsa_aes_cbc.rb +86 -0
- data/lib/cuboid/support/database.rb +5 -0
- data/lib/cuboid/support/database/base.rb +177 -0
- data/lib/cuboid/support/database/categorized_queue.rb +195 -0
- data/lib/cuboid/support/database/hash.rb +300 -0
- data/lib/cuboid/support/database/queue.rb +149 -0
- data/lib/cuboid/support/filter.rb +3 -0
- data/lib/cuboid/support/filter/base.rb +110 -0
- data/lib/cuboid/support/filter/set.rb +29 -0
- data/lib/cuboid/support/glob.rb +27 -0
- data/lib/cuboid/support/mixins.rb +8 -0
- data/lib/cuboid/support/mixins/observable.rb +99 -0
- data/lib/cuboid/support/mixins/parts.rb +20 -0
- data/lib/cuboid/support/mixins/profiler.rb +93 -0
- data/lib/cuboid/support/mixins/spec_instances.rb +65 -0
- data/lib/cuboid/support/mixins/terminal.rb +57 -0
- data/lib/cuboid/system.rb +119 -0
- data/lib/cuboid/system/platforms.rb +84 -0
- data/lib/cuboid/system/platforms/linux.rb +26 -0
- data/lib/cuboid/system/platforms/mixins/unix.rb +46 -0
- data/lib/cuboid/system/platforms/osx.rb +25 -0
- data/lib/cuboid/system/platforms/windows.rb +81 -0
- data/lib/cuboid/system/slots.rb +143 -0
- data/lib/cuboid/ui/output.rb +52 -0
- data/lib/cuboid/ui/output_interface.rb +43 -0
- data/lib/cuboid/ui/output_interface/abstract.rb +68 -0
- data/lib/cuboid/ui/output_interface/controls.rb +84 -0
- data/lib/cuboid/ui/output_interface/error_logging.rb +119 -0
- data/lib/cuboid/ui/output_interface/implemented.rb +58 -0
- data/lib/cuboid/ui/output_interface/personalization.rb +62 -0
- data/lib/cuboid/utilities.rb +155 -0
- data/lib/cuboid/version.rb +4 -3
- data/lib/version +1 -0
- data/logs/placeholder +0 -0
- data/spec/cuboid/application/parts/data_spec.rb +12 -0
- data/spec/cuboid/application/parts/report_spec.rb +6 -0
- data/spec/cuboid/application/parts/state_spec.rb +192 -0
- data/spec/cuboid/application/runtime_spec.rb +21 -0
- data/spec/cuboid/application_spec.rb +37 -0
- data/spec/cuboid/data/application_spec.rb +22 -0
- data/spec/cuboid/data_spec.rb +47 -0
- data/spec/cuboid/error_spec.rb +23 -0
- data/spec/cuboid/option_groups/datastore_spec.rb +54 -0
- data/spec/cuboid/option_groups/dispatcher_spec.rb +12 -0
- data/spec/cuboid/option_groups/output_spec.rb +11 -0
- data/spec/cuboid/option_groups/paths_spec.rb +184 -0
- data/spec/cuboid/option_groups/report_spec.rb +26 -0
- data/spec/cuboid/option_groups/rpc_spec.rb +53 -0
- data/spec/cuboid/option_groups/snapshot_spec.rb +26 -0
- data/spec/cuboid/option_groups/system.rb +12 -0
- data/spec/cuboid/options_spec.rb +218 -0
- data/spec/cuboid/report_spec.rb +221 -0
- data/spec/cuboid/rest/server_spec.rb +1205 -0
- data/spec/cuboid/rpc/client/base_spec.rb +151 -0
- data/spec/cuboid/rpc/client/dispatcher_spec.rb +13 -0
- data/spec/cuboid/rpc/client/instance_spec.rb +38 -0
- data/spec/cuboid/rpc/server/active_options_spec.rb +21 -0
- data/spec/cuboid/rpc/server/base_spec.rb +60 -0
- data/spec/cuboid/rpc/server/dispatcher/node_spec.rb +222 -0
- data/spec/cuboid/rpc/server/dispatcher/service_spec.rb +112 -0
- data/spec/cuboid/rpc/server/dispatcher_spec.rb +317 -0
- data/spec/cuboid/rpc/server/instance_spec.rb +307 -0
- data/spec/cuboid/rpc/server/output_spec.rb +32 -0
- data/spec/cuboid/rpc/server/scheduler_spec.rb +400 -0
- data/spec/cuboid/ruby/array_spec.rb +77 -0
- data/spec/cuboid/ruby/hash_spec.rb +63 -0
- data/spec/cuboid/ruby/object_spec.rb +22 -0
- data/spec/cuboid/snapshot_spec.rb +123 -0
- data/spec/cuboid/state/application_spec.rb +538 -0
- data/spec/cuboid/state/options_spec.rb +37 -0
- data/spec/cuboid/state_spec.rb +53 -0
- data/spec/cuboid/support/buffer/autoflush_spec.rb +78 -0
- data/spec/cuboid/support/buffer/base_spec.rb +193 -0
- data/spec/cuboid/support/cache/least_cost_replacement_spec.rb +61 -0
- data/spec/cuboid/support/cache/least_recently_pushed_spec.rb +90 -0
- data/spec/cuboid/support/cache/least_recently_used_spec.rb +80 -0
- data/spec/cuboid/support/cache/preference_spec.rb +37 -0
- data/spec/cuboid/support/cache/random_replacement_spec.rb +42 -0
- data/spec/cuboid/support/crypto/rsa_aes_cbc_spec.rb +28 -0
- data/spec/cuboid/support/database/categorized_queue_spec.rb +327 -0
- data/spec/cuboid/support/database/hash_spec.rb +204 -0
- data/spec/cuboid/support/database/scheduler_spec.rb +325 -0
- data/spec/cuboid/support/filter/set_spec.rb +19 -0
- data/spec/cuboid/support/glob_spec.rb +75 -0
- data/spec/cuboid/support/mixins/observable_spec.rb +95 -0
- data/spec/cuboid/system/platforms/linux_spec.rb +31 -0
- data/spec/cuboid/system/platforms/osx_spec.rb +32 -0
- data/spec/cuboid/system/platforms/windows_spec.rb +41 -0
- data/spec/cuboid/system/slots_spec.rb +202 -0
- data/spec/cuboid/system_spec.rb +105 -0
- data/spec/cuboid/utilities_spec.rb +131 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/factories/placeholder +0 -0
- data/spec/support/factories/scan_report.rb +18 -0
- data/spec/support/fixtures/empty/placeholder +0 -0
- data/spec/support/fixtures/executables/node.rb +50 -0
- data/spec/support/fixtures/mock_app.rb +61 -0
- data/spec/support/fixtures/mock_app/test_service.rb +64 -0
- data/spec/support/fixtures/services/echo.rb +64 -0
- data/spec/support/helpers/framework.rb +3 -0
- data/spec/support/helpers/matchers.rb +5 -0
- data/spec/support/helpers/misc.rb +3 -0
- data/spec/support/helpers/paths.rb +15 -0
- data/spec/support/helpers/request_helpers.rb +38 -0
- data/spec/support/helpers/requires.rb +8 -0
- data/spec/support/helpers/resets.rb +52 -0
- data/spec/support/helpers/web_server.rb +15 -0
- data/spec/support/lib/factory.rb +107 -0
- data/spec/support/lib/web_server_client.rb +41 -0
- data/spec/support/lib/web_server_dispatcher.rb +25 -0
- data/spec/support/lib/web_server_manager.rb +118 -0
- data/spec/support/logs/placeholder +0 -0
- data/spec/support/pems/cacert.pem +37 -0
- data/spec/support/pems/client/cert.pem +37 -0
- data/spec/support/pems/client/foo-cert.pem +39 -0
- data/spec/support/pems/client/foo-key.pem +51 -0
- data/spec/support/pems/client/key.pem +51 -0
- data/spec/support/pems/server/cert.pem +37 -0
- data/spec/support/pems/server/key.pem +51 -0
- data/spec/support/reports/placeholder +0 -0
- data/spec/support/shared/application.rb +10 -0
- data/spec/support/shared/component.rb +31 -0
- data/spec/support/shared/component/options/base.rb +187 -0
- data/spec/support/shared/option_group.rb +98 -0
- data/spec/support/shared/support/cache.rb +419 -0
- data/spec/support/shared/support/filter.rb +143 -0
- data/spec/support/shared/system/platforms/base.rb +25 -0
- data/spec/support/shared/system/platforms/mixins/unix.rb +37 -0
- data/spec/support/snapshots/placeholder +0 -0
- metadata +566 -21
- data/.gitignore +0 -8
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40773cee8ae1dcd306b0d5e1832f0b9948116f0098fedf1e3f5d6b89e8f7fe4
|
4
|
+
data.tar.gz: 38d5ef49a0329bb16788467653875820994c604d6ac20128e95af8b26811d7eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a83686aa22ee70f5bcdb9ee597c7dcc3f00fcbc511ad337980b725dfc47e0e94ff5089e73d26835a25777b389c79d9294c1ec4a7584d9ca18341a193a258d48
|
7
|
+
data.tar.gz: f9eb78ace44e7754f91543a9738443a8c15fe7fdac558a96aaf7290da5fa3cf35f570b49b82a51b5de2fd78e56781b80de9496eedf4632a8eedf8e8b360d3d0a
|
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
CHANGED
@@ -1,8 +1,23 @@
|
|
1
|
-
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
gem 'rake', '11.3.0'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
group :docs do
|
6
|
+
gem 'yard'
|
7
|
+
gem 'redcarpet'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :spec do
|
11
|
+
gem 'simplecov', require: false, group: :test
|
12
|
+
|
13
|
+
gem 'typhoeus'
|
14
|
+
gem 'rspec'
|
15
|
+
gem 'faker'
|
16
|
+
end
|
7
17
|
|
8
|
-
|
18
|
+
group :prof do
|
19
|
+
gem 'benchmark-ips'
|
20
|
+
gem 'memory_profiler'
|
21
|
+
end
|
22
|
+
|
23
|
+
gemspec
|
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Tasos Laskos \<tasos.laskos@gmail.com\>.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,35 +1,174 @@
|
|
1
|
-
# Cuboid
|
1
|
+
# Cuboid Framework -- a decentralized distributed framework in Ruby.
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
The Cuboid Framework offers the possibility of easily creating decentralized and
|
6
|
+
distributed applications in Ruby.
|
7
|
+
|
8
|
+
In hipper terms, you can very easily setup your own specialized _Cloud_ or
|
9
|
+
_Cloud_ within a _Cloud_.
|
10
|
+
|
11
|
+
It offers:
|
12
|
+
|
13
|
+
* Load-balancing of _**Instances**_ via a software mesh network (_**Grid**_) of _**Dispatchers**_.
|
14
|
+
* No need to setup a topology manually, _**Dispatchers**_ will reach
|
15
|
+
convergence on their own, just point them to an existing _**Grid**_ member.
|
16
|
+
* Scaling up and down can be easily achieved by _plugging_ or _unplugging_ nodes.
|
17
|
+
* Fault tolerant -- one application per process (_**Instance**_).
|
18
|
+
* Self-healing -- keeps an eye out for disappearing and also re-appearing members.
|
19
|
+
* A clean and simple framework for application development.
|
20
|
+
* Basically, Ruby -- and all the libraries and extensions that come with it.
|
21
|
+
* Events (_pause_, _resume_, _abort_, _suspend_, _restore_).
|
22
|
+
* Suspend to disk is a cinch by automatically creating a _**snapshot**_
|
23
|
+
of the runtime environment of the application and storing it to disk
|
24
|
+
for later restoration of state and data.
|
25
|
+
* Also allows for running job transfers.
|
26
|
+
* Management of Instances via RPC or REST APIs.
|
27
|
+
* Aside from what **Cuboid** uses, custom serializers can be specified for
|
28
|
+
application related objects.
|
29
|
+
* Developer freedom.
|
30
|
+
* Apart from keeping _Data_ and _State_ separate not many other rules to follow.
|
31
|
+
* Only if interested in _suspensions_ and can also be left to the last minute
|
32
|
+
if necessary -- in cases of Ractor enforced isolation for example.
|
33
|
+
|
34
|
+
## Entities
|
35
|
+
|
36
|
+
### Application
|
37
|
+
|
38
|
+
A Ruby `class` which inherits from `Cuboid::Application` and complies with a few
|
39
|
+
simple specifications; at the least, a `#run` method, serving as the execution
|
40
|
+
entry point.
|
2
41
|
|
3
|
-
|
42
|
+
The application can use the following methods to better take advantage of the
|
43
|
+
framework:
|
4
44
|
|
5
|
-
|
45
|
+
* `#validate_options( options )` -- Validates _**Application**_ options.
|
46
|
+
* `#provision_cores( Fixnum )` -- Specifies the maximum amount of cores the
|
47
|
+
_**Application**_ will be using.
|
48
|
+
* `#provision_memory( Fixnum )` -- Specifies the maximum amount of RAM the
|
49
|
+
_**Application**_ will be using.
|
50
|
+
* `#provision_disk( Fixnum )` -- Specifies the maximum amount of disk space the
|
51
|
+
_**Application**_ will be using.
|
52
|
+
* `#handler_for( Symbol, Symbol )` -- Specifies methods to handle the following events:
|
53
|
+
* `:pause`
|
54
|
+
* `:resume`
|
55
|
+
* `:abort`
|
56
|
+
* `:suspend`
|
57
|
+
* `:restore`
|
58
|
+
* `instance_service_for( Symbol, Class )` -- Adds a custom _**Instance**_ RPC API.
|
59
|
+
* `rest_service_for( Symbol, Module )` -- Hooks-up to the _**REST**_ service to provide a custom REST API.
|
60
|
+
* `dispatcher_service_for( Symbol, Class )` -- Hooks-up to the _**Dispatcher**_ to provide a custom RPC API.
|
61
|
+
* `serialize_with( Module )` -- A serializer to be used for:
|
62
|
+
* `#options`
|
63
|
+
* `Report#data`
|
64
|
+
* `Runtime` `Snapshot`
|
6
65
|
|
7
|
-
|
66
|
+
Access is also available to:
|
8
67
|
|
9
|
-
|
68
|
+
* `#options` -- Passed options.
|
69
|
+
* `#runtime` -- The _**Application**_'s `Runtime` environment, as a way to
|
70
|
+
store and access _state_ and _data_. Upon receiving a _suspend_ event, the
|
71
|
+
`Runtime` will be stored to disk as a `Snapshot` for later restoration.
|
72
|
+
* `Runtime#state` -- State accessor.
|
73
|
+
* `Runtime#data` -- Data accessor.
|
74
|
+
* `#report( data )` -- Stores given `data`, to be included in a later generated
|
75
|
+
`Report` and accessed via `Report#data`.
|
10
76
|
|
11
|
-
|
12
|
-
gem 'cuboid'
|
13
|
-
```
|
77
|
+
### Instance
|
14
78
|
|
15
|
-
|
79
|
+
An _**Instance**_ is a process container for a **Cuboid** _**Application**_;
|
80
|
+
**Cuboid** is application-centric and follows the one process-per-application principle.
|
16
81
|
|
17
|
-
|
82
|
+
This is in order to enforce isolation (_state_, _data_, _fault_) between
|
83
|
+
_**Applications**_, take advantage of _OS_ task management and generally keep
|
84
|
+
things simple.
|
18
85
|
|
19
|
-
|
86
|
+
### Dispatcher
|
20
87
|
|
21
|
-
|
88
|
+
A _**Dispatcher**_ is a server which awaits for _**Instance**_ spawn requests
|
89
|
+
(`dispatch` calls) upon which it spawns and passes the _**Instance**_'s
|
90
|
+
connection info to the client.
|
22
91
|
|
23
|
-
|
92
|
+
The client can then proceed to use the _**Instance**_ to run and generally manage
|
93
|
+
the contained _**Application**_.
|
24
94
|
|
25
|
-
|
95
|
+
#### Grid
|
26
96
|
|
27
|
-
|
97
|
+
A _**Dispatcher**_ _**Grid**_ is a software mesh network of _**Dispatcher**_
|
98
|
+
servers, aimed towards providing automated _load-balancing_ based on available
|
99
|
+
system resources and each _**Application**_'s provisioning configuration.
|
28
100
|
|
29
|
-
|
101
|
+
No _topology_ needs to be specified, the only configuration necessary is
|
102
|
+
providing any existing _**Grid**_ member upon start-up and the rest will be
|
103
|
+
sorted out automatically.
|
30
104
|
|
31
|
-
|
105
|
+
The network is _self-healing_ and will monitor _node_ connectivity, taking steps
|
106
|
+
to ensure that neither server nor network conditions will disrupt dispatching.
|
32
107
|
|
33
|
-
|
108
|
+
##### Scalability
|
34
109
|
|
35
|
-
|
110
|
+
_**Dispatchers**_ can be easily _plugged_ to or _unplugged_ from the _**Grid**_
|
111
|
+
to scale up or down as necessary.
|
112
|
+
|
113
|
+
_Plugging_ happens at boot-time and _unplugging_ can take place via the available
|
114
|
+
_APIs_.
|
115
|
+
|
116
|
+
### Scheduler
|
117
|
+
|
118
|
+
The _**Scheduler**_ is a server which:
|
119
|
+
|
120
|
+
1. Accepts _**Application**_ options.
|
121
|
+
2. Stores them in a queue.
|
122
|
+
3. Pops options and passes them to spawned _**Instances**_.
|
123
|
+
4. Monitors _**Instance**_ progress.
|
124
|
+
5. Upon _**Application**_ completion stores report to disk.
|
125
|
+
6. Shuts down the _**Instance**_.
|
126
|
+
|
127
|
+
#### Dispatcher
|
128
|
+
|
129
|
+
The _**Scheduler**_ can be configured with a _**Dispatcher**_, upon which case,
|
130
|
+
it will use it to spawn _**Instances**_.
|
131
|
+
|
132
|
+
If the _**Dispatcher**_ is a _**Grid**_ member then the _**Scheduler**_ will
|
133
|
+
also enjoy _load-balancing_ features.
|
134
|
+
|
135
|
+
## APIs
|
136
|
+
|
137
|
+
### Local
|
138
|
+
|
139
|
+
Local access can call upon via the `Cuboid::Application` API and the API defined by the
|
140
|
+
_**Application**_ itself.
|
141
|
+
|
142
|
+
### RPC
|
143
|
+
|
144
|
+
A simple RPC is employed, specs for 3rd party implementations can be found at:
|
145
|
+
|
146
|
+
https://github.com/Arachni/arachni-rpc/wiki
|
147
|
+
|
148
|
+
Each _**Application**_ can extend upon this and expose an API via its _**Instance**_'s
|
149
|
+
RPC interface.
|
150
|
+
|
151
|
+
### REST
|
152
|
+
|
153
|
+
A REST API is also available, taking advantage of HTTP sessions to make progress
|
154
|
+
tracking easier.
|
155
|
+
|
156
|
+
The REST interface is basically a web _**Dispatcher**_ and centralised point of
|
157
|
+
management for the rest of the entities.
|
158
|
+
|
159
|
+
Each _**Application**_ can extend upon this and expose an API via its _**REST**_
|
160
|
+
service's interface.
|
161
|
+
|
162
|
+
## Examples
|
163
|
+
|
164
|
+
See `examples/`.
|
165
|
+
|
166
|
+
### MyApp
|
167
|
+
|
168
|
+
Tutorial application going over different APIs and **Cuboid** _**Application**_
|
169
|
+
options and specification.
|
170
|
+
|
171
|
+
|
172
|
+
## License
|
173
|
+
|
174
|
+
Please see the _LICENSE.md_ file.
|
data/Rakefile
CHANGED
@@ -1,4 +1,57 @@
|
|
1
|
-
|
1
|
+
=begin
|
2
|
+
Copyright 2020 Alex Douckas <alexdouckas@gmail.com>, Tasos Laskos <tasos.laskos@gmail.com>
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
This file is part of the Engine Framework project and is subject to
|
5
|
+
redistribution and commercial restrictions. Please see the Engine Framework
|
6
|
+
web site for more information on licensing and terms of use.
|
7
|
+
=end
|
8
|
+
|
9
|
+
require File.expand_path(File.dirname(__FILE__)) + '/lib/cuboid'
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'rspec'
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
|
15
|
+
namespace :spec do
|
16
|
+
|
17
|
+
desc 'Run core library tests.'
|
18
|
+
RSpec::Core::RakeTask.new( :core ) do |t|
|
19
|
+
t.pattern = FileList[ 'spec/cuboid/**/*_spec.rb' ]
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Run plugin tests.'
|
23
|
+
RSpec::Core::RakeTask.new( :plugins ) do |t|
|
24
|
+
t.pattern = FileList[ 'spec/components/plugins/**/*_spec.rb' ]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec::Core::RakeTask.new
|
29
|
+
rescue LoadError
|
30
|
+
puts 'If you want to run the tests please install rspec first:'
|
31
|
+
puts ' gem install rspec'
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'Generate docs.'
|
35
|
+
task :docs do
|
36
|
+
outdir = "../cuboid-docs"
|
37
|
+
sh "rm -rf #{outdir}"
|
38
|
+
sh "mkdir -p #{outdir}"
|
39
|
+
|
40
|
+
sh "yardoc -o #{outdir}"
|
41
|
+
|
42
|
+
sh "rm -rf .yardoc"
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Remove reporter and log files.'
|
46
|
+
task :clean do
|
47
|
+
files = %w(error.log *.crf *.csf *.yaml *.json *.marshal *.gem pkg/*.gem
|
48
|
+
reports/*.crf snapshots/*.csf logs/*.log spec/support/logs/*.log
|
49
|
+
spec/support/reports/*.crf spec/support/snapshots/*.csf
|
50
|
+
).map { |file| Dir.glob( file ) }.flatten
|
51
|
+
|
52
|
+
next if files.empty?
|
53
|
+
|
54
|
+
puts 'Removing:'
|
55
|
+
files.each { |file| puts " * #{file}" }
|
56
|
+
FileUtils.rm files
|
57
|
+
end
|
data/config/paths.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Sets default locations for writing different kinds of files.
|
2
|
+
#
|
3
|
+
# * '~' will be expanded to $HOME.
|
4
|
+
# * Directories will be created if they don't already exist.
|
5
|
+
|
6
|
+
# Error and RPC logs.
|
7
|
+
logs:
|
8
|
+
# Default directory for scan snapshots generated by RPC Instances.
|
9
|
+
snapshots:
|
10
|
+
# Default report location for the RPC Scheduler.
|
11
|
+
reports:
|
12
|
+
# Directory for temporary files -- like for excess workload that's been
|
13
|
+
# offloaded to disk etc.
|
14
|
+
# Will default to the OS temporary directory.
|
15
|
+
tmpdir:
|
data/cuboid.gemspec
CHANGED
@@ -1,31 +1,69 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
require_relative File.expand_path( File.dirname( __FILE__ ) ) + '/lib/cuboid/version'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
spec.email = ["tasos.laskos@gmail.com"]
|
6
|
+
s.name = 'cuboid'
|
7
|
+
s.version = Cuboid::VERSION
|
8
|
+
s.date = Time.now.strftime( '%Y-%m-%d' )
|
9
|
+
s.summary = 'An application-centric, decentralised and distributed computing solution. '
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
s.homepage = 'https://github.com/qadron/cuboid'
|
12
|
+
s.email = 'tasos.laskos@gmail.com'
|
13
|
+
s.authors = [ 'Tasos Laskos' ]
|
14
|
+
s.licenses = ['All rights reserved.']
|
14
15
|
|
15
|
-
|
16
|
+
s.files += Dir.glob( 'config/**/**' )
|
17
|
+
s.files += Dir.glob( 'lib/**/**' )
|
18
|
+
s.files += Dir.glob( 'logs/**/**' )
|
19
|
+
s.files += Dir.glob( 'components/**/**' )
|
20
|
+
s.files += Dir.glob( 'spec/**/**' )
|
21
|
+
s.files += %w(Gemfile Rakefile cuboid.gemspec)
|
22
|
+
s.test_files = Dir.glob( 'spec/**/**' )
|
16
23
|
|
17
|
-
|
18
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
21
|
-
end
|
22
|
-
spec.bindir = "exe"
|
23
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
24
|
-
spec.require_paths = ["lib"]
|
24
|
+
s.extra_rdoc_files = %w(README.md LICENSE.md CHANGELOG.md)
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
s.rdoc_options = [ '--charset=UTF-8' ]
|
27
|
+
|
28
|
+
s.add_dependency 'awesome_print', '1.6.1'
|
29
|
+
|
30
|
+
# Don't specify version, messes with the packages since they always grab the
|
31
|
+
# latest one.
|
32
|
+
s.add_dependency 'bundler'
|
33
|
+
|
34
|
+
s.add_dependency 'concurrent-ruby', '1.1.8'
|
35
|
+
s.add_dependency 'concurrent-ruby-ext', '1.1.8'
|
36
|
+
|
37
|
+
# For compressing/decompressing system state archives.
|
38
|
+
s.add_dependency 'rubyzip', '1.2.2'
|
39
|
+
|
40
|
+
s.add_dependency 'childprocess', '0.8.0'
|
41
|
+
|
42
|
+
# RPC serialization.
|
43
|
+
s.add_dependency 'msgpack', '1.1.0'
|
44
|
+
|
45
|
+
# Optimized JSON.
|
46
|
+
s.add_dependency 'oj', '3.11.5'
|
47
|
+
s.add_dependency 'oj_mimic_json', '1.0.1'
|
48
|
+
|
49
|
+
# Web server
|
50
|
+
s.add_dependency 'puma', '3.10.0'
|
51
|
+
|
52
|
+
s.add_dependency 'rack', '2.2.3'
|
53
|
+
s.add_dependency 'rack-test'
|
54
|
+
|
55
|
+
# REST API
|
56
|
+
s.add_dependency 'sinatra', '2.1.0'
|
57
|
+
s.add_dependency 'sinatra-contrib', '2.1.0'
|
58
|
+
|
59
|
+
# RPC client/server implementation.
|
60
|
+
s.add_dependency 'arachni-rpc', '~> 0.2.1.4'
|
61
|
+
|
62
|
+
s.add_dependency 'vmstat', '2.3.0'
|
63
|
+
s.add_dependency 'sys-proctable', '1.1.5'
|
64
|
+
|
65
|
+
s.description = <<DESCRIPTION
|
66
|
+
An application-centric, decentralised and distributed computing solution.
|
67
|
+
DESCRIPTION
|
28
68
|
|
29
|
-
# For more information and examples about making a new gem, checkout our
|
30
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
31
69
|
end
|
data/lib/cuboid.rb
CHANGED
@@ -1,8 +1,100 @@
|
|
1
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'tmpdir'
|
2
4
|
|
3
|
-
|
5
|
+
require 'oj'
|
6
|
+
require 'oj_mimic_json'
|
7
|
+
|
8
|
+
require_relative 'cuboid/version'
|
9
|
+
|
10
|
+
require 'concurrent'
|
11
|
+
require 'pp'
|
12
|
+
require 'ap'
|
13
|
+
|
14
|
+
def ap( obj )
|
15
|
+
super obj, raw: true
|
16
|
+
end
|
4
17
|
|
5
18
|
module Cuboid
|
6
|
-
|
7
|
-
|
19
|
+
|
20
|
+
class <<self
|
21
|
+
|
22
|
+
# Runs a minor GC to collect young, short-lived objects.
|
23
|
+
#
|
24
|
+
# Generally called after analysis operations that generate a lot of
|
25
|
+
# new temporary objects.
|
26
|
+
def collect_young_objects
|
27
|
+
# GC.start( full_mark: false )
|
28
|
+
end
|
29
|
+
|
30
|
+
def null_device
|
31
|
+
Gem.win_platform? ? 'NUL' : '/dev/null'
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Bool]
|
35
|
+
def windows?
|
36
|
+
Gem.win_platform?
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Bool]
|
40
|
+
def linux?
|
41
|
+
@is_linux ||= RbConfig::CONFIG['host_os'] =~ /linux/
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Bool]
|
45
|
+
def mac?
|
46
|
+
@is_mac ||= RbConfig::CONFIG['host_os'] =~ /darwin|mac os/i
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Bool]
|
50
|
+
# `true` if the `CUBOID_PROFILE` env variable is set,
|
51
|
+
# `false` otherwise.
|
52
|
+
def profile?
|
53
|
+
!!ENV['CUBOID_PROFILE']
|
54
|
+
end
|
55
|
+
|
56
|
+
if Cuboid.windows?
|
57
|
+
require 'find'
|
58
|
+
require 'fileutils'
|
59
|
+
require 'Win32API'
|
60
|
+
require 'win32ole'
|
61
|
+
|
62
|
+
def get_long_win32_filename( short_name )
|
63
|
+
short_name = short_name.dup
|
64
|
+
max_path = 1024
|
65
|
+
long_name = ' ' * max_path
|
66
|
+
|
67
|
+
lfn_size = Win32API.new(
|
68
|
+
"kernel32",
|
69
|
+
"GetLongPathName",
|
70
|
+
['P','P','L'],
|
71
|
+
'L'
|
72
|
+
).call( short_name, long_name, max_path )
|
73
|
+
|
74
|
+
(1..max_path).include?( lfn_size ) ?
|
75
|
+
long_name[0..lfn_size-1] : short_name
|
76
|
+
end
|
77
|
+
else
|
78
|
+
def get_long_win32_filename( short_name )
|
79
|
+
short_name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
8
84
|
end
|
85
|
+
|
86
|
+
require_relative 'cuboid/banner'
|
87
|
+
require_relative 'cuboid/ui/output_interface'
|
88
|
+
|
89
|
+
# If there's no UI driving us then there's no output interface.
|
90
|
+
# Chances are that someone is using Engine as a Ruby lib so there's no
|
91
|
+
# need for a functional output interface, so provide non-functional one.
|
92
|
+
#
|
93
|
+
# However, functional or not, the system does depend on one being available.
|
94
|
+
if !Cuboid::UI.constants.include?(:Output)
|
95
|
+
require_relative 'cuboid/ui/output'
|
96
|
+
end
|
97
|
+
|
98
|
+
require_relative 'cuboid/application'
|
99
|
+
|
100
|
+
Cuboid::UI::OutputInterface.initialize
|