storage_service: take a snapshot of a particular column family

Signed-off-by: Glauber Costa <glommer@scylladb.com>
This commit is contained in:
Glauber Costa
2015-10-08 17:02:20 +02:00
parent fe3164714f
commit 2f2a4e83e0
2 changed files with 32 additions and 22 deletions

View File

@@ -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

View File

@@ -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
{