mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Add dump and restore functionality for internal DBs
This commit is contained in:
committed by
Dan Christian Bogos
parent
17248c5dde
commit
a168f262e2
@@ -2076,3 +2076,62 @@ func (apierSv1 *APIerSv1) TimingIsActiveAt(ctx *context.Context, params TimePara
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DumpDataDB will dump all of datadb from memory to a file
|
||||
func (apierSv1 *APIerSv1) DumpDataDB(ctx *context.Context, ignr *string, reply *string) (err error) {
|
||||
if err = apierSv1.DataManager.DataDB().DumpDataDB(); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
// Will rewrite every dump file of DataDB
|
||||
func (apierSv1 *APIerSv1) RewriteDataDB(ctx *context.Context, ignr *string, reply *string) (err error) {
|
||||
if err = apierSv1.DataManager.DataDB().RewriteDataDB(); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
// DumpStorDB will dump all of stordb from memory to a file
|
||||
func (apierSv1 *APIerSv1) DumpStorDB(ctx *context.Context, ignr *string, reply *string) (err error) {
|
||||
if err = apierSv1.StorDb.DumpStorDB(); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
// Will rewrite every dump file of StorDB
|
||||
func (apierSv1 *APIerSv1) RewriteStorDB(ctx *context.Context, ignr *string, reply *string) (err error) {
|
||||
if err = apierSv1.StorDb.RewriteStorDB(); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
type DumpBackupParams struct {
|
||||
BackupFolderPath string // The path to the folder where the backup will be created
|
||||
Zip bool // creates a zip compressing the backup
|
||||
}
|
||||
|
||||
// BackupDataDB will momentarely stop any dumping and rewriting in dataDB, until dump folder is backed up in folder path backupFolderPath. Making zip true will create a zip file in the path instead
|
||||
func (apierSv1 *APIerSv1) BackupDataDB(ctx *context.Context, params DumpBackupParams, reply *string) (err error) {
|
||||
if err = apierSv1.DataManager.DataDB().BackupDataDB(params.BackupFolderPath, params.Zip); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
// BackupStorDB will momentarely stop any dumping and rewriting in storDB, until dump folder is backed up in folder path backupFolderPath. Making zip true will create a zip file in the path instead
|
||||
func (apierSv1 *APIerSv1) BackupStorDB(ctx *context.Context, params DumpBackupParams, reply *string) (err error) {
|
||||
if err = apierSv1.StorDb.BackupStorDB(params.BackupFolderPath, params.Zip); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = utils.OK
|
||||
return
|
||||
}
|
||||
|
||||
@@ -582,8 +582,7 @@ func (apierSv1 *APIerSv1) GetAccountActionPlansIndexHealth(ctx *context.Context,
|
||||
|
||||
func (apierSv1 *APIerSv1) GetReverseDestinationsIndexHealth(ctx *context.Context, args *engine.IndexHealthArgsWith2Ch, reply *engine.ReverseDestinationsIHReply) error {
|
||||
rp, err := engine.GetReverseDestinationsIndexHealth(apierSv1.DataManager, args.ObjectCacheLimit, args.IndexCacheLimit,
|
||||
args.ObjectCacheTTL, args.IndexCacheTTL,
|
||||
args.ObjectCacheStaticTTL, args.IndexCacheStaticTTL)
|
||||
args.ObjectCacheTTL, args.IndexCacheTTL, args.ObjectCacheStaticTTL, args.IndexCacheStaticTTL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -594,11 +593,11 @@ func (apierSv1 *APIerSv1) GetReverseDestinationsIndexHealth(ctx *context.Context
|
||||
func (apierSv1 *APIerSv1) GetReverseFilterHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *map[string]*engine.ReverseFilterIHReply) (err error) {
|
||||
objCaches := make(map[string]*ltcache.Cache)
|
||||
for indxType := range utils.CacheIndexesToPrefix {
|
||||
objCaches[indxType] = ltcache.NewCache(-1, 0, false, nil)
|
||||
objCaches[indxType] = ltcache.NewCache(-1, 0, false, false, nil)
|
||||
}
|
||||
*reply, err = engine.GetRevFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
objCaches,
|
||||
)
|
||||
return
|
||||
@@ -606,9 +605,9 @@ func (apierSv1 *APIerSv1) GetReverseFilterHealth(ctx *context.Context, args *eng
|
||||
|
||||
func (apierSv1 *APIerSv1) GetThresholdsIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheThresholdFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -620,9 +619,9 @@ func (apierSv1 *APIerSv1) GetThresholdsIndexesHealth(ctx *context.Context, args
|
||||
|
||||
func (apierSv1 *APIerSv1) GetResourcesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheResourceFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -634,9 +633,9 @@ func (apierSv1 *APIerSv1) GetResourcesIndexesHealth(ctx *context.Context, args *
|
||||
|
||||
func (apierSv1 *APIerSv1) GetStatsIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheStatFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -648,9 +647,9 @@ func (apierSv1 *APIerSv1) GetStatsIndexesHealth(ctx *context.Context, args *engi
|
||||
|
||||
func (apierSv1 *APIerSv1) GetRoutesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheRouteFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -662,9 +661,9 @@ func (apierSv1 *APIerSv1) GetRoutesIndexesHealth(ctx *context.Context, args *eng
|
||||
|
||||
func (apierSv1 *APIerSv1) GetAttributesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheAttributeFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -676,9 +675,9 @@ func (apierSv1 *APIerSv1) GetAttributesIndexesHealth(ctx *context.Context, args
|
||||
|
||||
func (apierSv1 *APIerSv1) GetChargersIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheChargerFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -690,9 +689,9 @@ func (apierSv1 *APIerSv1) GetChargersIndexesHealth(ctx *context.Context, args *e
|
||||
|
||||
func (apierSv1 *APIerSv1) GetDispatchersIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgsWith3Ch, reply *engine.FilterIHReply) error {
|
||||
rp, err := engine.GetFltrIdxHealth(apierSv1.DataManager,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, false, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, false, nil),
|
||||
utils.CacheDispatcherFilterIndexes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user