Class: BigShift::CloudStorageTransfer
- Inherits:
-
Object
- Object
- BigShift::CloudStorageTransfer
- Defined in:
- lib/bigshift/cloud_storage_transfer.rb
Instance Method Summary collapse
- #copy_to_cloud_storage(unload_manifest, cloud_storage_bucket, options = {}) ⇒ Object
-
#initialize(storage_transfer_service, project_id, aws_credentials, options = {}) ⇒ CloudStorageTransfer
constructor
A new instance of CloudStorageTransfer.
Constructor Details
#initialize(storage_transfer_service, project_id, aws_credentials, options = {}) ⇒ CloudStorageTransfer
Returns a new instance of CloudStorageTransfer.
3 4 5 6 7 8 9 10 |
# File 'lib/bigshift/cloud_storage_transfer.rb', line 3 def initialize(storage_transfer_service, project_id, aws_credentials, ={}) @storage_transfer_service = storage_transfer_service @project_id = project_id @aws_credentials = aws_credentials @clock = [:clock] || Time @thread = [:thread] || Kernel @logger = [:logger] || NullLogger::INSTANCE end |
Instance Method Details
#copy_to_cloud_storage(unload_manifest, cloud_storage_bucket, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/bigshift/cloud_storage_transfer.rb', line 12 def copy_to_cloud_storage(unload_manifest, cloud_storage_bucket, ={}) poll_interval = [:poll_interval] || DEFAULT_POLL_INTERVAL transfer_job = create_transfer_job(unload_manifest, cloud_storage_bucket, [:description], [:allow_overwrite]) transfer_job = @storage_transfer_service.create_transfer_job(transfer_job) @logger.info(sprintf('Transferring %d objects (%.2f GiB) from s3://%s/%s to gs://%s/%s', unload_manifest.count, unload_manifest.total_file_size.to_f/2**30, unload_manifest.bucket_name, unload_manifest.prefix, cloud_storage_bucket, unload_manifest.prefix)) await_completion(transfer_job, poll_interval) validate_transfer(unload_manifest, cloud_storage_bucket) nil end |