Skip to content

Commit

Permalink
Merge pull request #81 from JuliaParallel/fbot/deps
Browse files Browse the repository at this point in the history
Fix deprecations
  • Loading branch information
tanmaykm authored Dec 12, 2017
2 parents 62825f5 + 088869d commit 87e8e9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
4 changes: 1 addition & 3 deletions src/ClusterManagers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ worker_arg = `--worker`

function __init__()
global worker_arg
if VERSION >= v"0.5.0-dev+4047"
worker_arg = `--worker=$(Base.cluster_cookie())`
end
worker_arg = `--worker=$(Base.cluster_cookie())`
end

# PBS doesn't have the same semantics as SGE wrt to file accumulate,
Expand Down
29 changes: 11 additions & 18 deletions src/elastic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ type ElasticManager <: ClusterManager
topology::Symbol

function ElasticManager(;addr=IPv4("127.0.0.1"), port=9009, cookie=nothing, topology=:all_to_all)
if VERSION >= v"0.5.0-dev+4047"
cookie !== nothing && Base.cluster_cookie(cookie)
end
cookie !== nothing && Base.cluster_cookie(cookie)

l_sock = listen(addr, port)

Expand Down Expand Up @@ -47,18 +45,15 @@ function process_worker_conn(mgr::ElasticManager, s::TCPSocket)
wc.io = s

# Validate cookie
if VERSION >= v"0.5.0-dev+4047"
cookie = read(s, HDR_COOKIE_LEN)
if length(cookie) < HDR_COOKIE_LEN
error("Cookie read failed. Connection closed by peer.")
end

self_cookie = Base.cluster_cookie()
for i in 1:HDR_COOKIE_LEN
if UInt8(self_cookie[i]) != cookie[i]
println(i, " ", self_cookie[i], " ", cookie[i])
error("Invalid cookie sent by remote worker.")
end
cookie = read(s, HDR_COOKIE_LEN)
if length(cookie) < HDR_COOKIE_LEN
error("Cookie read failed. Connection closed by peer.")
end
self_cookie = Base.cluster_cookie()
for i in 1:HDR_COOKIE_LEN
if UInt8(self_cookie[i]) != cookie[i]
println(i, " ", self_cookie[i], " ", cookie[i])
error("Invalid cookie sent by remote worker.")
end
end

Expand Down Expand Up @@ -125,9 +120,7 @@ end
# addr, port that a ElasticManager on the master processes is listening on.
function elastic_worker(cookie, addr="127.0.0.1", port=9009; stdout_to_master=true)
c = connect(addr, port)
if VERSION >= v"0.5.0-dev+4047"
write(c, rpad(cookie, HDR_COOKIE_LEN)[1:HDR_COOKIE_LEN])
end
write(c, rpad(cookie, HDR_COOKIE_LEN)[1:HDR_COOKIE_LEN])
stdout_to_master && redirect_stdout(c)
Base.start_worker(c, cookie)
end
Expand Down

0 comments on commit 87e8e9b

Please sign in to comment.