class SyncPoint

Represents a single synchronization point

Attributes

date_time[R]
epoch_time[R]
id[R]

Public Class Methods

new(time, id=nil) click to toggle source

Creates a SyncPoint object by polling AWS S3 for the contents of sync point with the specified time. @param [String] time The epoch time of the sync point this object represents. @param [Integer] id An optionally specified integer ID for this object

# File lib/sync_point.rb, line 23
def initialize(time, id=nil)
  # Ensure time is passed and of the right type
  failValidation if time.nil? or not time.is_a?(String)

  # Ensure the id is of the right type if passed
  failValidation if id.not_nil? and not id.is_a?(Integer)

  # Save object attributes
  @id = id
  @epoch_time = time
  @date_time = Time.at(@epoch_time.to_i).strftime('%Y-%m-%d %H:%M:%S') #converts epoch time to a time and date

  # Retrieve tree representing the folder of the specified sync point
  bucket = AWS::S3.new(:access_key_id => $AWS_ID, :secret_access_key => $AWS_SECRET).buckets[$SYNC_BUCKET]
  tree = bucket.as_tree(:prefix => @epoch_time)

  # Retrieve the subfolders
  components = tree.children.select(&:branch?).collect(&:prefix)
  components = components.map{|x| x.gsub("#{@epoch_time}/", '')}.map(&:chop)

  # set these attributes if the subfolder for a component exists
  @configs = components.include?('configs')
  @database = components.include?('database')
end

Public Instance Methods

configs?() click to toggle source

Does this object contain configurations? @return [true, false]

# File lib/sync_point.rb, line 11
def configs?
  @configs
end
database?() click to toggle source

Does this object contain database dumps? @return [true, false]

# File lib/sync_point.rb, line 16
def database?
  @database
end

Private Instance Methods

get_usage() click to toggle source
Calls superclass method ErrorHandlingIface#get_usage
# File lib/sync_point.rb, line 54
def get_usage
  #Usage cases for all the usage in this class
  if @usage.nil?
    init_usage
    @usage['new'] = ['time = Time, dump_id = Integer']
  end

  super
end
parse_time(backup) click to toggle source
# File lib/sync_point.rb, line 50
def parse_time(backup)
  backup.scan(/BACKUP-(\d*)_\d-[0-9a-f]*.tar/).flatten[0]
end