chunkserver

package
v0.0.0-...-930013b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RW_STATUS  = 1
	RO_STATUS  = 2
	ERR_STATUS = 3

	GLOBAL_NORMAL_STATUS = 0
	GLOBAL_READ_STAUS    = 8
)
View Source
const (
	HEADERSIZE = 6
)

Variables

View Source
var (
	PUT    uint8 = 0x00
	GET    uint8 = 0x01
	DELETE uint8 = 0x02
	PING   uint8 = 0x0A
)
View Source
var (
	CONN_POOL_CLOSED_ERR = errors.New("connection pool is closed")
)
View Source
var (
	FIDS_EMPTY_ERR = fmt.Errorf("fids is empty")
)

Functions

This section is empty.

Types

type ChunkServer

type ChunkServer struct {
	GroupId        int32
	Ip             string
	Port           int64
	Status         int8
	GlobalStatus   int8
	TotalFreeSpace int64
	MaxFreeSpace   int64
	PendingWrites  int
	WritingCount   int
}

func (*ChunkServer) DeleteData

func (cs *ChunkServer) DeleteData(groupId, fileId string, conn *PooledConn) error

func (*ChunkServer) GetData

func (cs *ChunkServer) GetData(miv *meta.MetaInfoValue, conn *PooledConn) ([]byte, error)

func (*ChunkServer) HostInfoEqual

func (csi *ChunkServer) HostInfoEqual(another *ChunkServer) bool

func (*ChunkServer) Ping

func (cs *ChunkServer) Ping(conn *PooledConn) error

func (*ChunkServer) PutData

func (cs *ChunkServer) PutData(data []byte, conn *PooledConn, fileId uint64) error

type ChunkServerConnectionPool

type ChunkServerConnectionPool struct {
	Pools map[string]*ConnectionPool // <ip:port>:connectionpool
	// contains filtered or unexported fields
}

func NewChunkServerConnectionPool

func NewChunkServerConnectionPool() *ChunkServerConnectionPool

func (*ChunkServerConnectionPool) AddExistPool

func (cscp *ChunkServerConnectionPool) AddExistPool(key string, pool *ConnectionPool)

func (*ChunkServerConnectionPool) AddPool

func (cscp *ChunkServerConnectionPool) AddPool(chunkserver *ChunkServer, capacity int) error

func (*ChunkServerConnectionPool) CheckConnPool

func (cscp *ChunkServerConnectionPool) CheckConnPool(chunkserver *ChunkServer) error

chunkserver closed, the state of connection in pool is close_wait, need to close those connection

func (*ChunkServerConnectionPool) GetConn

func (cscp *ChunkServerConnectionPool) GetConn(chunkserver *ChunkServer) (PoolConnection, error)

func (*ChunkServerConnectionPool) ReleaseConn

func (cscp *ChunkServerConnectionPool) ReleaseConn(pc PoolConnection)

func (*ChunkServerConnectionPool) RemoveAndClosePool

func (cscp *ChunkServerConnectionPool) RemoveAndClosePool(chunkserver *ChunkServer) error

func (*ChunkServerConnectionPool) RemovePool

func (cscp *ChunkServerConnectionPool) RemovePool(chunkserver *ChunkServer)

type ChunkServerGroups

type ChunkServerGroups struct {
	GroupMap map[string][]ChunkServer //groupId <> []ChunkServer
}

func (*ChunkServerGroups) GetChunkServerGroup

func (csgs *ChunkServerGroups) GetChunkServerGroup(groupId string) ([]ChunkServer, bool)

func (*ChunkServerGroups) Print

func (csgs *ChunkServerGroups) Print()

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(addr string) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) IsClosed

func (c *Conn) IsClosed() bool

type ConnectionPool

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

func NewConnectionPool

func NewConnectionPool(name string, capacity int, idleTimeout time.Duration) *ConnectionPool

func (*ConnectionPool) Capacity

func (cp *ConnectionPool) Capacity() int64

func (*ConnectionPool) Close

func (cp *ConnectionPool) Close()

Close will close the pool and wait for connections to be returned before exiting

func (*ConnectionPool) Get

func (cp *ConnectionPool) Get() (PoolConnection, error)

func (*ConnectionPool) IdleTimeout

func (cp *ConnectionPool) IdleTimeout() time.Duration

func (*ConnectionPool) MaxCap

func (cp *ConnectionPool) MaxCap() int64

func (*ConnectionPool) Open

func (cp *ConnectionPool) Open(connFactory CreateConnectionFunc)

Open must be cal before starting to use the pool

func (*ConnectionPool) Put

func (cp *ConnectionPool) Put(conn PoolConnection)

func (*ConnectionPool) SetCapacity

func (cp *ConnectionPool) SetCapacity(capacity int) (err error)

func (*ConnectionPool) SetIdleTimeOut

func (cp *ConnectionPool) SetIdleTimeOut(idleTimeout time.Duration)

func (*ConnectionPool) StatsJSON

func (cp *ConnectionPool) StatsJSON() string

func (*ConnectionPool) TryGet

func (cp *ConnectionPool) TryGet() (PoolConnection, error)

func (*ConnectionPool) WaitCount

func (cp *ConnectionPool) WaitCount() int64

func (*ConnectionPool) WaitTime

func (cp *ConnectionPool) WaitTime() time.Duration

type CreateConnectionFunc

type CreateConnectionFunc func(*ConnectionPool) (connection PoolConnection, err error)

CreateConnectionFunc is the factory method to create new connections within the passed ConnectionPool.

func ConnectionCreator

func ConnectionCreator(addr string) CreateConnectionFunc

type Fids

type Fids struct {
	Start uint64 `json:"FidBegin"`
	End   uint64 `json:"FidEnd"`
	// contains filtered or unexported fields
}

[start, end)

func NewFids

func NewFids() *Fids

func (*Fids) GetFid

func (fids *Fids) GetFid() (uint64, error)

func (*Fids) GetFidWait

func (fids *Fids) GetFidWait() (uint64, error)

func (*Fids) IsShortage

func (fids *Fids) IsShortage() bool

func (*Fids) Merge

func (fids *Fids) Merge(start uint64, end uint64, wait bool)

[start,end)

func (*Fids) ReSet

func (fids *Fids) ReSet(start, end uint64)

type HeapElement

type HeapElement struct {
	GroupId       string
	FreeSpace     int64
	PendingWrites int
	WritingCount  int
}

type MinHeap

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

func NewMinHeap

func NewMinHeap(capa int) *MinHeap

func (*MinHeap) AddElement

func (h *MinHeap) AddElement(groupId string, freeSpace int64, pendingWrites int, writingCount int)

func (*MinHeap) BuildMinHeapSecondary

func (h *MinHeap) BuildMinHeapSecondary()

func (*MinHeap) GetElementGroupId

func (h *MinHeap) GetElementGroupId(index int) (string, error)

func (*MinHeap) GetSize

func (h *MinHeap) GetSize() int

func (*MinHeap) MinHeapifySecondary

func (h *MinHeap) MinHeapifySecondary(index int)

type PoolConnection

type PoolConnection interface {
	Close()
	IsClosed() bool
	Recycle()
}

type PooledConn

type PooledConn struct {
	*Conn
	// contains filtered or unexported fields
}

func (*PooledConn) Recycle

func (pc *PooledConn) Recycle()

type Resp

type Resp struct {
	Type int8
	Len  int32
	Data []byte
}

func Parse

func Parse(r *bufio.Reader) (*Resp, error)

func ReadHeader

func ReadHeader(r *bufio.Reader) (*Resp, error)

func (*Resp) Bytes

func (r *Resp) Bytes() ([]byte, error)

Jump to

Keyboard shortcuts

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