Files
scylladb/main.cc
Glauber Costa 7f96fc9509 db: read all keyspaces from directory structure
This patch includes a helper function that executes a function for each entry
in a directory. It is future based and can include in the future, future-based
code to asychronously read, for instance, an sstable.

At the moment, it only scan all keyspaces and make sure they appear in the
keyspaces hash.

Both the database and keyspace classes gain a populate<T> factory that returns a
populated database. At this point, the names found are just listed, but not really
stored anywhere.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-01-13 10:41:13 +02:00

37 lines
1.2 KiB
C++

/*
* Copyright 2014 Cloudius Systems
*/
#include "database.hh"
#include "core/app-template.hh"
#include "core/smp.hh"
#include "thrift/server.hh"
namespace bpo = boost::program_options;
int main(int ac, char** av) {
app_template app;
app.add_options()
("thrift-port", bpo::value<uint16_t>()->default_value(9160), "Thrift port")
("datadir", bpo::value<std::string>()->default_value("/var/lib/cassandra/data"), "data directory");
auto server = std::make_unique<distributed<thrift_server>>();;
return app.run(ac, av, [&] {
auto&& config = app.configuration();
uint16_t port = config["thrift-port"].as<uint16_t>();
sstring datadir = config["datadir"].as<std::string>();
return database::populate(datadir).then([port] (database db) {
auto pdb = new database(std::move(db));
auto server = new distributed<thrift_server>;
server->start(std::ref(*pdb)).then([server = std::move(server), port] () mutable {
server->invoke_on_all(&thrift_server::listen, ipv4_addr{port});
}).then([port] {
std::cout << "Thrift server listening on port " << port << " ...\n";
});
});
});
}