Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
25f319f9
Commit
25f319f9
authored
Apr 12, 2021
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
hostpool improvements
parent
9ec2d7b0
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/client.go
+1
-1
1 addition, 1 deletion
api/client.go
cmd/root.go
+1
-1
1 addition, 1 deletion
cmd/root.go
network/gateway/hostPool.go
+6
-4
6 additions, 4 deletions
network/gateway/hostPool.go
network/gateway/sender.go
+22
-2
22 additions, 2 deletions
network/gateway/sender.go
with
30 additions
and
8 deletions
api/client.go
+
1
−
1
View file @
25f319f9
...
@@ -446,7 +446,7 @@ func (c *Client) StopNetworkFollower(timeout time.Duration) error {
...
@@ -446,7 +446,7 @@ func (c *Client) StopNetworkFollower(timeout time.Duration) error {
return
nil
return
nil
}
}
// Gets the state of the network follower. Returns:
//
NetworkFollowerStatus
Gets the state of the network follower. Returns:
// Stopped - 0
// Stopped - 0
// Starting - 1000
// Starting - 1000
// Running - 2000
// Running - 2000
...
...
This diff is collapsed.
Click to expand it.
cmd/root.go
+
1
−
1
View file @
25f319f9
...
@@ -78,7 +78,7 @@ var rootCmd = &cobra.Command{
...
@@ -78,7 +78,7 @@ var rootCmd = &cobra.Command{
jww
.
INFO
.
Printf
(
"Message ListenerID: %v"
,
listenerID
)
jww
.
INFO
.
Printf
(
"Message ListenerID: %v"
,
listenerID
)
// Set up auth request handler, which simply prints the
// Set up auth request handler, which simply prints the
// user id of the request
o
r.
// user id of the request
e
r.
authMgr
:=
client
.
GetAuthRegistrar
()
authMgr
:=
client
.
GetAuthRegistrar
()
authMgr
.
AddGeneralRequestCallback
(
printChanRequest
)
authMgr
.
AddGeneralRequestCallback
(
printChanRequest
)
...
...
This diff is collapsed.
Click to expand it.
network/gateway/hostPool.go
+
6
−
4
View file @
25f319f9
...
@@ -116,7 +116,8 @@ func (h *HostPool) getAny(length uint32, excluded []*id.ID) []*connect.Host {
...
@@ -116,7 +116,8 @@ func (h *HostPool) getAny(length uint32, excluded []*id.ID) []*connect.Host {
length
=
h
.
poolParams
.
PoolSize
length
=
h
.
poolParams
.
PoolSize
}
}
if
excluded
!=
nil
{
if
excluded
!=
nil
{
for
_
,
gwId
:=
range
excluded
{
for
i
:=
range
excluded
{
gwId
:=
excluded
[
i
]
if
idx
,
ok
:=
h
.
hostMap
[
*
gwId
];
ok
{
if
idx
,
ok
:=
h
.
hostMap
[
*
gwId
];
ok
{
checked
[
idx
]
=
nil
checked
[
idx
]
=
nil
}
}
...
@@ -314,7 +315,7 @@ func (h *HostPool) updateConns() error {
...
@@ -314,7 +315,7 @@ func (h *HostPool) updateConns() error {
for
gwId
:=
range
h
.
ndfMap
{
for
gwId
:=
range
h
.
ndfMap
{
if
_
,
ok
:=
newMap
[
gwId
];
!
ok
{
if
_
,
ok
:=
newMap
[
gwId
];
!
ok
{
// If GwId in ndfMap is not in newMap, remove the Gateway
// If GwId in ndfMap is not in newMap, remove the Gateway
h
.
removeGateway
(
&
gwId
)
h
.
removeGateway
(
gwId
.
DeepCopy
()
)
}
}
}
}
...
@@ -322,7 +323,7 @@ func (h *HostPool) updateConns() error {
...
@@ -322,7 +323,7 @@ func (h *HostPool) updateConns() error {
for
gwId
,
ndfIdx
:=
range
newMap
{
for
gwId
,
ndfIdx
:=
range
newMap
{
if
_
,
ok
:=
h
.
ndfMap
[
gwId
];
!
ok
{
if
_
,
ok
:=
h
.
ndfMap
[
gwId
];
!
ok
{
// If GwId in newMap is not in ndfMap, add the Gateway
// If GwId in newMap is not in ndfMap, add the Gateway
h
.
addGateway
(
&
gwId
,
ndfIdx
)
h
.
addGateway
(
gwId
.
DeepCopy
()
,
ndfIdx
)
}
}
}
}
...
@@ -339,7 +340,8 @@ func convertNdfToMap(ndf *ndf.NetworkDefinition) (map[id.ID]int, error) {
...
@@ -339,7 +340,8 @@ func convertNdfToMap(ndf *ndf.NetworkDefinition) (map[id.ID]int, error) {
}
}
// Process gateway Id's into set
// Process gateway Id's into set
for
i
,
gw
:=
range
ndf
.
Gateways
{
for
i
:=
range
ndf
.
Gateways
{
gw
:=
ndf
.
Gateways
[
i
]
gwId
,
err
:=
id
.
Unmarshal
(
gw
.
ID
)
gwId
,
err
:=
id
.
Unmarshal
(
gw
.
ID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
network/gateway/sender.go
+
22
−
2
View file @
25f319f9
...
@@ -10,6 +10,7 @@ package gateway
...
@@ -10,6 +10,7 @@ package gateway
import
(
import
(
"github.com/pkg/errors"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/comms/network"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/comms/connect"
...
@@ -40,31 +41,44 @@ func (m *Sender) SendToSpecific(target *id.ID,
...
@@ -40,31 +41,44 @@ func (m *Sender) SendToSpecific(target *id.ID,
sendFunc
func
(
host
*
connect
.
Host
,
target
*
id
.
ID
)
(
interface
{},
error
))
(
interface
{},
error
)
{
sendFunc
func
(
host
*
connect
.
Host
,
target
*
id
.
ID
)
(
interface
{},
error
))
(
interface
{},
error
)
{
host
,
ok
:=
m
.
getSpecific
(
target
)
host
,
ok
:=
m
.
getSpecific
(
target
)
if
ok
{
if
ok
{
jww
.
WARN
.
Printf
(
"SendToSpecific %s"
,
host
.
GetId
()
.
String
())
result
,
err
:=
sendFunc
(
host
,
target
)
result
,
err
:=
sendFunc
(
host
,
target
)
if
err
==
nil
{
if
err
==
nil
{
return
result
,
m
.
forceAdd
([]
*
id
.
ID
{
host
.
GetId
()})
return
result
,
m
.
forceAdd
([]
*
id
.
ID
{
host
.
GetId
()})
}
else
{
jww
.
WARN
.
Printf
(
"Unable to SendToSpecific %s: %+v"
,
host
.
GetId
()
.
String
(),
err
)
}
}
}
}
proxies
:=
m
.
getAny
(
m
.
poolParams
.
ProxyAttempts
,
[]
*
id
.
ID
{
target
})
proxies
:=
m
.
getAny
(
m
.
poolParams
.
ProxyAttempts
,
[]
*
id
.
ID
{
target
})
for
proxyIdx
:=
0
;
proxyIdx
<
len
(
proxies
);
proxyIdx
++
{
for
proxyIdx
:=
0
;
proxyIdx
<
len
(
proxies
);
proxyIdx
++
{
jww
.
WARN
.
Printf
(
"SendToSpecific proxy %s"
,
proxies
[
proxyIdx
]
.
GetId
()
.
String
())
result
,
err
:=
sendFunc
(
proxies
[
proxyIdx
],
target
)
result
,
err
:=
sendFunc
(
proxies
[
proxyIdx
],
target
)
if
err
==
nil
{
if
err
==
nil
{
return
result
,
nil
return
result
,
nil
}
else
{
jww
.
WARN
.
Printf
(
"Unable to SendToSpecific proxy %s: %+v"
,
proxies
[
proxyIdx
]
.
GetId
()
.
String
(),
err
)
}
}
}
}
return
nil
,
errors
.
Errorf
(
"Unable to send to
any
specific
s
with proxies"
)
return
nil
,
errors
.
Errorf
(
"Unable to send to specific with proxies"
)
}
}
// SendToAny Call given sendFunc to any Host in the HostPool, attempting with up to numProxies destinations
// SendToAny Call given sendFunc to any Host in the HostPool, attempting with up to numProxies destinations
func
(
m
*
Sender
)
SendToAny
(
sendFunc
func
(
host
*
connect
.
Host
)
(
interface
{},
error
))
(
interface
{},
error
)
{
func
(
m
*
Sender
)
SendToAny
(
sendFunc
func
(
host
*
connect
.
Host
)
(
interface
{},
error
))
(
interface
{},
error
)
{
proxies
:=
m
.
getAny
(
m
.
poolParams
.
ProxyAttempts
,
nil
)
proxies
:=
m
.
getAny
(
m
.
poolParams
.
ProxyAttempts
,
nil
)
for
_
,
proxy
:=
range
proxies
{
for
i
:=
range
proxies
{
jww
.
WARN
.
Printf
(
"Sender %d %s"
,
i
,
proxies
[
i
]
.
GetId
()
.
String
())
}
for
i
:=
range
proxies
{
proxy
:=
proxies
[
i
]
jww
.
WARN
.
Printf
(
"SendToAny %s"
,
proxy
.
GetId
()
.
String
())
result
,
err
:=
sendFunc
(
proxy
)
result
,
err
:=
sendFunc
(
proxy
)
if
err
==
nil
{
if
err
==
nil
{
return
result
,
nil
return
result
,
nil
}
else
{
jww
.
WARN
.
Printf
(
"Unable to SendToAny %s: %+v"
,
proxy
.
GetId
()
.
String
(),
err
)
}
}
}
}
...
@@ -76,17 +90,23 @@ func (m *Sender) SendToPreferred(targets []*id.ID,
...
@@ -76,17 +90,23 @@ func (m *Sender) SendToPreferred(targets []*id.ID,
sendFunc
func
(
host
*
connect
.
Host
,
target
*
id
.
ID
)
(
interface
{},
error
))
(
interface
{},
error
)
{
sendFunc
func
(
host
*
connect
.
Host
,
target
*
id
.
ID
)
(
interface
{},
error
))
(
interface
{},
error
)
{
targetHosts
:=
m
.
getPreferred
(
targets
)
targetHosts
:=
m
.
getPreferred
(
targets
)
for
i
,
host
:=
range
targetHosts
{
for
i
,
host
:=
range
targetHosts
{
jww
.
WARN
.
Printf
(
"SendToPreferred %s"
,
host
.
GetId
()
.
String
())
result
,
err
:=
sendFunc
(
host
,
targets
[
i
])
result
,
err
:=
sendFunc
(
host
,
targets
[
i
])
if
err
==
nil
{
if
err
==
nil
{
return
result
,
nil
return
result
,
nil
}
else
{
jww
.
WARN
.
Printf
(
"Unable to SendToPreferred %s: %+v"
,
host
.
GetId
()
.
String
(),
err
)
}
}
}
}
proxies
:=
m
.
getAny
(
m
.
poolParams
.
ProxyAttempts
,
targets
)
proxies
:=
m
.
getAny
(
m
.
poolParams
.
ProxyAttempts
,
targets
)
for
i
,
proxy
:=
range
proxies
{
for
i
,
proxy
:=
range
proxies
{
jww
.
WARN
.
Printf
(
"SendToPreferred proxy %s"
,
proxy
.
GetId
()
.
String
())
result
,
err
:=
sendFunc
(
proxy
,
targets
[
i
%
len
(
targets
)])
result
,
err
:=
sendFunc
(
proxy
,
targets
[
i
%
len
(
targets
)])
if
err
==
nil
{
if
err
==
nil
{
return
result
,
nil
return
result
,
nil
}
else
{
jww
.
WARN
.
Printf
(
"Unable to SendToPreferred proxy %s: %+v"
,
proxy
.
GetId
()
.
String
(),
err
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment