Zhen Ye 61b6ca5b73
enhance: add in mem shard manager (#41749)
issue: #41544

- Implement in-memory shard manager to maintain the shard state at write
ahead.
- Remove all rpc and meta operation at write ahead, make the segment
assignment logic only use wal and memory.
- Refactor global stats management, add node-level flush policy.
- Fix the recovery storage inconsistency bug when graceful close.

Signed-off-by: chyezh <chyezh@outlook.com>
2025-05-13 12:04:56 +08:00

46 lines
1.6 KiB
Go

//go:build test
// +build test
package resource
import (
"testing"
"github.com/milvus-io/milvus/internal/flushcommon/syncmgr"
"github.com/milvus-io/milvus/internal/flushcommon/writebuffer"
"github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/segment/stats"
shardstats "github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/shard/stats"
tinspector "github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/timetick/inspector"
"github.com/milvus-io/milvus/internal/types"
"github.com/milvus-io/milvus/internal/util/idalloc"
"github.com/milvus-io/milvus/pkg/v2/log"
"github.com/milvus-io/milvus/pkg/v2/util/syncutil"
)
// InitForTest initializes the singleton of resources for test.
func InitForTest(t *testing.T, opts ...optResourceInit) {
r = &resourceImpl{
logger: log.With(),
}
for _, opt := range opts {
opt(r)
}
if r.chunkManager != nil {
r.syncMgr = syncmgr.NewSyncManager(r.chunkManager)
r.wbMgr = writebuffer.NewManager(r.syncMgr)
}
if r.mixCoordClient != nil {
r.timestampAllocator = idalloc.NewTSOAllocator(r.mixCoordClient)
r.idAllocator = idalloc.NewIDAllocator(r.mixCoordClient)
} else {
f := syncutil.NewFuture[types.MixCoordClient]()
f.Set(idalloc.NewMockRootCoordClient(t))
r.mixCoordClient = f
r.timestampAllocator = idalloc.NewTSOAllocator(r.mixCoordClient)
r.idAllocator = idalloc.NewIDAllocator(r.mixCoordClient)
}
r.segmentAssignStatsManager = stats.NewStatsManager()
r.segmentStatsManager = shardstats.NewStatsManager()
r.timeTickInspector = tinspector.NewTimeTickSyncInspector()
}