-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make pool statistics optional #453
Conversation
473b938
to
bf18054
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I propose is to think more in line of #431 (comment) and #431 (comment)
It may look like an additional SetOperationCallback()
for Client
's (!) PrmInit
. In the form of f func(nodekey []byte, endpoint string, method string, t time.Duration, err error)
. Endpoint is to be taken from Dial()
parameters while nodekey
is to be extracted from EndpointInfo()
(which can be called instead of a Balance()
in Client.Dial()
. The rest of the things are pretty obvious, method names should be specified in the documentation.
The reason for endpoint/key is that there can be multiple nodes behind one address and we need to deal with it. This also makes the interface generic enough to be reused in exactly the same way in Pool.InitParameters
.
Then there is going to be a stats
package with a structure implementing this method (Statistic
can be moved there), it has to be protected for concurrent access though. This package could be used both for client
and pool
. But node could reuse the same interface for its (kludgy) reputationClient
(counting things it wants to count).
Then pool
has to manage the health of its clients. Always. It has some knobs for it (like ErrorThreshold, but it's an internal pool thing, always there, always passed to clients. If it also has an externally-requested OperationCallback()
then it's also called (kinda a proxied call). SetRequestCallback()
can be removed, because it's the same thing, just with less parameters.
I think this scheme will cover all of our use cases and allow for some more.
bf18054
to
8f4c375
Compare
d5cea25
to
6ec5b2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But looks OK otherwise.
pool/pool.go
Outdated
case methodContainerAnnounceUsedSpace: | ||
return "containerAnnounceUsedSpace" | ||
case methodSyncContainerWithNetwork: | ||
return "syncContainerWithNetwork" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will be removed eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will remove it from stat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean from the pool! All of the real client method should be covered. But syncContainer
is not a proper method at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still there, container sync is not a client method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it uses the client but not it's part. Removed
pool/pool.go
Outdated
return res, nil | ||
} | ||
|
||
func (c *clientWrapper) statisticMiddleware(nodeKey []byte, endpoint string, method stat.Method, duration time.Duration, err error) { | ||
c.incRequests(duration, MethodIndex(method)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one won't be needed after default statistics decoupling from the pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still there and we still have Statistics
which can be reworked into a stat
thing (some structure that exposes the same interface to retrieve statistics and implements OperationCallback
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to stat
package
5620e71
to
f2512e0
Compare
stat/stat.go
Outdated
MethodNetMapSnapshot | ||
MethodObjectHash | ||
MethodObjectSearch | ||
methodLast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have all client methods here? It should cover all of them even though the pool doesn't use some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method list is updated, now we have all client methods
client/accounting.go
Outdated
res accounting.Decimal | ||
cc contextCall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a useful change (moving var definition).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change removed
stat/stat.go
Outdated
@@ -28,6 +28,7 @@ const ( | |||
MethodObjectSearch | |||
MethodContainerAnnounceUsedSpace | |||
MethodSyncContainerWithNetwork | |||
// methodLast is no a valid method name, it's a system anchor for tests, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is added in a separate commit from methodLast
definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
client/object_search.go
Outdated
} | ||
r.client = c | ||
r.statisticCallback = func(duration time.Duration, err error) { | ||
c.sendStatistic(stat.MethodObjectSearch, duration, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it counted like a MethodObjectSearch
now in pool
? I'd expect some separate name since it's not a real method, rather just reading from the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with get/put.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extended with three new Method*
client/client.go
Outdated
_, err := rpc.Balance(&c.c, new(v2accounting.BalanceRequest), | ||
client.WithContext(prm.parentCtx), | ||
) | ||
endpointInfo, err := c.EndpointInfo(prm.parentCtx, PrmEndpointInfo{}) | ||
// return context errors since they signal about dial problem | ||
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why do we still have these then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
pool/pool.go
Outdated
return res, nil | ||
} | ||
|
||
func (c *clientWrapper) statisticMiddleware(nodeKey []byte, endpoint string, method stat.Method, duration time.Duration, err error) { | ||
c.incRequests(duration, MethodIndex(method)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still there and we still have Statistics
which can be reworked into a stat
thing (some structure that exposes the same interface to retrieve statistics and implements OperationCallback
).
pool/pool.go
Outdated
case methodContainerAnnounceUsedSpace: | ||
return "containerAnnounceUsedSpace" | ||
case methodSyncContainerWithNetwork: | ||
return "syncContainerWithNetwork" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still there, container sync is not a client method.
2bae95b
to
a55bfbc
Compare
a55bfbc
to
3ac0b0b
Compare
Also, a general suggestion: add more details to commit messages. Some examples from node: nspcc-dev/neofs-node@00afc57, nspcc-dev/neofs-node@67bd9c2. Changes are good, but the knowledge of why they were done allows speeding up reading and understanding. |
9fab285
to
1dabbc3
Compare
It makes sense |
Using EndpointInfo, instead of Balance have two advantages: - Check the entrypoint is available; - Get node public key for statistic purposes. Any error now is a reason to return from the constructor and broke initialization. Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
…mands Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
1dabbc3
to
41bd8e5
Compare
close #431