filecluster 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fc/storage.rb +31 -19
- data/lib/fc/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fc12e92010113085a66dea7bfbac267f67768247
         | 
| 4 | 
            +
              data.tar.gz: 80afdcb6ec68e4b282e359bd75cc46975787a22b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b67df5a734df911038c68f9b2780f355357adfec7865af7cacb55c661c09cb719dbec6f7d038d2cccb79dd9dee423391898efdcf9b98236cb6d2b0c01e46fd4e
         | 
| 7 | 
            +
              data.tar.gz: 1d7eb36494a02a57c786da0a53c65bc60e280d13abd438e391384607a1f25951dc79584579d739d7d96a2c2a863ece8fa8d6dc7bc7dc639a7c5ac51cda9bbf37
         | 
    
        data/lib/fc/storage.rb
    CHANGED
    
    | @@ -16,7 +16,7 @@ module FC | |
| 16 16 | 
             
                def self.curr_host
         | 
| 17 17 | 
             
                  @uname || @uname = `uname -n`.chomp
         | 
| 18 18 | 
             
                end
         | 
| 19 | 
            -
             | 
| 19 | 
            +
             | 
| 20 20 | 
             
                def self.select_proper_storage_for_create(storages, size, exclude = [])
         | 
| 21 21 | 
             
                  list = storages.select do |storage|
         | 
| 22 22 | 
             
                    !exclude.include?(storage.name) && storage.up? && storage.size + size < storage.size_limit && storage.write_weight.to_i >= 0
         | 
| @@ -101,23 +101,33 @@ module FC | |
| 101 101 | 
             
                def up?
         | 
| 102 102 | 
             
                  check_time_delay < self.class.check_time_limit
         | 
| 103 103 | 
             
                end
         | 
| 104 | 
            -
             | 
| 104 | 
            +
             | 
| 105 | 
            +
                def self.speed_limit_to_rsync_opt(speed_limit)
         | 
| 106 | 
            +
                  return "--bwlimit=#{(speed_limit.to_f * 125.0).ceil} " if speed_limit.to_f > 0
         | 
| 107 | 
            +
                  ''
         | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
             | 
| 105 110 | 
             
                # copy local_path to storage
         | 
| 106 111 | 
             
                def copy_path(local_path, file_name, try_move = false, speed_limit = nil)
         | 
| 107 112 | 
             
                  dst_path = "#{self.path}#{file_name}"
         | 
| 108 113 |  | 
| 109 | 
            -
                   | 
| 110 | 
            -
             | 
| 111 | 
            -
                   | 
| 112 | 
            -
                   | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
                   | 
| 116 | 
            -
                   | 
| 117 | 
            -
             | 
| 118 | 
            -
                     | 
| 119 | 
            -
             | 
| 120 | 
            -
                   | 
| 114 | 
            +
                  recreate_dirs_cmd = "rm -rf #{dst_path.shellescape}; mkdir -p #{File.dirname(dst_path).shellescape}"
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                  # recreate dirs anyway if local op
         | 
| 117 | 
            +
                  if try_move && self.class.curr_host == host
         | 
| 118 | 
            +
                    r = `#{recreate_dirs_cmd} 2>&1`
         | 
| 119 | 
            +
                    raise r if $?.exitstatus != 0
         | 
| 120 | 
            +
                  end
         | 
| 121 | 
            +
                  # if we can make mv command
         | 
| 122 | 
            +
                  if try_move && self.class.curr_host == host && File.stat(local_path).dev == File.stat(File.dirname(dst_path)).dev
         | 
| 123 | 
            +
                    r = `mv #{local_path.shellescape} #{dst_path.shellescape} 2>&1`
         | 
| 124 | 
            +
                    raise r if $?.exitstatus != 0
         | 
| 125 | 
            +
                  else
         | 
| 126 | 
            +
                    local_path += '/' if File.stat(local_path).directory?
         | 
| 127 | 
            +
                    cmd = "ionice -c 2 -n 7 rsync -a #{FC::Storage.speed_limit_to_rsync_opt(speed_limit)}--rsync-path=\"#{recreate_dirs_cmd} && ionice -c 2 -n 7 rsync\" #{local_path.shellescape} #{self.host}:\"#{dst_path.shellescape}\""
         | 
| 128 | 
            +
                    r = `#{cmd} 2>&1`
         | 
| 129 | 
            +
                    raise r if $?.exitstatus != 0
         | 
| 130 | 
            +
                  end
         | 
| 121 131 | 
             
                end
         | 
| 122 132 |  | 
| 123 133 | 
             
                # copy object to local_path
         | 
| @@ -126,11 +136,13 @@ module FC | |
| 126 136 |  | 
| 127 137 | 
             
                  r = `rm -rf #{local_path.shellescape}; mkdir -p #{File.dirname(local_path).shellescape} 2>&1`
         | 
| 128 138 | 
             
                  raise r if $?.exitstatus != 0
         | 
| 129 | 
            -
             | 
| 130 | 
            -
                   | 
| 131 | 
            -
                  cmd = self. | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 139 | 
            +
             | 
| 140 | 
            +
                  # if remote file is directory?
         | 
| 141 | 
            +
                  cmd = "ssh -oStrictHostKeyChecking=no -q #{self.host} \"if [ -d #{src_path.shellescape} ]; then /bin/true; else /bin/false; fi\""
         | 
| 142 | 
            +
                  r = `#{cmd} 2>&1`
         | 
| 143 | 
            +
                  src_path += '/' if $?.exitstatus == 0
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                  cmd = "ionice -c 2 -n 7 rsync -a #{FC::Storage.speed_limit_to_rsync_opt(speed_limit)}--rsync-path=\"ionice -c 2 -n 7 rsync\" #{self.host}:\"#{src_path.shellescape}\" #{local_path.shellescape}"
         | 
| 134 146 | 
             
                  r = `#{cmd} 2>&1`
         | 
| 135 147 | 
             
                  raise r if $?.exitstatus != 0
         | 
| 136 148 | 
             
                end
         | 
    
        data/lib/fc/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: filecluster
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - sh
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-05-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: mysql2
         |