Example #1
0
TEST(MultiDatabase, ClearAllLog)
{
	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++)
	{
		WriteOptions oWriteOptions;
		oWriteOptions.bSync = true;

		ASSERT_TRUE(oDB.Put(oWriteOptions, iGroupIdx, llInstanceID, sValue) == 0);
	}

	for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++)
	{
		ASSERT_TRUE(oDB.ClearAllLog(iGroupIdx) == 0);
	}

	for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++)
	{
		const uint64_t llInstanceID = 3;
		std::string sGetValue;

		ASSERT_TRUE(oDB.Get(iGroupIdx, llInstanceID, sGetValue) == 1);
	}
}
Example #2
0
int InitDB(const int iGroupCount, MultiDatabase & oDB)
{
	string sDBPath;
    int ret = MakeLogStoragePath(sDBPath);
    if (ret != 0)
    {
        return ret;
    }

	ret = oDB.Init(sDBPath, iGroupCount);
	if (ret != 0)
	{
		return ret;
	}
	
	for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++)
	{
		ret = oDB.ClearAllLog(iGroupIdx);
		if (ret != 0)
		{
			return ret;
		}
	}
	
	return 0;
}