mirror of https://github.com/prometheus/prometheus
Rename to OpenHeadBlock
parent
cabd7e4ebc
commit
8aba95048a
2
block.go
2
block.go
|
@ -128,7 +128,7 @@ func findBlocks(path string) ([]*persistedBlock, *HeadBlock, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Errorf("invalid directory name")
|
return nil, nil, errors.Errorf("invalid directory name")
|
||||||
}
|
}
|
||||||
head, err = NewHeadBlock(p, int64(ts))
|
head, err = OpenHeadBlock(p, int64(ts))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
4
db.go
4
db.go
|
@ -206,7 +206,7 @@ func OpenShard(path string, logger log.Logger) (*Shard, error) {
|
||||||
if head == nil {
|
if head == nil {
|
||||||
fmt.Println("creating new head", baset)
|
fmt.Println("creating new head", baset)
|
||||||
|
|
||||||
head, err = NewHeadBlock(filepath.Join(path, fmt.Sprintf("%d", baset)), baset)
|
head, err = OpenHeadBlock(filepath.Join(path, fmt.Sprintf("%d", baset)), baset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ func (s *Shard) persist() error {
|
||||||
|
|
||||||
// Set new head block.
|
// Set new head block.
|
||||||
head := s.head
|
head := s.head
|
||||||
newHead, err := NewHeadBlock(filepath.Join(s.path, fmt.Sprintf("%d", head.stats.MaxTime)), head.stats.MaxTime)
|
newHead, err := OpenHeadBlock(filepath.Join(s.path, fmt.Sprintf("%d", head.stats.MaxTime)), head.stats.MaxTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.mtx.Unlock()
|
s.mtx.Unlock()
|
||||||
return err
|
return err
|
||||||
|
|
4
head.go
4
head.go
|
@ -29,8 +29,8 @@ type HeadBlock struct {
|
||||||
stats BlockStats
|
stats BlockStats
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHeadBlock creates a new empty head block.
|
// OpenHeadBlock creates a new empty head block.
|
||||||
func NewHeadBlock(dir string, baseTime int64) (*HeadBlock, error) {
|
func OpenHeadBlock(dir string, baseTime int64) (*HeadBlock, error) {
|
||||||
wal, err := OpenWAL(dir)
|
wal, err := OpenWAL(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
13
wal.go
13
wal.go
|
@ -122,11 +122,14 @@ type walEncoder struct {
|
||||||
buf []byte
|
buf []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// walPageBytes is the alignment for flushing records to the backing Writer.
|
const (
|
||||||
// It should be a multiple of the minimum sector size so that WAL can safely
|
minSectorSize = 512
|
||||||
// distinguish between torn writes and ordinary data corruption.
|
|
||||||
const minSectorSize = 512
|
// walPageBytes is the alignment for flushing records to the backing Writer.
|
||||||
const walPageBytes = 8 * minSectorSize
|
// It should be a multiple of the minimum sector size so that WAL can safely
|
||||||
|
// distinguish between torn writes and ordinary data corruption.
|
||||||
|
walPageBytes = 8 * minSectorSize
|
||||||
|
)
|
||||||
|
|
||||||
func newWALEncoder(f *os.File) (*walEncoder, error) {
|
func newWALEncoder(f *os.File) (*walEncoder, error) {
|
||||||
offset, err := f.Seek(0, os.SEEK_CUR)
|
offset, err := f.Seek(0, os.SEEK_CUR)
|
||||||
|
|
|
@ -178,7 +178,7 @@ func BenchmarkWALReadIntoHead(b *testing.B) {
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
head, err := NewHeadBlock(d, 0)
|
head, err := OpenHeadBlock(d, 0)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
|
|
||||||
stat, _ := head.wal.f.Stat()
|
stat, _ := head.wal.f.Stat()
|
||||||
|
|
Loading…
Reference in New Issue