mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 09:00:35 +00:00
In CQL, before a user can create a table, they must create a keyspace to contain this table and, among other things, specify this keyspace's RF. But in the DynamoDB API, there is no "create keyspace" operation - the user just creates a table, and there is no way, and no opportunity, to specify the requested RF. Presumably, Amazon always uses the same RF for all tables, most likely 3, although this is not officially documented anywhere. The existing code creates the keyspace during Scylla boot, with RF=1. This RF=1 always works, and is a good choice for a one-node test run, but was a really bad choice for a real cluster with multiple nodes, so this patch fixes this choice: With this patch, the keyspace creation is delayed - it doesn't happen when the first node of the cluster boots, but only when the user creates the first table. Presumably, at that time, the cluster is already up, so at that point we can make the obvious choice automatically: a one-node cluster will get RF=1, a >=3 node cluster will get RF=3. The choice of RF is logged - and the choice of RF=1 is considered a warning. Note that with this patch, keyspace creation is still automatic as it was before. The user may manually create the keyspace via CQL, to override this automatic choice. In the future we may also add additional keyspace configuration options via configuration flags or new REST requests, and the keyspace management code will also likely change as we start to support clusters with multiple regions and global tables. But for now, I think the automatic method is easiest for users who want to test-drive Alternator without reading lengthy instructions on how to set up the keyspace. Signed-off-by: Nadav Har'El <nyh@scylladb.com> Message-Id: <20190820180610.5341-1-nyh@scylladb.com>
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
/*
|
|
* Copyright 2019 ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* This file is part of Scylla.
|
|
*
|
|
* See the LICENSE.PROPRIETARY file in the top-level directory for licensing information.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/future.hh>
|
|
#include <seastar/http/httpd.hh>
|
|
#include "seastarx.hh"
|
|
#include <seastar/json/json_elements.hh>
|
|
|
|
#include "service/storage_proxy.hh"
|
|
#include "service/migration_manager.hh"
|
|
|
|
#include "stats.hh"
|
|
|
|
namespace alternator {
|
|
|
|
class executor {
|
|
service::storage_proxy& _proxy;
|
|
service::migration_manager& _mm;
|
|
public:
|
|
stats _stats;
|
|
static constexpr auto ATTRS_COLUMN_NAME = "attrs";
|
|
static constexpr auto KEYSPACE_NAME = "alternator";
|
|
|
|
executor(service::storage_proxy& proxy, service::migration_manager& mm) : _proxy(proxy), _mm(mm) {}
|
|
|
|
future<json::json_return_type> create_table(std::string content);
|
|
future<json::json_return_type> describe_table(std::string content);
|
|
future<json::json_return_type> delete_table(std::string content);
|
|
future<json::json_return_type> put_item(std::string content);
|
|
future<json::json_return_type> get_item(std::string content);
|
|
future<json::json_return_type> delete_item(std::string content);
|
|
future<json::json_return_type> update_item(std::string content);
|
|
future<json::json_return_type> list_tables(std::string content);
|
|
future<json::json_return_type> scan(std::string content);
|
|
future<json::json_return_type> describe_endpoints(std::string content, std::string host_header);
|
|
future<json::json_return_type> batch_write_item(std::string content);
|
|
future<json::json_return_type> batch_get_item(std::string content);
|
|
future<json::json_return_type> query(std::string content);
|
|
|
|
future<> start();
|
|
future<> stop() { return make_ready_future<>(); }
|
|
|
|
future<> maybe_create_keyspace();
|
|
};
|
|
|
|
}
|