drb_fileserver_plus 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/drb_fileserver_plus.rb +46 -5
- metadata +4 -4
- 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: d527d94fb71c9732110bfe785a6efc2e2e5eb2fe7b2904cd92ea349c8015d022
|
4
|
+
data.tar.gz: 78d01af07689868674507859d7d158dd1db37e92c45ca4666d85ef3df4570944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc1fcb04de4f3c1bafdb5e0e89fa7118fe0c002995348f7b3b412d3873499624ff5b26dcf5b0a6103e109c7eeb74474a8897a368f5328c95927cf0c46877d607
|
7
|
+
data.tar.gz: 308c514a2e598cd0fba771cf8b38992f33b87b2efb4d332ca4872af206c302c056f4a4775ad5b57010f2ee5f53fb3dacdbdf6c53ade1927e315fcc26f7cdaa63
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/drb_fileserver_plus.rb
CHANGED
@@ -5,21 +5,30 @@
|
|
5
5
|
# description: Designed to provide fault tolerant access to a DRb file server
|
6
6
|
# when 2 or more back-end nodes are running.
|
7
7
|
|
8
|
+
require 'sps-pub'
|
8
9
|
require 'drb_fileclient'
|
9
10
|
|
10
11
|
|
11
12
|
class DRbFileServer
|
12
13
|
|
13
|
-
def initialize(nodes)
|
14
|
+
def initialize(nodes, sps: nil, topic: 'file')
|
15
|
+
|
14
16
|
@nodes = nodes.map {|x| 'dfs://' + x}
|
15
17
|
@failcount = 0
|
18
|
+
@sps, @topic = sps, topic
|
19
|
+
|
16
20
|
end
|
17
21
|
|
18
22
|
def cp(path, path2)
|
19
|
-
|
23
|
+
|
20
24
|
file_op do |f|
|
21
25
|
f.cp File.join(@nodes.first, path), File.join(@nodes.first, path2)
|
22
26
|
end
|
27
|
+
|
28
|
+
if @sps then
|
29
|
+
@sps.notice "%s/copy: %s %s" % [@topic, File.join(@nodes.first, path),
|
30
|
+
File.join(@nodes.first, path2)]
|
31
|
+
end
|
23
32
|
|
24
33
|
end
|
25
34
|
|
@@ -38,13 +47,21 @@ class DRbFileServer
|
|
38
47
|
def mkdir(path)
|
39
48
|
|
40
49
|
file_op {|f| f.mkdir File.join(@nodes.first, path) }
|
50
|
+
|
51
|
+
if @sps then
|
52
|
+
@sps.notice "%s/mkdir: %s" % [@topic, File.join(@nodes.first, path)]
|
53
|
+
end
|
41
54
|
|
42
55
|
end
|
43
56
|
|
44
57
|
def mkdir_p(path)
|
45
58
|
|
46
59
|
file_op {|f| f.mkdir_p File.join(@nodes.first, path) }
|
47
|
-
|
60
|
+
|
61
|
+
if @sps then
|
62
|
+
@sps.notice "%s/mkdir_p: %s" % [@topic, File.join(@nodes.first, path)]
|
63
|
+
end
|
64
|
+
|
48
65
|
end
|
49
66
|
|
50
67
|
def mv(path, path2)
|
@@ -52,6 +69,11 @@ class DRbFileServer
|
|
52
69
|
file_op do |f|
|
53
70
|
f.mv File.join(@nodes.first, path), File.join(@nodes.first, path2)
|
54
71
|
end
|
72
|
+
|
73
|
+
if @sps then
|
74
|
+
@sps.notice "%s/mv: %s %s" % [@topic, File.join(@nodes.first, path),
|
75
|
+
File.join(@nodes.first, path2)]
|
76
|
+
end
|
55
77
|
|
56
78
|
end
|
57
79
|
|
@@ -64,6 +86,10 @@ class DRbFileServer
|
|
64
86
|
def rm(fname)
|
65
87
|
|
66
88
|
file_op {|f| f.rm File.join(@nodes.first, fname) }
|
89
|
+
|
90
|
+
if @sps then
|
91
|
+
@sps.notice "%s/rm: %s" % [@topic, File.join(@nodes.first, fname)]
|
92
|
+
end
|
67
93
|
|
68
94
|
end
|
69
95
|
|
@@ -71,12 +97,20 @@ class DRbFileServer
|
|
71
97
|
|
72
98
|
file_op {|f| f.write File.join(@nodes.first, fname), content }
|
73
99
|
|
100
|
+
if @sps then
|
101
|
+
@sps.notice("%s/write: %s" % [@topic, File.join(@nodes.first, fname)])
|
102
|
+
end
|
103
|
+
|
74
104
|
end
|
75
105
|
|
76
106
|
def zip(fname, a)
|
77
107
|
|
78
108
|
file_op {|f| f.zip File.join(@nodes.first, fname), a }
|
79
109
|
|
110
|
+
if @sps then
|
111
|
+
@sps.notice "%s/zip: %s" % [@topic, File.join(@nodes.first, fname)]
|
112
|
+
end
|
113
|
+
|
80
114
|
end
|
81
115
|
|
82
116
|
|
@@ -103,15 +137,22 @@ end
|
|
103
137
|
class DRbFileServerPlus
|
104
138
|
|
105
139
|
|
106
|
-
def initialize(host: 'localhost', port: '61010', nodes: []
|
140
|
+
def initialize(host: 'localhost', port: '61010', nodes: [], sps_host: nil,
|
141
|
+
sps_port: '59010', sps_topic: 'file')
|
107
142
|
|
108
143
|
@host, @port, @nodes = host, port, nodes
|
144
|
+
|
145
|
+
if sps_host then
|
146
|
+
@sps = SPSPub.new(host: sps_host, port: sps_port)
|
147
|
+
@topic = sps_topic
|
148
|
+
end
|
109
149
|
|
110
150
|
end
|
111
151
|
|
112
152
|
def start()
|
113
153
|
|
114
|
-
DRb.start_service "druby://#{@host}:#{@port}",
|
154
|
+
DRb.start_service "druby://#{@host}:#{@port}",
|
155
|
+
DRbFileServer.new(@nodes, sps: @sps, topic: @topic)
|
115
156
|
DRb.thread.join
|
116
157
|
|
117
158
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drb_fileserver_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
IzajbtHbQOY56M17vmJw7Y9ei8bGWzjVxfRUg33mVpGQQIWHA2JpaJ8+jpwrxdbF
|
36
36
|
DfzPJWgIRbTOgE4v1XGQcqsO
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2018-08-
|
38
|
+
date: 2018-08-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: drb_fileclient
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.4'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.4.
|
49
|
+
version: 0.4.4
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: '0.4'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.4.
|
59
|
+
version: 0.4.4
|
60
60
|
description:
|
61
61
|
email: james@jamesrobertson.eu
|
62
62
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|