Class: Pmux::BBFSAdapter
Constant Summary
StorageAdapter::Adapters
Instance Attribute Summary
#addrs
Instance Method Summary
collapse
#getaddr
create, #init_node_hash, #initialize
Instance Method Details
#connect_to_storage(locator_host, locator_port) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/pmux/storage_adapter.rb', line 109
def connect_to_storage locator_host, locator_port
@addr2dirs = {}
for b in @options[:bricks]
if b =~ %r{(\S+):(.+)}
dir = $2
addr = getaddr $1
(@addr2dirs[addr] ||= []).push dir
end
end
@addrs = @addr2dirs.keys
@h = init_node_hash @addrs
end
|
#get_files(args, glob_flag = false) ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/pmux/storage_adapter.rb', line 122
def get_files args, glob_flag=false
msession = MRSession.new @addrs, @options
msession.on_error {|addr, err| $stderr.printf "%s: %s\n", addr, err.to_s}
msession.connect
@locations = {}
mf = MR::MultiFuture.new
mf.on_success {|f|
addr = f.addr
res = f.get
for rpath, apath in res
(@locations[rpath] ||= []).push [addr, apath]
end
}
for addr in @addrs
future = msession.call_async addr, 'ls', @addr2dirs[addr], args
mf.add future
end
mf.join_all
@locations.keys
end
|
#lookup_file(file) ⇒ Object
143
144
145
|
# File 'lib/pmux/storage_adapter.rb', line 143
def lookup_file file
@locations[file]
end
|