diskserver

package
v0.0.0-...-e27f3f3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartLogTemplate = "begin: host=[%s] remoteRealIP=[%s] method=[%s] url=[%s] start_time=[%s] form_data=[%s] \n"
	EndLogTemplate   = "" /* 139-byte string literal not displayed */
	TimeFormat       = "2006-01-02 15:04:05"

	RespBodyTypeJson   = "json"
	RespBodyTypeString = "string"
)
View Source
const (
	HeaderXRealIP = "x-real-ip"
)
View Source
const (
	MAX_TTL_VOLUME_REMOVAL_DELAY = 10 // 10 minutes
)

Variables

View Source
var (
	ErrorNotFound = errors.New("not found")
)

Functions

func Logger

func Logger(ctx *Context)

service log

func Summary

func Summary(w http.ResponseWriter, ctx *Context)

Types

type Context

type Context struct {
	RemoteRealIP   string
	Host           string
	Start          time.Time
	ProcessTime    int64
	FormValues     string
	Request        *http.Request
	RespHttpStatus int
	Err            error
	RespBodyType   string
	RespBody       string
	RespBodyJson   interface{}
}

func NewContext

func NewContext(r *http.Request) *Context

type DiskServer

type DiskServer struct {
	Port            *int
	Ip              *string
	MaxCpu          *int
	DataCenter      *string
	Rack            *string
	Folders         []string
	FolderMaxLimits []int
	Debug           *bool
	Router          *mux.Router
	Disk            *diskopt.Disk
	CurrentLeader   string
	ManageNode      []string
	DiskServerLock  sync.RWMutex
	PulseSeconds    *int
}

func NewDiskServer

func NewDiskServer() *DiskServer

func (*DiskServer) AssignVolumeHandler

func (d *DiskServer) AssignVolumeHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) CreateDiskOpt

func (s *DiskServer) CreateDiskOpt()

CreateDiskOpt 创建新磁盘

func (*DiskServer) DeleteHandler

func (d *DiskServer) DeleteHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) DistributedOperation

func (s *DiskServer) DistributedOperation(masterNode string, volumeId util.VIDType, op func(location Location) error) error

func (*DiskServer) GetHandler

func (d *DiskServer) GetHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) Heartbeat

func (s *DiskServer) Heartbeat()

Heartbeat 开启心跳

func (*DiskServer) PostHandler

func (d *DiskServer) PostHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) RegistRouter

func (s *DiskServer) RegistRouter()

func (*DiskServer) ReplicatedDelete

func (d *DiskServer) ReplicatedDelete(masterNode string,
	volumeId util.VIDType, n *needle.Needle, r *http.Request) (uint32, error)

func (*DiskServer) ReplicatedWrite

func (s *DiskServer) ReplicatedWrite(masterNode string, volumeId util.VIDType, n *needle.Needle,
	r *http.Request) (size uint32, isUnchanged bool, errorStatus error)

func (*DiskServer) StartServer

func (s *DiskServer) StartServer() bool

StartServer 启动服务

func (*DiskServer) StatusHandler

func (s *DiskServer) StatusHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) VacuumVolumeCheckHandler

func (d *DiskServer) VacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) VacuumVolumeCommitHandler

func (d *DiskServer) VacuumVolumeCommitHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) VacuumVolumeCompactHandler

func (d *DiskServer) VacuumVolumeCompactHandler(w http.ResponseWriter, r *http.Request)

func (*DiskServer) VolumeDeleteHandler

func (d *DiskServer) VolumeDeleteHandler(w http.ResponseWriter, r *http.Request)

type DistributedOperationResult

type DistributedOperationResult map[string]error

func (DistributedOperationResult) Error

func (dr DistributedOperationResult) Error() error

type Location

type Location struct {
	Url string `json:"url,omitempty"`
}

type LookupResult

type LookupResult struct {
	VolumeId  string     `json:"volumeId,omitempty"`
	Locations []Location `json:"locations,omitempty"`
	Error     string     `json:"error,omitempty"`
}

func Lookup

func Lookup(server string, vid string) (ret *LookupResult, err error)

type RemoteResult

type RemoteResult struct {
	Host  string
	Error error
}

type UploadResult

type UploadResult struct {
	Name  string `json:"name,omitempty"`
	Size  uint32 `json:"size,omitempty"`
	Error string `json:"error,omitempty"`
	ETag  string `json:"eTag,omitempty"`
}

func Upload

func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool, mtype string,
	pairMap map[string]string, jwt security.EncodedJwt) (*UploadResult, error)

type VidCache

type VidCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*VidCache) Get

func (vc *VidCache) Get(vid string) ([]Location, error)

func (*VidCache) Set

func (vc *VidCache) Set(vid string, locations []Location, duration time.Duration)

type VidInfo

type VidInfo struct {
	Locations       []Location
	NextRefreshTime time.Time
}

Jump to

Keyboard shortcuts

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