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

feat(rocksdb): Remove all calls of Pegasus introduced APIs on RocksDB #556

Merged
merged 2 commits into from
Jul 7, 2020
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
61 changes: 13 additions & 48 deletions src/server/meta_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
namespace pegasus {
namespace server {

DSN_DEFINE_string("pegasus.server",
get_meta_store_type,
"metacf",
"Where to get meta data, now support 'manifest' and 'metacf'");
DSN_DEFINE_validator(get_meta_store_type, [](const char *type) {
return strcmp(type, "manifest") == 0 || strcmp(type, "metacf") == 0;
});

const std::string meta_store::DATA_VERSION = "pegasus_data_version";
const std::string meta_store::LAST_FLUSHED_DECREE = "pegasus_last_flushed_decree";
const std::string meta_store::LAST_MANUAL_COMPACT_FINISH_TIME =
Expand All @@ -30,58 +22,31 @@ meta_store::meta_store(pegasus_server_impl *server,
{
// disable write ahead logging as replication handles logging instead now
_wt_opts.disableWAL = true;
_get_meta_store_type =
(strcmp(FLAGS_get_meta_store_type, "manifest") == 0 ? meta_store_type::kManifestOnly
: meta_store_type::kMetaCFOnly);
}

uint64_t meta_store::get_last_flushed_decree() const
{
switch (_get_meta_store_type) {
case meta_store_type::kManifestOnly:
return _db->GetLastFlushedDecree();
case meta_store_type::kMetaCFOnly: {
uint64_t last_flushed_decree = 0;
auto ec = get_value_from_meta_cf(true, LAST_FLUSHED_DECREE, &last_flushed_decree);
dcheck_eq_replica(::dsn::ERR_OK, ec);
return last_flushed_decree;
}
default:
__builtin_unreachable();
}
uint64_t last_flushed_decree = 0;
auto ec = get_value_from_meta_cf(true, LAST_FLUSHED_DECREE, &last_flushed_decree);
dcheck_eq_replica(::dsn::ERR_OK, ec);
return last_flushed_decree;
}

uint32_t meta_store::get_data_version() const
{
switch (_get_meta_store_type) {
case meta_store_type::kManifestOnly:
return _db->GetPegasusDataVersion();
case meta_store_type::kMetaCFOnly: {
uint64_t pegasus_data_version = 0;
auto ec = get_value_from_meta_cf(false, DATA_VERSION, &pegasus_data_version);
dcheck_eq_replica(::dsn::ERR_OK, ec);
return static_cast<uint32_t>(pegasus_data_version);
}
default:
__builtin_unreachable();
}
uint64_t pegasus_data_version = 0;
auto ec = get_value_from_meta_cf(false, DATA_VERSION, &pegasus_data_version);
dcheck_eq_replica(::dsn::ERR_OK, ec);
return static_cast<uint32_t>(pegasus_data_version);
}

uint64_t meta_store::get_last_manual_compact_finish_time() const
{
switch (_get_meta_store_type) {
case meta_store_type::kManifestOnly:
return _db->GetLastManualCompactFinishTime();
case meta_store_type::kMetaCFOnly: {
uint64_t last_manual_compact_finish_time = 0;
auto ec = get_value_from_meta_cf(
false, LAST_MANUAL_COMPACT_FINISH_TIME, &last_manual_compact_finish_time);
dcheck_eq_replica(::dsn::ERR_OK, ec);
return last_manual_compact_finish_time;
}
default:
__builtin_unreachable();
}
uint64_t last_manual_compact_finish_time = 0;
auto ec = get_value_from_meta_cf(
false, LAST_MANUAL_COMPACT_FINISH_TIME, &last_manual_compact_finish_time);
dcheck_eq_replica(::dsn::ERR_OK, ec);
return last_manual_compact_finish_time;
}

uint64_t meta_store::get_decree_from_readonly_db(rocksdb::DB *db,
Expand Down
9 changes: 0 additions & 9 deletions src/server/meta_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ class pegasus_server_impl;
class meta_store : public dsn::replication::replica_base
{
public:
enum class meta_store_type
{
kManifestOnly = 0,
kMetaCFOnly,
kBothManifestAndMetaCF,
};

meta_store(pegasus_server_impl *server, rocksdb::DB *db, rocksdb::ColumnFamilyHandle *meta_cf);

uint64_t get_last_flushed_decree() const;
Expand Down Expand Up @@ -63,8 +56,6 @@ class meta_store : public dsn::replication::replica_base
rocksdb::DB *_db;
rocksdb::ColumnFamilyHandle *_meta_cf;
rocksdb::WriteOptions _wt_opts;

meta_store_type _get_meta_store_type;
};

} // namespace server
Expand Down
2 changes: 0 additions & 2 deletions src/server/pegasus_server_impl_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r)
_rng_rd_opts.rocksdb_iteration_threshold_time_ms_in_config;

// init rocksdb::DBOptions
_db_opts.pegasus_data = true;
_db_opts.pegasus_data_version = _pegasus_data_version;
_db_opts.create_if_missing = true;
// atomic flush data CF and meta CF, aim to keep consistency of 'last flushed decree' in meta CF
// and data in data CF.
Expand Down
1 change: 0 additions & 1 deletion src/server/pegasus_write_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ class pegasus_write_service::impl : public dsn::replication::replica_base
return status.code();
}

_wt_opts.given_decree = static_cast<uint64_t>(decree);
status = _db->Write(_wt_opts, &_batch);
if (dsn_unlikely(!status.ok())) {
derror_rocksdb("Write", status.ToString(), "write rocksdb error, decree: {}", decree);
Expand Down