Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move func ingestion_files to rocksdb_wrapper #671

Merged
merged 11 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/server/pegasus_write_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,10 @@ class pegasus_write_service::impl : public dsn::replication::replica_base
}

// ingest external files
rocksdb::IngestExternalFileOptions ifo;
rocksdb::Status s = _db->IngestExternalFile(sst_file_list, ifo);
if (!s.ok()) {
derror_rocksdb("IngestExternalFile", s.ToString(), "decree = {}", decree);
if (dsn_unlikely(_rocksdb_wrapper->ingestion_files(decree, sst_file_list) != 0)) {
return dsn::ERR_INGESTION_FAILED;
} else {
ddebug_rocksdb("IngestExternalFile", "Ingest files succeed, decree = {}", decree);
return dsn::ERR_OK;
}
return dsn::ERR_OK;
}

/// For batch write.
Expand Down
12 changes: 12 additions & 0 deletions src/server/rocksdb_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ int rocksdb_wrapper::write_batch_delete(int64_t decree, dsn::string_view raw_key

void rocksdb_wrapper::clear_up_write_batch() { _write_batch->Clear(); }

int rocksdb_wrapper::ingestion_files(int64_t decree, const std::vector<std::string> &sst_file_list)
{
rocksdb::IngestExternalFileOptions ifo;
rocksdb::Status s = _db->IngestExternalFile(sst_file_list, ifo);
if (dsn_unlikely(!s.ok())) {
derror_rocksdb("IngestExternalFile", s.ToString(), "decree = {}", decree);
} else {
ddebug_rocksdb("IngestExternalFile", "Ingest files succeed, decree = {}", decree);
}
return s.code();
}

void rocksdb_wrapper::set_default_ttl(uint32_t ttl)
{
if (_default_ttl != ttl) {
Expand Down
1 change: 1 addition & 0 deletions src/server/rocksdb_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class rocksdb_wrapper : public dsn::replication::replica_base
int write(int64_t decree);
int write_batch_delete(int64_t decree, dsn::string_view raw_key);
void clear_up_write_batch();
int ingestion_files(int64_t decree, const std::vector<std::string> &sst_file_list);

void set_default_ttl(uint32_t ttl);

Expand Down