Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7d1367
commit cf4038f
Showing
14 changed files
with
246 additions
and
196 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cluster | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
|
||
"github.com/travisjeffery/jocko/commitlog" | ||
) | ||
|
||
type TopicPartition struct { | ||
Topic string `json:"topic"` | ||
Partition int `json:"partition"` | ||
|
||
// broker ids | ||
Replicas []string `json:"replicas"` | ||
Leader string `json:"leader"` | ||
PreferredLeader string `json:"preferred_leader"` | ||
|
||
CommitLog *commitlog.CommitLog `json:"-"` | ||
} | ||
|
||
func (p TopicPartition) String() string { | ||
return fmt.Sprintf("%s-%d", p.Topic, p.Partition) | ||
} | ||
|
||
// OpenCommitLog opens a commit log for the partition at the path. | ||
func (partition *TopicPartition) OpenCommitLog(logDir string) error { | ||
var err error | ||
partition.CommitLog, err = commitlog.New(commitlog.Options{ | ||
Path: path.Join(logDir, partition.String()), | ||
SegmentBytes: 1024, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
if err = partition.CommitLog.Init(); err != nil { | ||
return err | ||
} | ||
if err = partition.CommitLog.Open(); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.