filecluster 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff920ef51fc5d2c823900026fedc150173f6f52e
4
- data.tar.gz: a81702454f3bb7b5f754c62c7a3d4633122036c3
3
+ metadata.gz: 60a7cea9fe6d2870268e45b69048e1e6baefaf58
4
+ data.tar.gz: df929b92efd64aabdf1f15293864481985d7c556
5
5
  SHA512:
6
- metadata.gz: d9c31c9663b17e861653282877d70eeab6c108327cdb4acacc07752569a773bb438464e6c97bbd1a28319dd2d4a5c77ba998294c05d75f53aa62d76d2526df8b
7
- data.tar.gz: 15c10f14d399b173f5ffa748b623500a261632c856005143373e777215f109a9ef7430883218d4c46e87fbc8cbd1eb871500c979f03c88b29c152b2ad6f25ca2
6
+ metadata.gz: c0f1686a52969cbd70d7ebc2c0fd79ca00200b0929e9a0b7b5ac51d92fc59f4a0a82305c1801c87dc4182e4bd004cab5e0e2130a0bde7c7bb11df77f2984b35f
7
+ data.tar.gz: b22af5bff0622d403d12f3c6fe3767534e502c04d7ec5d32b9f55faf04db876316ad99783b7959d6c9f44132efef5b19bb6aa7fda7399fe834c5d0035dca1b7e
@@ -17,6 +17,7 @@ $tasks_copy_threads = {} # copy threads by storage name
17
17
  $tasks_delete_threads = {} # delete threads by storage name
18
18
  $check_threads = {} # check threads by storage name
19
19
  $copy_count = 0 # copy tasks count for current host
20
+ $copy_cont_avg = 0 # copy tasks avg count for current host
20
21
  $copy_speed = 0 # copy tasks speed sum for current host
21
22
  $exit_signal = false
22
23
  $global_daemon_thread = nil
@@ -4,7 +4,7 @@ class CopyTaskThread < BaseThread
4
4
  Thread.current[:tasks_processed] = 0 unless Thread.current[:tasks_processed]
5
5
  while task = $tasks_copy[storage_name].shift do
6
6
  $curr_tasks << task
7
- $log.debug("CopyTaskThread(#{storage_name}): run task for item_storage ##{task.id}, copy_count=#{$copy_count}, copy_speed=#{$copy_speed}")
7
+ $log.debug("CopyTaskThread(#{storage_name}): run task for item_storage ##{task.id}, copy_count=#{$copy_count}/#{$copy_cont_avg}, copy_speed=#{$copy_speed}")
8
8
  make_copy(task)
9
9
  $curr_tasks.delete(task)
10
10
  $log.debug("CopyTaskThread(#{storage_name}): finish task for item_storage ##{task.id}")
@@ -19,13 +19,18 @@ class CopyTaskThread < BaseThread
19
19
  speed_limit = nil
20
20
  if limit
21
21
  if $copy_count == 0
22
- speed_limit = (limit - $copy_speed) / 0.75
22
+ $copy_speed = 0
23
+ speed_limit = limit * 0.75
24
+ elsif $copy_count <= $copy_cont_avg && (speed_limit = limit / $copy_cont_avg) < limit * 1.1 - $copy_speed
23
25
  else
24
- sleep 0.1 while (speed_limit = (limit - $copy_speed) / ($copy_count + 0.4)) < limit*0.1
26
+ while (speed_limit = (limit - $copy_speed) * 0.75) < limit*0.1 do
27
+ sleep 0.1
28
+ end
25
29
  end
26
30
  end
27
31
  $copy_count += 1
28
32
  $copy_speed += speed_limit if speed_limit
33
+ calc_avg_count()
29
34
 
30
35
  storage = $storages.detect{|s| s.name == task.storage_name}
31
36
  begin
@@ -46,7 +51,7 @@ class CopyTaskThread < BaseThread
46
51
  end
47
52
  src_storage = $all_storages.detect{|s| s.name == src_item_storage.storage_name}
48
53
  $log.debug("Copy from #{src_storage.name} to #{storage.name} #{storage.path}#{item.name}")
49
- item.copy_item_storage(src_storage, storage, task, speed_limit)
54
+ item.copy_item_storage(src_storage, storage, task, false, speed_limit)
50
55
  rescue Exception => e
51
56
  error "Copy item_storage error: #{e.message}; #{e.backtrace.join(', ')}", :item_id => task.item_id, :item_storage_id => task.id
52
57
  $curr_tasks.delete(task)
@@ -54,4 +59,8 @@ class CopyTaskThread < BaseThread
54
59
  $copy_count -= 1 if $copy_count > 0
55
60
  $copy_speed -= speed_limit if speed_limit
56
61
  end
57
- end
62
+
63
+ def calc_avg_count
64
+ $copy_cont_avg = ($copy_count + $copy_cont_avg) / 2.0
65
+ end
66
+ end
@@ -85,7 +85,7 @@ module FC
85
85
  def self.init_db(silent = false)
86
86
  FC::DB.query(%{
87
87
  CREATE TABLE #{@prefix}items (
88
- id int NOT NULL AUTO_INCREMENT,
88
+ id bigint NOT NULL AUTO_INCREMENT,
89
89
  name varchar(1024) NOT NULL DEFAULT '',
90
90
  tag varchar(255) DEFAULT NULL,
91
91
  outer_id int DEFAULT NULL,
@@ -155,8 +155,8 @@ module FC
155
155
 
156
156
  FC::DB.query(%{
157
157
  CREATE TABLE #{@prefix}items_storages (
158
- id int NOT NULL AUTO_INCREMENT,
159
- item_id int DEFAULT NULL,
158
+ id bigint NOT NULL AUTO_INCREMENT,
159
+ item_id bigint DEFAULT NULL,
160
160
  storage_name varchar(255) DEFAULT NULL,
161
161
  status ENUM('new', 'copy', 'error', 'ready', 'delete') NOT NULL DEFAULT 'new',
162
162
  time int DEFAULT NULL,
@@ -199,8 +199,8 @@ module FC
199
199
  FC::DB.query(%{
200
200
  CREATE TABLE #{@prefix}errors (
201
201
  id int NOT NULL AUTO_INCREMENT,
202
- item_id int DEFAULT NULL,
203
- item_storage_id int DEFAULT NULL,
202
+ item_id bigint DEFAULT NULL,
203
+ item_storage_id bigint DEFAULT NULL,
204
204
  host varchar(255) DEFAULT NULL,
205
205
  message text DEFAULT NULL,
206
206
  time int DEFAULT NULL,
@@ -1,3 +1,3 @@
1
1
  module FC
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
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.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - sh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2