TEST(MultiDatabase, PUT_GET) { int iGroupCount = 2; MultiDatabase oDB; ASSERT_TRUE(InitDB(iGroupCount, oDB) == 0); const uint64_t llInstanceID = 3; std::string sValue = "hello paxos"; for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { std::string sGetValue; ASSERT_TRUE(oDB.Get(iGroupIdx, llInstanceID, sGetValue) == 1); } for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { WriteOptions oWriteOptions; oWriteOptions.bSync = true; ASSERT_TRUE(oDB.Put(oWriteOptions, iGroupIdx, llInstanceID, sValue) == 0); } for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { std::string sGetValue; ASSERT_TRUE(oDB.Get(iGroupIdx, llInstanceID, sGetValue) == 0); } }
void DelInstance(const int iGroupIdx, MultiDatabase & oLogStorage, uint64_t llInstanceID) { string sValue; int ret = oLogStorage.Get(iGroupIdx, llInstanceID, sValue); if (ret != 0) { printf("get this instance %lu fail, do you want to delete it? (y/n)\n", llInstanceID); } else { printf("this instance %lu value size is %zu, do you want to delete it? (y/n)\n", llInstanceID, sValue.size()); } string c = "n"; cin >> c; if (c == "y") { WriteOptions oWriteOptions; oWriteOptions.bSync = true; ret = oLogStorage.ForceDel(oWriteOptions, iGroupIdx, llInstanceID); if (ret != 0) { printf("delete instance %lu fail\n", llInstanceID); } else { printf("delete instance %lu ok\n", llInstanceID); } } }