forked from sonic-net/sonic-sairedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap saidump's functions into a class and update the unittest codes.
- Loading branch information
1 parent
5ba869c
commit 5cf3960
Showing
5 changed files
with
130 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "saidump.h" | ||
|
||
using namespace syncd; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); | ||
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_NOTICE); | ||
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_INFO); | ||
|
||
SaiDump m_saiDump; | ||
|
||
if(SAI_STATUS_SUCCESS != m_saiDump.handleCmdLine(argc, argv)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
m_saiDump.dumpFromRedisDb(); | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,52 @@ | ||
#pragma once | ||
|
||
extern "C" { | ||
#include <sai.h> | ||
} | ||
#include <inttypes.h> | ||
#include <set> | ||
#include <regex> | ||
#include <climits> | ||
#include <getopt.h> | ||
#include "swss/table.h" | ||
#include "meta/sai_serialize.h" | ||
#include "sairediscommon.h" | ||
#include "swss/json.hpp" | ||
|
||
using namespace swss; | ||
using json = nlohmann::json; | ||
|
||
// Default value: 100MB | ||
constexpr int64_t RDB_JSON_MAX_SIZE = 1024 * 1024 * 100; | ||
static constexpr int64_t RDB_JSON_MAX_SIZE = 1024 * 1024 * 100; | ||
|
||
struct CmdOptions | ||
namespace syncd | ||
{ | ||
bool skipAttributes; | ||
bool dumpTempView; | ||
bool dumpGraph; | ||
std::string rdbJsonFile; | ||
uint64_t rdbJSonSizeLimit; | ||
}; | ||
class SaiDump | ||
{ | ||
public: | ||
SaiDump() = default; | ||
~SaiDump() = default; | ||
sai_status_t handleCmdLine(int argc, char **argv); | ||
void dumpFromRedisDb(); | ||
void printUsage(); | ||
sai_status_t dumpFromRedisRdbJson(); | ||
sai_status_t preProcessFile(const std::string file_name); | ||
|
||
public: | ||
std::string rdbJsonFile; | ||
uint64_t rdbJSonSizeLimit; | ||
|
||
private: | ||
bool skipAttributes; | ||
bool dumpTempView; | ||
bool dumpGraph; | ||
std::map<sai_object_id_t, const TableMap*> g_oid_map; | ||
|
||
void printUsage(); | ||
CmdOptions handleCmdLine(int argc, char **argv); | ||
sai_status_t dumpFromRedisRdbJson(const std::string file_name); | ||
sai_status_t preProcessFile(const std::string file_name); | ||
private: | ||
size_t get_max_attr_len(const TableMap& map); | ||
std::string pad_string(std::string s, size_t pad); | ||
const TableMap* get_table_map(sai_object_id_t object_id); | ||
void dumpGraphFun(const TableDump& td); | ||
void print_attributes(size_t indent, const TableMap& map); | ||
}; | ||
} |
Oops, something went wrong.