Rename sync tree
This commit is contained in:
parent
b97df8d5f6
commit
d1fe82b086
@ -132,7 +132,7 @@ func (d *diffSyncer) syncWithPeer(ctx context.Context, p peer.Peer) (err error)
|
||||
|
||||
d.syncStatus.RemoveAllExcept(p.Id(), filteredIds, stateCounter)
|
||||
|
||||
d.pingTreesInCache(ctx, p.Id(), filteredIds)
|
||||
d.syncTrees(ctx, p.Id(), filteredIds)
|
||||
|
||||
d.log.Info("sync done:", zap.Int("newIds", len(newIds)),
|
||||
zap.Int("changedIds", len(changedIds)),
|
||||
@ -143,7 +143,7 @@ func (d *diffSyncer) syncWithPeer(ctx context.Context, p peer.Peer) (err error)
|
||||
return
|
||||
}
|
||||
|
||||
func (d *diffSyncer) pingTreesInCache(ctx context.Context, peerId string, trees []string) {
|
||||
func (d *diffSyncer) syncTrees(ctx context.Context, peerId string, trees []string) {
|
||||
for _, tId := range trees {
|
||||
tree, err := d.cache.GetTree(ctx, d.spaceId, tId)
|
||||
if err != nil {
|
||||
@ -159,10 +159,10 @@ func (d *diffSyncer) pingTreesInCache(ctx context.Context, peerId string, trees
|
||||
// it may be already there (i.e. loaded)
|
||||
// and build func will not be called, thus we won't sync the tree
|
||||
// therefore we just do it manually
|
||||
if err = syncTree.Ping(ctx, peerId); err != nil {
|
||||
d.log.WarnCtx(ctx, "synctree.Ping error", zap.Error(err), zap.String("treeId", tId))
|
||||
if err = syncTree.SyncWithPeer(ctx, peerId); err != nil {
|
||||
d.log.WarnCtx(ctx, "synctree.SyncWithPeer error", zap.Error(err), zap.String("treeId", tId))
|
||||
} else {
|
||||
d.log.DebugCtx(ctx, "success tree ping", zap.String("treeId", tId))
|
||||
d.log.DebugCtx(ctx, "success synctree.SyncWithPeer", zap.String("treeId", tId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,20 +380,6 @@ func (mr *MockSyncTreeMockRecorder) Lock() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Lock", reflect.TypeOf((*MockSyncTree)(nil).Lock))
|
||||
}
|
||||
|
||||
// Ping mocks base method.
|
||||
func (m *MockSyncTree) Ping(arg0 context.Context, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Ping", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Ping indicates an expected call of Ping.
|
||||
func (mr *MockSyncTreeMockRecorder) Ping(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ping", reflect.TypeOf((*MockSyncTree)(nil).Ping), arg0, arg1)
|
||||
}
|
||||
|
||||
// RLock mocks base method.
|
||||
func (m *MockSyncTree) RLock() {
|
||||
m.ctrl.T.Helper()
|
||||
@ -472,6 +458,20 @@ func (mr *MockSyncTreeMockRecorder) Storage() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Storage", reflect.TypeOf((*MockSyncTree)(nil).Storage))
|
||||
}
|
||||
|
||||
// SyncWithPeer mocks base method.
|
||||
func (m *MockSyncTree) SyncWithPeer(arg0 context.Context, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SyncWithPeer", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SyncWithPeer indicates an expected call of SyncWithPeer.
|
||||
func (mr *MockSyncTreeMockRecorder) SyncWithPeer(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncWithPeer", reflect.TypeOf((*MockSyncTree)(nil).SyncWithPeer), arg0, arg1)
|
||||
}
|
||||
|
||||
// Unlock mocks base method.
|
||||
func (m *MockSyncTree) Unlock() {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@ -39,7 +39,7 @@ type SyncTree interface {
|
||||
objecttree.ObjectTree
|
||||
synchandler.SyncHandler
|
||||
ListenerSetter
|
||||
Ping(ctx context.Context, peerId string) (err error)
|
||||
SyncWithPeer(ctx context.Context, peerId string) (err error)
|
||||
}
|
||||
|
||||
// SyncTree sends head updates to sync service and also sends new changes to update listener
|
||||
@ -344,7 +344,7 @@ func (s *syncTree) checkAlive() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s *syncTree) Ping(ctx context.Context, peerId string) (err error) {
|
||||
func (s *syncTree) SyncWithPeer(ctx context.Context, peerId string) (err error) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
headUpdate := s.syncClient.CreateHeadUpdate(s, nil)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user