Skip to content

Commit

Permalink
use new wal
Browse files Browse the repository at this point in the history
  • Loading branch information
vadiminshakov committed Dec 15, 2024
1 parent b7dad4e commit 14ae414
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.2.0
github.com/stretchr/testify v1.9.0
github.com/vadiminshakov/gowal v0.0.0-20240924193609-26914d93ef10
github.com/vadiminshakov/gowal v0.0.1
google.golang.org/grpc v1.50.0
google.golang.org/protobuf v1.28.1
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ github.com/vadiminshakov/gowal v0.0.0-20240915145658-65d881f4a5e4 h1:cPrEApgpt5Z
github.com/vadiminshakov/gowal v0.0.0-20240915145658-65d881f4a5e4/go.mod h1:MixWBivF0qsRLcHGyfRFPbujtxYkpD1VNcO0yD7Xla0=
github.com/vadiminshakov/gowal v0.0.0-20240924193609-26914d93ef10 h1:gHh4fpcJLCBIzYRDD2kSenlNI1TaOjeFjqTVvfIgoIE=
github.com/vadiminshakov/gowal v0.0.0-20240924193609-26914d93ef10/go.mod h1:MixWBivF0qsRLcHGyfRFPbujtxYkpD1VNcO0yD7Xla0=
github.com/vadiminshakov/gowal v0.0.1 h1:lNcc4YaPX9ocYnpa9FQ6VkEbUD+iVB2So6Q8+OewYOA=
github.com/vadiminshakov/gowal v0.0.1/go.mod h1:MixWBivF0qsRLcHGyfRFPbujtxYkpD1VNcO0yD7Xla0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
24 changes: 18 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import (
"syscall"
)

const (
walDir string = "wal"
walSegmentPrefix string = "msgs_"
walSegmentThreshold int = 10000
walMaxSegments int = 100
walIsInSyncDiskMode bool = true
)

func main() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
Expand All @@ -25,21 +33,25 @@ func main() {
panic(err)
}

mlog, err := gowal.NewWAL("wal", "msgs_")
if err != nil {
panic(err)
walConfig := gowal.Config{
Dir: walDir,
Prefix: walSegmentPrefix,
SegmentThreshold: walSegmentThreshold,
MaxSegments: walMaxSegments,
IsInSyncDiskMode: walIsInSyncDiskMode,
}
vlog, err := gowal.NewWAL("wal", "votes_")

wal, err := gowal.NewWAL(walConfig)
if err != nil {
panic(err)
}

coordImpl, err := coordinator.New(conf, mlog, vlog, database)
coordImpl, err := coordinator.New(conf, wal, database)
if err != nil {
panic(err)
}

committer := commitalgo.NewCommitter(database, conf.CommitType, mlog, hooks.Propose, hooks.Commit, conf.Timeout)
committer := commitalgo.NewCommitter(database, conf.CommitType, wal, hooks.Propose, hooks.Commit, conf.Timeout)
cohortImpl := cohort.NewCohort(committer, cohort.Mode(conf.CommitType))

s, err := server.New(conf, cohortImpl, coordImpl, database)
Expand Down
23 changes: 19 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,14 @@ func startnodes(block int, commitType pb.CommitType) func() error {
database, err := db.New(node.DBPath)
failfast(err)

c, err := gowal.NewWAL("./tmp/cohort/"+strconv.Itoa(i), "msgs")
walConfig := gowal.Config{
Dir: "./tmp/cohort/" + strconv.Itoa(i),
Prefix: "msgs_",
SegmentThreshold: 100,
MaxSegments: 100,
IsInSyncDiskMode: false,
}
c, err := gowal.NewWAL(walConfig)
failfast(err)

ct := server.TWO_PHASE
Expand Down Expand Up @@ -312,10 +319,18 @@ func startnodes(block int, commitType pb.CommitType) func() error {
database, err := db.New(coordConfig.DBPath)
failfast(err)

c, err := gowal.NewWAL("./tmp/coord/"+strconv.Itoa(i), "msgs")
v, err := gowal.NewWAL("./tmp/coord/"+strconv.Itoa(i), "votes")
walConfig := gowal.Config{
Dir: "./tmp/coord/msgs" + strconv.Itoa(i),
Prefix: "msgs",
SegmentThreshold: 100,
MaxSegments: 100,
IsInSyncDiskMode: false,
}

c, err := gowal.NewWAL(walConfig)
failfast(err)
coord, err := coordinator.New(coordConfig, c, v, database)

coord, err := coordinator.New(coordConfig, c, database)
failfast(err)

coordServer, err := server.New(coordConfig, nil, coord, database)
Expand Down

0 comments on commit 14ae414

Please sign in to comment.