mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
crimson: add prototype of crimson/osd
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
9fae689b6e
commit
81d78fe5fe
@ -80,6 +80,7 @@ add_library(crimson-common STATIC
|
||||
${PROJECT_SOURCE_DIR}/src/msg/msg_types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/msg/Message.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mon/MonCap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mon/MonMap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/osd_types.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/ECMsgTypes.cc
|
||||
${PROJECT_SOURCE_DIR}/src/osd/HitSet.cc
|
||||
@ -110,7 +111,6 @@ set(crimson_auth_srcs
|
||||
auth/KeyRing.cc)
|
||||
set(crimson_mon_srcs
|
||||
mon/MonClient.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mon/MonMap.cc
|
||||
${PROJECT_SOURCE_DIR}/src/mon/MonSub.cc)
|
||||
set(crimson_net_srcs
|
||||
net/Dispatcher.cc
|
||||
@ -134,3 +134,4 @@ target_link_libraries(crimson
|
||||
crimson-common
|
||||
crimson::cflags)
|
||||
add_subdirectory(os)
|
||||
add_subdirectory(osd)
|
||||
|
5
src/crimson/osd/CMakeLists.txt
Normal file
5
src/crimson/osd/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_executable(crimson-osd
|
||||
main.cc
|
||||
osd.cc)
|
||||
target_link_libraries(crimson-osd
|
||||
crimson-common crimson-os crimson)
|
81
src/crimson/osd/main.cc
Normal file
81
src/crimson/osd/main.cc
Normal file
@ -0,0 +1,81 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <seastar/core/app-template.hh>
|
||||
#include <seastar/core/thread.hh>
|
||||
|
||||
#include "common/ceph_argparse.h"
|
||||
#include "crimson/common/config_proxy.h"
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
using config_t = ceph::common::ConfigProxy;
|
||||
|
||||
void usage(const char* prog) {
|
||||
std::cout << "usage: " << prog << " -i <ID>" << std::endl;
|
||||
generic_server_usage();
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::vector<const char*> args{argv + 1, argv + argc};
|
||||
if (ceph_argparse_need_usage(args)) {
|
||||
usage(argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
std::string cluster;
|
||||
std::string conf_file_list;
|
||||
// ceph_argparse_early_args() could _exit(), while local_conf() won't ready
|
||||
// until it's started. so do the boilerplate-settings parsing here.
|
||||
auto init_params = ceph_argparse_early_args(args,
|
||||
CEPH_ENTITY_TYPE_OSD,
|
||||
&cluster,
|
||||
&conf_file_list);
|
||||
seastar::app_template app;
|
||||
seastar::sharded<OSD> osd;
|
||||
|
||||
using ceph::common::sharded_conf;
|
||||
using ceph::common::sharded_perf_coll;
|
||||
using ceph::common::local_conf;
|
||||
|
||||
args.insert(begin(args), argv[0]);
|
||||
try {
|
||||
return app.run_deprecated(args.size(), const_cast<char**>(args.data()), [&] {
|
||||
seastar::engine().at_exit([] {
|
||||
return sharded_conf().stop();
|
||||
});
|
||||
seastar::engine().at_exit([] {
|
||||
return sharded_perf_coll().stop();
|
||||
});
|
||||
seastar::engine().at_exit([&] {
|
||||
return osd.stop();
|
||||
});
|
||||
return sharded_conf().start(init_params.name, cluster).then([] {
|
||||
return sharded_perf_coll().start();
|
||||
}).then([&conf_file_list] {
|
||||
return local_conf().parse_config_files(conf_file_list);
|
||||
}).then([&] {
|
||||
return osd.start_single(std::stoi(local_conf()->name.get_id()),
|
||||
static_cast<uint32_t>(getpid()));
|
||||
}).then([&] {
|
||||
return osd.invoke_on(0, &OSD::start);
|
||||
});
|
||||
});
|
||||
} catch (...) {
|
||||
seastar::fprint(std::cerr, "FATAL: Exception during startup, aborting: %s\n", std::current_exception());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* compile-command: "make -j4 \
|
||||
* -C ../../../build \
|
||||
* crimson-osd"
|
||||
* End:
|
||||
*/
|
42
src/crimson/osd/osd.cc
Normal file
42
src/crimson/osd/osd.cc
Normal file
@ -0,0 +1,42 @@
|
||||
#include "osd.h"
|
||||
|
||||
#include "crimson/net/SocketMessenger.h"
|
||||
|
||||
namespace {
|
||||
seastar::logger& logger() {
|
||||
return ceph::get_logger(ceph_subsys_osd);
|
||||
}
|
||||
}
|
||||
|
||||
using ceph::common::local_conf;
|
||||
|
||||
OSD::OSD(int id, uint32_t nonce)
|
||||
: whoami{id},
|
||||
cluster_msgr{new ceph::net::SocketMessenger{entity_name_t::OSD(whoami),
|
||||
"cluster", nonce}},
|
||||
client_msgr{new ceph::net::SocketMessenger{entity_name_t::OSD(whoami),
|
||||
"client", nonce}},
|
||||
monc{*client_msgr}
|
||||
{
|
||||
for (auto msgr : {cluster_msgr.get(), client_msgr.get()}) {
|
||||
if (local_conf()->ms_crc_data) {
|
||||
msgr->set_crc_data();
|
||||
}
|
||||
if (local_conf()->ms_crc_header) {
|
||||
msgr->set_crc_header();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OSD::~OSD() = default;
|
||||
|
||||
seastar::future<> OSD::start()
|
||||
{
|
||||
logger().info("start");
|
||||
return seastar::now();
|
||||
}
|
||||
|
||||
seastar::future<> OSD::stop()
|
||||
{
|
||||
return gate.close();
|
||||
}
|
26
src/crimson/osd/osd.h
Normal file
26
src/crimson/osd/osd.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <seastar/core/future.hh>
|
||||
#include <seastar/core/gate.hh>
|
||||
|
||||
#include "crimson/net/Dispatcher.h"
|
||||
|
||||
namespace ceph::net {
|
||||
class Messenger;
|
||||
}
|
||||
|
||||
class OSD : public ceph::net::Dispatcher {
|
||||
seastar::gate gate;
|
||||
const int whoami;
|
||||
// talk with osd
|
||||
std::unique_ptr<ceph::net::Messenger> cluster_msgr;
|
||||
// talk with mon/mgr
|
||||
std::unique_ptr<ceph::net::Messenger> client_msgr;
|
||||
|
||||
public:
|
||||
OSD(int id, uint32_t nonce);
|
||||
~OSD();
|
||||
|
||||
seastar::future<> start();
|
||||
seastar::future<> stop();
|
||||
};
|
Loading…
Reference in New Issue
Block a user