filecluster 0.4.7 → 0.4.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/bin/fc-daemon +1 -0
- data/lib/daemon/copy_task_thread.rb +14 -5
- data/lib/fc/db.rb +5 -5
- 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: 60a7cea9fe6d2870268e45b69048e1e6baefaf58
|
4
|
+
data.tar.gz: df929b92efd64aabdf1f15293864481985d7c556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0f1686a52969cbd70d7ebc2c0fd79ca00200b0929e9a0b7b5ac51d92fc59f4a0a82305c1801c87dc4182e4bd004cab5e0e2130a0bde7c7bb11df77f2984b35f
|
7
|
+
data.tar.gz: b22af5bff0622d403d12f3c6fe3767534e502c04d7ec5d32b9f55faf04db876316ad99783b7959d6c9f44132efef5b19bb6aa7fda7399fe834c5d0035dca1b7e
|
data/bin/fc-daemon
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
62
|
+
|
63
|
+
def calc_avg_count
|
64
|
+
$copy_cont_avg = ($copy_count + $copy_cont_avg) / 2.0
|
65
|
+
end
|
66
|
+
end
|
data/lib/fc/db.rb
CHANGED
@@ -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
|
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
|
159
|
-
item_id
|
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
|
203
|
-
item_storage_id
|
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,
|
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.4.
|
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-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|