mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 15:49:33 -05:00
feat(redshift-serverless): copy snapshots into the configured destination region (#7024)
* feat(redshift-serverless): copy snapshots into the configured destination region A SnapshotCopyConfiguration used to be stored and echoed, with nothing copied. A background sweep now carries each AVAILABLE snapshot of the namespace, taken at or after the configuration was created, into the destination Region with its dump and metadata. The copy is an ordinary snapshot there, so describe, restore, delete and expiration work on it unchanged. - The source records the Regions it has been copied to, so a deleted or expired copy is not made again and a retry or restart after a crash makes no second copy. A copy made for an earlier snapshot of the same name is replaced. - Retention and KMS key come from the configuration. A name already taken by an unrelated snapshot in the destination is kept and logged. - Rules carry the account and namespace id, so accounts never collide and a recreated namespace does not inherit its predecessor's configuration. - The destination must be a known Region in the namespace's partition. - ResetAll now removes every snapshot dump, which it used to leak. - New switches: snapshot-copy-enabled and snapshot-copy-sweep-interval-seconds. * fix(redshift-serverless): keep the earlier snapshot copy restorable when a replacement fails Each copy now gets its own dump file and the replaced copy's dump is removed only after the new record is saved. Drop the slow, partition-bound compatibility test; the in-repo engine and integration tests cover the copy. * fix(redshift-serverless): name a snapshot copy's dump by id so long snapshot names still copy
This commit is contained in:
1 parent
fa243bf78e
commit
9b69b3dac3
14 files changed
+1241
-10
No files matched your search
@@ -1917,6 +1917,12 @@ public interface EmulatorConfig {
|
||||
@WithDefault("60")
|
||||
int snapshotExpirationSweepIntervalSeconds();
|
||||
|
||||
@WithDefault("true")
|
||||
boolean snapshotCopyEnabled();
|
||||
|
||||
@WithDefault("60")
|
||||
int snapshotCopySweepIntervalSeconds();
|
||||
|
||||
@WithDefault("true")
|
||||
boolean scheduledActionsEnabled();
|
||||
|
||||
|
||||
+175
@@ -11,6 +11,7 @@ import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.redshift.TempCredential;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.RedshiftServerlessSnapshotCopyService.CopyRule;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.model.ConfigParameter;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.model.Namespace;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.model.PricePerformanceTarget;
|
||||
@@ -30,9 +31,11 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -44,6 +47,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ApplicationScoped
|
||||
public class RedshiftServerlessService implements Resettable {
|
||||
@@ -641,6 +645,12 @@ public class RedshiftServerlessService implements Resettable {
|
||||
return namespaceName == null ? Optional.empty() : namespaces.get(storageKey(region, namespaceName));
|
||||
}
|
||||
|
||||
/** Like {@link #findNamespace}, for a background sweep that acts for an account other than the ambient one. */
|
||||
Optional<Namespace> findNamespaceForAccount(String accountId, String namespaceName, String region) {
|
||||
return namespaceName == null ? Optional.empty()
|
||||
: namespaces.getForAccount(accountId, storageKey(region, namespaceName));
|
||||
}
|
||||
|
||||
/** The snapshot called {@code snapshotName} in {@code region}, empty when there is none. */
|
||||
public Optional<RedshiftServerlessSnapshot> findSnapshot(String snapshotName, String region) {
|
||||
return snapshotName == null ? Optional.empty() : snapshots.get(storageKey(region, snapshotName));
|
||||
@@ -698,6 +708,151 @@ public class RedshiftServerlessService implements Resettable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the snapshots each rule has not yet carried to its destination Region. One snapshot
|
||||
* failing is logged and retried by the next sweep without stopping the rest. The monitor keeps
|
||||
* a copy from racing a delete, a retention change or an expiration of the same snapshot.
|
||||
*/
|
||||
synchronized void copySnapshots(Instant now, List<CopyRule> rules) {
|
||||
for (CopyRule rule : rules) {
|
||||
boolean sameNamespace = findNamespaceForAccount(rule.accountId(), rule.namespaceName(), rule.sourceRegion())
|
||||
.map(namespace -> Objects.equals(namespace.getNamespaceId(), rule.namespaceId())).orElse(false);
|
||||
if (!sameNamespace) {
|
||||
continue;
|
||||
}
|
||||
for (RedshiftServerlessSnapshot snapshot : snapshots.scanForAccount(rule.accountId(),
|
||||
key -> key.startsWith(rule.sourceRegion() + "::"))) {
|
||||
if (!isCopyCandidate(snapshot, rule)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
copyToRegion(snapshot, rule, now);
|
||||
} catch (IOException | RuntimeException e) {
|
||||
// Without the stack: a snapshot that cannot be copied fails again every sweep.
|
||||
LOG.warnv("Could not copy Redshift Serverless snapshot {0} of account {1} to {2}; will retry: {3}",
|
||||
snapshot.getSnapshotName(), rule.accountId(), rule.destinationRegion(), e.getMessage());
|
||||
LOG.debugv(e, "Copy failure of snapshot {0}", snapshot.getSnapshotName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A copy is never copied on, and a snapshot taken before the configuration existed stays where it is. */
|
||||
private static boolean isCopyCandidate(RedshiftServerlessSnapshot snapshot, CopyRule rule) {
|
||||
return "AVAILABLE".equals(snapshot.getStatus())
|
||||
&& snapshot.getCopiedFromSnapshotArn() == null
|
||||
&& rule.namespaceName().equals(snapshot.getNamespaceName())
|
||||
&& !snapshot.getCopiedToRegions().contains(rule.destinationRegion())
|
||||
&& (rule.createdAt() == null || (snapshot.getSnapshotCreateTime() != null
|
||||
&& !snapshot.getSnapshotCreateTime().isBefore(rule.createdAt())));
|
||||
}
|
||||
|
||||
private void copyToRegion(RedshiftServerlessSnapshot source, CopyRule rule, Instant now) throws IOException {
|
||||
String name = source.getSnapshotName();
|
||||
String destinationKey = storageKey(rule.destinationRegion(), name);
|
||||
RedshiftServerlessSnapshot existing = snapshots.getForAccount(rule.accountId(), destinationKey).orElse(null);
|
||||
if (existing != null) {
|
||||
boolean copyOfThisName = source.getSnapshotArn().equals(existing.getCopiedFromSnapshotArn());
|
||||
if (copyOfThisName && Objects.equals(source.getSnapshotCreateTime(),
|
||||
existing.getCopiedFromSnapshotCreateTime())) {
|
||||
// A previous sweep committed this very copy and died before marking the source.
|
||||
markCopied(rule, name);
|
||||
return;
|
||||
}
|
||||
if (!copyOfThisName) {
|
||||
// The name belongs to a snapshot someone else made there, which the copy must not overwrite.
|
||||
LOG.warnv("Snapshot {0} of account {1} was not copied to {2}: a snapshot of that name is already there",
|
||||
name, rule.accountId(), rule.destinationRegion());
|
||||
markCopied(rule, name);
|
||||
return;
|
||||
}
|
||||
// Otherwise it is the copy of an earlier snapshot that had the same name: replace it.
|
||||
}
|
||||
|
||||
Path destinationDump = copyDump(source, rule);
|
||||
RedshiftServerlessSnapshot copy = new RedshiftServerlessSnapshot(source);
|
||||
copy.setRegion(rule.destinationRegion());
|
||||
copy.setSnapshotArn(AwsArnUtils.Arn.of("redshift-serverless", rule.destinationRegion(), rule.accountId(),
|
||||
"snapshot/" + name).toString());
|
||||
copy.setStatus("AVAILABLE");
|
||||
copy.setSnapshotCreateTime(now);
|
||||
copy.setKmsKeyId(rule.destinationKmsKeyId());
|
||||
copy.setRetentionPeriod(rule.retentionPeriod() == null || rule.retentionPeriod() == -1
|
||||
? null : rule.retentionPeriod());
|
||||
copy.setSqlDump(destinationDump == null ? null : destinationDump.toString());
|
||||
copy.setCopiedFromSnapshotArn(source.getSnapshotArn());
|
||||
copy.setCopiedFromSnapshotCreateTime(source.getSnapshotCreateTime());
|
||||
copy.setCopiedToRegions(Set.of());
|
||||
try {
|
||||
snapshots.putAllAtomicallyForAccount(rule.accountId(), Map.of(destinationKey, copy));
|
||||
} catch (RuntimeException e) {
|
||||
if (destinationDump != null) {
|
||||
deleteDumpQuietly(destinationDump);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
if (existing != null) {
|
||||
// Only now that the new record is saved is the replaced copy's dump unreferenced.
|
||||
deleteReplacedDump(existing, rule, destinationDump);
|
||||
}
|
||||
markCopied(rule, name);
|
||||
}
|
||||
|
||||
/** Removes the dump of a replaced copy, if it still lies in the rule account's destination directory. */
|
||||
private void deleteReplacedDump(RedshiftServerlessSnapshot replaced, CopyRule rule, Path keep) {
|
||||
String stored = replaced.getSqlDump();
|
||||
if (stored == null || stored.isBlank()) {
|
||||
return;
|
||||
}
|
||||
Path old = Paths.get(stored).toAbsolutePath().normalize();
|
||||
if (old.startsWith(dumpDir(rule.accountId(), rule.destinationRegion())) && !old.equals(keep)) {
|
||||
deleteDumpQuietly(old);
|
||||
}
|
||||
}
|
||||
|
||||
/** Copies the source dump beside the destination snapshot, or returns {@code null} for a metadata-only snapshot. */
|
||||
private Path copyDump(RedshiftServerlessSnapshot source, CopyRule rule) throws IOException {
|
||||
String stored = source.getSqlDump();
|
||||
if (stored == null || stored.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
Path sourceDirectory = dumpDir(rule.accountId(), rule.sourceRegion());
|
||||
Path from = Paths.get(stored).toAbsolutePath().normalize();
|
||||
if (!from.startsWith(sourceDirectory) || from.equals(sourceDirectory) || !Files.isRegularFile(from)) {
|
||||
throw new IOException("Snapshot dump is missing or outside its account and Region directory: " + from);
|
||||
}
|
||||
Path destinationDirectory = dumpDir(rule.accountId(), rule.destinationRegion());
|
||||
// Each copy gets its own file, so replacing an earlier copy never touches the dump it still points to.
|
||||
// The name is left out: a 255-character snapshot name plus a suffix would exceed filesystem filename limits.
|
||||
String copyFileName = UUID.randomUUID().toString();
|
||||
Path to = destinationDirectory.resolve(copyFileName + ".sql").normalize();
|
||||
Path staging = destinationDirectory.resolve(copyFileName + ".sql.copying").normalize();
|
||||
if (!to.startsWith(destinationDirectory) || !staging.startsWith(destinationDirectory)) {
|
||||
throw new IOException("Invalid snapshot name: " + source.getSnapshotName());
|
||||
}
|
||||
Files.createDirectories(destinationDirectory);
|
||||
try {
|
||||
Files.copy(from, staging, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.move(staging, to, StandardCopyOption.ATOMIC_MOVE);
|
||||
} catch (IOException e) {
|
||||
deleteDumpQuietly(staging);
|
||||
throw e;
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
/** Records that the snapshot has been carried to the rule's Region, so a deleted or expired copy stays gone. */
|
||||
private void markCopied(CopyRule rule, String snapshotName) {
|
||||
String key = storageKey(rule.sourceRegion(), snapshotName);
|
||||
RedshiftServerlessSnapshot current = snapshots.getForAccount(rule.accountId(), key).orElse(null);
|
||||
if (current == null || !"AVAILABLE".equals(current.getStatus())) {
|
||||
return;
|
||||
}
|
||||
RedshiftServerlessSnapshot marked = new RedshiftServerlessSnapshot(current);
|
||||
marked.getCopiedToRegions().add(rule.destinationRegion());
|
||||
snapshots.putAllAtomicallyForAccount(rule.accountId(), Map.of(key, marked));
|
||||
}
|
||||
|
||||
private static boolean isExpired(RedshiftServerlessSnapshot snapshot, Instant now) {
|
||||
if ("DELETED".equals(snapshot.getStatus())) {
|
||||
return true;
|
||||
@@ -1225,6 +1380,26 @@ public class RedshiftServerlessService implements Resettable {
|
||||
}
|
||||
}
|
||||
snapshots.clear();
|
||||
deleteDumpTree();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset empties the stores before it calls {@link #clear()}, so the loop above finds no snapshot
|
||||
* left to name a dump. Every dump lives under this one directory, copies included.
|
||||
*/
|
||||
private void deleteDumpTree() {
|
||||
Path root = Paths.get(config.storage().persistentPath()).resolve("redshift-serverless-dumps")
|
||||
.toAbsolutePath().normalize();
|
||||
if (!Files.isDirectory(root)) {
|
||||
return;
|
||||
}
|
||||
try (Stream<Path> paths = Files.walk(root)) {
|
||||
for (Path path : paths.sorted(Comparator.reverseOrder()).toList()) {
|
||||
Files.deleteIfExists(path);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.warnv(e, "Could not delete the snapshot dump directory {0} while clearing state", root);
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireSnapshotName(String snapshotName) {
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package io.github.hectorvent.floci.services.redshiftserverless;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.core.common.SweepWorker;
|
||||
import io.quarkus.runtime.ShutdownEvent;
|
||||
import io.quarkus.runtime.StartupEvent;
|
||||
import jakarta.annotation.Priority;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.enterprise.event.Observes;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/** Drives Serverless snapshot copies outside AWS request threads, one sweep at a time. */
|
||||
@ApplicationScoped
|
||||
public class RedshiftServerlessSnapshotCopyScheduler implements Resettable {
|
||||
private final SweepWorker worker;
|
||||
|
||||
@Inject
|
||||
public RedshiftServerlessSnapshotCopyScheduler(RedshiftServerlessSnapshotCopyService copies,
|
||||
EmulatorConfig config) {
|
||||
EmulatorConfig.RedshiftServerlessServiceConfig serverless = config.services().redshiftServerless();
|
||||
this.worker = new SweepWorker("redshift-serverless-snapshot-copy",
|
||||
serverless.enabled() && serverless.snapshotCopyEnabled(),
|
||||
serverless.snapshotCopySweepIntervalSeconds(), true,
|
||||
copies::runCopySweep);
|
||||
}
|
||||
|
||||
void onStart(@Observes StartupEvent ignored) {
|
||||
worker.start();
|
||||
}
|
||||
|
||||
// Priority below APPLICATION (2000) so the worker drains before EmulatorLifecycle.onStop flushes storage.
|
||||
void onStop(@Observes @Priority(1000) ShutdownEvent ignored) {
|
||||
worker.stop();
|
||||
}
|
||||
|
||||
/** Whether a background worker exists, which the two configuration switches decide. */
|
||||
boolean active() {
|
||||
return worker.active();
|
||||
}
|
||||
|
||||
public void tick(Instant now) {
|
||||
worker.tick(now);
|
||||
}
|
||||
|
||||
/** Drains a running sweep so it cannot write a copy back into storage that reset is about to clear. */
|
||||
@Override
|
||||
public void beforeReset() {
|
||||
worker.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
// Copies live in RedshiftServerlessService storage, which reset wipes.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterReset() {
|
||||
worker.resume();
|
||||
}
|
||||
}
|
||||
+59
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.redshiftserverless;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsRegions;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -12,6 +13,8 @@ import io.github.hectorvent.floci.services.redshiftserverless.model.SnapshotCopy
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -57,6 +60,12 @@ public class RedshiftServerlessSnapshotCopyService implements Resettable {
|
||||
if (destinationRegion.equals(region)) {
|
||||
throw ServerlessSupport.validation("destinationRegion must differ from the namespace's Region.");
|
||||
}
|
||||
if (!AwsRegions.isRegionId(destinationRegion)) {
|
||||
throw ServerlessSupport.validation("destinationRegion " + destinationRegion + " is not a known Region.");
|
||||
}
|
||||
if (!AwsRegions.partitionFor(destinationRegion).equals(AwsRegions.partitionFor(region))) {
|
||||
throw ServerlessSupport.validation("destinationRegion must be in the same partition as the namespace's Region.");
|
||||
}
|
||||
validateRetention(snapshotRetentionPeriod);
|
||||
Namespace namespace = serverless.findNamespace(namespaceName, region)
|
||||
.orElseThrow(() -> ServerlessSupport.notFound("The namespace " + namespaceName + " was not found."));
|
||||
@@ -76,6 +85,7 @@ public class RedshiftServerlessSnapshotCopyService implements Resettable {
|
||||
configuration.setDestinationRegion(destinationRegion);
|
||||
configuration.setDestinationKmsKeyId(destinationKmsKeyId);
|
||||
configuration.setSnapshotRetentionPeriod(snapshotRetentionPeriod);
|
||||
configuration.setCreatedAt(Instant.now());
|
||||
configurations.put(storageKey(region, configuration.getSnapshotCopyConfigurationId()), configuration);
|
||||
return new SnapshotCopyConfiguration(configuration);
|
||||
}
|
||||
@@ -114,6 +124,55 @@ public class RedshiftServerlessSnapshotCopyService implements Resettable {
|
||||
return existing;
|
||||
}
|
||||
|
||||
/**
|
||||
* One configuration as the copy sweep needs it, with the account and Region it lives in. The
|
||||
* sweep runs outside any request, so it cannot rely on the ambient account.
|
||||
*/
|
||||
public record CopyRule(String accountId, String sourceRegion, String namespaceName, String namespaceId,
|
||||
String destinationRegion, String destinationKmsKeyId, Integer retentionPeriod,
|
||||
Instant createdAt) {}
|
||||
|
||||
/**
|
||||
* Runs one copy sweep. The monitor is held from listing the rules to the last copy, so
|
||||
* deleting a configuration returns only once no copy of it is still on its way; a namespace
|
||||
* recreated meanwhile is caught by the id each rule carries.
|
||||
*/
|
||||
public synchronized void runCopySweep(Instant now) {
|
||||
serverless.copySnapshots(now, activeRules());
|
||||
}
|
||||
|
||||
/**
|
||||
* The configurations of every account whose namespace is still the one they were made for. A
|
||||
* configuration left behind by a deleted or recreated namespace is skipped here and dropped by
|
||||
* the next read in its own Region.
|
||||
*/
|
||||
public synchronized List<CopyRule> activeRules() {
|
||||
List<CopyRule> rules = new ArrayList<>();
|
||||
for (AccountAwareStorageBackend.AccountEntry<SnapshotCopyConfiguration> entry
|
||||
: configurations.scanAllAccountEntries(key -> true)) {
|
||||
SnapshotCopyConfiguration stored = entry.value();
|
||||
String sourceRegion = entry.key().substring(0, entry.key().indexOf("::"));
|
||||
boolean current = serverless.findNamespaceForAccount(entry.accountId(),
|
||||
stored.getNamespaceName(), sourceRegion)
|
||||
.map(namespace -> Objects.equals(namespace.getNamespaceId(), stored.getOwnerId()))
|
||||
.orElse(false);
|
||||
if (current) {
|
||||
SnapshotCopyConfiguration configuration = stored;
|
||||
if (configuration.getCreatedAt() == null) {
|
||||
// Made before the creation time was recorded: copy from now on rather than the whole history.
|
||||
configuration = new SnapshotCopyConfiguration(stored);
|
||||
configuration.setCreatedAt(Instant.now());
|
||||
configurations.putForAccount(entry.accountId(), entry.key(), configuration);
|
||||
}
|
||||
rules.add(new CopyRule(entry.accountId(), sourceRegion, configuration.getNamespaceName(),
|
||||
configuration.getOwnerId(), configuration.getDestinationRegion(),
|
||||
configuration.getDestinationKmsKeyId(), configuration.getSnapshotRetentionPeriod(),
|
||||
configuration.getCreatedAt()));
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
configurations.clear();
|
||||
|
||||
+41
-4
@@ -5,13 +5,13 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A Redshift Serverless snapshot. Floci stores snapshot metadata only and does not model async
|
||||
* cross-region copy: a snapshot created via {@code CreateSnapshot} in the standby region is
|
||||
* immediately {@code AVAILABLE} there, standing in for what a real
|
||||
* {@code SnapshotCopyConfiguration} would eventually produce.
|
||||
* A Redshift Serverless snapshot. A cross-region copy made for a {@code SnapshotCopyConfiguration}
|
||||
* is a snapshot of its own in the destination Region, immediately {@code AVAILABLE} there.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@@ -32,6 +32,9 @@ public class RedshiftServerlessSnapshot {
|
||||
private Integer retentionPeriod;
|
||||
private String sqlDump;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
private String copiedFromSnapshotArn;
|
||||
private Instant copiedFromSnapshotCreateTime;
|
||||
private Set<String> copiedToRegions = new LinkedHashSet<>();
|
||||
|
||||
public RedshiftServerlessSnapshot() {
|
||||
}
|
||||
@@ -52,6 +55,9 @@ public class RedshiftServerlessSnapshot {
|
||||
this.retentionPeriod = other.retentionPeriod;
|
||||
this.sqlDump = other.sqlDump;
|
||||
this.tags = new LinkedHashMap<>(other.tags);
|
||||
this.copiedFromSnapshotArn = other.copiedFromSnapshotArn;
|
||||
this.copiedFromSnapshotCreateTime = other.copiedFromSnapshotCreateTime;
|
||||
this.copiedToRegions = new LinkedHashSet<>(other.copiedToRegions);
|
||||
}
|
||||
|
||||
public String getSnapshotName() {
|
||||
@@ -175,4 +181,35 @@ public class RedshiftServerlessSnapshot {
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags);
|
||||
}
|
||||
|
||||
/** ARN of the snapshot this one was copied from, or {@code null} for a snapshot taken here. Never in a response. */
|
||||
public String getCopiedFromSnapshotArn() {
|
||||
return copiedFromSnapshotArn;
|
||||
}
|
||||
|
||||
public void setCopiedFromSnapshotArn(String copiedFromSnapshotArn) {
|
||||
this.copiedFromSnapshotArn = copiedFromSnapshotArn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creation time of the source snapshot at the moment of the copy. A snapshot ARN is built from
|
||||
* the name alone, so this is what tells a copy of the current source from a copy of an earlier
|
||||
* snapshot that had the same name.
|
||||
*/
|
||||
public Instant getCopiedFromSnapshotCreateTime() {
|
||||
return copiedFromSnapshotCreateTime;
|
||||
}
|
||||
|
||||
public void setCopiedFromSnapshotCreateTime(Instant copiedFromSnapshotCreateTime) {
|
||||
this.copiedFromSnapshotCreateTime = copiedFromSnapshotCreateTime;
|
||||
}
|
||||
|
||||
/** Regions this snapshot has already been copied to, so a deleted or expired copy is not made again. */
|
||||
public Set<String> getCopiedToRegions() {
|
||||
return copiedToRegions;
|
||||
}
|
||||
|
||||
public void setCopiedToRegions(Set<String> copiedToRegions) {
|
||||
this.copiedToRegions = copiedToRegions == null ? new LinkedHashSet<>() : new LinkedHashSet<>(copiedToRegions);
|
||||
}
|
||||
}
|
||||
+15
-2
@@ -3,9 +3,11 @@ package io.github.hectorvent.floci.services.redshiftserverless.model;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A Redshift Serverless snapshot copy configuration. Floci records it but copies nothing: a snapshot
|
||||
* that should appear in another Region is created there directly.
|
||||
* A Redshift Serverless snapshot copy configuration. The copy sweep copies the namespace's snapshots
|
||||
* into the destination Region.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@@ -18,12 +20,14 @@ public class SnapshotCopyConfiguration {
|
||||
private String destinationKmsKeyId;
|
||||
private Integer snapshotRetentionPeriod;
|
||||
private String ownerId;
|
||||
private Instant createdAt;
|
||||
|
||||
public SnapshotCopyConfiguration() {
|
||||
}
|
||||
|
||||
public SnapshotCopyConfiguration(SnapshotCopyConfiguration other) {
|
||||
this.ownerId = other.ownerId;
|
||||
this.createdAt = other.createdAt;
|
||||
this.snapshotCopyConfigurationId = other.snapshotCopyConfigurationId;
|
||||
this.snapshotCopyConfigurationArn = other.snapshotCopyConfigurationArn;
|
||||
this.namespaceName = other.namespaceName;
|
||||
@@ -87,4 +91,13 @@ public class SnapshotCopyConfiguration {
|
||||
public void setOwnerId(String ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
/** When the configuration was created; only snapshots taken from then on are copied. Never in a response. */
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user