Line data Source code
1 : /* 2 : * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #include "cmn/agent.h" 6 : #include "cmn/agent_cmn.h" 7 : #include <sandesh/sandesh_types.h> 8 : #include <sandesh/sandesh.h> 9 : #include "resource_manager/resource_manager.h" 10 : #include "resource_manager/resource_table.h" 11 : #include "resource_manager/resource_cmn.h" 12 : #include "mirror_index.h" 13 : #include "resource_manager/resource_manager_types.h" 14 : #include "resource_manager/resource_backup.h" 15 : 16 0 : MirrorIndexResourceKey::MirrorIndexResourceKey (ResourceManager *rm, 17 0 : const string& analyzer_name):IndexResourceKey(rm, Resource::MIRROR_INDEX), 18 0 : analyzer_name_(analyzer_name) { 19 : 20 0 : } 21 : 22 0 : void MirrorIndexResourceKey::Backup(ResourceData *data, uint16_t op){ 23 0 : IndexResourceData *index_data = static_cast<IndexResourceData *>(data); 24 0 : if (op == ResourceBackupReq::DEL) { 25 : rm()->backup_mgr()-> 26 0 : sandesh_maps().DeleteMirrorResourceEntry(index_data->index()); 27 : } else { 28 0 : MirrorIndexResource backup_data; 29 0 : backup_data.set_analyzer_name(analyzer_name_); 30 0 : backup_data.set_time_stamp(UTCTimestampUsec()); 31 : rm()->backup_mgr()-> 32 0 : sandesh_maps().AddMirrorResourceEntry(index_data->index(), 33 : backup_data); 34 0 : } 35 0 : rm()->backup_mgr()->sandesh_maps().mirror_index_table().TriggerBackup(); 36 : 37 0 : } 38 : 39 0 : bool MirrorIndexResourceKey::IsLess(const ResourceKey &rhs) const { 40 0 : const MirrorIndexResourceKey * key = 41 : static_cast<const MirrorIndexResourceKey*> (&rhs); 42 0 : return analyzer_name_ < key->analyzer_name_; 43 : }