Class: BigShift::CloudStorageTransfer

Inherits:
Object
  • Object
show all
Defined in:
lib/bigshift/cloud_storage_transfer.rb

Instance Method Summary collapse

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, options={})
  @storage_transfer_service = storage_transfer_service
  @project_id = project_id
  @aws_credentials = aws_credentials
  @clock = options[:clock] || Time
  @thread = options[:thread] || Kernel
  @logger = options[: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, options={})
  poll_interval = options[:poll_interval] || DEFAULT_POLL_INTERVAL
  transfer_job = create_transfer_job(unload_manifest, cloud_storage_bucket, options[:description], options[: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