func (P *Proc) ToJson() *ProcJson {
	var pJson ProcJson
	pJson.IP = P.IP
	pJson.Port = P.Port
	pJson.MemoryCapacity = P.MemCap
	stats := P.LoadStats()
	if stats == nil {
		return nil
	}
	pJson.MemoryUsed = stats.Mem
	pJson.ClientsConnected = stats.Clients
	pJson.Uptime = stats.Uptime
	pJson.LastSyncedToMaster = stats.LastSyced
	return &pJson
}
ToJson Convert a PROC to json but only selected fileds
package types
import (
	"encoding/json"
	"fmt"
	"log"
	"strconv"
	"strings"
	"github.com/mesos/mr-redis/common/store/etcd"
)
type Proc struct {
	Instance string  
	Nodename string  
	MemCap   int     
	MemUsed  int     
	Pid      int     
	ID       string  
	State    string  
	Type     string  
	SlaveOf  string  
	Stats    string  
	Msg      string  
	IP       string  
	Port     string  
	EID      string  
	SID      string  
}
type Stats struct {
	Uptime        int64
	Mem           int64
	Clients       int
	LastSyced     int
	SlaveOffset   int64  
	SlavePriority int
}
type ProcJson struct {
	IP                 string
	Port               string
	MemoryCapacity     int
	MemoryUsed         int64
	Uptime             int64
	ClientsConnected   int
	LastSyncedToMaster int
}
func NewProc(TskName string, Capacity int, Type string, SlaveOf string) *Proc {
	var tmpProc Proc
	Tids := strings.Split(TskName, "::")
	if len(Tids) != 2 {
		log.Printf("Wrong format Task Name %s", TskName)
		return nil
	}
	tmpProc.Instance = Tids[0]
	tmpProc.ID = Tids[1]
	tmpProc.MemCap = Capacity
	tmpProc.Type = Type
	tmpProc.SlaveOf = SlaveOf
	tmpProc.Nodename = etcd.ETC_INST_DIR + "/" + tmpProc.Instance + "/Procs/" + tmpProc.ID
	return &tmpProc
}
func LoadProc(TskName string) *Proc {
	var P Proc
	Tids := strings.Split(TskName, "::")
	if len(Tids) != 2 {
		log.Printf("Proc.Load() Wrong format Task Name %s", TskName)
		return nil
	}
	P.Instance = Tids[0]
	P.ID = Tids[1]
	P.Nodename = etcd.ETC_INST_DIR + "/" + P.Instance + "/Procs/" + P.ID
	P.Load()
	return &P
}
func (P *Proc) Load() bool {
	var err error
	var tmpStr string
	if Gdb.IsSetup() != true {
		return false
	}
	if ok, _ := Gdb.IsKey(P.Nodename); !ok {
		log.Printf("Invalid Key %v, Cannot load", P.Nodename)
		return false
	}
	tmpStr, err = Gdb.Get(P.Nodename + "/Capacity")
	P.MemCap, err = strconv.Atoi(tmpStr)
	tmpStr, err = Gdb.Get(P.Nodename + "/MemUsed")
	P.MemUsed, err = strconv.Atoi(tmpStr)
	P.Port, err = Gdb.Get(P.Nodename + "/Port")
	P.IP, err = Gdb.Get(P.Nodename + "/IP")
	tmpStr, err = Gdb.Get(P.Nodename + "/Pid")
	P.Pid, err = strconv.Atoi(tmpStr)
	P.State, err = Gdb.Get(P.Nodename + "/State")
	P.Type, err = Gdb.Get(P.Nodename + "/Type")
	P.EID, err = Gdb.Get(P.Nodename + "/EID")
	P.SID, err = Gdb.Get(P.Nodename + "/SID")
	P.Msg, err = Gdb.Get(P.Nodename + "/Msg")
	P.Stats, err = Gdb.Get(P.Nodename + "/Stats")
	P.SlaveOf, err = Gdb.Get(P.Nodename + "/SlaveOf")
	if err != nil {
		log.Printf("Error occured %v", err)
		return false
	}
	return true
}
func (P *Proc) Sync() bool {
	if Gdb.IsSetup() != true {
		return false
	}
	Gdb.CreateSection(P.Nodename)
	Gdb.Set(P.Nodename+"/Instance", P.Instance)
	Gdb.Set(P.Nodename+"/Nodename", P.Nodename)
	Gdb.Set(P.Nodename+"/Capacity", fmt.Sprintf("%d", P.MemCap))
	Gdb.Set(P.Nodename+"/MemUsed", fmt.Sprintf("%d", P.MemUsed))
	Gdb.Set(P.Nodename+"/Pid", fmt.Sprintf("%d", P.Pid))
	Gdb.Set(P.Nodename+"/IP", P.IP)
	Gdb.Set(P.Nodename+"/Port", P.Port)
	Gdb.Set(P.Nodename+"/State", P.State)
	Gdb.Set(P.Nodename+"/Stats", P.Stats)
	Gdb.Set(P.Nodename+"/SlaveOf", P.SlaveOf)
	Gdb.Set(P.Nodename+"/Msg", P.Msg)
	Gdb.Set(P.Nodename+"/EID", P.EID)
	Gdb.Set(P.Nodename+"/SID", P.SID)
	Gdb.Set(P.Nodename+"/Type", P.Type)
	return true
}
func (P *Proc) SyncStats(s Stats) bool {
	if Gdb.IsSetup() != true {
		return false
	}
	sBytes, err := json.Marshal(s)
	if err != nil {
		log.Printf("SyncStats() unbale to marshal error %v", err)
		return false
	}
	P.Stats = string(sBytes)
	Gdb.Set(P.Nodename+"/Stats", P.Stats)
	return true
}
func (P *Proc) SyncType() bool {
	if Gdb.IsSetup() != true {
		return false
	}
	Gdb.Set(P.Nodename+"/Type", P.Type)
	return true
}
func (P *Proc) SyncMsg() bool {
	if Gdb.IsSetup() != true {
		return false
	}
	Gdb.Set(P.Nodename+"/Msg", P.Msg)
	return true
}
func (P *Proc) SyncSlaveOf() bool {
	if Gdb.IsSetup() != true {
		return false
	}
	Gdb.Set(P.Nodename+"/SlaveOf", P.SlaveOf)
	return true
}
func (P *Proc) LoadStats() *Stats {
	var err error
	var s Stats
	if Gdb.IsSetup() != true {
		return nil
	}
	P.Stats, err = Gdb.Get(P.Nodename + "/Stats")
	if err != nil {
		log.Printf("Error occured %v", err)
		return nil
	}
	err = json.Unmarshal([]byte(P.Stats), &s)
	if err != nil {
		log.Printf("Error occured un-marshalling stats LoadStats() %v stats=%s", err, P.Stats)
		return nil
	}
	return &s
}
func (P *Proc) LoadType() bool {
	var err error
	if Gdb.IsSetup() != true {
		return false
	}
	P.Type, err = Gdb.Get(P.Nodename + "/Type")
	if err != nil {
		log.Printf("Error occured %v", err)
		return false
	}
	return true
}
func (P *Proc) LoadMsg() bool {
	var err error
	if Gdb.IsSetup() != true {
		return false
	}
	P.Msg, err = Gdb.Get(P.Nodename + "/Msg")
	if err != nil {
		log.Printf("Error occured %v", err)
		return false
	}
	return true
}