Compare commits

..

5 Commits

Author SHA1 Message Date
Vitaliy Filippov 9116bb761b Add detailed help 2024-05-07 17:53:40 +03:00
Vitaliy Filippov 258f0d7d1f Implement client 2024-05-07 17:53:40 +03:00
Vitaliy Filippov e912747ebb Add ESLint 2024-05-07 17:53:40 +03:00
Vitaliy Filippov dea46388d2 Add forgotten package.json 2024-05-07 17:53:40 +03:00
Vitaliy Filippov 76239ea24c Implement simple clustering 2024-05-07 17:53:40 +03:00
1 changed files with 7 additions and 7 deletions

View File

@ -161,7 +161,6 @@ class AntiCluster
dumps: {},
loads: {},
};
this.resync_state.dumps[this.cfg.node_id] = { ...this.antietcd.etctree.dump(), term: this.antietcd.stored_term };
}
const seen = {};
for (const f of followers)
@ -205,15 +204,16 @@ class AntiCluster
_continueResync()
{
if (Object.values(this.resync_state.dumps).filter(d => !d).length > 0)
{
// Some dump(s) are still pending
return;
}
this.resync_state.dumps[this.cfg.node_id] = { ...this.antietcd.etctree.dump(), term: this.antietcd.stored_term };
let max_term = -1, with_max = [];
for (const follower in this.resync_state.dumps)
{
const dump = this.resync_state.dumps[follower];
if (!dump)
{
// Some dump(s) are still pending
return;
}
if (dump.term > max_term)
{
max_term = dump.term;
@ -228,8 +228,8 @@ class AntiCluster
{
throw new Error('BUG: no max term during resync');
}
with_max = with_max.filter(w => w != this.cfg.node_id);
console.log('Local term '+this.antietcd.stored_term+', max follower term '+max_term+' at nodes '+with_max.join(', '));
with_max = with_max.filter(w => w != this.cfg.node_id);
// Merge databases of all nodes with maximum term
// Force other nodes to replicate the merged DB, throwing away their own states
for (let i = 0; i < with_max.length; i++)