From 7eb7586c48f45f142fd93620111eaa3fb0cd0bc7 Mon Sep 17 00:00:00 2001 From: Anevo Date: Tue, 13 Mar 2018 10:05:17 -0400 Subject: [PATCH] Console cache_stats command --- console/cache_clear.go | 65 ++++++++++++++++++++++++++++++ console/cache_group_item_id.go | 66 +++++++++++++++++++++++++++++++ console/cache_has_group.go | 66 +++++++++++++++++++++++++++++++ console/cache_has_item.go | 66 +++++++++++++++++++++++++++++++ console/cache_item_expiry_time.go | 66 +++++++++++++++++++++++++++++++ console/cache_item_ids.go | 66 +++++++++++++++++++++++++++++++ console/cache_precache_status.go | 66 +++++++++++++++++++++++++++++++ console/cache_remove_group.go | 66 +++++++++++++++++++++++++++++++ console/cache_remove_item.go | 66 +++++++++++++++++++++++++++++++ utils/consts.go | 12 +++++- 10 files changed, 604 insertions(+), 1 deletion(-) create mode 100644 console/cache_clear.go create mode 100644 console/cache_group_item_id.go create mode 100644 console/cache_has_group.go create mode 100644 console/cache_has_item.go create mode 100644 console/cache_item_expiry_time.go create mode 100644 console/cache_item_ids.go create mode 100644 console/cache_precache_status.go create mode 100644 console/cache_remove_group.go create mode 100644 console/cache_remove_item.go diff --git a/console/cache_clear.go b/console/cache_clear.go new file mode 100644 index 000000000..6f6e423a2 --- /dev/null +++ b/console/cache_clear.go @@ -0,0 +1,65 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdClear{ + name: "cache_clear", + rpcMethod: utils.CacheSv1Clear, + rpcParams: []string{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdClear struct { + name string + rpcMethod string + rpcParams []string + *CommandExecuter +} + +func (self *CmdClear) Name() string { + return self.name +} + +func (self *CmdClear) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdClear) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = []string{} + } + return self.rpcParams +} + +func (self *CmdClear) PostprocessRpcParams() error { + return nil +} + +func (self *CmdClear) RpcResult() interface{} { + var reply string + return &reply +} diff --git a/console/cache_group_item_id.go b/console/cache_group_item_id.go new file mode 100644 index 000000000..c02457d76 --- /dev/null +++ b/console/cache_group_item_id.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheGetGroupItemIDs{ + name: "cache_group_item_ids", + rpcMethod: utils.CacheSv1GetGroupItemIDs, + rpcParams: &engine.ArgsGetGroup{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheGetGroupItemIDs struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetGroup + *CommandExecuter +} + +func (self *CmdCacheGetGroupItemIDs) Name() string { + return self.name +} + +func (self *CmdCacheGetGroupItemIDs) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheGetGroupItemIDs) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetGroup{} + } + return self.rpcParams +} + +func (self *CmdCacheGetGroupItemIDs) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheGetGroupItemIDs) RpcResult() interface{} { + reply := []string{} + return &reply +} diff --git a/console/cache_has_group.go b/console/cache_has_group.go new file mode 100644 index 000000000..79ba811d8 --- /dev/null +++ b/console/cache_has_group.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheHasGroup{ + name: "cache_has_group", + rpcMethod: utils.CacheSv1HasGroup, + rpcParams: &engine.ArgsGetGroup{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheHasGroup struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetGroup + *CommandExecuter +} + +func (self *CmdCacheHasGroup) Name() string { + return self.name +} + +func (self *CmdCacheHasGroup) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheHasGroup) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetGroup{} + } + return self.rpcParams +} + +func (self *CmdCacheHasGroup) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheHasGroup) RpcResult() interface{} { + var reply bool + return &reply +} diff --git a/console/cache_has_item.go b/console/cache_has_item.go new file mode 100644 index 000000000..eacb4b7db --- /dev/null +++ b/console/cache_has_item.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheHasItem{ + name: "cache_has_item", + rpcMethod: utils.CacheSv1HasItem, + rpcParams: &engine.ArgsGetCacheItem{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheHasItem struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetCacheItem + *CommandExecuter +} + +func (self *CmdCacheHasItem) Name() string { + return self.name +} + +func (self *CmdCacheHasItem) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheHasItem) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetCacheItem{} + } + return self.rpcParams +} + +func (self *CmdCacheHasItem) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheHasItem) RpcResult() interface{} { + var reply bool + return &reply +} diff --git a/console/cache_item_expiry_time.go b/console/cache_item_expiry_time.go new file mode 100644 index 000000000..f02b31bcf --- /dev/null +++ b/console/cache_item_expiry_time.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheGetItemExpiryTime{ + name: "cache_item_expiry_time", + rpcMethod: utils.CacheSv1GetItemExpiryTime, + rpcParams: &engine.ArgsGetCacheItem{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheGetItemExpiryTime struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetCacheItem + *CommandExecuter +} + +func (self *CmdCacheGetItemExpiryTime) Name() string { + return self.name +} + +func (self *CmdCacheGetItemExpiryTime) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheGetItemExpiryTime) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetCacheItem{} + } + return self.rpcParams +} + +func (self *CmdCacheGetItemExpiryTime) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheGetItemExpiryTime) RpcResult() interface{} { + var reply string + return &reply +} diff --git a/console/cache_item_ids.go b/console/cache_item_ids.go new file mode 100644 index 000000000..78ba4602f --- /dev/null +++ b/console/cache_item_ids.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheGetItemIDs{ + name: "cache_item_ids", + rpcMethod: utils.CacheSv1GetItemIDs, + rpcParams: &engine.ArgsGetCacheItemIDs{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheGetItemIDs struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetCacheItemIDs + *CommandExecuter +} + +func (self *CmdCacheGetItemIDs) Name() string { + return self.name +} + +func (self *CmdCacheGetItemIDs) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheGetItemIDs) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetCacheItemIDs{} + } + return self.rpcParams +} + +func (self *CmdCacheGetItemIDs) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheGetItemIDs) RpcResult() interface{} { + reply := []string{} + return &reply +} diff --git a/console/cache_precache_status.go b/console/cache_precache_status.go new file mode 100644 index 000000000..dd7761162 --- /dev/null +++ b/console/cache_precache_status.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/utils" + "github.com/cgrates/ltcache" +) + +func init() { + c := &CmdGetPrecacheStatus{ + name: "cache_precache_status", + rpcMethod: utils.CacheSv1PrecacheStatus, + rpcParams: []string{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdGetPrecacheStatus struct { + name string + rpcMethod string + rpcParams []string + *CommandExecuter +} + +func (self *CmdGetPrecacheStatus) Name() string { + return self.name +} + +func (self *CmdGetPrecacheStatus) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdGetPrecacheStatus) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = []string{} + } + return self.rpcParams +} + +func (self *CmdGetPrecacheStatus) PostprocessRpcParams() error { + return nil +} + +func (self *CmdGetPrecacheStatus) RpcResult() interface{} { + reply := make(map[string]*ltcache.CacheStats) + return &reply +} diff --git a/console/cache_remove_group.go b/console/cache_remove_group.go new file mode 100644 index 000000000..1dd054962 --- /dev/null +++ b/console/cache_remove_group.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheRemoveGroup{ + name: "cache_remove_group", + rpcMethod: utils.CacheSv1RemoveGroup, + rpcParams: &engine.ArgsGetGroup{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheRemoveGroup struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetGroup + *CommandExecuter +} + +func (self *CmdCacheRemoveGroup) Name() string { + return self.name +} + +func (self *CmdCacheRemoveGroup) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheRemoveGroup) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetGroup{} + } + return self.rpcParams +} + +func (self *CmdCacheRemoveGroup) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheRemoveGroup) RpcResult() interface{} { + var reply string + return &reply +} diff --git a/console/cache_remove_item.go b/console/cache_remove_item.go new file mode 100644 index 000000000..731600d06 --- /dev/null +++ b/console/cache_remove_item.go @@ -0,0 +1,66 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdCacheRemoveItem{ + name: "cache_remove_item", + rpcMethod: utils.CacheSv1RemoveItem, + rpcParams: &engine.ArgsGetCacheItem{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdCacheRemoveItem struct { + name string + rpcMethod string + rpcParams *engine.ArgsGetCacheItem + *CommandExecuter +} + +func (self *CmdCacheRemoveItem) Name() string { + return self.name +} + +func (self *CmdCacheRemoveItem) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdCacheRemoveItem) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &engine.ArgsGetCacheItem{} + } + return self.rpcParams +} + +func (self *CmdCacheRemoveItem) PostprocessRpcParams() error { + return nil +} + +func (self *CmdCacheRemoveItem) RpcResult() interface{} { + var reply string + return &reply +} diff --git a/utils/consts.go b/utils/consts.go index 1d557aa8c..7943977bc 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -638,8 +638,18 @@ const ( SMGenericV2UpdateSession = "SMGenericV2.UpdateSession" ) +// Cache const ( - CacheSv1GetCacheStats = "CacheSv1.GetCacheStats" + CacheSv1GetCacheStats = "CacheSv1.GetCacheStats" + CacheSv1GetItemIDs = "CacheSv1.GetItemIDs" + CacheSv1HasItem = "CacheSv1.HasItem" + CacheSv1GetItemExpiryTime = "CacheSv1.GetItemExpiryTime" + CacheSv1RemoveItem = "CacheSv1.RemoveItem" + CacheSv1PrecacheStatus = "CacheSv1.PrecacheStatus" + CacheSv1HasGroup = "CacheSv1.HasGroup" + CacheSv1GetGroupItemIDs = "CacheSv1.GetGroupItemIDs" + CacheSv1RemoveGroup = "CacheSv1.RemoveGroup" + CacheSv1Clear = "CacheSv1.Clear" ) //CSV file name