mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-03 13:37:04 +00:00
storage_service: take a snapshot of a particular column family
Signed-off-by: Glauber Costa <glommer@scylladb.com>
This commit is contained in:
@@ -1287,6 +1287,36 @@ future<> storage_service::take_snapshot(sstring tag, std::vector<sstring> keyspa
|
||||
});
|
||||
}
|
||||
|
||||
future<> storage_service::take_column_family_snapshot(sstring ks_name, sstring cf_name, sstring tag) {
|
||||
if (ks_name.empty()) {
|
||||
throw std::runtime_error("You must supply a keyspace name");
|
||||
}
|
||||
if (cf_name.empty()) {
|
||||
throw std::runtime_error("You must supply a table name");
|
||||
}
|
||||
if (cf_name.find(".") != sstring::npos) {
|
||||
throw std::invalid_argument("Cannot take a snapshot of a secondary index by itself. Run snapshot on the table that owns the index.");
|
||||
}
|
||||
|
||||
if (tag.empty()) {
|
||||
throw std::runtime_error("You must supply a snapshot name.");
|
||||
}
|
||||
|
||||
return smp::submit_to(0, [] {
|
||||
auto mode = get_local_storage_service()._operation_mode;
|
||||
if (mode == storage_service::mode::JOINING) {
|
||||
throw std::runtime_error("Cannot snapshot until bootstrap completes");
|
||||
}
|
||||
}).then([this, ks_name = std::move(ks_name), cf_name = std::move(cf_name), tag = std::move(tag)] {
|
||||
return check_snapshot_not_exist(_db.local(), ks_name, tag).then([this, ks_name, cf_name, tag] {
|
||||
return _db.invoke_on_all([ks_name, cf_name, tag] (database &db) {
|
||||
auto& cf = db.find_column_family(ks_name, cf_name);
|
||||
return cf.snapshot(tag);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
future<> storage_service::start_rpc_server() {
|
||||
fail(unimplemented::cause::STORAGE_SERVICE);
|
||||
#if 0
|
||||
|
||||
@@ -1106,7 +1106,6 @@ public:
|
||||
* @param keyspaceNames the names of the keyspaces to snapshot; empty means "all."
|
||||
*/
|
||||
future<> take_snapshot(sstring tag, std::vector<sstring> keyspace_names);
|
||||
#if 0
|
||||
|
||||
/**
|
||||
* Takes the snapshot of a specific column family. A snapshot name must be specified.
|
||||
@@ -1115,27 +1114,8 @@ public:
|
||||
* @param columnFamilyName the column family to snapshot
|
||||
* @param tag the tag given to the snapshot; may not be null or empty
|
||||
*/
|
||||
public void takeColumnFamilySnapshot(String keyspaceName, String columnFamilyName, String tag) throws IOException
|
||||
{
|
||||
if (keyspaceName == null)
|
||||
throw new IOException("You must supply a keyspace name");
|
||||
if (operationMode == Mode.JOINING)
|
||||
throw new IOException("Cannot snapshot until bootstrap completes");
|
||||
|
||||
if (columnFamilyName == null)
|
||||
throw new IOException("You must supply a table name");
|
||||
if (columnFamilyName.contains("."))
|
||||
throw new IllegalArgumentException("Cannot take a snapshot of a secondary index by itself. Run snapshot on the table that owns the index.");
|
||||
|
||||
if (tag == null || tag.equals(""))
|
||||
throw new IOException("You must supply a snapshot name.");
|
||||
|
||||
Keyspace keyspace = getValidKeyspace(keyspaceName);
|
||||
if (keyspace.snapshotExists(tag))
|
||||
throw new IOException("Snapshot " + tag + " already exists.");
|
||||
|
||||
keyspace.snapshot(tag, columnFamilyName);
|
||||
}
|
||||
future<> take_column_family_snapshot(sstring ks_name, sstring cf_name, sstring tag);
|
||||
#if 0
|
||||
|
||||
private Keyspace getValidKeyspace(String keyspaceName) throws IOException
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user