@brown-ds/distribution 0.0.45 → 0.0.47
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 +7 -22
- package/distribution/all/comm.js +1 -1
- package/distribution/all/mem.js +1 -1
- package/distribution/all/mr.js +1 -1
- package/distribution/local/comm.js +1 -1
- package/distribution/local/mem.js +1 -1
- package/distribution/local/node.js +1 -1
- package/distribution/local/routes.js +1 -1
- package/distribution/local/store.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,30 +17,15 @@ There are several categories of tests:
|
|
|
17
17
|
* Scenario Tests (`*.scenario.js`)
|
|
18
18
|
* Extra Credit Tests (`*.extra.test.js`)
|
|
19
19
|
|
|
20
|
-
By default, tests excluding those with non-distribution in their names are run. Use the options below to control the test suite:
|
|
21
|
-
|
|
22
20
|
### Running Tests
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
3. Run extra credit tests:
|
|
33
|
-
```sh
|
|
34
|
-
$ npm test -- -ec
|
|
35
|
-
```
|
|
36
|
-
4. Run the `non-distribution` tests:
|
|
37
|
-
```sh
|
|
38
|
-
$ npm test -- -n
|
|
39
|
-
```
|
|
40
|
-
5. Combine options:
|
|
41
|
-
```sh
|
|
42
|
-
$ npm test -- -c -ec -n
|
|
43
|
-
```
|
|
22
|
+
By default, all regular tests are run. Use the options below to run different sets of tests:
|
|
23
|
+
|
|
24
|
+
1. Run all regular tests (default): `$ npm test` or `$ npm test -- -t`
|
|
25
|
+
2. Run scenario tests: `$ npm test -- -c`
|
|
26
|
+
3. Run extra credit tests: `$ npm test -- -ec`
|
|
27
|
+
4. Run the `non-distribution` tests: `$ npm test -- -nd`
|
|
28
|
+
5. Combine options: `$ npm test -- -c -ec -nd -t`
|
|
44
29
|
|
|
45
30
|
## Usage
|
|
46
31
|
|
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(_0x5a736b){const _0x1f8e14={};_0x1f8e14['gid']=_0x5a736b['gid']||'global';function _0x428ebf(_0xac1e24,_0x170d5d,_0x3f9384){global['distributi'+'on']['local']['groups']['get'](_0x1f8e14['gid'],(_0x51053e,_0xd3f57c)=>{const _0x3d6eb0=Object['keys'](_0xd3f57c)['length'];if(_0x3d6eb0===-0xf6*0xc+-0x2476+0x2ffe){_0x3f9384(new Error('No\x20nodes\x20f'+'ound'));return;}let _0x11c100=0x1ff0+-0x201a+-0x7*-0x6;const _0x21b9eb={},_0x123cab={};for(const _0x2d8d17 of Object['keys'](_0xd3f57c)){const _0x197072=_0xd3f57c[_0x2d8d17],_0x3e3388={'node':{'ip':_0x197072['ip'],'port':_0x197072['port']},'service':_0x170d5d['service'],'method':_0x170d5d['method'],'group':_0x170d5d['group']||'local'};global['distributi'+'on']['local']['comm']['send'](_0xac1e24,_0x3e3388,(_0x2b4d5f,_0x47e3c1)=>{_0x2b4d5f?_0x123cab[_0x2d8d17]=_0x2b4d5f:_0x21b9eb[_0x2d8d17]=_0x47e3c1,_0x11c100+=0x1a6e+0x19f2+-0x1175*0x3,_0x11c100===_0x3d6eb0&&_0x3f9384(_0x123cab,_0x21b9eb);});}});}return{'send':_0x428ebf};};module['exports']=comm;
|
|
10
10
|
/* eslint-enable */
|
package/distribution/all/mem.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
|
-
const distribution=global['distributi'+'on'],util=distribution['util'],log=require('../util/lo'+'g');function getNode(
|
|
9
|
+
const distribution=global['distributi'+'on'],util=distribution['util'],log=require('../util/lo'+'g');function getNode(_0x3ba64f,_0x2c9ee5,_0x30b3a1){typeof _0x2c9ee5==='object'&&(_0x2c9ee5=_0x2c9ee5['key']),distribution[_0x3ba64f['gid']]['status']['get']('nid',(_0x1e2529,_0x33b0f8)=>{const _0x4cf427=Object['values'](_0x33b0f8),_0x10c42a=util['id']['getID'](_0x2c9ee5),_0x2075a7=_0x3ba64f['hash'](_0x10c42a,_0x4cf427),_0x224ecf=_0x2075a7['substring'](-0x2b*-0xe6+-0x2f*0xbb+-0x44d,0x26b5+-0x1*-0xf1+-0x27a1);distribution['local']['groups']['get'](_0x3ba64f['gid'],(_0x4313d3,_0x361168)=>{const _0x4de3ae=_0x361168[_0x224ecf];log('[mem\x20(getN'+'ode)]\x20conf'+'iguration:'+'\x20'+JSON['stringify'](_0x2c9ee5)+'group:\x20'+JSON['stringify'](_0x361168)+'\x20node:\x20'+JSON['stringify'](_0x4de3ae)+'nid:\x20'+JSON['stringify'](_0x2075a7)+'\x20sid:\x20'+JSON['stringify'](_0x224ecf)),_0x30b3a1(_0x4de3ae);});});}function normalize(_0x204615,_0x39f633){const _0x3580d0={};_0x204615===null&&(_0x204615={});if(typeof _0x204615==='string')_0x3580d0['key']=_0x204615,_0x3580d0['gid']=_0x39f633,_0x3580d0['action']='put';else typeof _0x204615==='object'&&(_0x3580d0['key']=_0x204615['key'],_0x3580d0['gid']=_0x204615['gid']||_0x39f633,_0x3580d0['action']=_0x204615['action']||'put');return _0x3580d0;};function mem(_0x4da3ff){const _0x42ed82={};return _0x42ed82['gid']=_0x4da3ff['gid']||'all',_0x42ed82['hash']=_0x4da3ff['hash']||util['id']['naiveHash'],{'get':(_0x256b00,_0x32d4f9)=>{if(!_0x256b00){const _0x1f6564=[{'key':null,'gid':_0x42ed82['gid']}];distribution[_0x42ed82['gid']]['comm']['send'](_0x1f6564,{'service':'mem','method':'get'},(_0x3e5078,_0x1eb776)=>{const _0x159334=Object['values'](_0x1eb776)['reduce']((_0x33062f,_0x2b3920)=>_0x33062f['concat'](_0x2b3920),[]);_0x32d4f9(_0x3e5078,_0x159334);});return;}_0x256b00=normalize(_0x256b00,_0x42ed82['gid']),getNode(_0x42ed82,_0x256b00,_0x237fa2=>{const _0x57f5f7=[_0x256b00],_0x1c44f6={'service':'mem','method':'get','node':_0x237fa2};log('[all.mem.g'+'et]\x20config'+'uration:\x20'+JSON['stringify'](_0x256b00)+'\x20node:\x20'+JSON['stringify'](global['nodeConfig'])+('\x20target\x20no'+'de:\x20')+JSON['stringify'](_0x237fa2)),distribution['local']['comm']['send'](_0x57f5f7,_0x1c44f6,_0x32d4f9);});},'put':(_0x113743,_0x328c86,_0x4b7004)=>{_0x328c86=_0x328c86||util['id']['getID'](_0x113743),_0x328c86=normalize(_0x328c86,_0x42ed82['gid']),getNode(_0x42ed82,_0x328c86,_0x4d9acd=>{const _0x18817a=[_0x113743,_0x328c86],_0x57ae35={'service':'mem','method':'put','node':_0x4d9acd};log('[all.mem.p'+'ut]\x20state:'+'\x20'+JSON['stringify'](_0x113743)+('configurat'+'ion:\x20')+JSON['stringify'](_0x328c86)+('target\x20nod'+'e:\x20')+JSON['stringify'](_0x4d9acd)),distribution['local']['comm']['send'](_0x18817a,_0x57ae35,_0x4b7004);});},'del':(_0xa12052,_0x2a7439)=>{getNode(_0x42ed82,_0xa12052,_0x22b652=>{const _0x327271=[{'key':_0xa12052,'gid':_0x42ed82['gid']}],_0x4838d8={'service':'mem','method':'del','node':_0x22b652};distribution['local']['comm']['send'](_0x327271,_0x4838d8,_0x2a7439);});},'reconf':(_0x25fd4d,_0x12bb17)=>{distribution[_0x42ed82['gid']]['mem']['get'](null,(_0xa873d3,_0x651583)=>{distribution[_0x42ed82['gid']]['status']['get']('nid',(_0x48643a,_0x8bd506)=>{const _0x3dc7fe=Object['values'](_0x8bd506),_0x163a21=Object['values'](_0x25fd4d)['map'](_0x5ea3e6=>util['id']['getNID'](_0x5ea3e6));log('[mem.recon'+'f\x20received'+'\x20'+_0x651583['length']+('\x20keys\x20from'+'\x20')+_0x8bd506['length']+'\x20nodes');let _0x4456b6=0x18d+-0x504+0x377;const _0x8db5eb=()=>{_0x4456b6===_0x651583['length']&&_0x12bb17();};if(_0x651583['length']===-0x2040+0x8b2+0x178e){_0x12bb17();return;}for(const _0x47fffc of _0x651583){const _0x17bfa9=util['id']['getID'](_0x47fffc),_0x101786=_0x42ed82['hash'](_0x17bfa9,_0x163a21),_0x3bc0bf=_0x42ed82['hash'](_0x17bfa9,_0x3dc7fe);log('[mem.recon'+'f]\x20old\x20nid'+':\x20'+_0x101786+'\x20new\x20nid:\x20'+_0x3bc0bf);if(_0x101786===_0x3bc0bf){_0x4456b6++,_0x8db5eb();continue;}const _0x44c3f4=_0x25fd4d[_0x101786['substring'](-0xac1+-0x7e9+0x12aa,0xee8*-0x1+0x14ee+-0x601)],_0x1b69f5=[{'key':_0x47fffc,'gid':_0x42ed82['gid']}],_0xc01f25={'service':'mem','method':'del','node':_0x44c3f4};log('[mem.recon'+'f]\x20deletin'+'g\x20key\x20'+_0x47fffc+'\x20from\x20'+JSON['stringify'](_0xc01f25)),distribution['local']['comm']['send'](_0x1b69f5,_0xc01f25,(_0x2d47fd,_0x5af87d)=>{distribution[_0x42ed82['gid']]['mem']['put'](_0x5af87d,_0x47fffc,(_0x1e9731,_0xba6e06)=>{_0x4456b6++,_0x8db5eb();});});}});});}};};module['exports']=mem;
|
|
10
10
|
/* eslint-enable */
|
package/distribution/all/mr.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
|
-
const distribution=require('../../dist'+'ribution'),id=distribution['util']['id'];function mr(
|
|
9
|
+
const distribution=require('../../dist'+'ribution'),id=distribution['util']['id'];function mr(_0xec35b){const _0x19e1d6={'gid':_0xec35b['gid']||'global'};function _0x3ef6e4(_0x11964b,_0xd1d4ed){const _0x5aef47=id['getSID'](_0x11964b),_0x11c35d={'mapper':_0x11964b['map'],'reducer':_0x11964b['reduce'],'map':function(_0x365602,_0x38c1d1,_0x34231d,_0x1bec09){if(_0x365602['length']==-0xa59*-0x3+0xbad*0x3+-0x4212)_0x1bec09(null,{});else{const _0x536d19=[];let _0x11e731=-0x989+-0x102*0x1f+0x28c7;_0x365602['forEach'](_0x1b59fc=>{distribution[_0x38c1d1]['store']['get'](_0x1b59fc,(_0x401c24,_0x352aaa)=>{_0x11e731++;const _0xa6772e=this['mapper'](_0x1b59fc,_0x352aaa);Array['isArray'](_0xa6772e)?_0x536d19['push'](..._0xa6772e):_0x536d19['push'](_0xa6772e),_0x11e731==_0x365602['length']&&distribution['local']['store']['put'](_0x536d19,_0x34231d+'_map',(_0x19471e,_0x12dd47)=>{_0x1bec09(_0x19471e,_0x536d19);});});});}},'shuffle':function(_0x58cc9b,_0x5cb604,_0x19a6d3){distribution['local']['store']['get'](_0x5cb604+'_map',(_0x4b4df1,_0x2d5d19)=>{if(!_0x4b4df1){let _0x4a63d9=0xe7f+0x43+-0xec2;_0x2d5d19['forEach'](_0x9c8ab3=>{const [_0x266b04]=Object['keys'](_0x9c8ab3);distribution[_0x58cc9b]['mem']['put'](_0x9c8ab3[_0x266b04],{'key':_0x266b04,'action':'append'},(_0x1e9e4b,_0x5c6918)=>{_0x4a63d9++,_0x4a63d9==_0x2d5d19['length']&&_0x19a6d3(null,_0x2d5d19);});});}else _0x19a6d3(_0x4b4df1,{});});},'reduce':function(_0x24052a,_0x3e4b4a,_0x2a0942){distribution['local']['mem']['get']({'key':null,'gid':_0x24052a},(_0x3d524c,_0x5675e9)=>{let _0x44907a=[],_0x5a5867=-0x1aa6+-0x22d8+0x1*0x3d7e;_0x5675e9['length']==0x243c+0x6*-0x3af+-0xe22&&_0x2a0942(null,null),_0x5675e9['forEach'](_0x2b7979=>distribution['local']['mem']['get']({'key':_0x2b7979,'gid':_0x24052a},(_0x5c5fb9,_0x3c0e8c)=>{const _0x2391e0=this['reducer'](_0x2b7979,_0x3c0e8c);_0x44907a=_0x44907a['concat'](_0x2391e0),_0x5a5867++,_0x5a5867==_0x5675e9['length']&&_0x2a0942(null,_0x44907a);}));});}},_0x3e724c=function(_0x46cbac,_0x31ae55){const _0x1b4e2e={};return Object['keys'](_0x31ae55)['forEach'](_0x3f03f9=>{_0x1b4e2e[_0x3f03f9]=[];}),_0x46cbac['forEach'](_0x11c1dc=>{const _0x487702=id['getID'](_0x11c1dc),_0x11a4e3=id['naiveHash'](_0x487702,Object['keys'](_0x31ae55));_0x1b4e2e[_0x11a4e3]['push'](_0x11c1dc);}),_0x1b4e2e;};distribution[_0x19e1d6['gid']]['routes']['put'](_0x11c35d,'mr-'+_0x5aef47,(_0x41bff3,_0x53d96f)=>{distribution['local']['groups']['get'](_0x19e1d6['gid'],(_0x3620bf,_0x672f74)=>{const _0x56ea04=_0x3e724c(_0x11964b['keys'],_0x672f74);let _0xe09642=0xc4*-0x20+0xc63*-0x1+-0x85*-0x47;const _0x3ce435=Object['keys'](_0x672f74)['length'],_0x5059ac={'service':'mr-'+_0x5aef47,'method':'map'};for(const _0x470607 in _0x672f74){_0x5059ac['node']=_0x672f74[_0x470607];const _0x802d07=[_0x56ea04[_0x470607],_0x19e1d6['gid'],_0x5aef47];distribution['local']['comm']['send'](_0x802d07,_0x5059ac,(_0x2576cb,_0x2c21d6)=>{++_0xe09642;if(_0xe09642==_0x3ce435){const _0x3a28f2={'service':'mr-'+_0x5aef47,'method':'shuffle'};distribution[_0x19e1d6['gid']]['comm']['send']([_0x19e1d6['gid'],_0x5aef47],_0x3a28f2,(_0x2ec81f,_0x52ccdb)=>{const _0x19aa91={'service':'mr-'+_0x5aef47,'method':'reduce'};distribution[_0x19e1d6['gid']]['comm']['send']([_0x19e1d6['gid'],_0x5aef47],_0x19aa91,(_0x476341,_0x221f74)=>{let _0x58c8fd=[];for(const _0x30cf48 of Object['values'](_0x221f74)){_0x30cf48!==null&&(_0x58c8fd=_0x58c8fd['concat'](_0x30cf48));}_0xd1d4ed(null,_0x58c8fd);return;distribution[_0x19e1d6['gid']]['routes']['rem']('mr-'+_0x5aef47,(_0x433e5b,_0x542a20)=>{});});});}});}});});}return{'exec':_0x3ef6e4};};module['exports']=mr;
|
|
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
|
-
const http=require('http'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g');function send(
|
|
9
|
+
const http=require('http'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g');function send(_0x5a65c8,_0x48c395,_0x7b40bc){log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0x5a65c8)+'to\x20'+_0x48c395['service']+':'+_0x48c395['method']+'\x20on\x20'+_0x48c395['node']['ip']+':'+_0x48c395['node']['port']);if(!_0x5a65c8 instanceof Array)throw new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray');const _0xdd5700=_0x48c395['node'],_0x20bf2d=_0x48c395['service'],_0x687a05=_0x48c395['method'],_0x15198f=_0x48c395['group']||'local',_0x4c5014=serialization['serialize'](_0x5a65c8),_0x4c224b={'hostname':_0xdd5700['ip'],'port':_0xdd5700['port'],'path':'/'+_0x15198f+'/'+_0x20bf2d+'/'+_0x687a05,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x4c5014)}},_0x5de4a2=http['request'](_0x4c224b,_0x37333c=>{let _0x1e921c='';_0x37333c['on']('data',function(_0x561dd4){_0x1e921c+=_0x561dd4;}),_0x37333c['on']('end',function(){_0x7b40bc&&_0x7b40bc(...serialization['deserializ'+'e'](_0x1e921c));}),_0x37333c['on']('error',function(_0x43b47a){_0x7b40bc&&_0x7b40bc(new Error('Error\x20on\x20r'+'esponse'));});});_0x5de4a2['on']('error',function(_0x2264f4){_0x7b40bc&&_0x7b40bc(new Error(_0x2264f4));}),_0x5de4a2['write'](_0x4c5014),_0x5de4a2['end']();}module['exports']={'send':send};
|
|
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
|
-
const id=require('../util/id'),log=require('../util/lo'+'g'),kvStore={'store':new Map(),'get'(
|
|
9
|
+
const id=require('../util/id'),log=require('../util/lo'+'g'),kvStore={'store':new Map(),'get'(_0x26585a){if(!this['store'][_0x26585a['gid']])return undefined;return this['store'][_0x26585a['gid']][_0x26585a['key']];},'put'(_0xe29537,_0x43c1f7){!this['store'][_0xe29537['gid']]&&(this['store'][_0xe29537['gid']]=new Map()),this['store'][_0xe29537['gid']][_0xe29537['key']]=_0x43c1f7;},'append'(_0x16d74a,_0x18f333){!this['get'](_0x16d74a)&&this['put'](_0x16d74a,[]),!Array['isArray'](this['get'](_0x16d74a))&&this['put'](_0x16d74a,[this['get'](_0x16d74a)]),Array['isArray'](_0x18f333)?this['put'](_0x16d74a,this['get'](_0x16d74a)['concat'](_0x18f333)):this['store'][_0x16d74a['gid']][_0x16d74a['key']]['push'](_0x18f333);},'del'(_0x588206){if(!this['store'][_0x588206['gid']])return undefined;const _0x1c68b0=this['store'][_0x588206['gid']][_0x588206['key']];return delete this['store'][_0x588206['gid']][_0x588206['key']],_0x1c68b0;},'toString'(){let _0x5b2567='';for(const _0x2347a3 in this['store']){_0x5b2567+=_0x2347a3+':\x20'+JSON['stringify'](this['store'][_0x2347a3]);}return _0x5b2567;}};function normalize(_0x60e5f6){const _0x1ac61a={};_0x60e5f6===null&&(_0x60e5f6={});if(typeof _0x60e5f6==='string')_0x1ac61a['key']=_0x60e5f6,_0x1ac61a['gid']='local',_0x1ac61a['action']='put';else typeof _0x60e5f6==='object'&&(_0x1ac61a['key']=_0x60e5f6['key'],_0x1ac61a['gid']=_0x60e5f6['gid'],_0x1ac61a['action']=_0x60e5f6['action']);return _0x1ac61a;};function put(_0x40b1c3,_0x400283,_0x3d8828){log('[mem.put]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x400283)+'state:\x20'+JSON['stringify'](_0x40b1c3)+'\x20store:\x20'+kvStore['toString']()),_0x3d8828=_0x3d8828||function(){},_0x400283=normalize(_0x400283),_0x400283['key']=_0x400283['key']||id['getID'](_0x40b1c3),_0x400283['gid']=_0x400283['gid']||'local',_0x400283['action']=_0x400283['action']||'put',kvStore[_0x400283['action']](_0x400283,_0x40b1c3),log('[mem.put]\x20'+'store\x20(aft'+'er):\x20'+kvStore['toString']()),_0x3d8828&&_0x3d8828(null,_0x40b1c3);};function get(_0x10d1ff,_0x201974){log('[mem.get]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x10d1ff)+'\x20store:\x20'+kvStore['toString']()),_0x201974=_0x201974||function(){},_0x10d1ff=normalize(_0x10d1ff),_0x10d1ff['gid']=_0x10d1ff['gid']||'local';if(!_0x10d1ff['key']){let _0x4e192e=kvStore['store'][_0x10d1ff['gid']]||{};_0x4e192e=Object['keys'](_0x4e192e),_0x201974(null,_0x4e192e);return;}const _0x360c2e=kvStore['get'](_0x10d1ff);_0x360c2e?_0x201974(null,_0x360c2e):_0x201974(new Error('Memory\x20key'+'\x20\x22'+_0x10d1ff['key']+('\x22\x20\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20not\x20found'+'\x20for\x20')+_0x10d1ff['gid']+'\x27s\x20store'));}function del(_0x53b5c6,_0x214f32){log('[mem.del]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x53b5c6)+'\x20store:\x20'+kvStore['toString']()),_0x214f32=_0x214f32||function(){},_0x53b5c6=normalize(_0x53b5c6);const _0x27a824=kvStore['del'](_0x53b5c6);log('[mem.del]\x20'+'store\x20(aft'+'er):\x20'+kvStore['toString']()),_0x27a824?_0x214f32(null,_0x27a824):_0x214f32(new Error('Memory\x20key'+'\x20\x22'+_0x53b5c6['key']+('\x22\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'not\x20found\x20'+'for\x20')+_0x53b5c6['gid']+'\x27s\x20store'));};module['exports']={'put':put,'get':get,'del':del};
|
|
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
|
-
const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(
|
|
9
|
+
const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x1d8398){if(_0x1d8398['length']===0x3*-0x761+0x110+0x1*0x1513)return new Error('No\x20body');try{_0x1d8398=JSON['parse'](_0x1d8398);}catch(_0x2d3083){return _0x2d3083;}return undefined;}function endRequest(_0x11432d,_0x438dcc){_0x11432d['end'](serialization['serialize']([_0x438dcc]));}const start=function(_0x27f278){const _0x15ef75=http['createServ'+'er']((_0x5bde2a,_0x31a145)=>{if(_0x5bde2a['method']!=='PUT'){_0x31a145['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x56cb53=url['parse'](_0x5bde2a['url'])['pathname'],[,_0x4338f4,_0x4f6aef,_0x118ae6]=_0x56cb53['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x4338f4+'\x20'+_0x4f6aef+':'+_0x118ae6+'\x20from\x20'+_0x5bde2a['connection']['remoteAddr'+'ess']);let _0x26d95e=[];_0x5bde2a['on']('data',_0x7aa3ca=>{_0x26d95e['push'](_0x7aa3ca);}),_0x5bde2a['on']('end',()=>{_0x26d95e=Buffer['concat'](_0x26d95e)['toString']();let _0x207b74;if(_0x207b74=isValidBody(_0x26d95e)){endRequest(_0x31a145,_0x207b74);return;}_0x26d95e=JSON['parse'](_0x26d95e),_0x26d95e=serialization['deserializ'+'e'](_0x26d95e);const _0x315c69=_0x26d95e;!Array['isArray'](_0x315c69)&&endRequest(_0x31a145,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x315c69));const _0x2b0671=_0x4f6aef;global['distributi'+'on']['local']['routes']['get']({'serviceName':_0x2b0671,'gid':_0x4338f4},(_0x3988f3,_0x11edad)=>{const _0x7d459d=(_0x12eaa5,_0x31d838)=>{_0x31a145['end'](serialization['serialize']([_0x12eaa5,_0x31d838]));};if(_0x3988f3){_0x7d459d(_0x3988f3);return;}if(!_0x11edad[_0x118ae6]){_0x7d459d(new Error('Method\x20'+_0x118ae6+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x2b0671));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x2b0671+':'+_0x118ae6+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x315c69));_0x315c69['length']===-0x1037*0x1+0xa06*-0x3+0x942*0x5&&_0x11edad[_0x118ae6]['length']===0x1a3c+0x17*-0x13+0xc42*-0x2&&_0x315c69['push'](undefined);try{_0x11edad[_0x118ae6](..._0x315c69,_0x7d459d);}catch(_0x2b7917){_0x7d459d(_0x2b7917);}});});});_0x15ef75['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']=_0x15ef75,_0x27f278(_0x15ef75);}),_0x15ef75['on']('error',_0x21a19b=>{log('Server\x20err'+'or:\x20'+_0x21a19b);throw _0x21a19b;});};module['exports']={'start':start};
|
|
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
|
-
const log=require('../util/lo'+'g'),routesStore=new Map();function get(
|
|
9
|
+
const log=require('../util/lo'+'g'),routesStore=new Map();function get(_0xe9d645,_0x566453){log('[routes.ge'+'t]\x20Getting'+'\x20service:\x20'+JSON['stringify'](_0xe9d645));if(!_0x566453)return;typeof _0xe9d645==='string'&&(_0xe9d645={'serviceName':_0xe9d645});const _0x21a725=_0xe9d645['serviceNam'+'e'],_0x13c2a0=_0xe9d645['gid'];if(_0x13c2a0&&_0x13c2a0!=='local'){log('[routes.ge'+'t]\x20Found\x20d'+'istributed'+'\x20service:\x20'+_0x21a725);const _0x5d8a76=global['distributi'+'on'][_0x13c2a0][_0x21a725];_0x566453(null,_0x5d8a76);}else{if(_0x21a725 in routesStore){const _0x288455=routesStore[_0x21a725];log('[routes.ge'+'t]\x20Found\x20l'+'ocal\x20servi'+'ce:\x20'+_0x21a725),_0x566453(null,_0x288455);}else{const _0x5daf3e=global['toLocal']['get'](_0x21a725);_0x5daf3e?(log('[routes.ge'+'t]\x20Found\x20R'+'PC:\x20'+_0x21a725),_0x566453(null,{'call':_0x5daf3e})):_0x566453(new Error('Service\x20'+_0x21a725+('\x20not\x20found'+'\x20in\x20routes')));}}}function put(_0x571665,_0x4f08c8,_0x3c95de){log('[routes.pu'+'t]\x20Putting'+'\x20service:\x20'+_0x4f08c8+'\x20'+JSON['stringify'](_0x571665)),routesStore[_0x4f08c8]=_0x571665;_0x3c95de&&_0x3c95de(null,_0x4f08c8);;}function rem(_0x4bdabf,_0x1c74fd){const _0x1ccdcc=routesStore[_0x4bdabf];delete routesStore[_0x4bdabf],_0x1c74fd(null,_0x1ccdcc);};module['exports']={'get':get,'put':put,'rem':rem};
|
|
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
|
-
const fs=require('fs'),path=require('path'),id=require('../util/id'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g'),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(
|
|
9
|
+
const fs=require('fs'),path=require('path'),id=require('../util/id'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g'),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(_0x118f7e){const _0x3fd6db={};_0x118f7e===null&&(_0x118f7e={});if(typeof _0x118f7e==='string')_0x3fd6db['key']=_0x118f7e,_0x3fd6db['gid']='local';else typeof _0x118f7e==='object'&&(_0x3fd6db['key']=_0x118f7e['key'],_0x3fd6db['gid']=_0x118f7e['gid']);return _0x3fd6db;};function put(_0x36bd7c,_0x219bb1,_0x4cfea1){_0x4cfea1=_0x4cfea1||function(){},_0x219bb1=normalize(_0x219bb1),_0x219bb1['key']=_0x219bb1['key']||id['getID'](_0x36bd7c),_0x219bb1['gid']=_0x219bb1['gid']||'local';const _0x40a15f=serialization['serialize'](_0x36bd7c);let _0xb22032=Buffer['from'](_0x219bb1['key'])['toString']('base64');_0xb22032=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x219bb1['gid']+'-'+_0xb22032,log('[store.put'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x219bb1)+'\x20state:\x20'+JSON['stringify'](_0x36bd7c)+('\x20filename:'+'\x20')+_0xb22032),fs['writeFile'](_0xb22032,_0x40a15f,_0x3bcd97=>{_0x3bcd97?_0x4cfea1(_0x3bcd97):_0x4cfea1(null,_0x36bd7c);});}function get(_0x13325a,_0x1dabf5){_0x1dabf5=_0x1dabf5||function(){},_0x13325a=normalize(_0x13325a),_0x13325a['gid']=_0x13325a['gid']||'local';if(!_0x13325a['key']){fs['readdir'](baseFolder+'/s-'+global['moreStatus']['sid'],(_0x25bc24,_0x146254)=>{if(_0x25bc24)_0x1dabf5(_0x25bc24);else{const _0x5bb71e=[];for(let _0x2a63fe=0x351+0x112c+-0x147d;_0x2a63fe<_0x146254['length'];_0x2a63fe++){let _0x4dfc03=_0x146254[_0x2a63fe]['split']('-');const _0x286ecc=_0x4dfc03[0x1*-0x18f4+-0xf55+0x2849];if(_0x286ecc!==_0x13325a['gid'])continue;_0x4dfc03=_0x4dfc03[_0x4dfc03['length']-(0x76b*0x3+-0x8*-0x371+-0x31c8)],_0x5bb71e['push'](Buffer['from'](_0x4dfc03,'base64')['toString']());}_0x1dabf5(null,_0x5bb71e);}});return;}let _0x3fc3f0=Buffer['from'](_0x13325a['key'])['toString']('base64');_0x3fc3f0=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x13325a['gid']+'-'+_0x3fc3f0,log('[store.get'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x13325a)+('\x20filename:'+'\x20')+_0x3fc3f0),fs['readFile'](_0x3fc3f0,(_0xf9236e,_0x53a4f4)=>{_0xf9236e?_0xf9236e['code']==='ENOENT'?_0x1dabf5(new Error('File\x20'+_0x3fc3f0+('\x20(from\x20key'+'\x20\x27')+_0x13325a['key']+('\x27)\x20not\x20fou'+'nd\x20for\x20gro'+'up\x20')+_0x13325a['gid'])):_0x1dabf5(_0xf9236e):_0x1dabf5(null,serialization['deserializ'+'e'](_0x53a4f4['toString']()));});}function del(_0x337936,_0x19b174){_0x19b174=_0x19b174||function(){},_0x337936=normalize(_0x337936);let _0x8e6929=Buffer['from'](_0x337936['key'])['toString']('base64');_0x8e6929=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x337936['gid']+'-'+_0x8e6929,get(_0x337936,(_0x5986f4,_0x4aa473)=>{if(_0x5986f4){_0x19b174(_0x5986f4);return;}fs['rm'](_0x8e6929,_0x543c5a=>{_0x543c5a?_0x19b174(_0x543c5a):_0x19b174(null,_0x4aa473);});});}module['exports']={'put':put,'get':get,'del':del};
|
|
10
10
|
/* eslint-enable */
|