filecluster 0.4.10 → 0.4.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e28f98d4fa88347c8ed87cf76acfbcb2e3b9029
4
- data.tar.gz: 8ecadf4f538c78bd50119c94f89828955f84f1be
3
+ metadata.gz: 81a8deb986d25028bc35bcaa5e8eae3bd5f2631f
4
+ data.tar.gz: 5a10c3c2ccf9cbc6a3ad1677afcde8a364571872
5
5
  SHA512:
6
- metadata.gz: b0af133c153134f9b02bcf1853296ab4cfbb09fee84043b3595d0be69863cbd57bca69f802a11299f4c859c09d3d38691a006bbbbb6729da5cf88d9d8651445f
7
- data.tar.gz: 02982466b23fcd697e1c536535981d999a44f71dd069e2763c6bddf5dfe7ac4d1e2a66821e12f4d83f4a13b10c1bdcdf97c66f6d7cac0d1207a151470d356d8b
6
+ metadata.gz: ff27684b3bfbc4ecdd2a655db3f8ccd62464d50cdb122c0eb21a20dd83a2431d36895f03b95b75092a474ea89926fab5fd5342b85843f6658bec5d135a962949
7
+ data.tar.gz: 8d38c5bf40542c5c21ef033d45059cbe8beea14b8aa461182040d2c0733f0b5da6e81d5ee9067b937b9b39a41ea1aceff2ce70b134a9e9d4be672710f884a487
@@ -60,7 +60,7 @@ class GlobalDaemonThread < BaseThread
60
60
  storage = src_storage.get_proper_storage_for_copy(row['size'], item_storages) unless storage
61
61
  end
62
62
  if storage
63
- FC::Item.new(:id => row['item_id']).make_item_storage(storage, 'copy')
63
+ FC::Item.new(:id => row['item_id'], :size => row['size']).make_item_storage(storage, 'copy')
64
64
  else
65
65
  error 'No available storage', :item_id => row['item_id']
66
66
  end
@@ -7,12 +7,16 @@ class UpdateTasksThread < BaseThread
7
7
 
8
8
  def check_tasks(type)
9
9
  count = 0
10
+ limit = FC::Var.get("daemon_tasks_#{type}_group_limit", 1000).to_i
10
11
  tasks = (type == :copy ? $tasks_copy : $tasks_delete)
11
12
  $storages.each do |storage|
12
13
  tasks[storage.name] = [] unless tasks[storage.name]
13
- cond = "storage_name = '#{storage.name}' AND status='#{type.to_s}'"
14
14
  ids = tasks[storage.name].map(&:id) + $curr_tasks.map(&:id)
15
- limit = FC::Var.get("daemon_tasks_#{type}_group_limit", 1000).to_i
15
+ if ids.length > limit*2
16
+ $log.debug("Too many (#{ids.length}) #{type} tasks")
17
+ next
18
+ end
19
+ cond = "storage_name = '#{storage.name}' AND status='#{type.to_s}'"
16
20
  cond << "AND id not in (#{ids.join(',')})" if ids.length > 0
17
21
  cond << " LIMIT #{limit}"
18
22
  FC::ItemStorage.where(cond).each do |item_storage|
data/lib/fc/item.rb CHANGED
@@ -23,6 +23,7 @@ module FC
23
23
  })
24
24
  item_params.delete(:replace)
25
25
  item_params.delete(:remove_local)
26
+ item_params.delete(:not_local)
26
27
  raise 'Name is empty' if item_params[:name].empty?
27
28
  raise 'Zero size path' if item_params[:size] == 0
28
29
 
data/lib/fc/storage.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'shellwords'
3
+ require 'fileutils'
3
4
 
4
5
  module FC
5
6
  class Storage < DbBase
@@ -112,17 +113,21 @@ module FC
112
113
  # delete object from storage
113
114
  def delete_file(file_name)
114
115
  dst_path = "#{self.path}#{file_name}"
115
- cmd = self.class.curr_host == host ?
116
- "rm -rf #{dst_path.shellescape}" :
117
- "ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \"rm -rf #{dst_path.shellescape}\""
118
- r = `#{cmd} 2>&1`
119
- raise r if $?.exitstatus != 0
120
-
121
- cmd = self.class.curr_host == host ?
122
- "ls -la #{dst_path.shellescape}" :
123
- "ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \"ls -la #{dst_path.shellescape}\""
124
- r = `#{cmd} 2>/dev/null`
125
- raise "Path #{dst_path} not deleted" unless r.empty?
116
+ if self.class.curr_host == host
117
+ begin
118
+ File.delete(dst_path)
119
+ rescue Errno::EISDIR
120
+ FileUtils.rm_r(dst_path)
121
+ end
122
+ else
123
+ cmd = "ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \"rm -rf #{dst_path.shellescape}\""
124
+ r = `#{cmd} 2>&1`
125
+ raise r if $?.exitstatus != 0
126
+
127
+ cmd = "ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \"ls -la #{dst_path.shellescape}\""
128
+ r = `#{cmd} 2>/dev/null`
129
+ raise "Path #{dst_path} not deleted" unless r.empty?
130
+ end
126
131
  end
127
132
 
128
133
  # return object size on storage
data/lib/fc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FC
2
- VERSION = "0.4.10"
2
+ VERSION = "0.4.11"
3
3
  end
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.4.10
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - sh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-18 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2