@brown-ds/distribution 0.0.24

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/.eslintrc ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "extends": "google",
3
+ "env": {
4
+ "es6": true, // Enable ES6 syntax including new ES6 globals
5
+ "node": true // Adjust based on your environment
6
+ },
7
+ "parserOptions": {
8
+ "ecmaVersion": 2018, // Update ECMAScript version to at least 6 or later for arrow functions
9
+ "sourceType": "script" // Set to "module" if you are using ES6 modules
10
+ },
11
+ "rules": {
12
+ "max-len": "off",
13
+ "no-var": "off", // Allow 'var' for ES5 compatibility
14
+ "prefer-const": "off", // Do not enforce const over let
15
+ "prefer-spread": "off", // Do not enforce spread operator
16
+ "prefer-rest-params": "off", // Do not enforce rest parameters
17
+ "prefer-template": "off", // Do not enforce template literals
18
+ "object-shorthand": "off", // Do not enforce object method shorthand
19
+ "require-jsdoc": "off",
20
+ "guard-for-in": "off",
21
+ "no-restricted-syntax": [
22
+ "error",
23
+ {
24
+ "selector": "ClassDeclaration",
25
+ "message": "Class declarations are not allowed."
26
+ },
27
+ {
28
+ "selector": "ClassExpression",
29
+ "message": "Class expressions are not allowed."
30
+ }
31
+ ]
32
+ }
33
+ }
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # distribution
2
+
3
+ This is the distribution library. When loaded, distribution introduces functionality supporting the distributed execution of programs. To download it:
4
+
5
+ ```sh
6
+ $ npm i '@brown-ds/distribution'
7
+ ```
8
+
9
+ This command downloads and installs the distribution library globally — so that it can be accessed by any application running on your system. To import the library, be it in a JavaScript file or on the interactive console, run:
10
+
11
+ ```js
12
+ let distribution = require("@brown-ds/distribution");
13
+ ```
14
+
15
+ Now you have access to the full distribution library. You can start off by serializing some values.
16
+
17
+ ```js
18
+ let s = distribution.util.serialize(1); // '{"type":"number","value":"1"}'
19
+ let n = distribution.util.deserialize(s); // 1
20
+ ```
21
+
22
+ You can inspect information about the current node (for example its `sid`) by running:
23
+
24
+ ```js
25
+ distribution.local.status.get('sid', console.log); // 8cf1b
26
+ ```
27
+
28
+ You can also store and retrieve values from the local memory:
29
+
30
+ ```js
31
+ distribution.local.mem.put({name: 'nikos'}, 'key', console.log); // {name: 'nikos'}
32
+ distribution.local.mem.get('key', console.log); // {name: 'nikos'}
33
+ ```
34
+
35
+ You can also spawn a new node:
36
+
37
+ ```js
38
+ let node = { ip: '127.0.0.1', port: 8080 };
39
+ distribution.local.status.spawn(node, console.log);
40
+ ```
41
+
42
+ Using the `distribution.all` set of services will allow you to act
43
+ on the full set of nodes created as if they were a single one.
44
+
45
+ ```js
46
+ distribution.all.status.get('sid', console.log); // { '8cf1b': '8cf1b', '8cf1c': '8cf1c' }
47
+ ```
48
+
49
+ You can also send messages to other nodes:
50
+
51
+ ```js
52
+ distribution.all.comm.send(['sid'], {node: node, service: 'status', method: 'get'}, console.log); // 8cf1c
53
+ ```
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const comm=require('./comm'),groups=require('./groups'),routes=require('./routes'),status=require('./status'),gossip=require('./gossip'),mem=require('./mem'),store=require('./store'),mr=require('./mr');module['exports']={'comm':comm,'groups':groups,'status':status,'routes':routes,'gossip':gossip,'mem':mem,'store':store,'mr':mr};
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const comm=function(_0x5999fa){let _0x4f3532={};return _0x4f3532['gid']=_0x5999fa['gid']||'global',{'send':(_0x443e61,_0x4baafa,_0x37cd08)=>{global['distributi'+'on']['local']['groups']['get'](_0x4f3532['gid'],(_0x54d67d,_0x3a6985)=>{let _0x1dfd8a=Object['keys'](_0x3a6985)['length'];if(_0x1dfd8a===-0x5*0x371+-0x1164+0x2299){_0x37cd08(new Error('No\x20nodes\x20f'+'ound'));return;}let _0x1dc813=-0xf9*0x15+0x1646+-0x1d9,_0xd2bc36={},_0x41a9ba={};for(let _0x5dc2cb of Object['keys'](_0x3a6985)){let _0x174c8f=_0x3a6985[_0x5dc2cb],_0x4bf4b8={'node':{'ip':_0x174c8f['ip'],'port':_0x174c8f['port']},'service':_0x4baafa['service'],'method':_0x4baafa['method']};distribution['local']['comm']['send'](_0x443e61,_0x4bf4b8,(_0x518622,_0x23e1cb)=>{_0x518622?_0x41a9ba[_0x5dc2cb]=_0x518622:_0xd2bc36[_0x5dc2cb]=_0x23e1cb,_0x1dc813+=-0xf4c+0x237d+-0x286*0x8,_0x1dc813===_0x1dfd8a&&_0x37cd08(_0x41a9ba,_0xd2bc36);});}});}};};module['exports']=comm;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const id=require('../util/id');function getMID(_0x2813e4){let _0x2a018f={};return _0x2a018f['date']=new Date()['getTime'](),_0x2a018f['mss']=_0x2813e4,id['getID'](_0x2a018f);}let gossip=function(_0x54a319){let _0x15ea1f={};return _0x15ea1f['gid']=_0x54a319['gid']||'global',_0x15ea1f['subset']=_0x54a319['subset']||function(_0x112ff2){return Math['ceil'](Math['log'](_0x112ff2['length']));},{'send':(_0x4f1650,_0x168eda,_0x40f7b4)=>{global['distributi'+'on']['local']['groups']['get'](_0x15ea1f['gid'],(_0x4d3234,_0x4b46c1)=>{let _0x2f7edf=_0x15ea1f['subset'](Object['keys'](_0x4b46c1)),_0x3479e6=function(_0x503f92){let _0x8c2863=new Set();while(_0x8c2863['size']<_0x2f7edf){let _0x2999c3=Math['floor'](Math['random']()*_0x503f92['length']);_0x8c2863['add'](_0x503f92[_0x2999c3]);}return _0x8c2863;},_0x2c7c7e=_0x3479e6(Object['keys'](_0x4b46c1)),_0x3caef1={},_0x2294e2={},_0x12c908=-0x86e*0x2+0x1*0x1f2b+-0xe4f;if(_0x4f1650['mid']&&_0x4f1650['gid']){}else _0x4f1650={'message':_0x4f1650,'remote':_0x168eda,'mid':getMID(_0x4f1650),'gid':_0x15ea1f['gid']};for(let _0x4a5bdd of _0x2c7c7e){let _0x3a7196=_0x4b46c1[_0x4a5bdd],_0x39e523={'node':{'ip':_0x3a7196['ip'],'port':_0x3a7196['port']},'service':'gossip','method':'recv'};global['distributi'+'on']['local']['comm']['send']([_0x4f1650],_0x39e523,(_0x4340b5,_0x9e2d64)=>{_0x4340b5?_0x2294e2[_0x4a5bdd]=_0x4340b5:_0x3caef1[_0x4a5bdd]=_0x9e2d64,_0x12c908+=0x1d9*0x1+0xd6*-0x29+0x251*0xe,_0x12c908===_0x2f7edf&&(_0x40f7b4&&_0x40f7b4(_0x2294e2,_0x3caef1));});}});},'at':(_0x531b52,_0x3b134d,_0x4062a4)=>{let _0x4e543f=setInterval(_0x3b134d,_0x531b52);_0x4062a4&&_0x4062a4(null,_0x4e543f);},'del':(_0x189ae8,_0x10d053)=>{clearInterval(_0x189ae8),_0x10d053&&_0x10d053(null,_0x189ae8);}};};module['exports']=gossip;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const groups=function(_0x39b223){let _0x309c4a={};return _0x309c4a['gid']=_0x39b223['gid']||'global',{'put':(_0x52beec,_0xa32a95,_0x4cf167)=>{global['distributi'+'on']['local']['groups']['put'](_0x52beec,_0xa32a95,(_0x3653de,_0x4f39b6)=>{_0x3653de&&_0x4cf167(_0x3653de),global['distributi'+'on'][_0x309c4a['gid']]['comm']['send']([_0x52beec,_0xa32a95],{'service':'groups','method':'put'},_0x4cf167);});},'del':(_0x1881a2,_0x37ea4d)=>{global['distributi'+'on'][_0x309c4a['gid']]['comm']['send']([_0x1881a2],{'service':'groups','method':'del'},_0x37ea4d);},'get':(_0x30bd61,_0x476f73)=>{global['distributi'+'on'][_0x309c4a['gid']]['comm']['send']([_0x30bd61],{'service':'groups','method':'get'},_0x476f73);},'add':(_0x2ba713,_0x491dfe,_0x1b2faa)=>{global['distributi'+'on']['local']['groups']['add'](_0x2ba713,_0x491dfe,(_0x1ccc9e,_0x55650c)=>{_0x1ccc9e&&_0x1b2faa(_0x1ccc9e),global['distributi'+'on'][_0x309c4a['gid']]['comm']['send']([_0x2ba713,_0x491dfe],{'service':'groups','method':'add'},_0x1b2faa);});},'rem':(_0x22df7b,_0x46d129,_0xbc411d)=>{global['distributi'+'on']['local']['groups']['rem'](_0x22df7b,_0x46d129,(_0x487ff4,_0x35521f)=>{_0x487ff4&&_0xbc411d(_0x487ff4),global['distributi'+'on'][_0x309c4a['gid']]['comm']['send']([_0x22df7b,_0x46d129],{'service':'groups','method':'rem'},_0xbc411d);});}};};module['exports']=groups;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const util=require('../util/ut'+'il'),distribution=global['distributi'+'on'],log=require('../util/lo'+'g');function getNode(_0x46da30,_0x4fddba,_0x14618d){typeof _0x4fddba==='object'&&(_0x4fddba=_0x4fddba['key']),distribution[_0x46da30['gid']]['status']['get']('nid',(_0x127a19,_0x2be3ca)=>{let _0x24819d=Object['values'](_0x2be3ca),_0x10ab23=util['id']['getID'](_0x4fddba),_0x3b02df=_0x46da30['hash'](_0x10ab23,_0x24819d),_0x12cd54=_0x3b02df['substring'](-0x85e+0x154a+0x2*-0x676,0xb8d*0x2+-0x1ef4+0x7df);distribution['local']['groups']['get'](_0x46da30['gid'],(_0x5b6446,_0x30285c)=>{let _0x2211f1=_0x30285c[_0x12cd54];log('[mem\x20(getN'+'ode)]\x20conf'+'iguration:'+'\x20'+JSON['stringify'](_0x4fddba)+'group:\x20'+JSON['stringify'](_0x30285c)+'\x20node:\x20'+JSON['stringify'](_0x2211f1)+'nid:\x20'+JSON['stringify'](_0x3b02df)+'\x20sid:\x20'+JSON['stringify'](_0x12cd54)),_0x14618d(_0x2211f1);});});}const mem=function(_0x4c89d8){let _0xd2f6e3={};return _0xd2f6e3['gid']=_0x4c89d8['gid']||'all',_0xd2f6e3['hash']=_0x4c89d8['hash']||util['id']['naiveHash'],{'get':(_0x4a36a1,_0x3fe1c9)=>{if(!_0x4a36a1){let _0x1bb42b=[{'key':null,'gid':_0xd2f6e3['gid']}];distribution[_0xd2f6e3['gid']]['comm']['send'](_0x1bb42b,{'service':'mem','method':'get'},(_0x4fa5d0,_0x59a00e)=>{let _0x30fc6e=Object['values'](_0x59a00e)['reduce']((_0x1a6b9b,_0x4fc79a)=>_0x1a6b9b['concat'](_0x4fc79a),[]);_0x3fe1c9(_0x4fa5d0,_0x30fc6e);});return;}getNode(_0xd2f6e3,_0x4a36a1,_0x5133a8=>{let _0x184dc5=[{'key':_0x4a36a1,'gid':_0xd2f6e3['gid']}],_0x594341={'service':'mem','method':'get','node':_0x5133a8};log('[all.mem.g'+'et]\x0a\x20\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20config'+'uration:\x20'+JSON['stringify'](_0x4a36a1)+('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20node:\x20')+JSON['stringify'](global['nodeConfig'])+('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20target\x20no'+'de:\x20')+JSON['stringify'](_0x5133a8)+('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20'+'\x20')),distribution['local']['comm']['send'](_0x184dc5,_0x594341,_0x3fe1c9);});},'put':(_0x42ab95,_0x131398,_0x5706a1)=>{_0x131398=_0x131398||util['id']['getID'](_0x42ab95),getNode(_0xd2f6e3,_0x131398,_0x55de23=>{let _0x56c755=[_0x42ab95,{'action':_0x131398['action'],'key':_0x131398['key'],'gid':_0xd2f6e3['gid']}],_0x5783fb={'service':'mem','method':'put','node':_0x55de23};log('[all.mem.p'+'ut]\x20state:'+'\x20'+JSON['stringify'](_0x42ab95)+('configurat'+'ion:\x20')+JSON['stringify'](_0x131398)+('target\x20nod'+'e:\x20')+JSON['stringify'](_0x55de23)),distribution['local']['comm']['send'](_0x56c755,_0x5783fb,_0x5706a1);});},'del':(_0x55b177,_0x30e0fc)=>{getNode(_0xd2f6e3,_0x55b177,_0x427a55=>{let _0x35a6ec=[{'key':_0x55b177,'gid':_0xd2f6e3['gid']}],_0x14d1b8={'service':'mem','method':'del','node':_0x427a55};distribution['local']['comm']['send'](_0x35a6ec,_0x14d1b8,_0x30e0fc);});},'reconf':(_0x323b5f,_0x56f397)=>{distribution[_0xd2f6e3['gid']]['mem']['get'](null,(_0x383b96,_0x178faa)=>{distribution[_0xd2f6e3['gid']]['status']['get']('nid',(_0x24d169,_0x3ac881)=>{let _0xa0947d=Object['values'](_0x3ac881),_0xde4b58=Object['values'](_0x323b5f)['map'](_0x79e6c8=>util['id']['getNID'](_0x79e6c8)),_0x438444=0xa70+-0x31*-0xc1+0x3*-0xfcb;const _0x8eebb8=()=>{_0x438444===_0x178faa['length']&&_0x56f397();};if(_0x178faa['length']===0x2b*-0x6d+0xefc+-0x353*-0x1){_0x56f397();return;}for(let _0x445910 of _0x178faa){let _0x160f41=util['id']['getID'](_0x445910),_0x183a3b=_0xd2f6e3['hash'](_0x160f41,_0xde4b58),_0x3484b1=_0xd2f6e3['hash'](_0x160f41,_0xa0947d);if(_0x183a3b===_0x3484b1){_0x438444++,_0x8eebb8();continue;}let _0x47dff8=_0x323b5f[_0x183a3b['substring'](0x167+-0x1*0x97b+0x814,-0x2124+0xd*0xdf+-0x45e*-0x5)],_0x969662=[{'key':_0x445910,'gid':_0xd2f6e3['gid']}],_0x13870a={'service':'mem','method':'del','node':_0x47dff8};distribution['local']['comm']['send'](_0x969662,_0x13870a,(_0x2ea9b4,_0x5e0e1d)=>{distribution[_0xd2f6e3['gid']]['mem']['put'](_0x5e0e1d,_0x445910,(_0x12d7e0,_0x54b2cd)=>{_0x438444++,_0x8eebb8();});});}});});}};};module['exports']=mem;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const distribution=require('../../dist'+'ribution'),id=distribution['util']['id'],mr=function(_0x5744e1={'gid':'all'}){const _0x2b27c9={};return _0x2b27c9['gid']=_0x5744e1['gid'],{'exec':(_0x33dc31,_0x4bbf87)=>{const _0x5c9256=id['getSID'](_0x33dc31);mrSvc={'mapper':_0x33dc31['map'],'reducer':_0x33dc31['reduce'],'map':function(_0x1864f0,_0xfb7038,_0x1055a9,_0x2d8874=function(){}){if(_0x1864f0['length']==0x316+-0x53a+0x224)_0x2d8874(null,{});else{let _0x556c9b=[],_0x4f69fa=0x11a8+0x11c9+-0x2371;_0x1864f0['forEach'](_0x2c9e10=>{distribution[_0xfb7038]['store']['get'](_0x2c9e10,(_0x80397a,_0xdaf9a5)=>{_0x4f69fa++;const _0x51049d=this['mapper'](_0x2c9e10,_0xdaf9a5);Array['isArray'](_0x51049d)?_0x556c9b['push'](..._0x51049d):_0x556c9b['push'](_0x51049d),_0x4f69fa==_0x1864f0['length']&&distribution['local']['store']['put'](_0x556c9b,_0x1055a9+'_map',(_0x4d2ad3,_0x49fc42)=>{_0x2d8874(_0x4d2ad3,_0x556c9b);});});});}},'shuffle':function(_0x22a932,_0x59afd8,_0x583b01=function(){}){distribution['local']['store']['get'](_0x59afd8+'_map',(_0x547962,_0x385afd)=>{!_0x547962?(cnt=-0x3*0x107+-0x2f*0xcf+0x1*0x2916,_0x385afd['forEach'](_0x306993=>{const [_0x5bae26]=Object['keys'](_0x306993);distribution[_0x22a932]['mem']['put'](_0x306993[_0x5bae26],{'key':_0x5bae26,'action':'append'},(_0xf2b8f,_0x4d53ed)=>{cnt++,cnt==_0x385afd['length']&&_0x583b01(null,_0x385afd);});})):_0x583b01(_0x547962,{});});},'reduce':function(_0x591a50,_0xca0f9a,_0x29d65d){distribution['local']['mem']['get']({'key':null,'gid':_0x591a50},(_0x399991,_0x463fe6)=>{let _0x441b96=[],_0x4879a6=0x163d+0x18*-0xeb+-0x35;_0x463fe6['length']==-0x11f*0xb+0xe26*0x2+-0xff7&&_0x29d65d(null,null),_0x463fe6['forEach'](_0x1a4fef=>distribution['local']['mem']['get']({'key':_0x1a4fef,'gid':_0x591a50},(_0x156158,_0x36c35)=>{let _0x3f63d7=this['reducer'](_0x1a4fef,_0x36c35);_0x441b96=_0x441b96['concat'](_0x3f63d7),_0x4879a6++,_0x4879a6==_0x463fe6['length']&&_0x29d65d(null,_0x441b96);}));});}};const _0x2df0af=function(_0x1da6fc,_0x26f45){let _0x4a8e8e={};return Object['keys'](_0x26f45)['forEach'](_0x4924b5=>{_0x4a8e8e[_0x4924b5]=[];}),_0x1da6fc['forEach'](_0x3233d1=>{let _0x286154=id['getID'](_0x3233d1),_0x14d8d2=id['naiveHash'](_0x286154,Object['keys'](_0x26f45));_0x4a8e8e[_0x14d8d2]['push'](_0x3233d1);}),_0x4a8e8e;};distribution[_0x2b27c9['gid']]['routes']['put'](mrSvc,'mr-'+_0x5c9256,(_0x550e6d,_0x1f5631)=>{distribution['local']['groups']['get'](_0x2b27c9['gid'],(_0x9ff936,_0x3120a4)=>{let _0x107c0b=_0x2df0af(_0x33dc31['keys'],_0x3120a4);var _0x34e7fb=-0x929+-0x1e1*0x11+0x148d*0x2;const _0x6d4696=Object['keys'](_0x3120a4)['length'];let _0x3f99f9={'service':'mr-'+_0x5c9256,'method':'map'};for(let _0x25d59c in _0x3120a4){if(!![]){_0x3f99f9['node']=_0x3120a4[_0x25d59c];let _0x480b5b=[_0x107c0b[_0x25d59c],_0x2b27c9['gid'],_0x5c9256];distribution['local']['comm']['send'](_0x480b5b,_0x3f99f9,(_0x4313df,_0xedf7fa)=>{++_0x34e7fb;if(_0x34e7fb==_0x6d4696){let _0x282e08={'service':'mr-'+_0x5c9256,'method':'shuffle'};distribution[_0x2b27c9['gid']]['comm']['send']([_0x2b27c9['gid'],_0x5c9256],_0x282e08,(_0x4cf6d3,_0x371862)=>{let _0x338acc={'service':'mr-'+_0x5c9256,'method':'reduce'};distribution[_0x2b27c9['gid']]['comm']['send']([_0x2b27c9['gid'],_0x5c9256],_0x338acc,(_0x242fb2,_0x40d759)=>{let _0x3ee736=[];for(let _0xb63750 of Object['values'](_0x40d759)){_0xb63750!==null&&(_0x3ee736=_0x3ee736['concat'](_0xb63750));}_0x4bbf87(_0x242fb2,_0x3ee736);return;distribution[_0x2b27c9['gid']]['routes']['rem']('mr-'+_0x5c9256,(_0x305f77,_0x69403e)=>{_0x4bbf87(null,_0x3ee736);});});});}});}}});});}};};module['exports']=mr;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const routes=function(_0x44eef3){let _0x58fcfe={};return _0x58fcfe['gid']=_0x44eef3['gid']||'global',{'put':(_0x17f621,_0x34b5ef,_0x327a31)=>{global['distributi'+'on'][_0x58fcfe['gid']]['comm']['send']([_0x17f621,_0x34b5ef],{'service':'routes','method':'put'},_0x327a31);},'rem':(_0x3f41de,_0x3e0e72)=>{global['distributi'+'on'][_0x58fcfe['gid']]['comm']['send']([_0x3f41de],{'service':'routes','method':'rem'},_0x3e0e72);}};};module['exports']=routes;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const status=function(_0x18d406){let _0x47a05e={};return _0x47a05e['gid']=_0x18d406['gid']||'global',{'get':(_0x1d1054,_0x9bb6c4)=>{let _0xea5151=[_0x1d1054],_0x318852={'service':'status','method':'get'};global['distributi'+'on'][_0x47a05e['gid']]['comm']['send'](_0xea5151,_0x318852,(_0x1cdcee,_0x52caeb)=>{switch(_0x1d1054){case'heapTotal':let _0x463eeb=Object['values'](_0x52caeb)['reduce']((_0x30fc32,_0x3b71a4)=>{return _0x30fc32+_0x3b71a4;},-0x8f5*-0x4+0x1bb9+-0x3f8d);_0x9bb6c4(_0x1cdcee,_0x463eeb);break;case'nid':let _0x1faea4=Object['values'](_0x52caeb)['reduce']((_0x1b4985,_0x4d4688)=>{return _0x1b4985['concat'](_0x4d4688);},[]);_0x9bb6c4(_0x1cdcee,_0x1faea4);break;default:_0x9bb6c4(_0x1cdcee,_0x52caeb);break;}});},'spawn':(_0x36eab7,_0x2a2a94)=>{_0x2a2a94=_0x2a2a94||function(){},global['distributi'+'on']['local']['status']['spawn'](_0x36eab7,(_0x5e8c7a,_0x9edc1d)=>{_0x5e8c7a?_0x2a2a94(_0x5e8c7a):global['distributi'+'on']['local']['groups']['add'](_0x47a05e['gid'],_0x36eab7,()=>{_0x2a2a94(null,_0x9edc1d);}),distribution[_0x47a05e['gid']]['comm']['send']([_0x47a05e['gid'],_0x36eab7],{'service':'groups','method':'add'},()=>{});});},'stop':_0x3e920e=>{distribution[_0x47a05e['gid']]['comm']['send']([],{'service':'status','method':'stop'},_0x3e920e);}};};module['exports']=status;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const log=require('../util/lo'+'g'),distribution=global['distributi'+'on'],util=distribution['util'];function getNode(_0x56d9a0,_0x164521,_0x4495f6){distribution[_0x56d9a0['gid']]['status']['get']('nid',(_0x56646c,_0x495510)=>{let _0x2cec7f=Object['values'](_0x495510),_0x1b9f86=util['id']['getID'](_0x164521),_0x47d598=_0x56d9a0['hash'](_0x1b9f86,_0x2cec7f),_0x358a8f=_0x47d598['substring'](-0x3*-0x3a1+-0x2466*-0x1+0x2f49*-0x1,-0x83*0x18+0x497+0x7b6);distribution['local']['groups']['get'](_0x56d9a0['gid'],(_0x533bcc,_0x5e1b80)=>{let _0x58b47b=_0x5e1b80[_0x358a8f];_0x4495f6(_0x58b47b);});});}const store=function(_0x38d58c){let _0x3cb975={};return _0x3cb975['gid']=_0x38d58c['gid']||'all',_0x3cb975['hash']=_0x38d58c['hash']||util['id']['naiveHash'],log('Store\x20serv'+'ice\x20initia'+'lized\x20for\x20'+_0x3cb975['gid']),{'get':(_0x3ddc07,_0x92711e)=>{if(!_0x3ddc07){let _0x2979f1=[{'key':null,'gid':_0x3cb975['gid']}];distribution[_0x3cb975['gid']]['comm']['send'](_0x2979f1,{'service':'store','method':'get'},(_0x56f553,_0x3fd7ab)=>{let _0xbbcac5=Object['values'](_0x3fd7ab)['reduce']((_0x4d091f,_0x424d51)=>_0x4d091f['concat'](_0x424d51),[]);_0x92711e(_0x56f553,_0xbbcac5);});return;}getNode(_0x3cb975,_0x3ddc07,_0x29aafb=>{let _0x4d40d6=[{'key':_0x3ddc07,'gid':_0x3cb975['gid']}],_0x33d7b9={'service':'store','method':'get','node':_0x29aafb};distribution['local']['comm']['send'](_0x4d40d6,_0x33d7b9,_0x92711e);});},'put':(_0x235514,_0x581010,_0x402f7f)=>{log('[all.store'+'.put]:\x20(gi'+'d:\x20'+_0x3cb975['gid']+')\x20'+_0x235514+'\x20'+_0x581010),_0x581010=_0x581010||util['id']['getID'](_0x235514),getNode(_0x3cb975,_0x581010,_0x845347=>{let _0x593765=[_0x235514,{'key':_0x581010,'gid':_0x3cb975['gid']}],_0x2af4dd={'service':'store','method':'put','node':_0x845347};distribution['local']['comm']['send'](_0x593765,_0x2af4dd,_0x402f7f);});},'del':(_0x2ff2d6,_0x5935ec)=>{getNode(_0x3cb975,_0x2ff2d6,_0x2fbcc4=>{let _0x41fd13=[{'key':_0x2ff2d6,'gid':_0x3cb975['gid']}],_0x9eace7={'service':'store','method':'del','node':_0x2fbcc4};distribution['local']['comm']['send'](_0x41fd13,_0x9eace7,_0x5935ec);});},'reconf':(_0x28240d,_0x14e4fa)=>{distribution[_0x3cb975['gid']]['store']['get'](null,(_0x8ab6f6,_0x20b9b2)=>{distribution[_0x3cb975['gid']]['status']['get']('nid',(_0x23fb50,_0x21eb4e)=>{let _0x25b2fa=Object['values'](_0x21eb4e),_0x46e3a7=Object['values'](_0x28240d)['map'](_0x51cbf1=>util['id']['getNID'](_0x51cbf1)),_0x24dcca=-0x1*0xaf3+-0xc2*-0x1d+-0xb07;const _0x5086d5=()=>{_0x24dcca===_0x20b9b2['length']&&_0x14e4fa();};if(_0x20b9b2['length']===0x10bf+-0x53*-0x3+-0x11b8){_0x14e4fa();return;}for(let _0x357dee of _0x20b9b2){let _0x35b038=util['id']['getID'](_0x357dee),_0x1ed0c2=_0x3cb975['hash'](_0x35b038,_0x46e3a7),_0x1c1776=_0x3cb975['hash'](_0x35b038,_0x25b2fa);if(_0x1ed0c2===_0x1c1776){_0x24dcca++,_0x5086d5();continue;}let _0x4914f1=_0x28240d[_0x1ed0c2['substring'](-0x1bf*0x7+0x4d*-0x59+0x7*0x592,0x3*-0x483+-0x944+0x16d2)],_0x58bc32=[{'key':_0x357dee,'gid':_0x3cb975['gid']}],_0x37d686={'service':'store','method':'del','node':_0x4914f1};distribution['local']['comm']['send'](_0x58bc32,_0x37d686,(_0x591ac2,_0x466571)=>{distribution[_0x3cb975['gid']]['store']['put'](_0x466571,_0x357dee,(_0x5bd4b5,_0x21c52f)=>{_0x24dcca++,_0x5086d5();});});}});});}};};module['exports']=store;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const http=require('http'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g'),comm={};comm['send']=function(_0x2042bb,_0x2adad3,_0x4fdfd6){log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0x2042bb)+'to\x20'+_0x2adad3['service']+':'+_0x2adad3['method']+'\x20on\x20'+_0x2adad3['node']['ip']+':'+_0x2adad3['node']['port']);if(!_0x2042bb instanceof Array)throw new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray');let _0x2731cb=_0x2adad3['node'],_0x7b64fc=_0x2adad3['service'],_0x15f355=_0x2adad3['method'],_0x3b5711=serialization['serialize'](_0x2042bb);const _0x1f1996={'hostname':_0x2731cb['ip'],'port':_0x2731cb['port'],'path':'/'+_0x7b64fc+'/'+_0x15f355,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x3b5711)}},_0x40d219=http['request'](_0x1f1996,_0x26f368=>{let _0x52670e='';_0x26f368['on']('data',function(_0x535ca0){_0x52670e+=_0x535ca0;}),_0x26f368['on']('end',function(){_0x4fdfd6&&_0x4fdfd6(...serialization['deserializ'+'e'](_0x52670e));}),_0x26f368['on']('error',function(_0x3e279d){_0x4fdfd6&&_0x4fdfd6(new Error('Error\x20on\x20r'+'esponse'));});});_0x40d219['on']('error',function(_0x494431){_0x4fdfd6&&_0x4fdfd6(new Error(_0x494431));}),_0x40d219['write'](_0x3b5711),_0x40d219['end']();},module['exports']=comm;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const gossip={},messageStore={'messages':[],'push':function(_0x2b6261){N=0xe47+0x16cb+-0x2508,messageStore['messages']['push'](_0x2b6261),messageStore['messages']['length']>N&&messageStore['messages']['shift']();},'has':function(_0x20373e){return messageStore['messages']['includes'](_0x20373e);}};gossip['recv']=function(_0x5bd71b,_0x5db55b){_0x5db55b=_0x5db55b||function(){};let _0x371b7d=_0x5bd71b['message'],_0x2234f8=_0x5bd71b['remote'],_0xa2b8d1=_0x5bd71b['mid'],_0x449a93=_0x5bd71b['gid'];if(messageStore['has'](_0xa2b8d1)){_0x5db55b(new Error('Message\x20al'+'ready\x20rece'+'ived'));return;}global['distributi'+'on'][_0x449a93]['gossip']['send'](_0x5bd71b,_0x2234f8),messageStore['push'](_0xa2b8d1),_0x2234f8['node']={'ip':global['nodeConfig']['ip'],'port':global['nodeConfig']['port']},global['distributi'+'on']['local']['comm']['send'](_0x371b7d,_0x2234f8,(_0x3df632,_0x9c9cb9)=>{_0x5db55b(_0x3df632,_0x9c9cb9);});},module['exports']=gossip;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ let groupsStore=new Map();groupsStore['all']={};const id=require('../util/id'),groups={};groups['get']=function(_0x72afeb,_0x499eb5){_0x499eb5=_0x499eb5||function(){},_0x72afeb in groupsStore?_0x499eb5(null,groupsStore[_0x72afeb]):_0x499eb5(new Error('Group\x20'+_0x72afeb+'\x20not\x20found'));},groups['put']=function(_0x301f90,_0x22851d,_0x5aad25){_0x22851d=_0x22851d||{},typeof _0x301f90==='string'&&(_0x301f90={'gid':_0x301f90}),groupsStore[_0x301f90['gid']]=_0x22851d,Object['keys'](_0x22851d)['forEach'](_0x2000be=>{groupsStore['all'][id['getSID'](_0x22851d[_0x2000be])]=_0x22851d[_0x2000be];}),global['distributi'+'on'][_0x301f90['gid']]={},global['distributi'+'on'][_0x301f90['gid']]['status']=require('../all/sta'+'tus')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['comm']=require('../all/com'+'m')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['gossip']=require('../all/gos'+'sip')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['groups']=require('../all/gro'+'ups')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['routes']=require('../all/rou'+'tes')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['mem']=require('../all/mem')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['store']=require('../all/sto'+'re')(_0x301f90),global['distributi'+'on'][_0x301f90['gid']]['mr']=require('../all/mr')(_0x301f90),_0x5aad25(null,_0x22851d);},groups['del']=function(_0x25cd81,_0x4fd651){if(_0x25cd81 in groupsStore){let _0x348cf1=groupsStore[_0x25cd81];delete groupsStore[_0x25cd81],_0x4fd651(null,_0x348cf1);}else _0x4fd651(new Error('Group\x20'+_0x25cd81+'\x20not\x20found'));},groups['add']=function(_0x6245f6,_0x1efc35,_0x4221e2){_0x4221e2=_0x4221e2||function(){},_0x6245f6 in groupsStore?(!groupsStore[_0x6245f6]&&(groupsStore[_0x6245f6]={}),groupsStore[_0x6245f6][id['getSID'](_0x1efc35)]=_0x1efc35,groupsStore['all'][id['getSID'](_0x1efc35)]=_0x1efc35,_0x4221e2&&_0x4221e2(null,groupsStore[_0x6245f6])):_0x4221e2&&_0x4221e2(new Error('Group\x20'+_0x6245f6+'\x20not\x20found'));},groups['rem']=function(_0x292d98,_0x4eb153,_0xba8fce){_0xba8fce=_0xba8fce||function(){},_0x292d98 in groupsStore?(delete groupsStore[_0x292d98][_0x4eb153],delete groupsStore['all'][_0x4eb153],_0xba8fce(null,groupsStore[_0x292d98])):_0xba8fce(new Error('Group\x20'+_0x292d98+'\x20not\x20found'));},module['exports']=groups;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const status=require('./status'),groups=require('./groups'),routes=require('./routes'),comm=require('./comm'),gossip=require('./gossip'),mem=require('./mem'),store=require('./store');module['exports']={'status':status,'routes':routes,'comm':comm,'groups':groups,'gossip':gossip,'mem':mem,'store':store};
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const id=require('../util/id'),log=require('../util/lo'+'g'),kvStore={'store':new Map(),'get'(_0xf42574){if(!this['store'][_0xf42574['gid']])return undefined;return this['store'][_0xf42574['gid']][_0xf42574['key']];},'put'(_0x352a33,_0x279851){!this['store'][_0x352a33['gid']]&&(this['store'][_0x352a33['gid']]=new Map()),this['store'][_0x352a33['gid']][_0x352a33['key']]=_0x279851;},'append'(_0x5cf71c,_0x66e5c4){!this['get'](_0x5cf71c)&&this['put'](_0x5cf71c,[]),!Array['isArray'](this['get'](_0x5cf71c))&&this['put'](_0x5cf71c,[this['get'](_0x5cf71c)]),Array['isArray'](_0x66e5c4)?this['put'](_0x5cf71c,this['get'](_0x5cf71c)['concat'](_0x66e5c4)):this['store'][_0x5cf71c['gid']][_0x5cf71c['key']]['push'](_0x66e5c4);},'del'(_0x592c91){if(!this['store'][_0x592c91['gid']])return undefined;let _0x330abd=this['store'][_0x592c91['gid']][_0x592c91['key']];return delete this['store'][_0x592c91['gid']][_0x592c91['key']],_0x330abd;},'toString'(){let _0x528f5a='';for(let _0x281e7b in this['store']){_0x528f5a+=_0x281e7b+':\x20'+JSON['stringify'](this['store'][_0x281e7b]);}return _0x528f5a;}};function normalize(_0x10282c){let _0x25b503={};_0x10282c===null&&(_0x10282c={});if(typeof _0x10282c==='string')_0x25b503['key']=_0x10282c,_0x25b503['gid']='local',_0x25b503['action']='put';else typeof _0x10282c==='object'&&(_0x25b503['key']=_0x10282c['key'],_0x25b503['gid']=_0x10282c['gid'],_0x25b503['action']=_0x10282c['action']);return _0x25b503;};const mem={};mem['put']=function(_0x27a718,_0x41cf7a,_0x5cacb4){log('[mem.put]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x41cf7a)+'state:\x20'+JSON['stringify'](_0x27a718)+'\x20store:\x20'+kvStore['toString']()+'\x20}'),_0x5cacb4=_0x5cacb4||function(){},_0x41cf7a=normalize(_0x41cf7a),_0x41cf7a['key']=_0x41cf7a['key']||id['getID'](_0x27a718),_0x41cf7a['gid']=_0x41cf7a['gid']||'local',_0x41cf7a['action']=_0x41cf7a['action']||'put',kvStore[_0x41cf7a['action']](_0x41cf7a,_0x27a718),log('[mem.put]\x20'+'store\x20(aft'+'er):\x20'+kvStore['toString']()),_0x5cacb4&&_0x5cacb4(null,_0x27a718);},mem['get']=function(_0x22f9e9,_0x618b2c){_0x618b2c=_0x618b2c||function(){},_0x22f9e9=normalize(_0x22f9e9),_0x22f9e9['gid']=_0x22f9e9['gid']||'local';if(!_0x22f9e9['key']){let _0x20c620=kvStore['store'][_0x22f9e9['gid']]||{};_0x20c620=Object['keys'](_0x20c620),_0x618b2c(null,_0x20c620);return;}let _0x2e68bc=kvStore['get'](_0x22f9e9);_0x2e68bc?_0x618b2c(null,_0x2e68bc):_0x618b2c(new Error('Memory\x20key'+'\x20\x22'+_0x22f9e9['key']+('\x22\x20\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20not\x20found'+'\x20for\x20')+_0x22f9e9['gid']+'\x27s\x20store'));},mem['del']=function(_0x2a6eb4,_0x99b816){_0x99b816=_0x99b816||function(){},_0x2a6eb4=normalize(_0x2a6eb4);let _0x4e8c44=kvStore['del'](_0x2a6eb4);_0x4e8c44?_0x99b816(null,_0x4e8c44):_0x99b816(new Error('Memory\x20key'+'\x20\x22'+_0x2a6eb4['key']+('\x22\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'not\x20found\x20'+'for\x20')+_0x2a6eb4['gid']+'\x27s\x20store'));},module['exports']=mem;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x1eeae6){error=undefined;if(_0x1eeae6['length']===0x576*-0x4+0x1611+0x3*-0x13)return new Error('No\x20body');try{_0x1eeae6=JSON['parse'](_0x1eeae6);}catch(_0x53fe26){return _0x53fe26;}return error;}function endRequest(_0x3f40df,_0xb84622){_0x3f40df['end'](serialization['serialize']([_0xb84622]));}const start=function(_0x2cc9a7){const _0x4aa175=http['createServ'+'er']((_0x3d7832,_0x221a47)=>{if(_0x3d7832['method']!=='PUT'){_0x221a47['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x16c7c9=url['parse'](_0x3d7832['url'])['pathname'],[,_0x3e8b4f,_0x3ad23e]=_0x16c7c9['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x3e8b4f+':'+_0x3ad23e);let _0x3b3614=[];_0x3d7832['on']('data',_0x12f62a=>{_0x3b3614['push'](_0x12f62a);}),_0x3d7832['on']('end',()=>{_0x3b3614=Buffer['concat'](_0x3b3614)['toString']();let _0x19fad1;if(_0x19fad1=isValidBody(_0x3b3614)){endRequest(_0x221a47,_0x19fad1);return;}_0x3b3614=JSON['parse'](_0x3b3614),_0x3b3614=serialization['deserializ'+'e'](_0x3b3614);let _0x265cfd=_0x3b3614;!Array['isArray'](_0x265cfd)&&endRequest(_0x221a47,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x265cfd));let _0x4f2523=_0x3e8b4f;global['distributi'+'on']['local']['routes']['get'](_0x4f2523,(_0x2e4569,_0x4d5395)=>{const _0x48d919=(_0x3659aa,_0x5b6bb8)=>{_0x221a47['end'](serialization['serialize']([_0x3659aa,_0x5b6bb8]));};if(_0x2e4569){_0x48d919(_0x2e4569);return;}if(!_0x4d5395[_0x3ad23e]){_0x48d919(new Error('Method\x20'+_0x3ad23e+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x4f2523));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x4f2523+':'+_0x3ad23e+('with\x20args:'+'\x20')+JSON['stringify'](_0x265cfd));_0x265cfd['length']===0x41c+0x12bb*-0x1+-0x24*-0x68&&_0x4d5395[_0x3ad23e]['length']===0x5f*0x15+-0x12d+-0x1*0x69b&&_0x265cfd['push'](undefined);try{_0x4d5395[_0x3ad23e](..._0x265cfd,_0x48d919);}catch(_0x54a2a7){_0x48d919(_0x54a2a7);}});});});_0x4aa175['listen'](global['nodeConfig']['port'],global['nodeConfig']['ip'],()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'/'),global['distributi'+'on']['node']['server']=_0x4aa175,_0x2cc9a7(_0x4aa175);}),_0x4aa175['on']('error',_0x32467f=>{log('Server\x20err'+'or:\x20'+_0x32467f);throw _0x32467f;});};module['exports']={'start':start};
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const log=require('../util/lo'+'g'),routesStore=new Map(),routes={};routes['get']=function(_0x226435,_0x250efb){log('[routes.ge'+'t]\x20Getting'+'\x20service:\x20'+_0x226435);if(!_0x250efb)return;if(_0x226435 in routesStore){log('[routes.ge'+'t]\x20Found\x20s'+'ervice:\x20'+_0x226435);let _0x26c66b=routesStore[_0x226435];_0x250efb(null,_0x26c66b);}else{const _0x537c1=global['toLocal']['get'](_0x226435);_0x537c1?(log('[routes.ge'+'t]\x20Found\x20R'+'PC:\x20'+_0x226435),_0x250efb(null,{'call':_0x537c1})):_0x250efb(new Error('Service\x20'+_0x226435+('\x20not\x20found'+'\x20in\x20routes')));}},routes['put']=function(_0x5a315d,_0x37e6e1,_0x19a632){log('[routes.pu'+'t]\x20Putting'+'\x20service:\x20'+_0x37e6e1),routesStore[_0x37e6e1]=_0x5a315d;_0x19a632&&_0x19a632(null,_0x37e6e1);;},routes['rem']=function(_0x54714b,_0x247021){delete routesStore[_0x54714b];},module['exports']=routes;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const id=require('../util/id'),log=require('../util/lo'+'g'),status={};global['moreStatus']={'sid':id['getSID'](global['nodeConfig']),'nid':id['getNID'](global['nodeConfig']),'counts':0x0},status['get']=function(_0x299f10,_0x127561){_0x127561=_0x127561||function(){};if(_0x299f10 in global['nodeConfig'])_0x127561(null,global['nodeConfig'][_0x299f10]);else{if(_0x299f10 in moreStatus)_0x127561(null,moreStatus[_0x299f10]);else{if(_0x299f10==='heapTotal')_0x127561(null,process['memoryUsag'+'e']()['heapTotal']);else _0x299f10==='heapUsed'?_0x127561(null,process['memoryUsag'+'e']()['heapUsed']):_0x127561(new Error('Status\x20key'+'\x20not\x20found'));}}};const path=require('path'),{spawn}=require('child_proc'+'ess'),wire=require('../util/wi'+'re'),createSpawnedCb=function(_0x3d4381,_0x27e09a){let _0x8e9a53='\x0a\x20\x20\x20\x20let\x20o'+'nStart\x20=\x20'+_0x3d4381['toString']()+(';\x0a\x0a\x20\x20\x20\x20let'+'\x20callbackR'+'PC\x20=\x20')+wire['createRPC'](wire['toAsync'](_0x27e09a))['toString']()+(';\x0a\x0a\x20\x20\x20\x20try'+'\x20{\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20onStart()'+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'callbackRP'+'C(null,\x20gl'+'obal.nodeC'+'onfig,\x20()\x20'+'=>\x20{});\x0a\x20\x20'+'\x20\x20}\x0a\x20\x20\x20\x20ca'+'tch\x20(e)\x20{\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20ca'+'llbackRPC('+'e,\x20null,\x20('+')\x20=>\x20{});\x0a'+'\x20\x20\x20\x20}\x0a\x20\x20\x20\x20');return new Function(_0x8e9a53);};status['spawn']=function(_0x382039,_0x474cdc){const _0x5abc90=_0x382039;_0x5abc90['onStart']=_0x5abc90['onStart']||function(){};if(!_0x5abc90['port']||!_0x5abc90['ip']){_0x474cdc(new Error('Port\x20and\x20I'+'P\x20are\x20requ'+'ired\x20in\x20th'+'e\x20configur'+'ation'));return;}log('[status.sp'+'awn]\x20Spawn'+'ing\x20node\x20w'+'ith\x20config'+'uration:\x20'+JSON['stringify'](_0x5abc90)),_0x5abc90['onStart']=createSpawnedCb(_0x5abc90['onStart'],_0x474cdc);const _0xd3ce64=path['join'](__dirname,'../../dist'+'ribution.j'+'s');let _0x2faa93=spawn('node',[_0xd3ce64,'--config',global['distributi'+'on']['util']['serialize'](_0x5abc90)],{'detached':!![],'stdio':'inherit'});_0x2faa93;},status['stop']=function(_0x83069){_0x83069=_0x83069||function(){},_0x83069(null,global['nodeConfig']),setTimeout(()=>{log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),global['distributi'+'on']['node']['server']['close'](),process['exit'](-0xa7*0x1+-0xb1a*0x2+0x1*0x16db);},-0x1*0x71e+0x1013+-0x8f5);},module['exports']=status;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const fs=require('fs'),path=require('path'),id=require('../util/id'),serialization=require('../util/se'+'rializatio'+'n'),store={},baseFolder=path['join'](__dirname,'../../stor'+'e');!fs['existsSync'](baseFolder)&&fs['mkdirSync'](baseFolder);!fs['existsSync'](baseFolder+'/s-'+global['moreStatus']['sid'])&&fs['mkdirSync'](baseFolder+'/s-'+global['moreStatus']['sid']);function normalize(_0x5eb1ad){let _0x12bd9f={};_0x5eb1ad===null&&(_0x5eb1ad={});if(typeof _0x5eb1ad==='string')_0x12bd9f['key']=_0x5eb1ad,_0x12bd9f['gid']='local';else typeof _0x5eb1ad==='object'&&(_0x12bd9f['key']=_0x5eb1ad['key'],_0x12bd9f['gid']=_0x5eb1ad['gid']);return _0x12bd9f;};store['put']=function(_0x1bb1ac,_0x36fab2,_0x46b437){_0x46b437=_0x46b437||function(){},_0x36fab2=normalize(_0x36fab2),_0x36fab2['key']=_0x36fab2['key']||id['getID'](_0x1bb1ac),_0x36fab2['gid']=_0x36fab2['gid']||'local';let _0x5d3b2c=serialization['serialize'](_0x1bb1ac),_0x22a85e=Buffer['from'](_0x36fab2['key'])['toString']('base64');_0x22a85e=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x36fab2['gid']+'-'+_0x22a85e,fs['writeFile'](_0x22a85e,_0x5d3b2c,_0x2572e4=>{_0x2572e4?_0x46b437(_0x2572e4):_0x46b437(null,_0x1bb1ac);});},store['get']=function(_0x29839d,_0x23d3b7){_0x23d3b7=_0x23d3b7||function(){},_0x29839d=normalize(_0x29839d),_0x29839d['gid']=_0x29839d['gid']||'local';if(!_0x29839d['key']){fs['readdir'](baseFolder+'/s-'+global['moreStatus']['sid'],(_0x38ca91,_0x3de406)=>{if(_0x38ca91)_0x23d3b7(_0x38ca91);else{let _0x4624b4=[];for(let _0x1a6a62=0xe77+0x2*0x3fd+-0x1671;_0x1a6a62<_0x3de406['length'];_0x1a6a62++){let _0x58f448=_0x3de406[_0x1a6a62]['split']('-'),_0x3c0d63=_0x58f448[-0x12a*0x1c+-0x1*-0x1fb5+0xe3];if(_0x3c0d63!==_0x29839d['gid'])continue;_0x58f448=_0x58f448[_0x58f448['length']-(0x7c*-0x44+-0xf27+0x3018)],_0x4624b4['push'](Buffer['from'](_0x58f448,'base64')['toString']());}_0x23d3b7(null,_0x4624b4);}});return;}let _0x5e7471=Buffer['from'](_0x29839d['key'])['toString']('base64');_0x5e7471=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x29839d['gid']+'-'+_0x5e7471,fs['exists'](_0x5e7471,_0x18ba52=>{if(!_0x18ba52){_0x23d3b7(new Error('File\x20'+_0x5e7471+('\x20not\x20found'+'\x20for\x20group'+'\x0a')+_0x29839d['gid']));return;}fs['readFile'](_0x5e7471,(_0x2f1e2b,_0xd7cd4d)=>{_0xd7cd4d=_0xd7cd4d['toString']();if(!_0x23d3b7)return;_0x2f1e2b?_0x23d3b7(_0x2f1e2b):_0x23d3b7(null,serialization['deserializ'+'e'](_0xd7cd4d));});});},store['del']=function(_0x56da0d,_0x47f178){_0x47f178=_0x47f178||function(){},_0x56da0d=normalize(_0x56da0d);let _0x2b7e49=Buffer['from'](_0x56da0d['key'])['toString']('base64');_0x2b7e49=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x56da0d['gid']+'-'+_0x2b7e49,fs['exists'](_0x2b7e49,_0x2b21d9=>{if(!_0x2b21d9){_0x47f178(new Error('File\x20'+_0x2b7e49+('\x20not\x20found'+'\x20for\x20group'+'\x0a')+_0x56da0d['gid']));return;}store['get'](_0x56da0d,(_0x434439,_0x2369e2)=>{fs['rm'](_0x2b7e49,function(_0x9fd879){_0x9fd879?_0x47f178(_0x9fd879):_0x47f178(null,_0x2369e2);});});});},module['exports']=store;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const assert=require('assert');var crypto=require('crypto');function getID(_0x599bbb){const _0x4d5fdd=crypto['createHash']('sha256');return _0x4d5fdd['update'](JSON['stringify'](_0x599bbb)),_0x4d5fdd['digest']('hex');}function getNID(_0x5e7587){return _0x5e7587={'ip':_0x5e7587['ip'],'port':_0x5e7587['port']},getID(_0x5e7587);}function getSID(_0x1fa62e){return getNID(_0x1fa62e)['substring'](-0x10*0x156+0x26e7*-0x1+0x1*0x3c47,0x629*-0x4+0x1e5b*0x1+0x36*-0x1b);}function idToNum(_0x1e938a){let _0x19cf6a=parseInt(_0x1e938a,0x1e6b+-0x27c*-0x6+0x1*-0x2d43);return assert(!isNaN(_0x19cf6a),'idToNum:\x20i'+'d\x20is\x20not\x20i'+'n\x20KID\x20form'+'!'),_0x19cf6a;}function naiveHash(_0x2e5398,_0x3c5f95){return _0x3c5f95['sort'](),_0x3c5f95[idToNum(_0x2e5398)%_0x3c5f95['length']];}function consistentHash(_0x506995,_0x2ab120){const _0x5e13c2=idToNum(_0x506995),_0xbbdb88=_0x2ab120['map'](_0x535d21=>({'id':_0x535d21,'hash':idToNum(_0x535d21)}));_0xbbdb88['sort']((_0x3dbcf9,_0x4f618b)=>_0x3dbcf9['hash']-_0x4f618b['hash']);for(let _0x31fbec of _0xbbdb88){if(_0x5e13c2<=_0x31fbec['hash'])return _0x31fbec['id'];}return _0xbbdb88[-0x1e*0x1+0x23a1+-0x2383]['id'];}function rendezvousHash(_0x51dd12,_0x12c01f){let _0x1c9c13=-0x2326+-0x1c4f*0x1+-0xf*-0x43b,_0x517287=null;for(let _0x31ef4e of _0x12c01f){let _0x432584=getID(_0x51dd12+_0x31ef4e),_0x3febcb=idToNum(_0x432584);_0x3febcb>_0x1c9c13&&(_0x1c9c13=_0x3febcb,_0x517287=_0x31ef4e);}return _0x517287;}module['exports']={'getID':getID,'getNID':getNID,'getSID':getSID,'naiveHash':naiveHash,'consistentHash':consistentHash,'rendezvousHash':rendezvousHash};
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const fs=require('fs'),path=require('path'),logFile=path['join'](__dirname,'../../','log.txt');function log(_0x2b5c3c,_0x5e5b18){_0x5e5b18===undefined&&(_0x5e5b18='info');const _0x365d46=new Date(),_0x117db9=new Intl['DateTimeFo'+'rmat']('en-GB',{'day':'2-digit','month':'2-digit','year':'numeric','hour':'2-digit','minute':'2-digit','second':'2-digit','hour12':![]})['format'](_0x365d46)+'.'+String(_0x365d46['getMillise'+'conds']()*(-0x1b0d+-0x144+0x2039))['padStart'](-0x7f3*-0x4+-0x611+-0x19b5,'0');global['distributi'+'on']['local']['status']['get']('sid',(_0x1cac62,_0xcb04d3)=>{fs['appendFile'+'Sync'](logFile,_0x117db9+'\x20['+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'('+_0xcb04d3+')]\x20['+_0x5e5b18+']\x20'+_0x2b5c3c+'\x0a');});}module['exports']=log;
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ var nativeFunctions={'forward':new Map(),'reverse':new Map()};function createNativeMap(){var _0x43938f=[];function _0x21c53d(_0x4fba12,_0x4b9cc6){if(_0x4b9cc6===null||_0x4b9cc6===undefined)return;if(_0x43938f['indexOf'](_0x4b9cc6)!==-(-0x12b1+0x2691+-0x13df*0x1))return;_0x43938f['push'](_0x4b9cc6),Object['getOwnProp'+'ertyNames'](_0x4b9cc6)['forEach'](_0x2c360f=>{if(typeof _0x4b9cc6[_0x2c360f]==='function'){nativeFunctions['forward']['set'](_0x4b9cc6[_0x2c360f],_0x4fba12+'.'+_0x2c360f),nativeFunctions['reverse']['set'](_0x4fba12+'.'+_0x2c360f,_0x4b9cc6[_0x2c360f]);return;}typeof _0x4b9cc6[_0x2c360f]==='object'&&_0x43938f['indexOf'](_0x4b9cc6[_0x2c360f])===-(-0xa7*0x3b+0x12e2+0x2*0x9ce)&&_0x21c53d(_0x4fba12+'.'+_0x2c360f,_0x4b9cc6[_0x2c360f]);});}const _0x50b94f=require('fs'),_0x1c1403=require('http'),_0x395800=require('https'),_0x41820e=require('url'),_0xdd56b2=require('path'),_0x571818=require('os'),_0x29d39f=require('events'),_0x5d3c79=require('stream'),_0x146b88=require('util'),_0x2fc06a=require('querystrin'+'g'),_0x6743b6=require('zlib'),_0x16656b=require('buffer'),_0x31f4b6=require('child_proc'+'ess'),_0x301344=require('cluster'),_0x115e9f=require('dgram'),_0x308c7d=require('dns'),_0x311348=require('http2'),_0xd4ff28=require('v8');_0x21c53d('globalThis',globalThis),_0x21c53d('fs',_0x50b94f),_0x21c53d('http',_0x1c1403),_0x21c53d('https',_0x395800),_0x21c53d('url',_0x41820e),_0x21c53d('path',_0xdd56b2),_0x21c53d('os',_0x571818),_0x21c53d('events',_0x29d39f),_0x21c53d('stream',_0x5d3c79),_0x21c53d('util',_0x146b88),_0x21c53d('querystrin'+'g',_0x2fc06a),_0x21c53d('zlib',_0x6743b6),_0x21c53d('buffer',_0x16656b),_0x21c53d('child_proc'+'ess',_0x31f4b6),_0x21c53d('cluster',_0x301344),_0x21c53d('dgram',_0x115e9f),_0x21c53d('dns',_0x308c7d),_0x21c53d('http2',_0x311348),_0x21c53d('v8',_0xd4ff28);}createNativeMap();function decycleObject(_0x10c549){if(_0x10c549===null||_0x10c549===undefined)return _0x10c549;var _0x16f22d=new WeakMap();function _0x359a0b(_0x1ddbb4,_0x22dfb2){var _0xdf3411,_0x12e38f;if(!(typeof _0x1ddbb4==='object'&&!(_0x1ddbb4 instanceof Error)&&!(_0x1ddbb4 instanceof Date)&&!(_0x1ddbb4 instanceof Boolean)&&_0x1ddbb4!==null))return _0x1ddbb4;_0xdf3411=_0x16f22d['get'](_0x1ddbb4);if(_0xdf3411!==undefined)return{'$reference':_0xdf3411};return _0x16f22d['set'](_0x1ddbb4,_0x22dfb2),Array['isArray'](_0x1ddbb4)?(_0x12e38f=[],_0x1ddbb4['forEach'](function(_0x44d48c,_0x47fc41){let _0x538fb6=[..._0x22dfb2,_0x47fc41];_0x12e38f[_0x47fc41]=_0x359a0b(_0x44d48c,_0x538fb6);})):(_0x12e38f={},Object['keys'](_0x1ddbb4)['forEach'](_0x3c70fd=>{let _0xd8c68e=[..._0x22dfb2,JSON['stringify'](_0x3c70fd)];_0x12e38f[_0x3c70fd]=_0x359a0b(_0x1ddbb4[_0x3c70fd],_0xd8c68e);})),_0x12e38f;}return _0x359a0b(_0x10c549,[]);};function serializeBaseStructure(_0x4f32f1){return{'type':typeof _0x4f32f1,'value':_0x4f32f1['toString']()};}function serializeUndefined(_0x581eb3){return{'type':'undefined','value':''};}function getObjectSubType(_0x58dd90){if(_0x58dd90 instanceof Array)return'array';if(_0x58dd90 instanceof Date)return'date';if(_0x58dd90 instanceof Error)return'error';if(_0x58dd90===null)return'null';return'object';}function serializeObject(_0x51a272){let _0x5cec06=getObjectSubType(_0x51a272);if(_0x5cec06==='null')return{'type':_0x5cec06,'value':''};if(_0x5cec06==='date')return{'type':_0x5cec06,'value':_0x51a272['toJSON']()};if(_0x5cec06==='error')return{'type':_0x5cec06,'value':serializeObject({'name':_0x51a272['name'],'message':_0x51a272['message'],'cause':_0x51a272['cause']})};function _0x19b59a(_0x5c1359){return Object['keys'](_0x5c1359)['length']==-0x8ef+0x109+0x11*0x77&&Object['keys'](_0x5c1359)[0x2003+0xd4c+-0x1*0x2d4f]=='$reference';}if(_0x19b59a(_0x51a272))return{'type':'reference','value':_0x51a272['$reference']};let _0x439e43={};for(const [_0x19023e,_0x3fc321]of Object['entries'](_0x51a272)){_0x439e43[_0x19023e]=serialize(_0x3fc321);}return{'type':_0x5cec06,'value':_0x439e43};}function serializeFunction(_0x54bec2){if(nativeFunctions['forward']['has'](_0x54bec2))return{'type':'native','value':nativeFunctions['forward']['get'](_0x54bec2)};return{'type':'function','value':_0x54bec2['toString']()};}function serialize(_0x41cba5){_0x41cba5=decycleObject(_0x41cba5);let _0x41fb8a;switch(typeof _0x41cba5){case'object':_0x41fb8a=serializeObject(_0x41cba5);break;case'function':_0x41fb8a=serializeFunction(_0x41cba5);break;case'undefined':_0x41fb8a=serializeUndefined(_0x41cba5);break;case'number':case'string':case'boolean':_0x41fb8a=serializeBaseStructure(_0x41cba5);break;}return JSON['stringify'](_0x41fb8a);}function deserializeObject(_0x694dbf,_0x574b90){for(const [_0x36ed91,_0x166576]of Object['entries'](_0x694dbf)){_0x574b90[_0x36ed91]=deserialize(_0x166576,_0x574b90);}return _0x574b90;}function deserializeArray(_0x362f16,_0x5b50e1){for(const [_0x1acab7,_0x4ce3f6]of Object['entries'](_0x362f16)){_0x5b50e1[_0x1acab7]=deserialize(_0x4ce3f6,_0x5b50e1);}return _0x5b50e1;}function deserializeString(_0x8bc56a){return _0x8bc56a;}function deserializeNumber(_0x526c40){return Number(_0x526c40);}function deserializeFunction(_0x7a8e18){return new Function('return\x20'+_0x7a8e18)();}function deserializeError(_0x28a902){let _0x3c85c6=deserialize(_0x28a902),_0x4a2649=new Error(_0x3c85c6['message'],_0x3c85c6['cause']);return _0x4a2649;}function deserializeReference(_0x5b9ad8,_0x54948e){let _0x399993=_0x54948e;for(let _0x2f3f81 of _0x5b9ad8){_0x2f3f81=JSON['parse'](_0x2f3f81),_0x399993=_0x399993[_0x2f3f81];}return _0x399993;}function deserializeNative(_0x2c7720){return nativeFunctions['reverse']['get'](_0x2c7720);}function deserialize(_0x44d385,_0x224987=null){let _0x5c44ee;if(typeof _0x44d385==='object')_0x5c44ee=_0x44d385;else{if(typeof _0x44d385==='string')_0x5c44ee=JSON['parse'](_0x44d385);else throw new Error('Invalid\x20ar'+'gument\x20typ'+'e:\x20'+typeof _0x44d385+'.');}_0x224987===null&&(_0x224987={});switch(_0x5c44ee['type']){case'object':_0x224987=deserializeObject(_0x5c44ee['value'],{});break;case'array':_0x224987=deserializeArray(_0x5c44ee['value'],[]);break;case'function':_0x224987=deserializeFunction(_0x5c44ee['value']);break;case'native':_0x224987=deserializeNative(_0x5c44ee['value']);break;case'reference':_0x224987=deserializeReference(_0x5c44ee['value'],_0x224987);break;case'number':_0x224987=deserializeNumber(_0x5c44ee['value']);break;case'string':_0x224987=deserializeString(_0x5c44ee['value']);break;case'boolean':_0x224987=_0x5c44ee['value']==='true';break;case'date':_0x224987=new Date(_0x5c44ee['value']);break;case'error':_0x224987=deserializeError(_0x5c44ee['value']);break;case'null':_0x224987=null;break;case'undefined':_0x224987=undefined;break;}return _0x224987;}module['exports']={'serialize':serialize,'deserialize':deserialize};
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const serialization=require('./serializ'+'ation'),id=require('./id'),wire=require('./wire');module['exports']={'serialize':serialization['serialize'],'deserialize':serialization['deserializ'+'e'],'id':id,'wire':wire};
10
+ /* eslint-enable */
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+
3
+ /*
4
+ ATTENTION: This is an obfuscated file. You do not need to understand it.
5
+ Do NOT edit this file directly. Use it as a black box.
6
+
7
+ If you notice any issues with using this file, please contact the TAs.
8
+ */
9
+ const id=require('../util/id'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g');global['toLocal']=new Map();function createRPC(_0x184582){let _0x4f9a08=id['getID'](serialization['serialize'](_0x184582));global['toLocal']['set'](_0x4f9a08,_0x184582);let _0x10ee0b='\x0a\x20\x20\x20\x20const'+'\x20callback\x20'+'=\x20args.pop'+'();\x0a\x0a\x20\x20\x20\x20l'+'et\x20remote\x20'+'=\x20{node:\x20'+JSON['stringify'](global['nodeConfig'])+(',\x20service:'+'\x20\x27')+_0x4f9a08+('\x27,\x20method:'+'\x20\x27call\x27};\x0a'+'\x20\x20\x20\x20let\x20me'+'ssage\x20=\x20ar'+'gs;\x0a\x0a\x20\x20\x20\x20d'+'istributio'+'n.local.co'+'mm.send(me'+'ssage,\x20rem'+'ote,\x20(erro'+'r,\x20respons'+'e)\x20=>\x20{\x0a\x20\x20'+'\x20\x20\x20\x20if\x20(er'+'ror)\x20{\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20callb'+'ack(error)'+';\x0a\x20\x20\x20\x20\x20\x20}\x20'+'else\x20{\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20callb'+'ack(null,\x20'+'response);'+'\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20'+'\x20\x20\x20});\x0a\x20\x20');return log('Created\x20RP'+'C\x20with\x20id:'+'\x20'+_0x4f9a08),new Function('...args',_0x10ee0b);}function toAsync(_0x22739b){log('Converting'+'\x20function\x20'+'to\x20async:\x20'+_0x22739b['name']+':\x20'+_0x22739b['toString']()['replace'](/\n/g,'|'));const _0x30c7c4=(..._0x4fdfe7)=>{const _0x53d833=_0x4fdfe7['pop']();try{const _0x160d19=_0x22739b(..._0x4fdfe7);_0x53d833(null,_0x160d19);}catch(_0x1d7a05){_0x53d833(_0x1d7a05);}};return _0x30c7c4['toString']=()=>_0x22739b['toString'](),_0x30c7c4;}module['exports']={'createRPC':createRPC,'toAsync':toAsync};
10
+ /* eslint-enable */
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+
3
+ const util = require('./distribution/util/util.js');
4
+ const log = require('./distribution/util/log.js');
5
+ const args = require('yargs').argv;
6
+
7
+ // Default configuration
8
+ global.nodeConfig = global.nodeConfig || {
9
+ ip: '127.0.0.1',
10
+ port: 1234,
11
+ onStart: () => {
12
+ console.log(`Node started!`);
13
+ },
14
+ };
15
+
16
+ /*
17
+ You can pass "ip" and "port" arguments directly.
18
+ Use this to startup nodes from the terminal.
19
+
20
+ Usage:
21
+ ./distribution.js --ip '127.0.0.1' --port 1234 # Start node on localhost:1234
22
+ */
23
+ if (args.ip) {
24
+ global.nodeConfig.ip = args.ip;
25
+ }
26
+
27
+ if (args.port) {
28
+ global.nodeConfig.port = parseInt(args.port);
29
+ }
30
+
31
+ if (args.config) {
32
+ let nodeConfig = util.deserialize(args.config);
33
+ global.nodeConfig.ip = nodeConfig.ip ? nodeConfig.ip : global.nodeConfig.ip;
34
+ global.nodeConfig.port = nodeConfig.port ?
35
+ nodeConfig.port : global.nodeConfig.port;
36
+ global.nodeConfig.onStart = nodeConfig.onStart ?
37
+ nodeConfig.onStart : global.nodeConfig.onStart;
38
+ }
39
+
40
+ const distribution = function(config) {
41
+ if (config) {
42
+ global.nodeConfig = config;
43
+ this.nodeConfig = config;
44
+ }
45
+
46
+ return global.distribution;
47
+ };
48
+
49
+ global.distribution = distribution;
50
+ distribution.util = require('./distribution/util/util.js');
51
+ distribution.local = require('./distribution/local/local.js');
52
+ distribution.node = require('./distribution/local/node.js');
53
+
54
+ distribution.util.groups = require('./distribution/all/groups.js');
55
+
56
+ for (let key in distribution.local) {
57
+ distribution.local.routes.put(distribution.local[key], key);
58
+ }
59
+
60
+ /* Initialize distribution object */
61
+ distribution['all'] = {};
62
+ distribution['all'].status =
63
+ require('./distribution/all/status')({gid: 'all'});
64
+ distribution['all'].comm =
65
+ require('./distribution/all/comm')({gid: 'all'});
66
+ distribution['all'].gossip =
67
+ require('./distribution/all/gossip')({gid: 'all'});
68
+ distribution['all'].groups =
69
+ require('./distribution/all/groups')({gid: 'all'});
70
+ distribution['all'].routes =
71
+ require('./distribution/all/routes')({gid: 'all'});
72
+ distribution['all'].mem =
73
+ require('./distribution/all/mem')({gid: 'all'});
74
+ distribution['all'].store =
75
+ require('./distribution/all/store')({gid: 'all'});
76
+
77
+ distribution.node.config = global.nodeConfig;
78
+ module.exports = global.distribution;
79
+
80
+ /* The following code is run when distribution.js is run directly */
81
+ if (require.main === module) {
82
+ log(`[node] Starting node with configuration: ${JSON.stringify(global.nodeConfig)}`);
83
+ distribution.node.start(global.nodeConfig.onStart);
84
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@brown-ds/distribution",
3
+ "version": "0.0.24",
4
+ "description": "A library for building distributed systems.",
5
+ "main": "distribution.js",
6
+ "useLibrary": false,
7
+ "directories": {
8
+ "test": "test"
9
+ },
10
+ "devDependencies": {
11
+ "eslint": "^8.55.0",
12
+ "eslint-config-google": "^0.14.0",
13
+ "javascript-obfuscator": "^4.1.0",
14
+ "jest": "^27.4.7"
15
+ },
16
+ "scripts": {
17
+ "test": "jest --maxWorkers 1",
18
+ "build": "./scripts/publish.sh",
19
+ "lint": "eslint --ignore-path .gitignore --config .eslintrc ."
20
+ },
21
+ "author": "",
22
+ "license": "ISC",
23
+ "dependencies": {
24
+ "yargs": "^17.7.2"
25
+ }
26
+ }