-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle object persist/cleanup/read outside persistence_manager. (#1931)
### What problem does this PR solve? PersistenceManager::Persist, PersistenceManager::Finalize, PersistenceManager::Cleanup now return PersistWriteResult. PersistenceManager::GetObj now return PersistReadResult. PerisistResultHandler is used to handle the result. If remote filesystem is supported. the envict and recover key is inside the PersistWriteResult. and PersistReadResult will contain whether cache is valid. Send request to remote fielsystem and update cache is job of PersistResultHandler. ### Type of change - [x] Refactoring
- Loading branch information
1 parent
2bb1ecb
commit 0077b4a
Showing
13 changed files
with
247 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright(C) 2023 InfiniFlow, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
module; | ||
|
||
#include <vector> | ||
#include <filesystem> | ||
|
||
module persist_result_handler; | ||
|
||
import infinity_exception; | ||
import third_party; | ||
|
||
namespace fs = std::filesystem; | ||
|
||
namespace infinity { | ||
|
||
void PersistResultHandler::HandleWriteResult(const PersistWriteResult &result) { | ||
for ([[maybe_unused]] const String &persist_key : result.persist_keys_) { | ||
// | ||
} | ||
for (const String &drop_key : result.drop_keys_) { | ||
String drop_path = pm_->GetObjPath(drop_key); | ||
fs::remove(drop_path); | ||
} | ||
} | ||
|
||
ObjAddr PersistResultHandler::HandleReadResult(const PersistReadResult &result) { | ||
if (!result.cached_) { | ||
UnrecoverableError(fmt::format("HandleReadResult: object {} is not cached", result.obj_addr_.obj_key_)); | ||
} | ||
return result.obj_addr_; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright(C) 2023 InfiniFlow, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
module; | ||
|
||
export module persist_result_handler; | ||
|
||
import stl; | ||
import persistence_manager; | ||
|
||
namespace infinity { | ||
|
||
export class PersistResultHandler { | ||
public: | ||
PersistResultHandler(PersistenceManager *pm) : pm_(pm) {} | ||
|
||
void HandleWriteResult(const PersistWriteResult &result); | ||
|
||
ObjAddr HandleReadResult(const PersistReadResult &result); | ||
|
||
private: | ||
PersistenceManager *pm_; | ||
}; | ||
|
||
} |
Oops, something went wrong.