@brown-ds/distribution 0.2.28 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -5
- package/distribution/all/comm.js +1 -1
- package/distribution/all/status.js +1 -1
- package/distribution.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,15 +99,25 @@ If you wanted to run this same sequence of commands in a script, you could do so
|
|
|
99
99
|
```js
|
|
100
100
|
let distribution = require("@brown-ds/distribution")();
|
|
101
101
|
// Now we're only doing a few of the things we did above
|
|
102
|
+
const out = (cb) => {
|
|
103
|
+
distribution.local.status.stop(cb); // Shut down the local node
|
|
104
|
+
};
|
|
102
105
|
distribution.node.start(() => {
|
|
103
106
|
// This will run only after the node has started
|
|
104
|
-
node = {
|
|
105
|
-
distribution.local.status.spawn(node, () => {
|
|
107
|
+
const node = {ip: '127.0.0.1', port: 8765};
|
|
108
|
+
distribution.local.status.spawn(node, (e, v) => {
|
|
109
|
+
if (e) {
|
|
110
|
+
return out(console.log);
|
|
111
|
+
}
|
|
106
112
|
// This will run only after the new node has been spawned
|
|
107
113
|
distribution.all.status.get('sid', (e, v) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
// This will run only after we communicated with all nodes and got their sids
|
|
115
|
+
console.log(v); // { '8cf1b': '8cf1b', '8cf1c': '8cf1c' }
|
|
116
|
+
// Shut down the remote node
|
|
117
|
+
distribution.local.comm.send([], {service: 'status', method: 'stop', node: node}, () => {
|
|
118
|
+
// Finally, stop the local node
|
|
119
|
+
out(console.log); // null, {ip: '127.0.0.1', port: 1380}
|
|
120
|
+
});
|
|
111
121
|
});
|
|
112
122
|
});
|
|
113
123
|
});
|
package/distribution/all/comm.js
CHANGED
|
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
|
|
|
6
6
|
|
|
7
7
|
If you notice any issues with using this file, please contact the TAs.
|
|
8
8
|
*/
|
|
9
|
-
function comm(
|
|
9
|
+
function comm(_0x17e568){const _0x543f7b={};_0x543f7b['gid']=_0x17e568['gid']||'all';function _0x4738df(_0x114e26,_0x27d271,_0x43252b){globalThis['distributi'+'on']['local']['groups']['get'](_0x543f7b['gid'],(_0x5d70cd,_0x40759f)=>{if(!_0x40759f){_0x43252b(_0x5d70cd);return;}const _0x369edf=Object['keys'](_0x40759f)['length'];if(_0x369edf===-0x2*0x3f5+-0x2*0x9f1+0x1bcc){_0x43252b(new Error('No\x20nodes\x20i'+'n\x20group\x20'+_0x543f7b['gid']+'\x20found!'));return;}let _0x1b730e=0x1072+0xfdd+-0x204f;const _0x5ae99f={},_0x2af7b0={};for(const _0x33c7ce of Object['keys'](_0x40759f)){const _0x959419=_0x40759f[_0x33c7ce],_0x574b2d={'node':{'ip':_0x959419['ip'],'port':_0x959419['port']},'service':_0x27d271['service'],'method':_0x27d271['method'],'gid':_0x27d271['gid']||'local'};globalThis['distributi'+'on']['local']['comm']['send'](_0x114e26,_0x574b2d,(_0x4aadb3,_0x3ecdc4)=>{_0x4aadb3?_0x2af7b0[_0x33c7ce]=_0x4aadb3:_0x5ae99f[_0x33c7ce]=_0x3ecdc4;_0x1b730e+=0x6da+0x1*0x17ee+-0x1ec7;if(_0x1b730e===_0x369edf)return _0x43252b(_0x2af7b0,_0x5ae99f);});}});return;_0x43252b(new Error('comm.send\x20'+'not\x20implem'+'ented'));}return{'send':_0x4738df};}module['exports']=comm;
|
|
10
10
|
/* eslint-enable */
|
|
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
|
|
|
6
6
|
|
|
7
7
|
If you notice any issues with using this file, please contact the TAs.
|
|
8
8
|
*/
|
|
9
|
-
function status(
|
|
9
|
+
function status(_0x423aac){const _0x41f0a4={};_0x41f0a4['gid']=_0x423aac['gid']||'all';function _0x28bb8a(_0x5996f0,_0x40a397){const _0x45ffcc=[_0x5996f0],_0x321e52={'service':'status','method':'get'};globalThis['distributi'+'on'][_0x41f0a4['gid']]['comm']['send'](_0x45ffcc,_0x321e52,(_0x3ac603,_0x3c8658)=>{switch(_0x5996f0){case'heapTotal':const _0x16d43a=Object['values'](_0x3c8658)['reduce']((_0x36a757,_0x4c9396)=>{return _0x36a757+_0x4c9396;},-0x7f*0x4a+0x19*0x1d+-0x15*-0x19d);return _0x40a397(_0x3ac603,_0x16d43a);break;case'nid':const _0x34ffda=Object['values'](_0x3c8658)['reduce']((_0x27a954,_0x186898)=>{return _0x27a954['concat'](_0x186898);},[]);return _0x40a397(_0x3ac603,_0x34ffda);break;default:return _0x40a397(_0x3ac603,_0x3c8658);break;}});return;_0x40a397(new Error('status.get'+'\x20not\x20imple'+'mented'));}function _0x38df6f(_0x1b0684,_0x2f73ba){globalThis['distributi'+'on']['local']['status']['spawn'](_0x1b0684,(_0x484b26,_0x1ab6fd)=>{globalThis['distributi'+'on'][_0x41f0a4['gid']]['comm']['send']([_0x41f0a4['gid'],_0x1b0684],{'service':'groups','method':'add'},()=>{});if(_0x484b26)return _0x2f73ba(_0x484b26);globalThis['distributi'+'on']['local']['groups']['add'](_0x41f0a4['gid'],_0x1b0684,()=>{return _0x2f73ba(null,_0x1ab6fd);});});return;_0x2f73ba(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function _0x547b3a(_0x4b6742){globalThis['distributi'+'on'][_0x41f0a4['gid']]['comm']['send']([],{'service':'status','method':'stop'},()=>{globalThis['distributi'+'on']['local']['status']['stop'](_0x4b6742);});return;_0x4b6742(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}return{'get':_0x28bb8a,'stop':_0x547b3a,'spawn':_0x38df6f};}module['exports']=status;
|
|
10
10
|
/* eslint-enable */
|
package/distribution.js
CHANGED
|
@@ -21,17 +21,17 @@ function bootstrap(config) {
|
|
|
21
21
|
}
|
|
22
22
|
// __end_solution__
|
|
23
23
|
const distribution = {};
|
|
24
|
+
|
|
24
25
|
// @ts-ignore This is the first time globalThis.distribution is being initialized, so the object does not have all the necessary properties.
|
|
25
26
|
globalThis.distribution = distribution;
|
|
26
27
|
distribution.util = require('./distribution/util/util.js');
|
|
27
28
|
|
|
28
29
|
// @ts-ignore node.server is lazily initialized.
|
|
29
30
|
distribution.node = require('./distribution/local/node.js');
|
|
30
|
-
distribution.local = require('./distribution/local/local.js');
|
|
31
|
-
|
|
32
31
|
if (config) {
|
|
33
32
|
distribution.node.config = config;
|
|
34
33
|
}
|
|
34
|
+
distribution.local = require('./distribution/local/local.js');
|
|
35
35
|
|
|
36
36
|
const {setup} = require('./distribution/all/all.js');
|
|
37
37
|
distribution.all = setup({gid: 'all'});
|