Skip to content

Commit

Permalink
refactor: refactor rrdb_server into pegasus _read_service (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
Smityz authored Jun 12, 2020
1 parent b127bfb commit 764ee4f
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 231 deletions.
1 change: 0 additions & 1 deletion src/idl/recompile_thrift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ echo
echo "You should manually modify these files:"
echo " src/include/rrdb/rrdb.code.definition.h"
echo " src/include/rrdb/rrdb.client.h"
echo " src/include/rrdb/rrdb.server.h"
echo
echo "done"
226 changes: 0 additions & 226 deletions src/include/rrdb/rrdb.server.h

This file was deleted.

103 changes: 103 additions & 0 deletions src/server/pegasus_read_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#pragma once
#include <iostream>
#include <dsn/dist/replication/replication_app_base.h>
#include <dsn/dist/replication/storage_serverlet.h>
#include <rrdb/rrdb.code.definition.h>

namespace pegasus {
namespace server {
class pegasus_read_service : public dsn::replication::replication_app_base,
public dsn::replication::storage_serverlet<pegasus_read_service>
{
public:
pegasus_read_service(dsn::replication::replica *r) : dsn::replication::replication_app_base(r)
{
}
virtual ~pegasus_read_service() {}
virtual int on_request(dsn::message_ex *request) override
{
handle_request(request);
return 0;
}

protected:
// all service handlers to be implemented further
// RPC_RRDB_RRDB_GET
virtual void on_get(const ::dsn::blob &args,
::dsn::rpc_replier<dsn::apps::read_response> &reply) = 0;
// RPC_RRDB_RRDB_MULTI_GET
virtual void on_multi_get(const dsn::apps::multi_get_request &args,
::dsn::rpc_replier<dsn::apps::multi_get_response> &reply) = 0;
// RPC_RRDB_RRDB_SORTKEY_COUNT
virtual void on_sortkey_count(const ::dsn::blob &args,
::dsn::rpc_replier<dsn::apps::count_response> &reply) = 0;
// RPC_RRDB_RRDB_TTL
virtual void on_ttl(const ::dsn::blob &args,
::dsn::rpc_replier<dsn::apps::ttl_response> &reply) = 0;
// RPC_RRDB_RRDB_GET_SCANNER
virtual void on_get_scanner(const dsn::apps::get_scanner_request &args,
::dsn::rpc_replier<dsn::apps::scan_response> &reply) = 0;
// RPC_RRDB_RRDB_SCAN
virtual void on_scan(const dsn::apps::scan_request &args,
::dsn::rpc_replier<dsn::apps::scan_response> &reply) = 0;
// RPC_RRDB_RRDB_CLEAR_SCANNER
virtual void on_clear_scanner(const int64_t &args) = 0;

static void register_rpc_handlers()
{
register_async_rpc_handler(dsn::apps::RPC_RRDB_RRDB_GET, "get", on_get);
register_async_rpc_handler(dsn::apps::RPC_RRDB_RRDB_MULTI_GET, "multi_get", on_multi_get);
register_async_rpc_handler(
dsn::apps::RPC_RRDB_RRDB_SORTKEY_COUNT, "sortkey_count", on_sortkey_count);
register_async_rpc_handler(dsn::apps::RPC_RRDB_RRDB_TTL, "ttl", on_ttl);
register_async_rpc_handler(
dsn::apps::RPC_RRDB_RRDB_GET_SCANNER, "get_scanner", on_get_scanner);
register_async_rpc_handler(dsn::apps::RPC_RRDB_RRDB_SCAN, "scan", on_scan);
register_async_rpc_handler(
dsn::apps::RPC_RRDB_RRDB_CLEAR_SCANNER, "clear_scanner", on_clear_scanner);
}

private:
static void on_get(pegasus_read_service *svc,
const ::dsn::blob &args,
::dsn::rpc_replier<dsn::apps::read_response> &reply)
{
svc->on_get(args, reply);
}
static void on_multi_get(pegasus_read_service *svc,
const dsn::apps::multi_get_request &args,
::dsn::rpc_replier<dsn::apps::multi_get_response> &reply)
{
svc->on_multi_get(args, reply);
}
static void on_sortkey_count(pegasus_read_service *svc,
const ::dsn::blob &args,
::dsn::rpc_replier<dsn::apps::count_response> &reply)
{
svc->on_sortkey_count(args, reply);
}
static void on_ttl(pegasus_read_service *svc,
const ::dsn::blob &args,
::dsn::rpc_replier<dsn::apps::ttl_response> &reply)
{
svc->on_ttl(args, reply);
}
static void on_get_scanner(pegasus_read_service *svc,
const dsn::apps::get_scanner_request &args,
::dsn::rpc_replier<dsn::apps::scan_response> &reply)
{
svc->on_get_scanner(args, reply);
}
static void on_scan(pegasus_read_service *svc,
const dsn::apps::scan_request &args,
::dsn::rpc_replier<dsn::apps::scan_response> &reply)
{
svc->on_scan(args, reply);
}
static void on_clear_scanner(pegasus_read_service *svc, const int64_t &args)
{
svc->on_clear_scanner(args);
}
};
} // namespace server
} // namespace pegasus
4 changes: 2 additions & 2 deletions src/server/pegasus_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#include <dsn/perf_counter/perf_counter_wrapper.h>
#include <dsn/dist/replication/replication.codes.h>
#include <rrdb/rrdb_types.h>
#include <rrdb/rrdb.server.h>
#include <gtest/gtest_prod.h>

#include "key_ttl_compaction_filter.h"
#include "pegasus_scan_context.h"
#include "pegasus_manual_compact_service.h"
#include "pegasus_write_service.h"
#include "range_read_limiter.h"
#include "pegasus_read_service.h"

namespace pegasus {
namespace server {
Expand All @@ -28,7 +28,7 @@ class meta_store;
class capacity_unit_calculator;
class pegasus_server_write;

class pegasus_server_impl : public ::dsn::apps::rrdb_service
class pegasus_server_impl : public pegasus_read_service
{
public:
static void register_service()
Expand Down
2 changes: 1 addition & 1 deletion src/server/pegasus_server_impl_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace pegasus {
namespace server {
pegasus_server_impl::pegasus_server_impl(dsn::replication::replica *r)
: dsn::apps::rrdb_service(r),
: pegasus_read_service(r),
_db(nullptr),
_data_cf(nullptr),
_meta_cf(nullptr),
Expand Down

0 comments on commit 764ee4f

Please sign in to comment.