int main(int argc, char ** argv) { if (argc < 5) { printf("%s <paxos log dir> <group idx> <del> <instanceid>\n", argv[0]); return -1; } string sPaxosLogPath = argv[1]; int iGroupIdx = atoi(argv[2]); if (sPaxosLogPath.size() == 0) { printf("paxos log path not valid, path %s\n", sPaxosLogPath.c_str()); return -1; } MultiDatabase oDefaultLogStorage; int ret = oDefaultLogStorage.Init(sPaxosLogPath, iGroupIdx + 1); if (ret != 0) { printf("init log storage fail, ret %d\n", ret); return ret; } string sOP = string(argv[3]); uint64_t llInstanceID = strtoull(argv[4], NULL, 10); if (sOP == "del") { DelInstance(iGroupIdx, oDefaultLogStorage, llInstanceID); } return 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; }