Skip to content

Commit

Permalink
Merge "Set DBTable partition for agent to 1"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 7, 2015
2 parents 5ca4a4f + 55ef374 commit 0e2f30f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/db/db_table.cc
Expand Up @@ -158,8 +158,8 @@ class DBTableBase::ListenerInfo {

DBTableBase::DBTableBase(DB *db, const string &name)
: db_(db), name_(name), info_(new ListenerInfo(name)),
enqueue_count_(0), input_count_(0), notify_count_(0),
walker_count_(0) {
enqueue_count_(0), input_count_(0), notify_count_(0) {
walker_count_ = 0;
walk_request_count_ = 0;
walk_complete_count_ = 0;
walk_cancel_count_ = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/db/db_table.h
Expand Up @@ -136,7 +136,7 @@ class DBTableBase {
uint64_t enqueue_count_;
uint64_t input_count_;
uint64_t notify_count_;
uint64_t walker_count_;
tbb::atomic<uint64_t> walker_count_;
tbb::atomic<uint64_t> walk_request_count_;
tbb::atomic<uint64_t> walk_complete_count_;
tbb::atomic<uint64_t> walk_cancel_count_;
Expand Down
2 changes: 1 addition & 1 deletion src/db/db_table_walker.cc
Expand Up @@ -163,7 +163,7 @@ DBTableWalker::Walker::Walker(WalkId id, DBTableWalker *wkmgr,
: id_(id), wkmgr_(wkmgr), table_(table),
key_start_(const_cast<DBRequestKey *>(key)),
walker_fn_(walker), done_fn_(walk_done) {
int num_worker = DB::PartitionCount();
int num_worker = table->PartitionCount();
should_stop_ = false;
status_ = num_worker;
for (int i = 0; i < num_worker; i++) {
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/cmn/agent_db.h
Expand Up @@ -125,6 +125,7 @@ class AgentDBEntry : public DBEntry {
/////////////////////////////////////////////////////////////////////////////
class AgentDBTable : public DBTable {
public:
static const int kPartitionCount = 1;
AgentDBTable(DB *db, const std::string &name) :
DBTable(db, name), ref_listener_id_(-1), agent_(NULL) {
ref_listener_id_ = Register(boost::bind(&AgentDBTable::Notify,
Expand All @@ -139,6 +140,7 @@ class AgentDBTable : public DBTable {

virtual ~AgentDBTable() { };

virtual int PartitionCount() const { return kPartitionCount; }
virtual void Input(DBTablePartition *root, DBClient *client,
DBRequest *req);
virtual DBEntry *CfgAdd(DBRequest *req) {return NULL;};
Expand Down
7 changes: 7 additions & 0 deletions src/vnsw/agent/cmn/test/test.cc
Expand Up @@ -402,6 +402,13 @@ void TestInit() {
TableB::ClearCount();
}

// Validate partition count
TEST_F(DBTest, Partition_0) {
TestInit();
EXPECT_EQ(1, table_a_->PartitionCount());
EXPECT_EQ(1, table_b_->PartitionCount());
}

// Add Entry-B, Add Entry-A, Del Entry-B, Del Entry-A
TEST_F(DBTest, TestRef_RefWait_0) {
TestInit();
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/oper/agent_route.h
Expand Up @@ -102,12 +102,14 @@ struct RouteTableWalkerState {
// bridge. This base class contains common code for all route tables
class AgentRouteTable : public RouteTable {
public:
static const int kPartitionCount = 1;
typedef std::set<const AgentRoute *, RouteComparator> UnresolvedRouteTree;
typedef std::set<const NextHop *, NHComparator> UnresolvedNHTree;

AgentRouteTable(DB *db, const std::string &name);
virtual ~AgentRouteTable();

virtual int PartitionCount() const { return kPartitionCount; }
virtual std::auto_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
virtual size_t Hash(const DBEntry *entry) const {return 0;}
virtual size_t Hash(const DBRequestKey *key) const {return 0;}
Expand Down
11 changes: 11 additions & 0 deletions src/vnsw/agent/test/test_route.cc
Expand Up @@ -250,6 +250,17 @@ class TestRtState : public DBState {
int dummy_;
};

// Validate that routes db-tables have 1 partition only
TEST_F(RouteTest, PartitionCount_1) {
string vrf_name = agent_->fabric_vrf_name();
VrfEntry *vrf = agent_->vrf_table()->FindVrfFromName(vrf_name);
EXPECT_TRUE(vrf != NULL);

for (int i = Agent::INVALID + 1; i < Agent::ROUTE_TABLE_MAX; i++) {
EXPECT_EQ(1, vrf->GetRouteTable(i)->PartitionCount());
}
}

TEST_F(RouteTest, HostRoute_1) {
//Host Route - Used to trap packets to agent
//Add and delete host route
Expand Down

0 comments on commit 0e2f30f

Please sign in to comment.