Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove redundant FindLogStream function #918

Open
wants to merge 1 commit into
base: tests_log_stream_uncommit_report
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func (adm *Admin) hasSealedReplica(ctx context.Context, lsdesc *varlogpb.LogStre
continue
}

lsmeta, ok := meta.FindLogStream(lsdesc.LogStreamID)
lsmeta, ok := meta.GetLogStream(lsdesc.LogStreamID)
if !ok {
continue
}
Expand Down
9 changes: 0 additions & 9 deletions proto/snpb/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ func (snmd *StorageNodeMetadataDescriptor) GetLogStream(logStreamID types.LogStr
return LogStreamReplicaMetadataDescriptor{}, false
}

func (snmd StorageNodeMetadataDescriptor) FindLogStream(logStreamID types.LogStreamID) (LogStreamReplicaMetadataDescriptor, bool) {
for _, lsmeta := range snmd.GetLogStreamReplicas() {
if lsmeta.GetLogStreamID() == logStreamID {
return lsmeta, true
}
}
return LogStreamReplicaMetadataDescriptor{}, false
}

func (lsrmd *LogStreamReplicaMetadataDescriptor) Head() varlogpb.LogEntryMeta {
if lsrmd == nil {
return varlogpb.LogEntryMeta{}
Expand Down
9 changes: 4 additions & 5 deletions tests/it/management/management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func TestSyncLogStream(t *testing.T) {
if err != nil {
return false
}
lsmd, exist := snmd.FindLogStream(lsID)
lsmd, exist := snmd.GetLogStream(lsID)
if !exist {
return false
}
Expand Down Expand Up @@ -544,7 +544,6 @@ func TestSyncLogStreamWithAutoUnseal(t *testing.T) {
assert.True(t, ok)
return lsrmd.LocalHighWatermark.GLSN == types.GLSN(numLogs) &&
lsrmd.Status == varlogpb.LogStreamStatusRunning

}, 5*time.Second, 100*time.Millisecond)
}

Expand Down Expand Up @@ -706,23 +705,23 @@ func TestGCZombieLogStream(t *testing.T) {
meta, err = snMCL.GetMetadata(context.TODO())
So(err, ShouldBeNil)

_, exist := meta.FindLogStream(lsID)
_, exist := meta.GetLogStream(lsID)
So(exist, ShouldBeTrue)

Convey("Then the LogStream should removed after GCTimeout", func(ctx C) {
time.Sleep(gcTimeout / 2)
meta, err := snMCL.GetMetadata(context.TODO())
So(err, ShouldBeNil)

_, exist := meta.FindLogStream(lsID)
_, exist := meta.GetLogStream(lsID)
So(exist, ShouldBeTrue)

So(testutil.CompareWait(func() bool {
meta, err := snMCL.GetMetadata(context.TODO())
if err != nil {
return false
}
_, exist := meta.FindLogStream(lsID)
_, exist := meta.GetLogStream(lsID)
return !exist
}, gcTimeout), ShouldBeTrue)
})
Expand Down
Loading