drb_fileserver_plus 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a83d40ba61a17b891cc7d36dee22ac41c86c287341e701b361cef36d606126e9
4
+ data.tar.gz: 7ebed2c7045431b5273ae8b94f81b6fd009d56bd0127d416c3f0553def9c1413
5
+ SHA512:
6
+ metadata.gz: 13cf6df31b68578697d4717f510aeea2fd5fcf3a000c9509fdbe1e16aac74a0a056e153a570ff4e12ebd80a104f29d68446148ea2b790d1011c61e94d0e38ef3
7
+ data.tar.gz: 533ab906f417e1dcb62ff755407e2f2f65f54e38b9c776619fc7314c084e952400997a4598f5ef8408895831faed7208de3a0b2484bdfb2bbf627d02a3f51422
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ BB���r8�|����:���=�W<���]���c�) ��U�����r>�{)N�(��\��d,�A��T�:J�5u�E�G����R��s�b6v��4����r\����"YBד�:
2
+ '�V�Ȉ��(�fΏ�B'�*�0�W��?��^N%#�m�8z�Z�)@�g����j� �$/IPa��I0�� ���M��U�۶9�.�Й��W�����ZKم�APIA�cՐ���8CPe
3
+ AkK&�_�G�$��?FZ��Eh���
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: drb_fileserver_plus.rb
4
+
5
+ # description: Designed to provide fault tolerant access to a DRb file
6
+ # server when 2 or more back-end nodes are running.
7
+
8
+ require 'drb_fileclient'
9
+
10
+
11
+ class DRbFileServer
12
+
13
+ def initialize(nodes)
14
+ @nodes = nodes.map {|x| 'dfs://' + x}
15
+ @failcount = 0
16
+ end
17
+
18
+ def read(fname)
19
+
20
+ file_op {|f| f.read File.join(@nodes.first, fname) }
21
+
22
+ end
23
+
24
+ def write(fname, content)
25
+
26
+ file_op {|f| f.write File.join(@nodes.first, fname), content }
27
+
28
+ end
29
+
30
+ private
31
+
32
+ def file_op()
33
+
34
+ begin
35
+ r = yield(DfsFile)
36
+ @failcount = 0
37
+ r
38
+ rescue
39
+ puts 'warning: ' + ($!).inspect
40
+ @nodes.rotate!
41
+ @failcount += 1
42
+ retry unless @failcount > @nodes.length
43
+ raise 'DRbFileServerPlus nodes exhausted'
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ class DRbFileServerPlus
51
+
52
+
53
+ def initialize(host: 'localhost', port: '61010', nodes: [])
54
+
55
+ @host, @port, @nodes = host, port, nodes
56
+
57
+ end
58
+
59
+ def start()
60
+
61
+ DRb.start_service "druby://#{@host}:#{@port}", DRbFileServer.new(@nodes)
62
+ DRb.thread.join
63
+
64
+ end
65
+
66
+ end
67
+
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drb_fileserver_plus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwODIyMTAzMzQ3WhcN
15
+ MTkwODIyMTAzMzQ3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQClKaO5
17
+ OJW0sxpai9US4G/mLYTlk/F0KsII6NStyEmHkwFj8iWodj7eGZ60UQ1ZC38IcyBG
18
+ 62sCsnjMUZOC1h3Ss9mIp8fYJfHPC9AxC71jMClbbTDBNGs/aBaIrvjcQ0qpmVh1
19
+ wE+rC5K/Knt/r7/OHiMwX1NmOINAyidT1N2EGXCKB5VTH2GrmRHi4B9PTQ7FFdYW
20
+ R9duTW7ka36Rh6eC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pGQQIWHA2JpaJ8+jpwrxdbF
36
+ DfzPJWgIRbTOgE4v1XGQcqsO
37
+ -----END CERTIFICATE-----
38
+ date: 2018-08-22 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: drb_fileclient
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.4'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.4.2
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.4'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.4.2
60
+ description:
61
+ email: james@jamesrobertson.eu
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - lib/drb_fileserver_plus.rb
67
+ homepage: https://github.com/jrobertson/drb_fileserver_plus
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.7.6
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Designed to provide fault tolerant access to a DRb file server when 2 or
91
+ more back-end nodes are running.
92
+ test_files: []
metadata.gz.sig ADDED
Binary file