Skip to content
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

1.1.1 #11

Merged
merged 2 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.instaclustr</groupId>
<artifactId>instaclustr-backup-restore</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>1.1.1</version>

<name>instaclustr-backup-restore</name>
<description>Backup and restoration tooling for Cassandra</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.google.common.base.MoreObjects;
import com.google.inject.Inject;
import com.instaclustr.cassandra.backup.guice.StorageProviders;
import picocli.CommandLine;

public class StorageLocation {

private static final Pattern filePattern = Pattern.compile("(.*)://(.*)/(.*)/(.*)/(.*)/(.*)");
private static final Pattern cloudPattern = Pattern.compile("(.*)://(.*)/(.*)/(.*)/(.*)");

Expand Down Expand Up @@ -100,20 +102,31 @@ public void validate() throws IllegalStateException {

@Override
public String toString() {
return rawLocation;
return MoreObjects.toStringHelper(this)
.add("rawLocation", rawLocation)
.add("storageProvider", storageProvider)
.add("bucket", bucket)
.add("clusterId", clusterId)
.add("datacenterId", datacenterId)
.add("nodeId", nodeId)
.add("fileBackupDirectory", fileBackupDirectory)
.add("cloudLocation", cloudLocation)
.toString();
}

@Target({TYPE, PARAMETER, FIELD})
@Retention(RUNTIME)
@Constraint(validatedBy = ValidStorageLocation.StorageLocationValidator.class)
public @interface ValidStorageLocation {

String message() default "{com.instaclustr.cassandra.backup.impl.StorageLocation.StorageLocationValidator.message}";

Class<?>[] groups() default {};

Class<? extends Payload>[] payload() default {};

class StorageLocationValidator implements ConstraintValidator<ValidStorageLocation, StorageLocation> {

private final Set<String> storageProviders;

@Inject
Expand Down Expand Up @@ -151,6 +164,7 @@ public boolean isValid(final StorageLocation value, final ConstraintValidatorCon
}

public static class StorageLocationTypeConverter implements CommandLine.ITypeConverter<StorageLocation> {

@Override
public StorageLocation convert(final String value) throws Exception {
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BaseBackupOperationRequest extends OperationRequest implements Kube
@Option(names = {"--sl", "--storage-location"},
converter = StorageLocationTypeConverter.class,
description = "Location to which files will be backed up, in form " +
"cloudProvider://bucketName/clusterId/nodeId or file:///some/path/bucketName/clusterId/nodeId. " +
"cloudProvider://bucketName/clusterId/datacenterId/nodeId or file:///some/path/bucketName/clusterId/datacenterId/nodeId. " +
"'cloudProvider' is one of 's3', 'azure' or 'gcp'.",
required = true)
@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BaseRestoreOperationRequest extends OperationRequest implements Kub
@Option(names = {"--sl", "--storage-location"},
converter = StorageLocationTypeConverter.class,
description = "Location from which files will be fetched for restore, in form " +
"cloudProvider://bucketName/clusterId/nodeId or file:///some/path/bucketName/clusterId/nodeId. " +
"cloudProvider://bucketName/clusterId/datacenterId/nodeId or file:///some/path/bucketName/clusterId/datacenterId/nodeId. " +
"'cloudProvider' is one of 'aws', 'azure' or 'gcp'.",
required = true
)
Expand Down