Skip to content

Commit

Permalink
Scaling changes for introspect.
Browse files Browse the repository at this point in the history
1. Currently, the IFMapTableShowReq and IFMapTableShowReq introspects buffer
the entire table and then send in batches. This will not work in scaling
scenarios where the number of nodes/links is huge. Change both the introspects
to buffer/send 50 entries at a time and add code to iterate by providing a
next_batch link on the client page.
2. Add the table size for the link-table as part of the introspect output. The
link-table size output cannot be put in IFMapNodeTableListShowReq since the
table names in that show are clickable.
3. Add new APIs in the db-partition code needed by the above changes.

Closes-Bug: 1457216

Change-Id: Ia5694269917913da36c2efc341293ba4f6f9350d
  • Loading branch information
tkarwa committed Jul 14, 2015
1 parent e6e07d4 commit 2e4276c
Show file tree
Hide file tree
Showing 12 changed files with 490 additions and 161 deletions.
4 changes: 4 additions & 0 deletions src/db/db.cc
Expand Up @@ -64,6 +64,10 @@ DBTableBase *DB::FindTable(const string &name) {
return NULL;
}

DB::iterator DB::FindTableIter(const string &name) {
return tables_.find(name);
}

void DB::AddTable(DBTableBase *tbl_base) {
pair<TableMap::iterator, bool> result =
tables_.insert(make_pair(tbl_base->name(), tbl_base));
Expand Down
1 change: 1 addition & 0 deletions src/db/db.h
Expand Up @@ -38,6 +38,7 @@ class DB {
// Table creation.
DBTableBase *CreateTable(const std::string &name);
DBTableBase *FindTable(const std::string &name);
iterator FindTableIter(const std::string &name);
void RemoveTable(DBTableBase *tbl_base);

// Table walker
Expand Down
12 changes: 12 additions & 0 deletions src/db/db_table_partition.cc
Expand Up @@ -144,6 +144,18 @@ DBEntry *DBTablePartition::Find(const DBRequestKey *key) {
return NULL;
}

DBEntry *DBTablePartition::FindNext(const DBRequestKey *key) {
tbb::mutex::scoped_lock lock(mutex_);
DBTable *table = static_cast<DBTable *>(parent());
std::auto_ptr<DBEntry> entry_ptr = table->AllocEntry(key);

Tree::iterator loc = tree_.upper_bound(*(entry_ptr.get()));
if (loc != tree_.end()) {
return loc.operator->();
}
return NULL;
}

// Returns the matching entry or next in lex order
DBEntry *DBTablePartition::lower_bound(const DBEntryBase *key) {
const DBEntry *entry = static_cast<const DBEntry *>(key);
Expand Down
4 changes: 4 additions & 0 deletions src/db/db_table_partition.h
Expand Up @@ -77,6 +77,7 @@ class DBTablePartition : public DBTablePartBase {
void Process(DBClient *client, DBRequest *req);
// Returns the matching route or next in lex order
virtual DBEntry *lower_bound(const DBEntryBase *entry);

// Returns the next route (Doesn't search). Threaded walk
virtual DBEntry *GetNext(const DBEntryBase *entry);

Expand All @@ -102,6 +103,9 @@ class DBTablePartition : public DBTablePartBase {
// Find DB Entry. Get key from from argument
DBEntry *Find(const DBRequestKey *key);

// Find the next in lex order
DBEntry *FindNext(const DBRequestKey *key);

DBTable *table();
size_t size() const { return tree_.size(); }

Expand Down
1 change: 1 addition & 0 deletions src/ifmap/SConscript
Expand Up @@ -17,6 +17,7 @@ except_env.CppEnableExceptions()
except_env.Append(CPPPATH = env['TOP'])

SandeshGenFiles = env.SandeshGenCpp('ifmap_server_show.sandesh')
SandeshGenFiles += env.SandeshGenOnlyCpp('ifmap_server_show_internal.sandesh')
SandeshGenFiles += env.SandeshGenCpp('ifmap_log.sandesh')
SandeshGenSrcs = env.ExtractCpp(SandeshGenFiles)

Expand Down
9 changes: 9 additions & 0 deletions src/ifmap/ifmap_link_table.cc
Expand Up @@ -75,6 +75,15 @@ IFMapLink *IFMapLinkTable::FindLink(const string &name) {
return static_cast<IFMapLink *>(partition->Find(&key));
}

IFMapLink *IFMapLinkTable::FindNextLink(const string &name) {

DBTablePartition *partition =
static_cast<DBTablePartition *>(GetTablePartition(0));
RequestKey key;
key.name = name;
return static_cast<IFMapLink *>(partition->FindNext(&key));
}

void IFMapLinkTable::DeleteLink(DBGraphEdge *edge) {
IFMapLink *link = static_cast<IFMapLink *>(edge);
link->set_last_change_at_to_now();
Expand Down
1 change: 1 addition & 0 deletions src/ifmap/ifmap_link_table.h
Expand Up @@ -50,6 +50,7 @@ class IFMapLinkTable : public DBTable {
static DBTable *CreateTable(DB *db, const std::string &name,
DBGraph *graph);
IFMapLink *FindLink(const std::string &name);
IFMapLink *FindNextLink(const std::string &name);

protected:
void DeleteLink(DBGraphEdge *edge);
Expand Down

0 comments on commit 2e4276c

Please sign in to comment.