streamclient

package
v0.0.0-...-e603270 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB

	HardMaxExtentSize = 3 * GB //Hard limit of extent size
)
View Source
const (
	HintReadThrough        = 1 << 0
	HintReadFromCache byte = 1 << 1
)

hint

Variables

This section is empty.

Functions

This section is empty.

Types

type AutumnEntryIter

type AutumnEntryIter struct {
	// contains filtered or unexported fields
}

func (*AutumnEntryIter) HasNext

func (iter *AutumnEntryIter) HasNext() (bool, error)

func (*AutumnEntryIter) Next

func (iter *AutumnEntryIter) Next() (block, uint64, uint32, uint32)

type AutumnStreamClient

type AutumnStreamClient struct {
	utils.SafeMutex //protect streamInfo from allocStream, Truncate, PunchHole
	// contains filtered or unexported fields
}

for single stream

func NewStreamClient

func NewStreamClient(sm *smclient.SMClient, em *smclient.ExtentManager, maxExtentSize uint32, streamID uint64, streamLock StreamLock) *AutumnStreamClient

func (*AutumnStreamClient) Append

func (sc *AutumnStreamClient) Append(ctx context.Context, blocks []block, mustSync bool) (uint64, []uint32, uint32, error)

func (*AutumnStreamClient) Close

func (sc *AutumnStreamClient) Close()

func (*AutumnStreamClient) CommitEnd

func (sc *AutumnStreamClient) CommitEnd() uint32

func (*AutumnStreamClient) Connect

func (sc *AutumnStreamClient) Connect() error

func (*AutumnStreamClient) MustAllocNewExtent

func (sc *AutumnStreamClient) MustAllocNewExtent() error

alloc new extent, and reset sc.end = 0

func (*AutumnStreamClient) NewLogEntryIter

func (sc *AutumnStreamClient) NewLogEntryIter(opts ...ReadOption) LogEntryIter

func (*AutumnStreamClient) PunchHoles

func (sc *AutumnStreamClient) PunchHoles(ctx context.Context, extentIDs []uint64) error

func (*AutumnStreamClient) Read

func (sc *AutumnStreamClient) Read(ctx context.Context, extentID uint64, offset uint32, numOfBlocks uint32) ([]block, uint32, error)

func (*AutumnStreamClient) ReadLastBlock

func (sc *AutumnStreamClient) ReadLastBlock(ctx context.Context) (block, error)

func (*AutumnStreamClient) SealedLength

func (sc *AutumnStreamClient) SealedLength(extentID uint64) (uint64, error)

func (*AutumnStreamClient) StreamInfo

func (sc *AutumnStreamClient) StreamInfo() *pb.StreamInfo

func (*AutumnStreamClient) Truncate

func (sc *AutumnStreamClient) Truncate(ctx context.Context, extentID uint64) error

type LogEntryIter

type LogEntryIter interface {
	HasNext() (bool, error)
	//(block, offset, end)
	Next() (data block, extentID uint64, offset uint32, end uint32)
}

type MockBlockReader

type MockBlockReader struct {
	utils.SafeMutex //protect exs
}

type MockLockEntryIter

type MockLockEntryIter struct {
	// contains filtered or unexported fields
}

func (*MockLockEntryIter) HasNext

func (iter *MockLockEntryIter) HasNext() (bool, error)

func (*MockLockEntryIter) Next

func (iter *MockLockEntryIter) Next() (block, uint64, uint32, uint32)

type MockStreamClient

type MockStreamClient struct {
	StreamClient

	ID uint64

	utils.SafeMutex
	// contains filtered or unexported fields
}

func (*MockStreamClient) Append

func (client *MockStreamClient) Append(ctx context.Context, blocks []block, mustSync bool) (uint64, []uint32, uint32, error)

block API

func (*MockStreamClient) CheckCommitLength

func (client *MockStreamClient) CheckCommitLength() error

func (*MockStreamClient) Close

func (client *MockStreamClient) Close()

func (*MockStreamClient) CommitEnd

func (client *MockStreamClient) CommitEnd() uint32

func (*MockStreamClient) Connect

func (client *MockStreamClient) Connect() error

func (*MockStreamClient) NewLogEntryIter

func (client *MockStreamClient) NewLogEntryIter(opts ...ReadOption) LogEntryIter

func (*MockStreamClient) PunchHoles

func (client *MockStreamClient) PunchHoles(ctx context.Context, extentIDs []uint64) error

func (*MockStreamClient) Read

func (client *MockStreamClient) Read(ctx context.Context, extentID uint64, offset uint32, numOfBlocks uint32) ([]block, uint32, error)

func (*MockStreamClient) ReadLastBlock

func (client *MockStreamClient) ReadLastBlock(ctx context.Context) (block, error)

func (*MockStreamClient) SealedLength

func (client *MockStreamClient) SealedLength(extentID uint64) (uint64, error)

func (*MockStreamClient) StreamInfo

func (client *MockStreamClient) StreamInfo() *pb.StreamInfo

func (*MockStreamClient) Truncate

func (client *MockStreamClient) Truncate(ctx context.Context, extentID uint64) error

type ReadOption

type ReadOption func(*readOption)

func WithReadFrom

func WithReadFrom(extentID uint64, offset uint32, maxExtents int) ReadOption

func WithReadFromStart

func WithReadFromStart(MaxExtentRead int) ReadOption

type StreamClient

type StreamClient interface {
	Connect() error
	Close()
	//AppendEntries(ctx context.Context, entries []block, mustSync bool) (uint64, uint32, error)
	ReadLastBlock(ctx context.Context) (block, error)
	Append(ctx context.Context, blocks []block, mustSync bool) (extentID uint64, offsets []uint32, end uint32, err error)
	PunchHoles(ctx context.Context, extentIDs []uint64) error
	NewLogEntryIter(opt ...ReadOption) LogEntryIter
	//truncate extent BEFORE extentID
	Truncate(ctx context.Context, extentID uint64) error
	//CommitEnd() is offset of current extent
	CommitEnd() uint32 //FIMME:remove this
	//total number of extents
	StreamInfo() *pb.StreamInfo
	Read(ctx context.Context, extentID uint64, offset uint32, numOfBlocks uint32) ([]block, uint32, error)
	SealedLength(extentID uint64) (uint64, error)
}

func NewMockStreamClient

func NewMockStreamClient(suffix string) StreamClient

func OpenMockStreamClient

func OpenMockStreamClient(si pb.StreamInfo, br *MockBlockReader) StreamClient

only open log file

type StreamLock

type StreamLock struct {
	// contains filtered or unexported fields
}

func MutexToLock

func MutexToLock(mutex *concurrency.Mutex) StreamLock

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL