service

package
v0.0.0-...-2108ab1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MinimumReplicaCount = func() int {
	valStr, found := os.LookupEnv("MIN_REPLICA_COUNT")
	var val int
	if !found {
		val = defaultMinimumReplicaCount
	} else {
		var err error
		val, err = strconv.Atoi(valStr)
		if err != nil {
			println("Unable to parse MIN_REPLICA_COUNT: ", err)
			println("Falling back to default value ", defaultMinimumReplicaCount)
			val = defaultMinimumReplicaCount
		}
	}
	return val
}()
View Source
var RedisAddress = func() string {
	val, found := os.LookupEnv("REDIS_ADDRESS")
	if !found {
		val = defaultRedisAddress
	}
	return val
}()
View Source
var RedisDb = func() int {
	valStr, found := os.LookupEnv("REDIS_DB")
	var val int
	if !found {
		val = defaultRedisDB
	} else {
		var err error
		val, err = strconv.Atoi(valStr)
		if err != nil {
			println("Unable to parse REDIS_DB: ", err)
			println("Falling back to default value ", defaultRedisDB)
			val = defaultRedisDB
		}
	}
	return val
}()
View Source
var RedisPassword = func() string {
	val, found := os.LookupEnv("REDIS_PASSWORD")
	if !found {
		val = defaultRedisPassword
	}
	return val
}()

Functions

func BeginDatanodeReplication

func BeginDatanodeReplication(datanodeUuid uuid.UUID) (err error)

func BeginFullReplication

func BeginFullReplication(sourceFileInfo FileInfo, targetFileInfo FileInfo) (err error)

func ChangeDatanodeStatus

func ChangeDatanodeStatus(datanodeUuid uuid.UUID, active bool) error

func CopyFile

func CopyFile(fileName string, copyName string) error

func InitNamespace

func InitNamespace() error

func MoveFile

func MoveFile(fileName string, newFileName string) error

func RegisterDatanode

func RegisterDatanode(info *DatanodeInfo) (datanodeUuid uuid.UUID, err error)

func RemoveDir

func RemoveDir(dirName string, withForce bool) error

func RemoveFile

func RemoveFile(fileName string) error

func RunDatanodesCleanup

func RunDatanodesCleanup(datanodesInfo []*DatanodeInfo, deletionMode bool)

func UnregisterDatanode

func UnregisterDatanode(datanodeUuid uuid.UUID) error

Types

type DatanodeInfo

type DatanodeInfo struct {
	NodeUuid           uuid.UUID
	NodePublicAddress  string
	NodePrivateAddress string
}

addr:<address>:<public port>:id -> uuid of node addr:<address>:<private port>:id -> uuid of node id:<uuid>:type -> type of entity (DATANODE) id:<uuid>:status -> current status of the datanode id:<uuid>:info -> string to string map to store datanode info list:datanodes -> list of uuid strings of datanodes list:files:<datanode uuid>:id -> list of uuid strings of files

func GetAllDatanodes

func GetAllDatanodes() (datanodes []*DatanodeInfo, err error)

func GetDatanodeInfo

func GetDatanodeInfo(uuidStr string) (info *DatanodeInfo, err error)

func GetDatanodeInfoByUuid

func GetDatanodeInfoByUuid(uuid uuid.UUID) (info *DatanodeInfo, err error)

type DirInfo

type DirInfo struct {
	// full path of the directory
	FullName string
	// uuid of the directory (may be unused)
	DirUUID    uuid.UUID
	SubDirList []string
	// list of file names whose are located in this directory
	FileList []string
}

func CreateDir

func CreateDir(dirName string) (dirInfo DirInfo, err error)

func GetDirInfo

func GetDirInfo(dirName string) (dirInfo DirInfo, err error)

func GetDirInfoByUuid

func GetDirInfoByUuid(dirUuid uuid.UUID) (dirInfo DirInfo, err error)

type FileInfo

type FileInfo struct {
	// full name of the file, including the path
	FullName string
	// file uuid (for datanodes access)
	FileUUID uuid.UUID
	// file size
	Size int64
	// uuids of datanodes which stores this file
	StorageUUIDs []uuid.UUID
}

func CreateFile

func CreateFile(fileName string) (fileInfo FileInfo, err error)

func GetFileInfo

func GetFileInfo(fileName string) (fileInfo FileInfo, err error)

func GetFileInfoByUuid

func GetFileInfoByUuid(fileUuid uuid.UUID) (fileInfo FileInfo, err error)

Jump to

Keyboard shortcuts

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