@brown-ds/distribution 0.0.47 → 0.1.0
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/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(_0x3ff307){const _0x27d376={};_0x27d376['gid']=_0x3ff307['gid']||'global';function _0x3a6af3(_0x2830e3,_0x55cfbd,_0xeaadfb){global['distributi'+'on']['local']['groups']['get'](_0x27d376['gid'],(_0x1ac991,_0x38d838)=>{const _0x372909=Object['keys'](_0x38d838)['length'];if(_0x372909===0x8f5*-0x2+0x1d5f+-0xb75){_0xeaadfb(new Error('No\x20nodes\x20f'+'ound'));return;}let _0xdc7351=0x29c*-0x7+-0x1082+0x22c6;const _0x1b694e={},_0x57635d={};for(const _0x395b8c of Object['keys'](_0x38d838)){const _0x931efa=_0x38d838[_0x395b8c],_0x1502ce={'node':{'ip':_0x931efa['ip'],'port':_0x931efa['port']},'service':_0x55cfbd['service'],'method':_0x55cfbd['method'],'gid':_0x55cfbd['gid']||'local'};global['distributi'+'on']['local']['comm']['send'](_0x2830e3,_0x1502ce,(_0x5e82ce,_0x24e7c4)=>{_0x5e82ce?_0x57635d[_0x395b8c]=_0x5e82ce:_0x1b694e[_0x395b8c]=_0x24e7c4,_0xdc7351+=0x1*-0xf63+0x61*-0x19+-0x43*-0x5f,_0xdc7351===_0x372909&&_0xeaadfb(_0x57635d,_0x1b694e);});}});}return{'send':_0x3a6af3};};module['exports']=comm;
|
|
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(_0x25fd4b){const _0x2e9d09={'gid':_0x25fd4b['gid']||'global'};function _0x2b94c5(_0x41aa83,_0x5882c1){const _0x3d7958=id['getSID'](_0x41aa83),_0x2c98d8={'mapper':_0x41aa83['map'],'reducer':_0x41aa83['reduce'],'map':function(_0x13da64,_0x96326c,_0x52508f,_0x4c64e4){if(_0x13da64['length']==-0x1f2b*0x1+-0x17de+0x3709)_0x4c64e4(null,{});else{const _0xadd485=[];let _0x2de1e9=0x1063*0x1+-0xad1*-0x1+-0x1b34;_0x13da64['forEach'](_0x47427a=>{distribution[_0x96326c]['store']['get'](_0x47427a,(_0x1643c8,_0x179075)=>{_0x2de1e9++;const _0x746072=this['mapper'](_0x47427a,_0x179075);Array['isArray'](_0x746072)?_0xadd485['push'](..._0x746072):_0xadd485['push'](_0x746072),_0x2de1e9==_0x13da64['length']&&distribution['local']['store']['put'](_0xadd485,_0x52508f+'_map',(_0x505369,_0x427025)=>{_0x4c64e4(_0x505369,_0xadd485);});});});}},'shuffle':function(_0x485683,_0x52a07d,_0x18715d){distribution['local']['store']['get'](_0x52a07d+'_map',(_0x379ccc,_0x4e5c28)=>{if(!_0x379ccc){let _0x59dc81=-0x23a2+0x1309+0x1099;_0x4e5c28['forEach'](_0x7e8d6b=>{const [_0x9e7f61]=Object['keys'](_0x7e8d6b);distribution[_0x485683]['mem']['put'](_0x7e8d6b[_0x9e7f61],{'key':_0x9e7f61,'action':'append'},(_0xee1926,_0x1eb4ff)=>{_0x59dc81++,_0x59dc81==_0x4e5c28['length']&&_0x18715d(null,_0x4e5c28);});});}else _0x18715d(_0x379ccc,{});});},'reduce':function(_0x3d4f5e,_0xd8c090,_0x31e966){distribution['local']['mem']['get']({'key':null,'gid':_0x3d4f5e},(_0x1f9175,_0x27a433)=>{let _0x4c4c0d=[],_0x560707=0x16f1+0x2331+-0x3a22;_0x27a433['length']==0x5*0x48f+-0x25ca+0x1*0xeff&&_0x31e966(null,null),_0x27a433['forEach'](_0x5c8bf2=>distribution['local']['mem']['get']({'key':_0x5c8bf2,'gid':_0x3d4f5e},(_0x450cc5,_0x46b259)=>{const _0x56c1db=this['reducer'](_0x5c8bf2,_0x46b259);_0x4c4c0d=_0x4c4c0d['concat'](_0x56c1db),_0x560707++,_0x560707==_0x27a433['length']&&_0x31e966(null,_0x4c4c0d);}));});}},_0x474ad0=function(_0x437781,_0x3ee4c8){const _0x51ef25={};return Object['keys'](_0x3ee4c8)['forEach'](_0x30d20e=>{_0x51ef25[_0x30d20e]=[];}),_0x437781['forEach'](_0x110627=>{const _0x570353=id['getID'](_0x110627),_0x36c0ec=id['naiveHash'](_0x570353,Object['keys'](_0x3ee4c8));_0x51ef25[_0x36c0ec]['push'](_0x110627);}),_0x51ef25;};distribution[_0x2e9d09['gid']]['routes']['put'](_0x2c98d8,'mr-'+_0x3d7958,(_0x574c15,_0xd4f7c5)=>{distribution['local']['groups']['get'](_0x2e9d09['gid'],(_0x26ea36,_0x18dfa7)=>{const _0x299848=_0x474ad0(_0x41aa83['keys'],_0x18dfa7);let _0x1148e8=0xf81+-0x2*0x74b+-0xeb;const _0x5b36e9=Object['keys'](_0x18dfa7)['length'],_0x237707={'service':'mr-'+_0x3d7958,'method':'map'};for(const _0xf35548 in _0x18dfa7){_0x237707['node']=_0x18dfa7[_0xf35548];const _0x22d5bf=[_0x299848[_0xf35548],_0x2e9d09['gid'],_0x3d7958];distribution['local']['comm']['send'](_0x22d5bf,_0x237707,(_0xb90796,_0xad07e0)=>{++_0x1148e8;if(_0x1148e8==_0x5b36e9){const _0x385a0e={'service':'mr-'+_0x3d7958,'method':'shuffle'};distribution[_0x2e9d09['gid']]['comm']['send']([_0x2e9d09['gid'],_0x3d7958],_0x385a0e,(_0x30d7e9,_0x1e99fd)=>{const _0x2936fa={'service':'mr-'+_0x3d7958,'method':'reduce'};distribution[_0x2e9d09['gid']]['comm']['send']([_0x2e9d09['gid'],_0x3d7958],_0x2936fa,(_0x268e02,_0x183165)=>{let _0x219824=[];for(const _0x2fbb50 of Object['values'](_0x183165)){_0x2fbb50!==null&&(_0x219824=_0x219824['concat'](_0x2fbb50));}_0x5882c1(null,_0x219824);return;distribution[_0x2e9d09['gid']]['routes']['rem']('mr-'+_0x3d7958,(_0x32a27f,_0x35cda5)=>{});});});}});}});});}return{'exec':_0x2b94c5};};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(_0x300bcb,_0x3023ca,_0x34e3b3){log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0x300bcb)+'to\x20'+_0x3023ca['service']+':'+_0x3023ca['method']+'\x20on\x20'+_0x3023ca['node']['ip']+':'+_0x3023ca['node']['port']);if(!_0x300bcb instanceof Array)throw new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray');const _0x35595c=_0x3023ca['node'],_0x184741=_0x3023ca['service'],_0x4a4e97=_0x3023ca['method'],_0x4e0578=_0x3023ca['gid']||'local',_0x5cfefb=serialization['serialize'](_0x300bcb),_0x20ba86={'hostname':_0x35595c['ip'],'port':_0x35595c['port'],'path':'/'+_0x4e0578+'/'+_0x184741+'/'+_0x4a4e97,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x5cfefb)}},_0x4aedd9=http['request'](_0x20ba86,_0x42eaf5=>{let _0x367027='';_0x42eaf5['on']('data',function(_0x5ca18f){_0x367027+=_0x5ca18f;}),_0x42eaf5['on']('end',function(){_0x34e3b3&&_0x34e3b3(...serialization['deserializ'+'e'](_0x367027));}),_0x42eaf5['on']('error',function(_0x190227){_0x34e3b3&&_0x34e3b3(new Error('Error\x20on\x20r'+'esponse'));});});_0x4aedd9['on']('error',function(_0x33f3a1){_0x34e3b3&&_0x34e3b3(new Error(_0x33f3a1));}),_0x4aedd9['write'](_0x5cfefb),_0x4aedd9['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 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(_0x377981){if(_0x377981['length']===-0x1814+-0x1cf9*0x1+0x350d)return new Error('No\x20body');try{_0x377981=JSON['parse'](_0x377981);}catch(_0x185f27){return _0x185f27;}return undefined;}function endRequest(_0x540e16,_0x3d1ccb){_0x540e16['end'](serialization['serialize']([_0x3d1ccb]));}const start=function(_0x966886){const _0x3a6518=http['createServ'+'er']((_0x81d7f9,_0x24b09d)=>{if(_0x81d7f9['method']!=='PUT'){_0x24b09d['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x25b575=url['parse'](_0x81d7f9['url'])['pathname'],[,_0x10d46f,_0x549703,_0x7b93c4]=_0x25b575['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x10d46f+'\x20'+_0x549703+':'+_0x7b93c4+'\x20from\x20'+_0x81d7f9['connection']['remoteAddr'+'ess']);let _0x5b05d9=[];_0x81d7f9['on']('data',_0x259bfc=>{_0x5b05d9['push'](_0x259bfc);}),_0x81d7f9['on']('end',()=>{_0x5b05d9=Buffer['concat'](_0x5b05d9)['toString']();let _0x3c4071;if(_0x3c4071=isValidBody(_0x5b05d9)){endRequest(_0x24b09d,_0x3c4071);return;}_0x5b05d9=JSON['parse'](_0x5b05d9),_0x5b05d9=serialization['deserializ'+'e'](_0x5b05d9);const _0xeab15c=_0x5b05d9;!Array['isArray'](_0xeab15c)&&endRequest(_0x24b09d,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0xeab15c));const _0x336473=_0x549703;global['distributi'+'on']['local']['routes']['get']({'service':_0x549703,'gid':_0x10d46f},(_0x53dc03,_0x1c3871)=>{const _0x9e7383=(_0x365a8e,_0x1d3e09)=>{_0x24b09d['end'](serialization['serialize']([_0x365a8e,_0x1d3e09]));};if(_0x53dc03){_0x9e7383(_0x53dc03);return;}if(!_0x1c3871[_0x7b93c4]){_0x9e7383(new Error('Method\x20'+_0x7b93c4+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x336473));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x336473+':'+_0x7b93c4+('\x20with\x20args'+':\x20')+JSON['stringify'](_0xeab15c));_0xeab15c['length']===-0x1ecd+-0x33*0x95+0x3c7d&&_0x1c3871[_0x7b93c4]['length']===0x43f*0x1+-0x9*0x24+-0x28*0x13&&_0xeab15c['push'](undefined);try{_0x1c3871[_0x7b93c4](..._0xeab15c,_0x9e7383);}catch(_0xebf001){_0x9e7383(_0xebf001);}});});});_0x3a6518['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']=_0x3a6518,_0x966886(_0x3a6518);}),_0x3a6518['on']('error',_0x51f1ef=>{log('Server\x20err'+'or:\x20'+_0x51f1ef);throw _0x51f1ef;});};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(_0xd7907f,_0xed0098){log('[routes.ge'+'t]\x20Getting'+'\x20service:\x20'+JSON['stringify'](_0xd7907f));if(!_0xed0098)return;typeof _0xd7907f==='string'&&(_0xd7907f={'service':_0xd7907f});const _0x3ba868=_0xd7907f['service'],_0x5195df=_0xd7907f['gid'];if(_0x5195df&&_0x5195df!=='local')log('[routes.ge'+'t]\x20Found\x20d'+'istributed'+'\x20service:\x20'+_0x3ba868),_0xed0098(null,global['distributi'+'on'][_0x5195df][_0x3ba868]);else{if(_0x3ba868 in routesStore)log('[routes.ge'+'t]\x20Found\x20l'+'ocal\x20servi'+'ce:\x20'+_0x3ba868),_0xed0098(null,routesStore[_0x3ba868]);else{const _0x32adc9=global['toLocal']['get'](_0x3ba868);_0x32adc9?(log('[routes.ge'+'t]\x20Found\x20R'+'PC:\x20'+_0x3ba868),_0xed0098(null,{'call':_0x32adc9})):_0xed0098(new Error('Service\x20'+_0x3ba868+('\x20not\x20found'+'\x20in\x20routes')));}}}function put(_0x1f51cd,_0x4a907d,_0x41a465){log('[routes.pu'+'t]\x20Putting'+'\x20service:\x20'+_0x4a907d+'\x20'+JSON['stringify'](_0x1f51cd)),routesStore[_0x4a907d]=_0x1f51cd;_0x41a465&&_0x41a465(null,_0x4a907d);;}function rem(_0x451b3f,_0x3f58ab){const _0x5b8abb=routesStore[_0x451b3f];delete routesStore[_0x451b3f],_0x3f58ab(null,_0x5b8abb);};module['exports']={'get':get,'put':put,'rem':rem};
|
|
10
10
|
/* eslint-enable */
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brown-ds/distribution",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A library for building distributed systems.",
|
|
5
5
|
"main": "distribution.js",
|
|
6
|
-
"useLibrary":
|
|
6
|
+
"useLibrary": true,
|
|
7
7
|
"directories": {
|
|
8
8
|
"test": "test"
|
|
9
9
|
},
|