Replace InstanceID -> NodeID

This commit is contained in:
TeoV
2018-01-12 16:57:50 +02:00
committed by Dan Christian Bogos
parent 6e384d0dea
commit b15a1166cd
8 changed files with 66 additions and 66 deletions

View File

@@ -66,7 +66,7 @@ func SetCgrConfig(cfg *CGRConfig) {
func NewDefaultCGRConfig() (*CGRConfig, error) {
cfg := new(CGRConfig)
cfg.RALsMaxComputedUsage = make(map[string]time.Duration)
cfg.InstanceID = utils.GenUUID()
cfg.NodeID = utils.GenUUID()
cfg.DataFolderPath = "/usr/share/cgrates/"
cfg.SmGenericConfig = new(SmGenericConfig)
cfg.cacheConfig = make(CacheConfig)
@@ -183,7 +183,7 @@ func NewCGRConfigFromFolder(cfgDir string) (*CGRConfig, error) {
// Holds system configuration, defaults are overwritten with values from config file if found
type CGRConfig struct {
InstanceID string // Identifier for this engine instance
NodeID string // Identifier for this engine instance
DataDbType string
DataDbHost string // The host to connect to. Values that start with / are for UNIX domain sockets.
DataDbPort string // The port to bind to.
@@ -780,8 +780,8 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
}
if jsnGeneralCfg != nil {
if jsnGeneralCfg.Instance_id != nil && *jsnGeneralCfg.Instance_id != "" {
self.InstanceID = *jsnGeneralCfg.Instance_id
if jsnGeneralCfg.Node_id != nil && *jsnGeneralCfg.Node_id != "" {
self.NodeID = *jsnGeneralCfg.Node_id
}
if jsnGeneralCfg.Logger != nil {
self.Logger = *jsnGeneralCfg.Logger

View File

@@ -28,7 +28,7 @@ const CGRATES_CFG_JSON = `
// This is what you get when you load CGRateS with an empty configuration file.
"general": {
"instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated
"node_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated
"logger":"*syslog", // controls the destination of logs <*syslog|*stdout>
"log_level": 6, // control the level of messages logged (0-emerg to 7-debug)
"http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate

View File

@@ -38,7 +38,7 @@ func TestDfNewdfCgrJsonCfgFromReader(t *testing.T) {
func TestDfGeneralJsonCfg(t *testing.T) {
eCfg := &GeneralJsonCfg{
Instance_id: utils.StringPointer(""),
Node_id: utils.StringPointer(""),
Logger: utils.StringPointer(utils.MetaSysLog),
Log_level: utils.IntPointer(utils.LOGLEVEL_INFO),
Http_skip_tls_verify: utils.BoolPointer(false),

View File

@@ -20,7 +20,7 @@ package config
// General config section
type GeneralJsonCfg struct {
Instance_id *string
Node_id *string
Logger *string
Log_level *int
Http_skip_tls_verify *bool

View File

@@ -7,7 +7,7 @@
// This is what you get when you load CGRateS with an empty configuration file.
// "general": {
// "instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated
// "node_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated
// "log_level": 6, // control the level of messages logged (0-emerg to 7-debug)
// "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate
// "rounding_decimals": 5, // system level precision for floats

View File

@@ -676,7 +676,7 @@ func (rs *Responder) Status(arg string, reply *map[string]interface{}) (err erro
memstats := new(runtime.MemStats)
runtime.ReadMemStats(memstats)
response := make(map[string]interface{})
response[utils.InstanceID] = config.CgrConfig().InstanceID
response[utils.NodeID] = config.CgrConfig().NodeID
response["MemoryUsage"] = utils.SizeFmt(float64(memstats.HeapAlloc), "")
response[utils.ActiveGoroutines] = runtime.NumGoroutine()
response["Footprint"] = utils.SizeFmt(float64(memstats.Sys), "")

View File

@@ -96,15 +96,15 @@ func TestRPCITLclStatusSecondEngine(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else {
ral2ID = status[utils.InstanceID].(string)
ral2ID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
t.Error(err)
} else if status[utils.InstanceID].(string) != ral2ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral2ID, status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) != ral2ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral2ID, status[utils.NodeID].(string))
}
}
@@ -120,17 +120,17 @@ func TestRPCITLclStatusFirstInitial(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.InstanceID].(string) == ral2ID {
t.Fatalf("Should receive ralID different than second one, got: %s", status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else if status[utils.NodeID].(string) == ral2ID {
t.Fatalf("Should receive ralID different than second one, got: %s", status[utils.NodeID].(string))
} else {
ral1ID = status[utils.InstanceID].(string)
ral1ID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
t.Error(err)
} else if status[utils.InstanceID].(string) != ral1ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral1ID, status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) != ral1ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral1ID, status[utils.NodeID].(string))
}
}
@@ -143,17 +143,17 @@ func TestRPCITLclStatusFirstFailover(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.InstanceID].(string) == ral1ID {
t.Fatalf("Should receive ralID different than first one, got: %s", status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else if status[utils.NodeID].(string) == ral1ID {
t.Fatalf("Should receive ralID different than first one, got: %s", status[utils.NodeID].(string))
} else {
ral2ID = status[utils.InstanceID].(string)
ral2ID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
t.Error(err)
} else if status[utils.InstanceID].(string) != ral2ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral2ID, status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) != ral2ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral2ID, status[utils.NodeID].(string))
}
}
@@ -164,15 +164,15 @@ func TestRPCITLclStatusFirstFailback(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == ral2ID {
} else if status[utils.NodeID].(string) == ral2ID {
t.Error("Should receive new ID")
} else {
ral1ID = status[utils.InstanceID].(string)
ral1ID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
t.Error(err)
} else if status[utils.InstanceID].(string) != ral1ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral1ID, status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) != ral1ID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ral1ID, status[utils.NodeID].(string))
}
}
@@ -204,13 +204,13 @@ func TestRPCITLclBcastStatusInitial(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
}
}
@@ -222,13 +222,13 @@ func TestRPCITLclBcastStatusNoRals1(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
}
}
@@ -250,13 +250,13 @@ func TestRPCITLclBcastStatusRALs2Up(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
}
}
@@ -267,12 +267,12 @@ func TestRPCITLclStatusBcastRALs1Up(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty InstanceID received")
}
if err := rpcPoolBroadcast.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty InstanceID received")
}
}
@@ -340,15 +340,15 @@ func TestRPCITRmtStatusFirstInitial(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else {
ralRmtID = status[utils.InstanceID].(string)
ralRmtID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
t.Error(err)
} else if status[utils.InstanceID].(string) != ralRmtID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ralRmtID, status[utils.InstanceID].(string))
} else if status[utils.NodeID].(string) != ralRmtID {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ralRmtID, status[utils.NodeID].(string))
}
}
@@ -366,18 +366,18 @@ func TestRPCITRmtStatusFirstFailover(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.InstanceID].(string) == ralRmtID {
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else if status[utils.NodeID].(string) == ralRmtID {
t.Fatal("Did not failover")
} else {
ralRmtID = status[utils.InstanceID].(string)
ralRmtID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.InstanceID].(string) != ralRmtID {
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else if status[utils.NodeID].(string) != ralRmtID {
t.Fatal("Did not do failover")
}
}
@@ -396,18 +396,18 @@ func TestRPCITRmtStatusFirstFailback(t *testing.T) {
var status map[string]interface{}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.InstanceID].(string) == ralRmtID {
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else if status[utils.NodeID].(string) == ralRmtID {
t.Fatal("Did not do failback")
} else {
ralRmtID = status[utils.InstanceID].(string)
ralRmtID = status[utils.NodeID].(string)
}
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
t.Error(err)
} else if status[utils.InstanceID].(string) == "" {
t.Error("Empty InstanceID received")
} else if status[utils.InstanceID].(string) != ralRmtID {
} else if status[utils.NodeID].(string) == "" {
t.Error("Empty NodeID received")
} else if status[utils.NodeID].(string) != ralRmtID {
t.Fatal("Did not do failback")
}
}

View File

@@ -331,7 +331,7 @@ const (
UpdatedAt = "UpdatedAt"
HandlerArgSep = "|"
FlagForceDuration = "fd"
InstanceID = "InstanceID"
NodeID = "NodeID"
ActiveGoroutines = "ActiveGoroutines"
SessionTTL = "SessionTTL"
SessionTTLMaxDelay = "SessionTTLMaxDelay"