types

package
v0.0.0-...-705e2cb Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ETC_BASE_DIR = "/MrRedis"
	ETC_INST_DIR = ETC_BASE_DIR + "/Instances"
	ETC_CONF_DIR = ETC_BASE_DIR + "/Config"
)

global Constants releated to ETCD

View Source
const (
	INST_STATUS_CREATING = "CREATING"
	INST_STATUS_RUNNING  = "RUNNING"
	INST_STATUS_DISABLED = "DISABLED"
	INST_STATUS_DELETED  = "DELETED"
)

Global constants for Instnace Status CREATING/ACTIVE/DELETED/DISABLED

View Source
const (
	INST_TYPE_SINGLE       = "S"  //A Single instance redis-server
	INST_TYPE_MASTER_SLAVE = "MS" //A redis instnace with master-slave
)

Const for instance type

View Source
const (
	PROC_TYPE_MASTER = "M"
	PROC_TYPE_SLAVE  = "S"
)

const for type of the redis-server

Variables

View Source
var (
	Gdb   store.DB //Golabal variables related to db connection/instace
	MemDb *InMem   //In memory store

	OfferList *list.List       //list for having offer
	Cchan     chan TaskCreate  //Channel for Creator
	Mchan     chan *TaskUpdate //Channel for Maintainer
	Dchan     chan *Proc       //Channel for Destroyer
)

Functions

func Initialize

func Initialize(dbtype string, config string) (bool, error)

Types

type InMem

type InMem struct {
	I map[string]*Instance //Map of instances
}

func NewInMem

func NewInMem() *InMem

func (*InMem) Add

func (inMem *InMem) Add(name string, instance *Instance) (bool, error)

Use add to add a new Instance entry in the inmemory, throws error if the element already exist

func (*InMem) Delete

func (inMem *InMem) Delete(name string) (bool, error)

func (*InMem) Get

func (inMem *InMem) Get(name string) *Instance

func (*InMem) IsValid

func (inMem *InMem) IsValid(name string) bool

func (*InMem) Update

func (inMem *InMem) Update(name string, instance *Instance) (bool, error)

use this to update an existing value, throws error otherwise

type Instance

type Instance struct {
	Name       string           //Name of the instance
	Type       string           //Type of the instance "Single Instance = S; Master-Slave  = MS; Cluster = C"
	Capacity   int              //Capacity of the Instance in MB
	Masters    int              //Number of masters in this Instance
	Slaves     int              //Number of slaves in this Instance
	ExpMasters int              //Expected number of Masters
	ExpSlaves  int              //Expected number of Slaves
	Status     string           //Status of this instance "CREATING/RUNNING/DISABLED"
	Mname      string           //Name / task id of the master redis proc
	Snames     []string         //Name of the slave
	Procs      map[string]*Proc //An array of redis procs to be filled later
}

func LoadInstance

func LoadInstance(Name string) *Instance

func NewInstance

func NewInstance(Name string, Type string, Masters int, Slaves int, Cap int) *Instance

func (*Instance) Load

func (I *Instance) Load() bool

func (*Instance) LoadProcs

func (I *Instance) LoadProcs() bool

func (*Instance) Sync

func (I *Instance) Sync() bool

func (*Instance) SyncMasters

func (I *Instance) SyncMasters() bool

func (*Instance) SyncSlaves

func (I *Instance) SyncSlaves() bool

func (*Instance) SyncStatus

func (I *Instance) SyncStatus() bool

func (*Instance) SyncType

func (I *Instance) SyncType(string) bool

func (*Instance) ToJson

func (I *Instance) ToJson() string

type Instance_Json

type Instance_Json struct {
	Name     string
	Type     string
	Status   string
	Capacity int
	Master   Proc_Json
	Slaves   []Proc_Json
}

type Offer

type Offer struct {
	Taskname     string //Name of the redis proc
	Cpu          int    //CPU default is one
	Mem          int    //Memory in MB
	IsMaster     bool   //Is this instance a master
	MasterIpPort string //If this is slave then send the masters IP and prot number
}

func NewOffer

func NewOffer(name string, cpu int, mem int, ismaster bool, masterIpPort string) Offer

type Proc

type Proc struct {
	Instance string //Name of the instance it belongs to
	Nodename string //Node name at which this should start syncing its details to
	MemCap   int    //Maximum Memory this instance can go to
	MemUsed  int    //Current usage of the memory
	Pid      int    //Unix Process id of this running instance
	ID       string //UUID that was generated for this PROC
	State    string //Current state of the process Active/Dead/Crashed etc.,
	Type     string //Type of the PROC master/Slave etc.,
	SlaveOf  string //Slave of which redis master
	Stats    string //All other statistics apart from Memory usage to be stored as a json/string
	Msg      string //Message we will revive fromt he scheduler and action to be taken on it
	IP       string //IP address of the slave at which this redis-server proc is running
	Port     string //Port number at which this PROC is bound to
	EID      string //Executor ID of this PROC  .. Just in case we need to send a framework messsage
	SID      string //Slave ID of this PROC .. Just in case we need to send a framework message

}

A standalone redis KV store is usually started in any slave (Linux) like below $./redis-server -p <PORT> ..... {OPTIONS} This stand alone redis-server will be an actual unix process bound to a particular port witha PID A redis Master Slave setup will have two such "redis-server" processes running in either the same machine or two different machines A redis KV with one master and 3 slaves will have a total of 4 "redis-server" processes running The below structure "Proc" is a representation of such a running 'redis-server' process started via this framework This started/running "Proc" could be a Master/Standalone instance or could be a Slave of another "redis-server' running as a master

func LoadProc

func LoadProc(TskName string) *Proc

Load a Proc information from the store to structure and return

func NewProc

func NewProc(TskName string, Capacity int, Type string, SlaveOf string) *Proc

func (*Proc) Load

func (P *Proc) Load() bool

Load the latest from ETC store

func (*Proc) LoadMsg

func (P *Proc) LoadMsg() bool

func (*Proc) LoadStats

func (P *Proc) LoadStats() bool

func (*Proc) LoadType

func (P *Proc) LoadType() bool

func (*Proc) Sync

func (P *Proc) Sync() bool

Sync everything thats in-memory to the the central store

func (*Proc) SyncMsg

func (P *Proc) SyncMsg() bool

func (*Proc) SyncStats

func (P *Proc) SyncStats() bool

func (*Proc) SyncType

func (P *Proc) SyncType() bool

func (*Proc) ToJson

func (P *Proc) ToJson() string

func (*Proc) ToJsonStats

func (P *Proc) ToJsonStats(stats Stats) string

type Proc_Json

type Proc_Json struct {
	IP   string
	Port string
}

type Rec

type Rec struct {
	Key           string
	Value         []byte
	Section       bool
	SectionValues []Rec
}

type Stats

type Stats struct {
	Mem    string
	Cpu    string
	Others string
}

ToDo the whole stats structure could be a json structure reflecting all the fields what redis info returns currently one field has many new line saperated values;ToDO will this work if returned in API?

type TaskCreate

type TaskCreate struct {
	M bool //Is this a master or slave
	I *Instance
	C int //count of number of instnace to be created
}

func CreateMaster

func CreateMaster(i *Instance) TaskCreate

func CreateSlaves

func CreateSlaves(i *Instance, c int) TaskCreate

func NewTaskCreate

func NewTaskCreate(m bool, i *Instance, c int) TaskCreate

type TaskUpdate

type TaskUpdate struct {
	Name  string
	State string
	Data  []byte
}

Jump to

Keyboard shortcuts

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