-
Notifications
You must be signed in to change notification settings - Fork 294
Allow for in-place restores. #1094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Changes from all commits
aa4dcc1
f9de9a7
a5a6bb0
6b19184
71756d1
50b41cb
515eb2f
948485a
78aca40
78dae29
a7c0975
71c045b
6b1027a
728645b
67a1c0a
9c3be36
a1b7e8d
e1ebaa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,11 +125,6 @@ default int getBackupRetentionDays() { | |
| return 0; | ||
| } | ||
|
|
||
| /** @return Get list of racs to backup. Backup all racs if empty */ | ||
| default List<String> getBackupRacs() { | ||
| return Collections.EMPTY_LIST; | ||
| } | ||
|
|
||
| /** | ||
| * Backup location i.e. remote file system to upload backups. e.g. for S3 it will be s3 bucket | ||
| * name | ||
|
|
@@ -403,6 +398,10 @@ default String getRestoreSnapshot() { | |
| return StringUtils.EMPTY; | ||
| } | ||
|
|
||
| default String getRestoreDataLocation() { | ||
| return getCassandraBaseDirectory() + "/restore"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To confirm my understanding on our systems this would be something like |
||
| } | ||
|
|
||
| /** @return Get the region to connect to SDB for instance identity */ | ||
| default String getSDBInstanceIdentityRegion() { | ||
| return "us-east-1"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,23 @@ | |
| */ | ||
| package com.netflix.priam.connection; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.google.common.collect.ImmutableSet; | ||
| import com.netflix.priam.backup.BackupRestoreUtil; | ||
| import com.netflix.priam.config.IConfiguration; | ||
| import com.netflix.priam.health.CassandraMonitor; | ||
| import com.netflix.priam.utils.RetryableCallable; | ||
| import java.io.IOException; | ||
| import java.nio.file.*; | ||
| import java.nio.file.attribute.BasicFileAttributes; | ||
| import java.util.*; | ||
| import javax.inject.Inject; | ||
| import org.apache.cassandra.db.ColumnFamilyStoreMBean; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import static java.nio.file.StandardCopyOption.*; | ||
|
|
||
| /** This class encapsulates interactions with Cassandra. Created by aagrawal on 6/19/18. */ | ||
| public class CassandraOperations implements ICassandraOperations { | ||
| private static final Logger logger = LoggerFactory.getLogger(CassandraOperations.class); | ||
|
|
@@ -202,4 +211,51 @@ public List<Map<String, String>> gossipInfo() throws Exception { | |
| } | ||
| return returnPublicIpSourceIpMap; | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> importAll(String srcDir) throws IOException { | ||
| List<String> failedImports = new ArrayList<>(); | ||
| if (CassandraMonitor.hasCassadraStarted()) { | ||
| for (Path tableDir : BackupRestoreUtil.getBackupDirectories(srcDir, "")) { | ||
| String keyspace = tableDir.getParent().getFileName().toString(); | ||
| String table = tableDir.getFileName().toString().split("-")[0]; | ||
| failedImports.addAll(importData(keyspace, table, tableDir.toString())); | ||
| } | ||
| } else { | ||
| Path target = Paths.get(configuration.getDataFileLocation()); | ||
| Path source = Paths.get(srcDir); | ||
| Files.walkFileTree(source, new SimpleFileVisitor<Path>() { | ||
| @Override | ||
| public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { | ||
| Path targetDir = target.resolve(source.relativize(dir)); | ||
| Files.createDirectories(targetDir); | ||
| return FileVisitResult.CONTINUE; | ||
| } | ||
|
|
||
| @Override | ||
| public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { | ||
| Files.move(file, target.resolve(source.relativize(file)), ATOMIC_MOVE, COPY_ATTRIBUTES); | ||
| return FileVisitResult.CONTINUE; | ||
| } | ||
| }); | ||
| } | ||
| return failedImports; | ||
| } | ||
|
|
||
| private List<String> importData(String keyspace, String table, String source) | ||
| throws IOException { | ||
| try (JMXNodeTool nodeTool = JMXNodeTool.instance(configuration)) { | ||
| return nodeTool.importNewSSTables( | ||
| keyspace, | ||
| table, | ||
| ImmutableSet.of(source), | ||
| false /* resetLevel */, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These defaults LGTM, do we want to add options to override them? |
||
| false /* clearRepaired */, | ||
| true /* verifySSTables */, | ||
| true /* verifyTokens */, | ||
| true /* invalidateCaches */, | ||
| false /* extendedVerify */, | ||
| false /* copyData */); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this cleanup 🙌