Documentation ¶
Index ¶
- Constants
- Variables
- func Initialize(dbtype string, config string) (bool, error)
- type InMem
- type Instance
- func (I *Instance) Load() bool
- func (I *Instance) LoadProcs() bool
- func (I *Instance) Sync() bool
- func (I *Instance) SyncMasters() bool
- func (I *Instance) SyncSlaves() bool
- func (I *Instance) SyncStatus() bool
- func (I *Instance) SyncType(string) bool
- func (I *Instance) ToJson() string
- func (I *Instance) ToJson_Obj() Instance_Json
- type Instance_Json
- type Offer
- type Proc
- func (P *Proc) Load() bool
- func (P *Proc) LoadMsg() bool
- func (P *Proc) LoadStats() *Stats
- func (P *Proc) LoadType() bool
- func (P *Proc) Sync() bool
- func (P *Proc) SyncMsg() bool
- func (P *Proc) SyncSlaveOf() bool
- func (P *Proc) SyncStats(s Stats) bool
- func (P *Proc) SyncType() bool
- func (P *Proc) ToJson() *ProcJson
- func (P *Proc) ToJsonStats(stats Stats) string
- type ProcJson
- type Rec
- type Stats
- type TaskCreate
- type TaskMsg
- type TaskUpdate
Constants ¶
const ( TASK_MSG_DESTROY = iota //0 TASK_MSG_DESTROY enum of Message tpe starts with 0 TASK_MSG_MAKEMASTER //1 TASK_MSG_SLAVEOF )
const ( ETC_BASE_DIR = "/MrRedis" ETC_INST_DIR = ETC_BASE_DIR + "/Instances" ETC_CONF_DIR = ETC_BASE_DIR + "/Config" )
global Constants releated to ETCD
const ( INST_STATUS_CREATING = "CREATING" INST_STATUS_RUNNING = "RUNNING" INST_STATUS_DISABLED = "DISABLED" INST_STATUS_DELETED = "DELETED" )
Global constants for Instance Status CREATING/ACTIVE/DELETED/DISABLED
const ( INST_TYPE_SINGLE = "S" //A Single instance redis-server INST_TYPE_MASTER_SLAVE = "MS" //A redis instance with master-slave )
Const for instance type
const ( PROC_TYPE_MASTER = "M" PROC_TYPE_SLAVE = "S" )
const for type of the redis-server
Variables ¶
var ( Gdb store.DB //Gdb Golabal variables related to db connection/instace MemDb *InMem //In memory store IsRegistered bool //Default flag OfferList *list.List //list for having offer Cchan chan TaskCreate //Channel for Creator Mchan chan *TaskUpdate //Channel for Maintainer Dchan chan TaskMsg //Channel for Destroyer Agents *agentstate.State //A Global View of aggents and the Instnaces book keeping )
Functions ¶
Types ¶
type InMem ¶
InMem a structure for maintaining InMemory cache about all the instances, All the api's interactive with the DB should first check this MAP before actually reading form the DB. for changes it should also update this map first before updating the DB
func NewInMem ¶
func NewInMem() *InMem
NewInMem is called when you want to initialize the In Memory cache for the first time
func (*InMem) Add ¶
Add Use add to add a new Instance entry in the inmemory, throws error if the element already exist
func (*InMem) Delete ¶
Delete use thsi to Delete an element from the cache
func (*InMem) Get ¶
Get get an Instance pointer from the cache
func (*InMem) IsValid ¶
IsValid A quick look up function to see if a key is available in the inmemory cache
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 DistributionValue int //HOw many redis-server that belong to this proc can be started in a single slave, Default to 1 }
A Instance structure that will be able to store a tree of data, Everything related to a redis intance
func LoadInstance ¶
LoadInstance Load an instance from the store using Instance Name from the store if the instance is unavailable then return nil
func NewInstance ¶
NewInstance Creates a new instance variable Fills up the structure and updates the central store Returns an instance pointer Returns nil if the instance already exists
func (*Instance) Load ¶
Load Loads up the datastructure for the given Service Name to the struture If the Instance cannot be loaded the it returns an error
func (*Instance) LoadProcs ¶
LoadProcs Should be called when all the PROCs need to be loaded to the lateest value, PS High DISK intensive function, should be used carefully
func (*Instance) Sync ¶
Sync Writes the entier content of an instance into store, an instance could have many keys to be updated this is a write intensive function should be used carefully, do not call this if you are planning to update only a single attribute of an instance
func (*Instance) SyncMasters ¶
SyncMasters Flushes only the master attribute to the DB, used when a new redis master is choose.
func (*Instance) SyncSlaves ¶
SyncSlaves Flushes only the Slaves attribute to the DB, used when a Slave died or promoted as a master
func (*Instance) SyncStatus ¶
SyncStatus Flushes only the status attribute to the DB
func (*Instance) SyncType ¶
SyncType Write only the TYPE attribute to the DB/store
func (*Instance) ToJson_Obj ¶
func (I *Instance) ToJson_Obj() Instance_Json
ToJson_Obj Filtered elementes of an Instnace that will be sent as an HTTP response
type Instance_Json ¶
type Instance_Json struct { Name string Type string Status string Capacity int Master *ProcJson Slaves []*ProcJson }
Instance_Json Filtered elementes of an Instnace that will be sent as an HTTP response
type Offer ¶
type Offer struct { Name string //Name of the instance Taskname string //Name of the redis proc Cpu int //CPU default is one Mem int //Memory in MB DValue int //Distribution Value IsMaster bool //Is this instance a master MasterIpPort string //If this is slave then send the masters IP and prot number }
Offer Structure that is used between creator and Mesos Scheduler
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 }
Proc 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 ¶
LoadProc Load a Proc information from the store and populate a structure
func NewProc ¶
NewProc Constructor for a PROC struct, this does not sync anything to the DB
func (*Proc) LoadMsg ¶
LoadMsg Get the latest MSG from the scheduler, usually called by the executor(RedMon)
func (*Proc) LoadStats ¶
LoadStats get the latest STATS info from the store, usually called by the scheduler to make a decision
func (*Proc) LoadType ¶
LoadType Update what is the current type of a PROC, usually called by the scheduler
func (*Proc) Sync ¶
Sync everything thats in-memory to the KV store, should be used only when you have more attributes to be synced/written to the DB at the same time, Disk intensive operation
func (*Proc) SyncMsg ¶
SyncMsg Should be used only to update a MSG with respect to a PROC
func (*Proc) SyncSlaveOf ¶
SyncSlaveOf should be used to make a slave (proc) point to a new master
func (*Proc) SyncStats ¶
SyncStats Updates only the statistic related information to the disk, used by RedMon every second
func (*Proc) SyncType ¶
SyncType should be used to only update the TYPE attribute of a PROC
func (*Proc) ToJson ¶
ToJson Convert a PROC to json but only selected fileds
type ProcJson ¶
type ProcJson struct { IP string Port string MemoryCapacity int MemoryUsed int64 Uptime int64 ClientsConnected int LastSyncedToMaster int }
ProcJson Fields to be packed in a json when replied to a HTTP REST query.
type Rec ¶
Rec Type that represents each Record
type Stats ¶
type Stats struct { Uptime int64 Mem int64 Clients int LastSyced int SlaveOffset int64 //Offset of the slave SlavePriority int }
Stats 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 instance to be created }
TaskCreate Type that is interpreted by the Creator Thread
func CreateMaster ¶
func CreateMaster(i *Instance) TaskCreate
CreateMaster Wrapper for Create a TaskCreate variable of type Master
func CreateSlaves ¶
func CreateSlaves(i *Instance, c int) TaskCreate
CreateSlaves Wrapper for Create a TaskCreate variable of type Slave
func NewTaskCreate ¶
func NewTaskCreate(m bool, i *Instance, c int) TaskCreate
NewTaskCreate Constructor of TaskCreate
type TaskMsg ¶
TaskMsg Type that is used to communicate with Destroyer