1
0
forked from extern/smegmesh

checking-latency-for-pull-only

This commit is contained in:
Tim Beatham 2023-12-17 09:44:32 +00:00
parent 19abf712a6
commit 092d9a4af5
2 changed files with 8 additions and 10 deletions

View File

@ -68,9 +68,16 @@ func prepare(syncer *TwoPhaseSyncer) ([]byte, bool) {
return nil, false return nil, false
} }
// Increment the clock here so the clock gets
// distributed to everyone else in the mesh
syncer.manager.store.Clock.IncrementClock()
var buffer bytes.Buffer var buffer bytes.Buffer
enc := gob.NewEncoder(&buffer) enc := gob.NewEncoder(&buffer)
mapState := syncer.manager.store.GenerateMessage()
syncer.mapState = mapState
err = enc.Encode(*syncer.mapState) err = enc.Encode(*syncer.mapState)
if err != nil { if err != nil {
@ -94,7 +101,7 @@ func present(syncer *TwoPhaseSyncer) ([]byte, bool) {
if err != nil { if err != nil {
logging.Log.WriteErrorf(err.Error()) logging.Log.WriteErrorf(err.Error())
} }
difference := syncer.mapState.Difference(syncer.manager.store.Clock.GetStaleCount(), &mapState) difference := syncer.mapState.Difference(syncer.manager.store.Clock.GetStaleCount(), &mapState)
syncer.manager.store.Clock.Merge(mapState.Vectors) syncer.manager.store.Clock.Merge(mapState.Vectors)
@ -164,9 +171,6 @@ func (t *TwoPhaseSyncer) RecvMessage(msg []byte) error {
func (t *TwoPhaseSyncer) Complete() { func (t *TwoPhaseSyncer) Complete() {
logging.Log.WriteInfof("SYNC COMPLETED") logging.Log.WriteInfof("SYNC COMPLETED")
if t.state >= MERGE {
t.manager.store.Clock.IncrementClock()
}
} }
func NewTwoPhaseSyncer(manager *TwoPhaseStoreMeshManager) *TwoPhaseSyncer { func NewTwoPhaseSyncer(manager *TwoPhaseStoreMeshManager) *TwoPhaseSyncer {
@ -181,7 +185,6 @@ func NewTwoPhaseSyncer(manager *TwoPhaseStoreMeshManager) *TwoPhaseSyncer {
return &TwoPhaseSyncer{ return &TwoPhaseSyncer{
manager: manager, manager: manager,
state: HASH, state: HASH,
mapState: manager.store.GenerateMessage(),
generateMessageFSM: generateMessageFsm, generateMessageFSM: generateMessageFsm,
} }
} }

View File

@ -37,11 +37,6 @@ func (s *SyncerImpl) Sync(meshId string) error {
correspondingMesh.Prune() correspondingMesh.Prune()
if self != nil && self.GetType() == conf.PEER_ROLE && !s.manager.HasChanges(meshId) && s.infectionCount == 0 {
logging.Log.WriteInfof("No changes for %s", meshId)
return nil
}
before := time.Now() before := time.Now()
s.manager.GetRouteManager().UpdateRoutes() s.manager.GetRouteManager().UpdateRoutes()