From a84aa135e3b7982b269197c9f9ec27f6beaf7287 Mon Sep 17 00:00:00 2001 From: Injun Song Date: Sun, 24 Nov 2024 01:31:10 +0900 Subject: [PATCH] refactor: remove redundant FindLogStream function The FindLogStream function in proto/snpb/metadata.go was removed as it was redundant and no longer needed. The functionality is already covered by the GetLogStream method. --- internal/admin/admin.go | 2 +- proto/snpb/metadata.go | 9 --------- tests/it/management/management_test.go | 9 ++++----- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/internal/admin/admin.go b/internal/admin/admin.go index 8aafa85ff..9107735fa 100644 --- a/internal/admin/admin.go +++ b/internal/admin/admin.go @@ -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 } diff --git a/proto/snpb/metadata.go b/proto/snpb/metadata.go index eb9b83e8b..3e89df940 100644 --- a/proto/snpb/metadata.go +++ b/proto/snpb/metadata.go @@ -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{} diff --git a/tests/it/management/management_test.go b/tests/it/management/management_test.go index 69f8e9b88..0aa09bf52 100644 --- a/tests/it/management/management_test.go +++ b/tests/it/management/management_test.go @@ -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 } @@ -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) } @@ -706,7 +705,7 @@ 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) { @@ -714,7 +713,7 @@ 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) So(testutil.CompareWait(func() bool { @@ -722,7 +721,7 @@ func TestGCZombieLogStream(t *testing.T) { if err != nil { return false } - _, exist := meta.FindLogStream(lsID) + _, exist := meta.GetLogStream(lsID) return !exist }, gcTimeout), ShouldBeTrue) })