sps_filesync 0.1.0 → 0.1.1
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sps_filesync.rb +65 -57
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ee9f212b84cfa40ec03c474550ec036e5c3280f75b72a6fbf0919213cf0a25d
|
4
|
+
data.tar.gz: b78039bd833d337375022039304b56eb4c2909b70fc7acfa57188ece382e19d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363a79b215ce9f7179a7b49c2b27d7ec2f187aa6f77dbf51083a652781e5033964ca29b2718987b2511ec5a350e68a1bc26224955f4af13c17111859c210484a
|
7
|
+
data.tar.gz: 7d453c72a738ea15263bf6fa3d8eaa42ee07ce14639fcff0c6a3860ef54fdb13c216ab3b219d71e50c635cbc28d97ec89a88749e305b2d8ae2b72d021f35fda9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/sps_filesync.rb
CHANGED
@@ -20,76 +20,84 @@ class SpsFileSync < SPSSub
|
|
20
20
|
|
21
21
|
def subscribe(topic: 'file/*')
|
22
22
|
|
23
|
-
super(topic: topic) do |msg, topic|
|
24
|
-
|
25
|
-
|
26
|
-
if @debug then
|
27
|
-
puts 'topic: ' + topic.inspect
|
28
|
-
puts 'msg: ' + msg.inspect
|
29
|
-
end
|
30
|
-
|
31
|
-
action = topic.split('/').last.to_sym
|
32
|
-
|
33
|
-
@master_address , path = msg.match(/^dfs:\/\/([^\/]+)(.*)/).captures
|
34
|
-
|
35
|
-
case action
|
36
|
-
when :cp
|
37
|
-
|
38
|
-
src, dest = msg.split(/ +/,2)
|
23
|
+
super(topic: topic + ' or nodes or nodes/*') do |msg, topic|
|
39
24
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
25
|
+
if msg =~ /^dfs:\/\// then
|
26
|
+
|
27
|
+
if @debug then
|
28
|
+
puts 'topic: ' + topic.inspect
|
29
|
+
puts 'msg: ' + msg.inspect
|
44
30
|
end
|
45
31
|
|
46
|
-
|
47
|
-
|
48
|
-
file_op {|f, node| f.mkdir "dfs://%s%s" % [node, path] }
|
32
|
+
action = topic.split('/').last.to_sym
|
49
33
|
|
50
|
-
|
51
|
-
|
52
|
-
file_op {|f, node| f.mkdir_p "dfs://%s%s" % [node, path] }
|
53
|
-
|
54
|
-
when :mv
|
34
|
+
@master_address , path = msg.match(/^dfs:\/\/([^\/]+)(.*)/).captures
|
55
35
|
|
56
|
-
|
36
|
+
case action
|
37
|
+
when :cp
|
57
38
|
|
58
|
-
|
59
|
-
src_path = "dfs://%s/%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
|
60
|
-
target_path = "dfs://%s/%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
|
61
|
-
f.mv src_path, target_path
|
62
|
-
end
|
63
|
-
|
64
|
-
when :write
|
39
|
+
src, dest = msg.split(/ +/,2)
|
65
40
|
|
66
|
-
|
41
|
+
file_op do |f, node|
|
42
|
+
src_path = "dfs://%s%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
|
43
|
+
target_path = "dfs://%s%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
|
44
|
+
f.cp src_path, target_path
|
45
|
+
end
|
46
|
+
|
47
|
+
when :mkdir
|
48
|
+
|
49
|
+
file_op {|f, node| f.mkdir "dfs://%s%s" % [node, path] }
|
67
50
|
|
68
|
-
|
69
|
-
target_path = "dfs://%s%s" % [node, path]
|
51
|
+
when :mkdir_p
|
70
52
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
53
|
+
file_op {|f, node| f.mkdir_p "dfs://%s%s" % [node, path] }
|
54
|
+
|
55
|
+
when :mv
|
56
|
+
|
57
|
+
src, dest = msg.split(/ +/,2)
|
58
|
+
|
59
|
+
file_op do |f, node|
|
60
|
+
src_path = "dfs://%s/%s" % [node, src[/^dfs:\/\/[^\/]+(.*)/]]
|
61
|
+
target_path = "dfs://%s/%s" % [node, dest[/^dfs:\/\/[^\/]+(.*)/]]
|
62
|
+
f.mv src_path, target_path
|
63
|
+
end
|
64
|
+
|
65
|
+
when :write
|
66
|
+
|
67
|
+
master_path = msg
|
68
|
+
|
69
|
+
file_op do |f, node|
|
70
|
+
target_path = "dfs://%s%s" % [node, path]
|
71
|
+
|
72
|
+
if @debug then
|
73
|
+
puts 'master_path: ' + master_path.inspect
|
74
|
+
puts 'target_path: ' + target_path.inspect
|
75
|
+
end
|
76
|
+
|
77
|
+
DfsFile.cp master_path, target_path
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
end
|
80
|
+
|
81
|
+
when :rm
|
82
|
+
|
83
|
+
file_op {|f, node| f.rm "dfs://%s%s" % [node, path] }
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
when :zip
|
85
|
+
when :zip
|
85
86
|
|
86
|
-
|
87
|
+
master_path = msg
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
file_op do |f, node|
|
90
|
+
target_path = "dfs://%s%s" % [node, path]
|
91
|
+
f.cp master_path, target_path
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
elsif topic == 'nodes/set'
|
97
|
+
@nodes = msg.split(/ +/)
|
98
|
+
elsif topic == 'nodes' and msg == 'get'
|
99
|
+
|
100
|
+
notice 'nodes/listed: ' + @nodes.join(' ')
|
93
101
|
end
|
94
102
|
end
|
95
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sps_filesync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
feUGIGfnNt45GzAXotThqQumr3i8r7QA6adlEdEvfEuB4QJ2sjZ+1mneJVJOWXuQ
|
36
36
|
0EhbgFKdvj2b8zaB8UqvKK0Q
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2018-08-
|
38
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: sps-sub
|
metadata.gz.sig
CHANGED
Binary file
|