Skip to content

Commit

Permalink
cluster/store: set stable and logs store
Browse files Browse the repository at this point in the history
  • Loading branch information
gernest committed Feb 27, 2024
1 parent 8c7adf2 commit f6d9f1d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/cluster/snapshots/snapshots.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package raft
package snapshots

import (
"bufio"
Expand Down
26 changes: 25 additions & 1 deletion internal/cluster/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/apache/arrow/go/v15/arrow/memory"
"github.com/hashicorp/raft"
v1 "github.com/vinceanalytics/vince/gen/go/vince/v1"
"github.com/vinceanalytics/vince/internal/cluster/log"
"github.com/vinceanalytics/vince/internal/cluster/snapshots"
"github.com/vinceanalytics/vince/internal/db"
"github.com/vinceanalytics/vince/internal/index/primary"
"github.com/vinceanalytics/vince/internal/indexer"
Expand Down Expand Up @@ -148,7 +150,8 @@ type Store struct {

raftLog raft.LogStore // Persistent log store.
raftStable raft.StableStore // Persistent k-v store.
snapshotStore SnapshotStore // Snapshot store.
snapshotStore *snapshots.Store // Snapshot store.
boltStore *log.Log

// Raft changes observer
leaderObserversMu sync.RWMutex
Expand Down Expand Up @@ -250,5 +253,26 @@ func (s *Store) Open() error {
nt := raft.NewNetworkTransport(NewTransport(s.ly), connectionPoolCount, connectionTimeout, nil)
s.raftTn = NewNodeTransport(nt)

s.snapshotStore, err = snapshots.New(s.snapshotDir, 2)
if err != nil {
return err
}
s.boltStore, err = log.New(filepath.Join(s.raftDir, raftDBPath), false)
if err != nil {
return err
}
s.raftStable = s.boltStore
s.raftLog, err = raft.NewLogCache(raftLogCacheSize, s.boltStore)
if err != nil {
return err
}
return nil
}

// pathExists returns true if the given path exists.
func pathExists(p string) bool {
if _, err := os.Lstat(p); err != nil && os.IsNotExist(err) {
return false
}
return true
}

0 comments on commit f6d9f1d

Please sign in to comment.