@brown-ds/distribution 0.1.11 → 0.1.12
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/gossip.js +1 -1
- package/distribution/all/mem.js +1 -1
- package/distribution/all/mr.js +1 -1
- package/distribution/all/status.js +1 -1
- package/distribution/all/store.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/status.js +1 -1
- package/distribution/local/store.js +1 -1
- package/distribution/util/id.js +1 -1
- package/distribution/util/log.js +1 -1
- package/distribution/util/wire.js +1 -1
- package/distribution.js +6 -2
- package/package.json +1 -1
|
@@ -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
|
|
9
|
+
const gossip=function(_0x363baf){const _0xaec938={};return _0xaec938['gid']=_0x363baf['gid']||'all',_0xaec938['subset']=_0x363baf['subset']||function(_0x3c0177){return Math['ceil'](Math['log'](_0x3c0177['length']));},{'send':(_0x1fd28f,_0x241fd9,_0x19ecda)=>{global['distributi'+'on']['local']['groups']['get'](_0xaec938['gid'],(_0x45d2ff,_0x17247f)=>{const _0x586949=_0xaec938['subset'](Object['keys'](_0x17247f)),_0x20addc=function(_0x58e9be){const _0x584e81=new Set();while(_0x584e81['size']<_0x586949){const _0x3d5b72=Math['floor'](Math['random']()*_0x58e9be['length']);_0x584e81['add'](_0x58e9be[_0x3d5b72]);}return _0x584e81;},_0x563e94=_0x20addc(Object['keys'](_0x17247f)),_0x506770={},_0x5602b1={};let _0x42d0bc=-0x1*-0x1de3+0xe42+-0x2c25;if(_0x1fd28f['mid']&&_0x1fd28f['gid']){}else _0x1fd28f={'message':_0x1fd28f,'remote':_0x241fd9,'mid':global['distributi'+'on']['util']['id']['getMID'](_0x1fd28f),'gid':_0xaec938['gid']};for(const _0x21a65e of _0x563e94){const _0x49309d=_0x17247f[_0x21a65e],_0x57bb71={'node':{'ip':_0x49309d['ip'],'port':_0x49309d['port']},'service':'gossip','method':'recv'};global['distributi'+'on']['local']['comm']['send']([_0x1fd28f],_0x57bb71,(_0xe3a903,_0x451b60)=>{_0xe3a903?_0x5602b1[_0x21a65e]=_0xe3a903:_0x506770[_0x21a65e]=_0x451b60,_0x42d0bc+=-0x8*-0x38b+-0xb2+-0x1ba5,_0x42d0bc===_0x586949&&(_0x19ecda&&_0x19ecda(_0x5602b1,_0x506770));});}});},'at':(_0x1e0c30,_0x40c9bf,_0x1713b9)=>{const _0x39beb0=setInterval(_0x40c9bf,_0x1e0c30);_0x1713b9&&_0x1713b9(null,_0x39beb0);},'del':(_0x37e59b,_0x54f7b8)=>{clearInterval(_0x37e59b),_0x54f7b8&&_0x54f7b8(null,_0x37e59b);}};};module['exports']=gossip;
|
|
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
|
|
9
|
+
const log=require('../util/lo'+'g');function getNode(_0x3ac292,_0x1d2ed4,_0x315152){typeof _0x1d2ed4==='object'&&(_0x1d2ed4=_0x1d2ed4['key']),global['distributi'+'on'][_0x3ac292['gid']]['status']['get']('nid',(_0x158d8a,_0xedcb32)=>{const _0x6f5a63=Object['values'](_0xedcb32),_0x1f7669=global['distributi'+'on']['util']['id']['getID'](_0x1d2ed4),_0x33c989=_0x3ac292['hash'](_0x1f7669,_0x6f5a63),_0x5a973f=_0x33c989['substring'](0x1e82+0x358+-0x4d6*0x7,0xb*-0xb7+0x19c3+0x11e1*-0x1);global['distributi'+'on']['local']['groups']['get'](_0x3ac292['gid'],(_0x2d2fe5,_0x3419ca)=>{const _0x360f11=_0x3419ca[_0x5a973f];log('[mem\x20(getN'+'ode)]\x20conf'+'iguration:'+'\x20'+JSON['stringify'](_0x1d2ed4)+'group:\x20'+JSON['stringify'](_0x3419ca)+'\x20node:\x20'+JSON['stringify'](_0x360f11)+'nid:\x20'+JSON['stringify'](_0x33c989)+'\x20sid:\x20'+JSON['stringify'](_0x5a973f)),_0x315152(_0x360f11);});});}function normalize(_0x17494b,_0x1fedc4){const _0x4a04c7={};_0x17494b===null&&(_0x17494b={});if(typeof _0x17494b==='string')_0x4a04c7['key']=_0x17494b,_0x4a04c7['gid']=_0x1fedc4,_0x4a04c7['action']='put';else typeof _0x17494b==='object'&&(_0x4a04c7['key']=_0x17494b['key'],_0x4a04c7['gid']=_0x17494b['gid']||_0x1fedc4,_0x4a04c7['action']=_0x17494b['action']||'put');return _0x4a04c7;};function mem(_0x43de2f){const _0x56c810={};return _0x56c810['gid']=_0x43de2f['gid']||'all',_0x56c810['hash']=_0x43de2f['hash']||global['distributi'+'on']['util']['id']['naiveHash'],{'get':(_0x1a9046,_0x5bcd16)=>{if(!_0x1a9046){const _0x261fd2=[{'key':null,'gid':_0x56c810['gid']}];global['distributi'+'on'][_0x56c810['gid']]['comm']['send'](_0x261fd2,{'service':'mem','method':'get'},(_0x31534c,_0x5270d0)=>{const _0x8e3144=Object['values'](_0x5270d0)['reduce']((_0x510818,_0xa4bccf)=>_0x510818['concat'](_0xa4bccf),[]);_0x5bcd16(_0x31534c,_0x8e3144);});return;}_0x1a9046=normalize(_0x1a9046,_0x56c810['gid']),getNode(_0x56c810,_0x1a9046,_0x340d90=>{const _0x5468b3=[_0x1a9046],_0x37300e={'service':'mem','method':'get','node':_0x340d90};log('[all.mem.g'+'et]\x20config'+'uration:\x20'+JSON['stringify'](_0x1a9046)+'\x20node:\x20'+JSON['stringify'](global['nodeConfig'])+('\x20target\x20no'+'de:\x20')+JSON['stringify'](_0x340d90)),global['distributi'+'on']['local']['comm']['send'](_0x5468b3,_0x37300e,_0x5bcd16);});},'put':(_0x4edcda,_0x13a371,_0x55080f)=>{_0x13a371=_0x13a371||global['distributi'+'on']['util']['id']['getID'](_0x4edcda),_0x13a371=normalize(_0x13a371,_0x56c810['gid']),getNode(_0x56c810,_0x13a371,_0x4d29bf=>{const _0x1c8c89=[_0x4edcda,_0x13a371],_0x399f1d={'service':'mem','method':'put','node':_0x4d29bf};log('[all.mem.p'+'ut]\x20state:'+'\x20'+JSON['stringify'](_0x4edcda)+('configurat'+'ion:\x20')+JSON['stringify'](_0x13a371)+('target\x20nod'+'e:\x20')+JSON['stringify'](_0x4d29bf)),global['distributi'+'on']['local']['comm']['send'](_0x1c8c89,_0x399f1d,_0x55080f);});},'del':(_0x2a9e48,_0x38b525)=>{getNode(_0x56c810,_0x2a9e48,_0x14669d=>{const _0x3c224a=[{'key':_0x2a9e48,'gid':_0x56c810['gid']}],_0x16c9f5={'service':'mem','method':'del','node':_0x14669d};global['distributi'+'on']['local']['comm']['send'](_0x3c224a,_0x16c9f5,_0x38b525);});},'reconf':(_0xf1bd05,_0xb3bc1c)=>{global['distributi'+'on'][_0x56c810['gid']]['mem']['get'](null,(_0x568572,_0x2e9a75)=>{global['distributi'+'on'][_0x56c810['gid']]['status']['get']('nid',(_0x455575,_0x59da2a)=>{const _0x52e00a=Object['values'](_0x59da2a),_0xfb18b0=Object['values'](_0xf1bd05)['map'](_0x183043=>global['distributi'+'on']['util']['id']['getNID'](_0x183043));log('[mem.recon'+'f\x20received'+'\x20'+_0x2e9a75['length']+('\x20keys\x20from'+'\x20')+_0x59da2a['length']+'\x20nodes');let _0x256f9b=-0xffa*-0x1+0x260f+-0x3609;const _0xcd0d46=()=>{_0x256f9b===_0x2e9a75['length']&&_0xb3bc1c();};if(_0x2e9a75['length']===0x4*0x8b1+0x1*-0x1f0c+-0x2*0x1dc){_0xb3bc1c();return;}for(const _0x254dff of _0x2e9a75){const _0x604a18=global['distributi'+'on']['util']['id']['getID'](_0x254dff),_0x5d4fa8=_0x56c810['hash'](_0x604a18,_0xfb18b0),_0x4ec856=_0x56c810['hash'](_0x604a18,_0x52e00a);log('[mem.recon'+'f]\x20old\x20nid'+':\x20'+_0x5d4fa8+'\x20new\x20nid:\x20'+_0x4ec856);if(_0x5d4fa8===_0x4ec856){_0x256f9b++,_0xcd0d46();continue;}const _0x41f7eb=_0xf1bd05[_0x5d4fa8['substring'](0xb3+-0x1*0xebb+-0x382*-0x4,-0x6*-0x275+-0x1b4d+0xc94)],_0x4229ee=[{'key':_0x254dff,'gid':_0x56c810['gid']}],_0x1e063b={'service':'mem','method':'del','node':_0x41f7eb};log('[mem.recon'+'f]\x20deletin'+'g\x20key\x20'+_0x254dff+'\x20from\x20'+JSON['stringify'](_0x1e063b)),global['distributi'+'on']['local']['comm']['send'](_0x4229ee,_0x1e063b,(_0x418360,_0x1009ce)=>{global['distributi'+'on'][_0x56c810['gid']]['mem']['put'](_0x1009ce,_0x254dff,(_0x641d25,_0x96fc42)=>{_0x256f9b++,_0xcd0d46();});});}});});}};};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(_0x91efe5){const _0xbc9aa={'gid':_0x91efe5['gid']||'all'};function _0x346c00(_0x3e1907,_0x3a646f){const _0x3d59cc=id['getID'](_0x3e1907),_0x2d3792={'mapper':_0x3e1907['map'],'reducer':_0x3e1907['reduce'],'map':function(_0x33b05e,_0x42f13a,_0x1db202,_0x1ea0bb){if(_0x33b05e['length']==0x1*0x1d39+0xd*0x25e+0x3bff*-0x1){_0x1ea0bb(null,[]);return;}else{const _0x317713=[];let _0x1a0fd2=-0x3*-0x4d5+-0x2238+-0x21*-0x99;_0x33b05e['forEach'](_0x34a98f=>{distribution[_0x42f13a]['store']['get'](_0x34a98f,(_0x21bc0c,_0x33ac07)=>{_0x1a0fd2++;const _0x1f8fac=this['mapper'](_0x34a98f,_0x33ac07);Array['isArray'](_0x1f8fac)?_0x317713['push'](..._0x1f8fac):_0x317713['push'](_0x1f8fac),_0x1a0fd2==_0x33b05e['length']&&distribution['local']['store']['put'](_0x317713,_0x1db202+'_map',(_0x3778ef,_0x31bc78)=>{_0x1ea0bb(_0x3778ef,_0x317713);});});});}},'shuffle':function(_0x31a211,_0x3b7dda,_0x492d22){distribution['local']['store']['get'](_0x3b7dda+'_map',(_0x21b907,_0x4a1fa9)=>{if(!_0x21b907){let _0xc8e54a=-0x13*-0x14b+-0x1*-0x49f+0x1d30*-0x1;_0x4a1fa9['forEach'](_0x18e867=>{const [_0x2f98d3]=Object['keys'](_0x18e867);distribution[_0x31a211]['mem']['put'](_0x18e867[_0x2f98d3],{'key':_0x2f98d3,'action':'append'},(_0x468c9f,_0x331470)=>{_0xc8e54a++,_0xc8e54a==_0x4a1fa9['length']&&_0x492d22(null,_0x4a1fa9);});});}else _0x492d22(_0x21b907,{});});},'reduce':function(_0x4e0ddb,_0xaeaeb1,_0x52b618){distribution['local']['mem']['get']({'key':null,'gid':_0x4e0ddb},(_0x272c7d,_0x504820)=>{let _0x46c073=[],_0x347a9c=-0x173b+-0xb*0x11f+0x2390*0x1;_0x504820['length']==-0x1*0x11bf+0x8d9*0x1+-0x86*-0x11&&_0x52b618(null,null),_0x504820['forEach'](_0x5522b7=>distribution['local']['mem']['get']({'key':_0x5522b7,'gid':_0x4e0ddb},(_0x175794,_0x462b8c)=>{const _0xb7dd39=this['reducer'](_0x5522b7,_0x462b8c);_0x46c073=_0x46c073['concat'](_0xb7dd39),_0x347a9c++,_0x347a9c==_0x504820['length']&&_0x52b618(null,_0x46c073);}));});}},_0x161946=function(_0x5bae3d,_0xdf12d5){const _0x4fd950={};return Object['keys'](_0xdf12d5)['forEach'](_0x167a83=>{_0x4fd950[_0x167a83]=[];}),_0x5bae3d['forEach'](_0x6678f9=>{const _0x47c661=id['getID'](_0x6678f9),_0x517d5f=id['naiveHash'](_0x47c661,Object['keys'](_0xdf12d5));_0x4fd950[_0x517d5f]['push'](_0x6678f9);}),_0x4fd950;};distribution[_0xbc9aa['gid']]['routes']['put'](_0x2d3792,'mr-'+_0x3d59cc,(_0x56d927,_0x185dc6)=>{distribution['local']['groups']['get'](_0xbc9aa['gid'],(_0x3eaf6d,_0x381426)=>{const _0x162883=_0x161946(_0x3e1907['keys'],_0x381426);let _0x5eb0c1=-0x1a83+-0x1096+0x2b19;const _0x509059=Object['keys'](_0x381426)['length'],_0x23a9b9={'service':'mr-'+_0x3d59cc,'method':'map'};for(const _0x2064db in _0x381426){const _0x448872=[_0x162883[_0x2064db],_0xbc9aa['gid'],_0x3d59cc];distribution['local']['comm']['send'](_0x448872,{'node':_0x381426[_0x2064db],..._0x23a9b9},(_0x1d5911,_0x328b27)=>{++_0x5eb0c1;if(_0x5eb0c1==_0x509059){const _0x23db66={'service':'mr-'+_0x3d59cc,'method':'shuffle'};distribution[_0xbc9aa['gid']]['comm']['send']([_0xbc9aa['gid'],_0x3d59cc],_0x23db66,(_0x2d1def,_0xc57f5c)=>{const _0x5c226c={'service':'mr-'+_0x3d59cc,'method':'reduce'};distribution[_0xbc9aa['gid']]['comm']['send']([_0xbc9aa['gid'],_0x3d59cc],_0x5c226c,(_0x1751aa,_0x33a63e)=>{let _0x5283f9=[];for(const _0x3f0c1a of Object['values'](_0x33a63e)){_0x3f0c1a!==null&&(_0x5283f9=_0x5283f9['concat'](_0x3f0c1a));}_0x3a646f(null,_0x5283f9);return;});});}});}});});}return{'exec':_0x346c00};};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 status=function(
|
|
9
|
+
const status=function(_0xaf222){const _0x49effd={};return _0x49effd['gid']=_0xaf222['gid']||'all',{'get':(_0x2c8358,_0x2b080c)=>{const _0x2f73eb=[_0x2c8358],_0x2a83d2={'service':'status','method':'get'};global['distributi'+'on'][_0x49effd['gid']]['comm']['send'](_0x2f73eb,_0x2a83d2,(_0x2c0694,_0x33d7ff)=>{switch(_0x2c8358){case'heapTotal':const _0x297e00=Object['values'](_0x33d7ff)['reduce']((_0x1310f3,_0x19f39b)=>{return _0x1310f3+_0x19f39b;},-0xfb6+0x7e*0xc+0xa*0xfb);_0x2b080c(_0x2c0694,_0x297e00);break;case'nid':const _0x394095=Object['values'](_0x33d7ff)['reduce']((_0x26e757,_0x4187a4)=>{return _0x26e757['concat'](_0x4187a4);},[]);_0x2b080c(_0x2c0694,_0x394095);break;default:_0x2b080c(_0x2c0694,_0x33d7ff);break;}});},'spawn':(_0x41ef1d,_0x4b51b8)=>{_0x4b51b8=_0x4b51b8||function(){},global['distributi'+'on']['local']['status']['spawn'](_0x41ef1d,(_0x5aaae3,_0xd9dea9)=>{_0x5aaae3?_0x4b51b8(_0x5aaae3):global['distributi'+'on']['local']['groups']['add'](_0x49effd['gid'],_0x41ef1d,()=>{_0x4b51b8(null,_0xd9dea9);}),global['distributi'+'on'][_0x49effd['gid']]['comm']['send']([_0x49effd['gid'],_0x41ef1d],{'service':'groups','method':'add'},()=>{});});},'stop':_0x322fe9=>{global['distributi'+'on'][_0x49effd['gid']]['comm']['send']([],{'service':'status','method':'stop'},_0x322fe9);}};};module['exports']=status;
|
|
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
|
|
9
|
+
const log=require('../util/lo'+'g');function getNode(_0x4e17be,_0x36ca18,_0x1a1744){global['distributi'+'on'][_0x4e17be['gid']]['status']['get']('nid',(_0x45715c,_0x4ae44d)=>{const _0x494ad1=Object['values'](_0x4ae44d),_0x3cf102=global['distributi'+'on']['util']['id']['getID'](_0x36ca18),_0x366ec9=_0x4e17be['hash'](_0x3cf102,_0x494ad1),_0x26e338=_0x366ec9['substring'](-0x1061*0x1+0x923+0x2*0x39f,0x1681*-0x1+-0x4c3*-0x1+0x11c3);global['distributi'+'on']['local']['groups']['get'](_0x4e17be['gid'],(_0x5bae1a,_0x26e22a)=>{const _0xecf4fa=_0x26e22a[_0x26e338];_0x1a1744(_0xecf4fa);});});}const store=function(_0x14d3d){const _0x27c5a5={};return _0x27c5a5['gid']=_0x14d3d['gid']||'all',_0x27c5a5['hash']=_0x14d3d['hash']||global['distributi'+'on']['util']['id']['naiveHash'],{'get':(_0x4fc5ef,_0x5a6081)=>{if(!_0x4fc5ef){const _0x487602=[{'key':null,'gid':_0x27c5a5['gid']}];global['distributi'+'on'][_0x27c5a5['gid']]['comm']['send'](_0x487602,{'service':'store','method':'get'},(_0x2c03a2,_0x14dd6a)=>{log('[all.store'+'.get\x20null\x20'+'given\x20as\x20k'+'ey.\x20keys:\x20'+JSON['stringify'](_0x14dd6a)+'\x20errors:\x20'+JSON['stringify'](_0x2c03a2));const _0x1cd07c=Object['values'](_0x14dd6a)['reduce']((_0xe5c384,_0xf23a91)=>_0xe5c384['concat'](_0xf23a91),[]);_0x5a6081(_0x2c03a2,_0x1cd07c);});return;}getNode(_0x27c5a5,_0x4fc5ef,_0x3f8d2b=>{const _0x395cae=[{'key':_0x4fc5ef,'gid':_0x27c5a5['gid']}],_0xab0ccd={'service':'store','method':'get','node':_0x3f8d2b};global['distributi'+'on']['local']['comm']['send'](_0x395cae,_0xab0ccd,_0x5a6081);});},'put':(_0x115347,_0x4c58a6,_0x56c5ba)=>{_0x4c58a6=_0x4c58a6||global['distributi'+'on']['util']['id']['getID'](_0x115347),getNode(_0x27c5a5,_0x4c58a6,_0x180f28=>{const _0x2800ba=[_0x115347,{'key':_0x4c58a6,'gid':_0x27c5a5['gid']}],_0x14613c={'service':'store','method':'put','node':_0x180f28};log('[all.store'+'.put]:\x20(gi'+'d:\x20'+_0x27c5a5['gid']+')\x20'+JSON['stringify'](_0x115347)+'\x20'+JSON['stringify'](_0x4c58a6)+('\x20target\x20no'+'de:\x20')+JSON['stringify'](_0x180f28)),global['distributi'+'on']['local']['comm']['send'](_0x2800ba,_0x14613c,_0x56c5ba);});},'del':(_0x52bf0d,_0x5b2d40)=>{getNode(_0x27c5a5,_0x52bf0d,_0x58d07f=>{const _0x5a2106=[{'key':_0x52bf0d,'gid':_0x27c5a5['gid']}],_0x29eb0e={'service':'store','method':'del','node':_0x58d07f};global['distributi'+'on']['local']['comm']['send'](_0x5a2106,_0x29eb0e,_0x5b2d40);});},'reconf':(_0x17a4a7,_0x1703e9)=>{global['distributi'+'on'][_0x27c5a5['gid']]['store']['get'](null,(_0x385d5c,_0x3fa5ce)=>{global['distributi'+'on'][_0x27c5a5['gid']]['status']['get']('nid',(_0x444294,_0x4f0c5c)=>{const _0x1fa341=Object['values'](_0x4f0c5c),_0x417ccf=Object['values'](_0x17a4a7)['map'](_0x2a3d6e=>global['distributi'+'on']['util']['id']['getNID'](_0x2a3d6e));log('[store.rec'+'onf\x20receiv'+'ed\x20'+_0x3fa5ce['length']+('\x20keys\x20from'+'\x20')+_0x4f0c5c['length']+'\x20nodes');let _0x5069d8=-0xc8c+0x1a72+-0xde6;const _0x3b8200=()=>{_0x5069d8===_0x3fa5ce['length']&&_0x1703e9();};if(_0x3fa5ce['length']===-0xd45+0x1*0x1d1b+0x1*-0xfd6){_0x1703e9();return;}for(const _0x1388f5 of _0x3fa5ce){const _0x543d78=global['distributi'+'on']['util']['id']['getID'](_0x1388f5),_0x481aec=_0x27c5a5['hash'](_0x543d78,_0x417ccf),_0x26d790=_0x27c5a5['hash'](_0x543d78,_0x1fa341);log('[store.rec'+'onf]\x20old\x20n'+'id:\x20'+_0x481aec+'\x20new\x20nid:\x20'+_0x26d790);if(_0x481aec===_0x26d790){_0x5069d8++,_0x3b8200();continue;}const _0x141e21=_0x17a4a7[_0x481aec['substring'](0xe61+0x97e+-0x17df,0x16d*-0x16+-0x7*0x359+0x36d2)],_0x286e99=[{'key':_0x1388f5,'gid':_0x27c5a5['gid']}],_0x5d74e5={'service':'store','method':'del','node':_0x141e21};log('[store.rec'+'onf]\x20delet'+'ing\x20key\x20'+_0x1388f5+'\x20from\x20'+JSON['stringify'](_0x5d74e5)),global['distributi'+'on']['local']['comm']['send'](_0x286e99,_0x5d74e5,(_0x26cbbe,_0x22f106)=>{global['distributi'+'on'][_0x27c5a5['gid']]['store']['put'](_0x22f106,_0x1388f5,(_0x53c3b8,_0x3c4b0b)=>{_0x5069d8++,_0x3b8200();});});}});});}};};module['exports']=store;
|
|
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'),
|
|
9
|
+
const http=require('http'),log=require('../util/lo'+'g');function send(_0x246bd4,_0x3c69da,_0x2ca3d2){log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0x246bd4)+'to\x20'+_0x3c69da['service']+':'+_0x3c69da['method']+'\x20on\x20'+_0x3c69da['node']['ip']+':'+_0x3c69da['node']['port']);if(!_0x246bd4 instanceof Array)throw new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray');const _0x33dff5=_0x3c69da['node'],_0x3ea0e5=_0x3c69da['service'],_0x2ba62c=_0x3c69da['method'],_0x5c343b=_0x3c69da['gid']||'local',_0x1c6a54=global['distributi'+'on']['util']['serialize'](_0x246bd4),_0x8930d4={'hostname':_0x33dff5['ip'],'port':_0x33dff5['port'],'path':'/'+_0x5c343b+'/'+_0x3ea0e5+'/'+_0x2ba62c,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x1c6a54)}},_0x464390=http['request'](_0x8930d4,_0x2b1db1=>{let _0x2e4319='';_0x2b1db1['on']('data',function(_0x2b1b7b){_0x2e4319+=_0x2b1b7b;}),_0x2b1db1['on']('end',function(){_0x2ca3d2&&_0x2ca3d2(...global['distributi'+'on']['util']['deserializ'+'e'](_0x2e4319));}),_0x2b1db1['on']('error',function(_0x16e6b5){_0x2ca3d2&&_0x2ca3d2(new Error('Error\x20on\x20r'+'esponse'));});});_0x464390['on']('error',function(_0x36322f){_0x2ca3d2&&_0x2ca3d2(new Error(_0x36322f));}),_0x464390['write'](_0x1c6a54),_0x464390['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
|
|
9
|
+
const log=require('../util/lo'+'g'),kvStore={'store':new Map(),'get'(_0x3f38ad){if(!this['store'][_0x3f38ad['gid']])return undefined;return this['store'][_0x3f38ad['gid']][_0x3f38ad['key']];},'put'(_0x25f423,_0x917dcf){!this['store'][_0x25f423['gid']]&&(this['store'][_0x25f423['gid']]=new Map()),this['store'][_0x25f423['gid']][_0x25f423['key']]=_0x917dcf;},'append'(_0x4e9e05,_0x3d2779){!this['get'](_0x4e9e05)&&this['put'](_0x4e9e05,[]),!Array['isArray'](this['get'](_0x4e9e05))&&this['put'](_0x4e9e05,[this['get'](_0x4e9e05)]),Array['isArray'](_0x3d2779)?this['put'](_0x4e9e05,this['get'](_0x4e9e05)['concat'](_0x3d2779)):this['store'][_0x4e9e05['gid']][_0x4e9e05['key']]['push'](_0x3d2779);},'del'(_0x1ab02c){if(!this['store'][_0x1ab02c['gid']])return undefined;const _0x46c34a=this['store'][_0x1ab02c['gid']][_0x1ab02c['key']];return delete this['store'][_0x1ab02c['gid']][_0x1ab02c['key']],_0x46c34a;},'toString'(){let _0x42e291='';for(const _0x4ebe47 in this['store']){_0x42e291+=_0x4ebe47+':\x20'+JSON['stringify'](this['store'][_0x4ebe47]);}return _0x42e291;}};function normalize(_0x24d948){const _0x5ce18d={};_0x24d948===null&&(_0x24d948={});if(typeof _0x24d948==='string')_0x5ce18d['key']=_0x24d948,_0x5ce18d['gid']='local',_0x5ce18d['action']='put';else typeof _0x24d948==='object'&&(_0x5ce18d['key']=_0x24d948['key'],_0x5ce18d['gid']=_0x24d948['gid'],_0x5ce18d['action']=_0x24d948['action']);return _0x5ce18d;};function put(_0x66645d,_0x591845,_0x1f5a6d){log('[mem.put]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x591845)+'state:\x20'+JSON['stringify'](_0x66645d)+'\x20store:\x20'+kvStore['toString']()),_0x1f5a6d=_0x1f5a6d||function(){},_0x591845=normalize(_0x591845),_0x591845['key']=_0x591845['key']||global['distributi'+'on']['util']['id']['getID'](_0x66645d),_0x591845['gid']=_0x591845['gid']||'local',_0x591845['action']=_0x591845['action']||'put',kvStore[_0x591845['action']](_0x591845,_0x66645d),log('[mem.put]\x20'+'store\x20(aft'+'er):\x20'+kvStore['toString']()),_0x1f5a6d&&_0x1f5a6d(null,_0x66645d);};function get(_0x11cffa,_0x11c9af){log('[mem.get]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x11cffa)+'\x20store:\x20'+kvStore['toString']()),_0x11c9af=_0x11c9af||function(){},_0x11cffa=normalize(_0x11cffa),_0x11cffa['gid']=_0x11cffa['gid']||'local';if(!_0x11cffa['key']){let _0x4ef0ff=kvStore['store'][_0x11cffa['gid']]||{};_0x4ef0ff=Object['keys'](_0x4ef0ff),_0x11c9af(null,_0x4ef0ff);return;}const _0x387e75=kvStore['get'](_0x11cffa);_0x387e75?_0x11c9af(null,_0x387e75):_0x11c9af(new Error('Memory\x20key'+'\x20\x22'+_0x11cffa['key']+('\x22\x20\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20not\x20found'+'\x20for\x20')+_0x11cffa['gid']+'\x27s\x20store'));}function del(_0x97f270,_0x4d0673){log('[mem.del]\x20'+'configurat'+'ion:\x20'+JSON['stringify'](_0x97f270)+'\x20store:\x20'+kvStore['toString']()),_0x4d0673=_0x4d0673||function(){},_0x97f270=normalize(_0x97f270);const _0x56e060=kvStore['del'](_0x97f270);log('[mem.del]\x20'+'store\x20(aft'+'er):\x20'+kvStore['toString']()),_0x56e060?_0x4d0673(null,_0x56e060):_0x4d0673(new Error('Memory\x20key'+'\x20\x22'+_0x97f270['key']+('\x22\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'not\x20found\x20'+'for\x20')+_0x97f270['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')
|
|
9
|
+
const http=require('http'),url=require('url'),log=require('../util/lo'+'g');function isValidBody(_0x528814){if(_0x528814['length']===0x5*-0x4db+0x975+-0x2*-0x769)return new Error('No\x20body');try{_0x528814=JSON['parse'](_0x528814);}catch(_0x29ed5e){return _0x29ed5e;}return undefined;}function endRequest(_0x2d3f07,_0x4b607b){_0x2d3f07['end'](global['distributi'+'on']['util']['serialize']([_0x4b607b]));}const start=function(_0x454a6e){const _0x328c99=http['createServ'+'er']((_0x176a9e,_0x1f674e)=>{if(_0x176a9e['method']!=='PUT'){_0x1f674e['end'](global['distributi'+'on']['util']['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x596d31=url['parse'](_0x176a9e['url'])['pathname'],[,_0x144188,_0x5623cc,_0x4864e3]=_0x596d31['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x144188+'\x20'+_0x5623cc+':'+_0x4864e3+'\x20from\x20'+_0x176a9e['connection']['remoteAddr'+'ess']);let _0x24cad9=[];_0x176a9e['on']('data',_0x5d1396=>{_0x24cad9['push'](_0x5d1396);}),_0x176a9e['on']('end',()=>{_0x24cad9=Buffer['concat'](_0x24cad9)['toString']();let _0xeea35f;if(_0xeea35f=isValidBody(_0x24cad9)){endRequest(_0x1f674e,_0xeea35f);return;}_0x24cad9=JSON['parse'](_0x24cad9),_0x24cad9=global['distributi'+'on']['util']['deserializ'+'e'](_0x24cad9);const _0x332e8f=_0x24cad9;!Array['isArray'](_0x332e8f)&&endRequest(_0x1f674e,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x332e8f));const _0x12f4b5=_0x5623cc;global['distributi'+'on']['local']['routes']['get']({'service':_0x5623cc,'gid':_0x144188},(_0x29a423,_0x20bbf6)=>{const _0x646fba=(_0x4247a6,_0x1834e1)=>{_0x1f674e['end'](global['distributi'+'on']['util']['serialize']([_0x4247a6,_0x1834e1]));};if(_0x29a423){_0x646fba(_0x29a423);return;}if(!_0x20bbf6[_0x4864e3]){_0x646fba(new Error('Method\x20'+_0x4864e3+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x12f4b5));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x12f4b5+':'+_0x4864e3+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x332e8f));_0x332e8f['length']===-0x2042*0x1+0xef8+-0x13*-0xe9&&_0x20bbf6[_0x4864e3]['length']===-0x1*-0x19b3+0x8f*0x3+-0x1b5d&&_0x332e8f['push'](undefined);try{_0x20bbf6[_0x4864e3](..._0x332e8f,_0x646fba);}catch(_0x4b9618){_0x646fba(_0x4b9618);}});});});_0x328c99['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']=_0x328c99,_0x454a6e(_0x328c99);}),_0x328c99['on']('error',_0x563d01=>{log('Server\x20err'+'or:\x20'+_0x563d01);throw _0x563d01;});};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
|
|
9
|
+
const log=require('../util/lo'+'g'),status={};global['moreStatus']={'sid':global['distributi'+'on']['util']['id']['getSID'](global['nodeConfig']),'nid':global['distributi'+'on']['util']['id']['getNID'](global['nodeConfig']),'counts':0x0},status['get']=function(_0xed5bd,_0x2ae74d){_0x2ae74d=_0x2ae74d||function(){};if(_0xed5bd in global['nodeConfig']){_0x2ae74d(null,global['nodeConfig'][_0xed5bd]);return;}if(_0xed5bd in global['moreStatus']){_0x2ae74d(null,global['moreStatus'][_0xed5bd]);return;}if(_0xed5bd==='heapTotal'){_0x2ae74d(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0xed5bd==='heapUsed'){_0x2ae74d(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x2ae74d(new Error('Status\x20key'+'\x20not\x20found'));};const fs=require('fs'),path=require('path'),{spawn,execSync}=require('child_proc'+'ess');function getDistribution(){let _0x498053=path['join'](process['cwd'](),'distributi'+'on.js');if(fs['existsSync'](_0x498053))return _0x498053;try{const _0x5d3be6=execSync('git\x20rev-pa'+'rse\x20--show'+'-toplevel',{'encoding':'utf8'})['trim']();_0x498053=path['join'](_0x5d3be6,'distributi'+'on.js');if(fs['existsSync'](_0x498053))return _0x498053;}catch(_0x3a5232){}_0x498053=path['join'](__dirname,'../../dist'+'ribution.j'+'s');if(fs['existsSync'](_0x498053))return _0x498053;return null;}const createSpawnedCb=function(_0x3abc12,_0x8164b8){const _0x3b55d4='\x0a\x20\x20\x20\x20let\x20o'+'nStart\x20=\x20'+_0x3abc12['toString']()+(';\x0a\x0a\x20\x20\x20\x20let'+'\x20callbackR'+'PC\x20=\x20')+global['distributi'+'on']['util']['wire']['createRPC'](global['distributi'+'on']['util']['wire']['toAsync'](_0x8164b8))['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(_0x3b55d4);};status['spawn']=function(_0x2a33fe,_0x35a083){const _0x22934f=_0x2a33fe;_0x22934f['onStart']=_0x22934f['onStart']||function(){};if(!_0x22934f['port']||!_0x22934f['ip']){_0x35a083(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'](_0x22934f)),_0x22934f['onStart']=createSpawnedCb(_0x22934f['onStart'],_0x35a083);const _0x2fef42=getDistribution(),_0x4bc187=spawn('node',[_0x2fef42,'--config',global['distributi'+'on']['util']['serialize'](_0x22934f)],{'detached':!![],'stdio':'inherit'});_0x4bc187;},status['stop']=function(_0x21756f){_0x21756f=_0x21756f||function(){},_0x21756f(null,global['nodeConfig']),log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),global['distributi'+'on']['node']['server']['close'](),process['exit'](-0x12dd+-0x78d+0x1a6a);},module['exports']=status;
|
|
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'),
|
|
9
|
+
const fs=require('fs'),path=require('path'),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(_0x2f8ccc){const _0x4720e3={};_0x2f8ccc===null&&(_0x2f8ccc={});if(typeof _0x2f8ccc==='string')_0x4720e3['key']=_0x2f8ccc,_0x4720e3['gid']='local';else typeof _0x2f8ccc==='object'&&(_0x4720e3['key']=_0x2f8ccc['key'],_0x4720e3['gid']=_0x2f8ccc['gid']);return _0x4720e3;};function put(_0x51c272,_0x4c65bb,_0x1836ed){_0x1836ed=_0x1836ed||function(){},_0x4c65bb=normalize(_0x4c65bb),_0x4c65bb['key']=_0x4c65bb['key']||global['distributi'+'on']['util']['id']['getID'](_0x51c272),_0x4c65bb['gid']=_0x4c65bb['gid']||'local';const _0xceb37=global['distributi'+'on']['util']['serialize'](_0x51c272);let _0xf6717f=Buffer['from'](_0x4c65bb['key'])['toString']('base64');_0xf6717f=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x4c65bb['gid']+'-'+_0xf6717f,log('[store.put'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x4c65bb)+'\x20state:\x20'+JSON['stringify'](_0x51c272)+('\x20filename:'+'\x20')+_0xf6717f),fs['writeFile'](_0xf6717f,_0xceb37,_0x13b631=>{_0x13b631?_0x1836ed(_0x13b631):_0x1836ed(null,_0x51c272);});}function get(_0x42161f,_0x347c86){_0x347c86=_0x347c86||function(){},_0x42161f=normalize(_0x42161f),_0x42161f['gid']=_0x42161f['gid']||'local';if(!_0x42161f['key']){fs['readdir'](baseFolder+'/s-'+global['moreStatus']['sid'],(_0x115b0a,_0x290e03)=>{if(_0x115b0a)_0x347c86(_0x115b0a);else{const _0x4cc450=[];for(let _0x2f9db0=0x979*0x2+-0x2659*0x1+0x1367;_0x2f9db0<_0x290e03['length'];_0x2f9db0++){let _0x30e0f3=_0x290e03[_0x2f9db0]['split']('-');const _0x291d46=_0x30e0f3[-0xdb4+-0x1f4a+0x2cfe];if(_0x291d46!==_0x42161f['gid'])continue;_0x30e0f3=_0x30e0f3[_0x30e0f3['length']-(0xf11+0x1673+-0x2583)],_0x4cc450['push'](Buffer['from'](_0x30e0f3,'base64')['toString']());}_0x347c86(null,_0x4cc450);}});return;}let _0x23570c=Buffer['from'](_0x42161f['key'])['toString']('base64');_0x23570c=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x42161f['gid']+'-'+_0x23570c,log('[store.get'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x42161f)+('\x20filename:'+'\x20')+_0x23570c),fs['readFile'](_0x23570c,(_0x2a82f5,_0x16a4b8)=>{_0x2a82f5?_0x2a82f5['code']==='ENOENT'?_0x347c86(new Error('File\x20'+_0x23570c+('\x20(from\x20key'+'\x20\x27')+_0x42161f['key']+('\x27)\x20not\x20fou'+'nd\x20for\x20gro'+'up\x20')+_0x42161f['gid'])):_0x347c86(_0x2a82f5):_0x347c86(null,global['distributi'+'on']['util']['deserializ'+'e'](_0x16a4b8['toString']()));});}function del(_0x51af6f,_0x2d287b){_0x2d287b=_0x2d287b||function(){},_0x51af6f=normalize(_0x51af6f);let _0x177b2b=Buffer['from'](_0x51af6f['key'])['toString']('base64');_0x177b2b=baseFolder+'/s-'+global['moreStatus']['sid']+'/'+_0x51af6f['gid']+'-'+_0x177b2b,get(_0x51af6f,(_0x52fc68,_0x3831cf)=>{if(_0x52fc68){_0x2d287b(_0x52fc68);return;}fs['rm'](_0x177b2b,_0x204d84=>{_0x204d84?_0x2d287b(_0x204d84):_0x2d287b(null,_0x3831cf);});});}module['exports']={'put':put,'get':get,'del':del};
|
|
10
10
|
/* eslint-enable */
|
package/distribution/util/id.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 assert=require('assert'),crypto=require('crypto');function getID(
|
|
9
|
+
const assert=require('assert'),crypto=require('crypto');function getID(_0x13974b){const _0x3e4be4=crypto['createHash']('sha256');return _0x3e4be4['update'](JSON['stringify'](_0x13974b)),_0x3e4be4['digest']('hex');}function getNID(_0x44b3e4){return _0x44b3e4={'ip':_0x44b3e4['ip'],'port':_0x44b3e4['port']},getID(_0x44b3e4);}function getSID(_0x61db2c){return getNID(_0x61db2c)['substring'](0xbaf+0x1*-0x143d+-0x1e*-0x49,0x385+0x1c9b+-0x201b);}function getMID(_0x5c61b5){const _0x272c7f={};return _0x272c7f['date']=new Date()['getTime'](),_0x272c7f['mss']=_0x5c61b5,getID(_0x272c7f);}function idToNum(_0x11fd4d){const _0xc93d4=parseInt(_0x11fd4d,0x14ca+-0x11bf*-0x1+-0x2679);return assert(!isNaN(_0xc93d4),'idToNum:\x20i'+'d\x20is\x20not\x20i'+'n\x20KID\x20form'+'!'),_0xc93d4;}function naiveHash(_0x1e9971,_0x5b5783){return _0x5b5783['sort'](),_0x5b5783[idToNum(_0x1e9971)%_0x5b5783['length']];}function consistentHash(_0x17c44b,_0x1dbb51){const _0xc2e84b=idToNum(_0x17c44b),_0x105a1f=_0x1dbb51['map'](_0x40a33d=>({'id':_0x40a33d,'hash':idToNum(_0x40a33d)}));_0x105a1f['sort']((_0x597b7e,_0x3e64f8)=>_0x597b7e['hash']-_0x3e64f8['hash']);for(const _0x271d2f of _0x105a1f){if(_0xc2e84b<=_0x271d2f['hash'])return _0x271d2f['id'];}return _0x105a1f[-0x1d*0x5e+-0x16fe+0x21a4]['id'];}function rendezvousHash(_0x353174,_0x55c6e5){let _0x4cb99a=0x17*-0x121+-0x11*0x143+0x2f6a,_0x1f7177=null;for(const _0xf279e3 of _0x55c6e5){const _0xc693ab=getID(_0x353174+_0xf279e3),_0x9576ec=idToNum(_0xc693ab);_0x9576ec>_0x4cb99a&&(_0x4cb99a=_0x9576ec,_0x1f7177=_0xf279e3);}return _0x1f7177;}module['exports']={'getID':getID,'getNID':getNID,'getSID':getSID,'getMID':getMID,'naiveHash':naiveHash,'consistentHash':consistentHash,'rendezvousHash':rendezvousHash};
|
|
10
10
|
/* eslint-enable */
|
package/distribution/util/log.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 fs=require('fs'),path=require('path'),logFile=path['join'](
|
|
9
|
+
const fs=require('fs'),path=require('path'),logFile=path['join']('/tmp','log.txt');function log(_0x14abef,_0x1e23ce){_0x1e23ce===undefined&&(_0x1e23ce='info');const _0x587c21=new Date(),_0x6dec24=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'](_0x587c21)+'.'+String(_0x587c21['getMillise'+'conds']()*(-0x1607+-0x24fa+0xc95*0x5))['padStart'](0x127d*-0x2+0xc18+0x63a*0x4,'0');fs['appendFile'+'Sync'](logFile,_0x6dec24+'\x20['+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'('+global['moreStatus']['sid']+')]\x20['+_0x1e23ce+']\x20'+_0x14abef+'\x0a');}module['exports']=log;
|
|
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')
|
|
9
|
+
const log=require('../util/lo'+'g');global['toLocal']=new Map();function createRPC(_0x188a3c){const _0x374a92=global['distributi'+'on']['util']['id']['getID'](global['distributi'+'on']['util']['serialize'](_0x188a3c));global['toLocal']['set'](_0x374a92,_0x188a3c);let _0x487026='\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')+_0x374a92+('\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'+_0x374a92),new Function('...args',_0x487026);}function toAsync(_0x417259){log('Converting'+'\x20function\x20'+'to\x20async:\x20'+_0x417259['name']+':\x20'+_0x417259['toString']()['replace'](/\n/g,'|'));const _0x12fb5a=(..._0x4bd1d3)=>{const _0x4c1f50=_0x4bd1d3['pop']();try{const _0x1d6e1a=_0x417259(..._0x4bd1d3);_0x4c1f50(null,_0x1d6e1a);}catch(_0x384053){_0x4c1f50(_0x384053);}};return _0x12fb5a['toString']=()=>_0x417259['toString'](),_0x12fb5a;}module['exports']={'createRPC':createRPC,'toAsync':toAsync};
|
|
10
10
|
/* eslint-enable */
|
package/distribution.js
CHANGED
|
@@ -46,7 +46,11 @@ const distribution = function(config) {
|
|
|
46
46
|
return global.distribution;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
// Don't overwrite the distribution object if it already exists
|
|
50
|
+
if (global.distribution === undefined) {
|
|
51
|
+
global.distribution = distribution;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
distribution.util = require('./distribution/util/util.js');
|
|
51
55
|
distribution.local = require('./distribution/local/local.js');
|
|
52
56
|
distribution.node = require('./distribution/local/node.js');
|
|
@@ -73,7 +77,7 @@ distribution['all'].store =
|
|
|
73
77
|
require('./distribution/all/store')({gid: 'all'});
|
|
74
78
|
|
|
75
79
|
distribution.node.config = global.nodeConfig;
|
|
76
|
-
module.exports =
|
|
80
|
+
module.exports = distribution;
|
|
77
81
|
|
|
78
82
|
/* The following code is run when distribution.js is run directly */
|
|
79
83
|
if (require.main === module) {
|