@Override public String downloadSchema(BackupRestoreContext ctx) throws Exception { final String nodeId = ctx.getNodeId(); final AmazonS3Client amazonS3Client = getAmazonS3Client(ctx); final String key = getPrefixKey(ctx) + "/" + nodeId + "/" + StorageUtil.SCHEMA_FILE; S3Object object = amazonS3Client.getObject( new GetObjectRequest(getBucketName(ctx), key)); InputStream objectData = object.getObjectContent(); String schema = IOUtils.toString(objectData, "UTF-8"); objectData.close(); return schema; }
@Override public void uploadSchema(BackupRestoreContext ctx, String schema) throws Exception { final String nodeId = ctx.getNodeId(); final AmazonS3Client amazonS3Client = getAmazonS3Client(ctx); final String key = getPrefixKey(ctx) + "/" + nodeId + "/" + StorageUtil.SCHEMA_FILE; final InputStream stream = new ByteArrayInputStream(schema.getBytes(StandardCharsets.UTF_8)); amazonS3Client.putObject(getBucketName(ctx), key, stream, new ObjectMetadata()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof BackupRestoreContext)) return false; BackupRestoreContext that = (BackupRestoreContext) o; return Objects.equals(getNodeId(), that.getNodeId()) && Objects.equals(getName(), that.getName()) && Objects.equals(getExternalLocation(), that.getExternalLocation()) && Objects.equals(getLocalLocation(), that.getLocalLocation()) && Objects.equals(getAccountId(), that.getAccountId()) && Objects.equals(getSecretKey(), that.getSecretKey()) && Objects.equals(getRestoreType(), that.getRestoreType()); }
final String localLocation = ctx.getLocalLocation(); final String backupName = ctx.getName(); final String nodeId = ctx.getNodeId();
final String localLocation = ctx.getLocalLocation(); final String backupName = ctx.getName(); final String nodeId = ctx.getNodeId(); final String key = getPrefixKey(ctx) + "/" + nodeId; LOGGER.info("Backup key: " + key);
context.getLocalLocation() + File.separator + context.getName() + File.separator + context.getNodeId();
final String nodeId = ctx.getNodeId(); final File[] keyspaces = getNonSystemKeyspaces(ctx); final String bucketName = getBucketName(ctx);
@Override public int hashCode() { return Objects.hash(getNodeId(), getName(), getExternalLocation(), getLocalLocation(), getAccountId(), getSecretKey(), getRestoreType()); }
@Override public void download(BackupRestoreContext ctx) throws IOException { final String accountName = ctx.getAccountId(); final String accountKey = ctx.getSecretKey(); final String localLocation = ctx.getLocalLocation(); final String backupName = ctx.getName(); final String nodeId = ctx.getNodeId(); final String containerName = StringUtils.lowerCase(getContainerName(ctx.getExternalLocation())); // https://<account_name>.blob.core.windows.net/<container_name> final CloudBlobContainer container = getCloudBlobContainer(accountName, accountKey, containerName); if (container == null) { logger.error("Error uploading snapshots. Unable to connect to {}, for container {}.", ctx.getExternalLocation(), containerName, localLocation); return; } String keyPrefix = String.format("%s/%s", backupName, nodeId); final Map<String, Long> snapshotFileKeys = getSnapshotFileKeys(container, keyPrefix); logger.info("Snapshot files for this node: {}", snapshotFileKeys); for (String fileKey : snapshotFileKeys.keySet()) { downloadFile(localLocation, container, fileKey, snapshotFileKeys.get(fileKey)); } }
public static final CassandraData createBackupSchemaData( final String hostname, final BackupRestoreContext context) { return new CassandraData( CassandraTask.TYPE.BACKUP_SCHEMA, hostname, context.getNodeId(), context.getName(), context.getExternalLocation(), context.getLocalLocation(), context.getAccountId(), context.getSecretKey(), context.getUsesEmc(), context.getRestoreType()); }
public static final CassandraData createBackupSnapshotData( final String hostname, final BackupRestoreContext context) { return new CassandraData( CassandraTask.TYPE.BACKUP_SNAPSHOT, hostname, context.getNodeId(), context.getName(), context.getExternalLocation(), context.getLocalLocation(), context.getAccountId(), context.getSecretKey(), context.getUsesEmc(), context.getRestoreType()); }
public static final CassandraData createBackupUploadData( final String hostname, final BackupRestoreContext context) { return new CassandraData( CassandraTask.TYPE.BACKUP_UPLOAD, hostname, context.getNodeId(), context.getName(), context.getExternalLocation(), context.getLocalLocation(), context.getAccountId(), context.getSecretKey(), context.getUsesEmc(), context.getRestoreType()); }
public static final CassandraData createSnapshotDownloadData( final String hostname, final BackupRestoreContext context) { return new CassandraData( CassandraTask.TYPE.SNAPSHOT_DOWNLOAD, hostname, context.getNodeId(), context.getName(), context.getExternalLocation(), context.getLocalLocation(), context.getAccountId(), context.getSecretKey(), context.getUsesEmc(), context.getRestoreType()); }
public static final CassandraData createRestoreSnapshotData( final String hostname, final BackupRestoreContext context) { return new CassandraData( CassandraTask.TYPE.SNAPSHOT_RESTORE, hostname, context.getNodeId(), context.getName(), context.getExternalLocation(), context.getLocalLocation(), context.getAccountId(), context.getSecretKey(), context.getUsesEmc(), context.getRestoreType()); }
public static final CassandraData createRestoreSchemaData( final String hostname, final BackupRestoreContext context) { return new CassandraData( CassandraTask.TYPE.SCHEMA_RESTORE, hostname, context.getNodeId(), context.getName(), context.getExternalLocation(), context.getLocalLocation(), context.getAccountId(), context.getSecretKey(), context.getUsesEmc(), context.getRestoreType()); }