-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Ecapsulate saidump.cpp with class.
2. Add unittest codes.
- Loading branch information
1 parent
4b32eaf
commit 033e6a2
Showing
10 changed files
with
304 additions
and
100 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
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,19 @@ | ||
#include "saidump.h" | ||
|
||
using namespace syncd; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#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 <nlohmann/json.hpp> | ||
|
||
// Default value: 100MB | ||
static constexpr int64_t RDB_JSON_MAX_SIZE = 1024 * 1024 * 100; | ||
|
||
namespace syncd | ||
{ | ||
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); | ||
void traverseJson(const json & jsn); | ||
|
||
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; | ||
|
||
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.