filecluster 0.5.12 → 0.5.13

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: 459674ee241f4d2417b693aaa7ba0afb162e9e6d
4
- data.tar.gz: 040e08202a413d3a3a27fda1914b6ba76b816711
3
+ metadata.gz: 55c62eefa42ab98952d048ba96e7467a4a88fd80
4
+ data.tar.gz: 6f9464f3d84c270a9ed46f84790dc605be33f72d
5
5
  SHA512:
6
- metadata.gz: c4bcb38015514c8b1c9330892e44fcf8f84f51ac8997dc139e0f39294d83189861dc4b9c77c5f0c3e80a1372ebdd365920abbb98d7d83fb45b50607b49707735
7
- data.tar.gz: 3a65d1610a21ca19246746491b5f5cf9470d0cc5d4a07fe0764cea44fc58f7b6eec089c65ab9d1ddf526b89c7b4c398dcba4366f4a3141aaf4726fb18006cbbe
6
+ metadata.gz: ff5af3f5f2c994df7bf18c191e7d4ad38c6c2f7bf79e43ac2f3ff2011ef49717d26b174d83a01d115f932c396f59a392e0dd98ca2a870d1b10ff873c2220a8a2
7
+ data.tar.gz: a4934117b805502c5f5b7ca0cf6d496455326f90c57e1587bf03a7bd913bea45b72a172e4f078182d97a7e16158c00d62f65d12b98831b539cfa5d4e08c29dee
@@ -44,12 +44,22 @@ class CopyTaskThread < BaseThread
44
44
  end
45
45
  end
46
46
  return nil unless item && item.status == 'ready'
47
- src_item_storage = FC::ItemStorage.where("item_id = ? AND status = 'ready'", item.id).sample
48
- unless src_item_storage
49
- $log.warn("Item ##{item.id} #{item.name} has no ready item_storage")
47
+ available_src_storages = FC::ItemStorage.where("item_id = ? AND status = 'ready'", item.id)
48
+ .map do |item_storage|
49
+ $all_storages.detect { |a_storage| a_storage.name == item_storage.storage_name && a_storage.up? }
50
+ end.compact
51
+
52
+ # pref for current host
53
+ src_storage = available_src_storages.detect { |src| src.host == storage.host }
54
+ # pref for same dc
55
+ src_storage = available_src_storages.detect { |src| src.dc == storage.dc } unless src_storage
56
+ # random from available storages
57
+ src_storage = available_src_storages.sample unless src_storage
58
+
59
+ unless src_storage
60
+ $log.warn("Item ##{item.id} #{item.name} has no ready item_storage or storage")
50
61
  return nil
51
62
  end
52
- src_storage = $all_storages.detect{|s| s.name == src_item_storage.storage_name}
53
63
  $log.debug("Copy from #{src_storage.name} to #{storage.name} #{storage.path}#{item.name}")
54
64
  item.copy_item_storage(src_storage, storage, task, false, speed_limit)
55
65
  rescue Exception => e
data/lib/fc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FC
2
- VERSION = '0.5.12'.freeze
2
+ VERSION = '0.5.13'.freeze
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.5.12
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - sh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2