-
Notifications
You must be signed in to change notification settings - Fork 68
Support load balancer health check even at full capacity #1509
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
Conversation
runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/registry/EngineBoss.java
Show resolved
Hide resolved
| for (BindingConfig binding : namespace.bindings) | ||
| { | ||
| BindingController controller = controllersByType.get(binding.type); | ||
| if (controller != null) | ||
| { | ||
| controller.detach(binding); | ||
| } | ||
| } |
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 think we need to offer this as a NamespaceTask too, to make sure it executes on the boss thread, not the caller thread.
| private void register( | ||
| NamespaceConfig namespace) | ||
| { | ||
| this.boss.attach(namespace).join(); |
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.boss.attach(namespace).join(); | |
| boss.attach(namespace).join(); |
| { | ||
| if (namespace != null) | ||
| { | ||
| boss.detach(namespace); |
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.
| boss.detach(namespace); | |
| boss.detach(namespace).join(); |
| { | ||
| try | ||
| { | ||
| controllersByType.values().forEach(BindingController::detachAll); |
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 detachAll() for EngineBoss and BindingController seems inconsistent with the design of separation between EngineWorker and BindingHandler.
Instead, we can keep track of the NamespaceConfigs that we have attached to the EngineBoss and then iterate each NamespaceConfig to here in doClose and detach them all.
| if (route != null) | ||
| { | ||
| final TcpServer server = new TcpServer(binding.id, route.id, network); | ||
| final TcpServer server = new TcpServer(bindingId, route.id, network); |
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.
| final TcpServer server = new TcpServer(bindingId, route.id, network); | |
| final TcpServer server = new TcpServer(binding.id, route.id, network); |
We already used bindingId to resolve binding so at this point it is more correct to use binding.id.
| if (binding != null) | ||
| { | ||
| route = router.resolve(binding, traceId, authorization, beginEx); | ||
| route = binding.resolve(binding, traceId, authorization, beginEx); |
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.
| route = binding.resolve(binding, traceId, authorization, beginEx); | |
| route = binding.resolve(traceId, authorization, beginEx); |
| public InetSocketAddress resolve( | ||
| TcpBindingConfig binding, | ||
| long traceId, | ||
| long authorization, | ||
| ProxyBeginExFW beginEx) | ||
| { | ||
| final TcpOptionsConfig options = binding.options; |
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.
| public InetSocketAddress resolve( | |
| TcpBindingConfig binding, | |
| long traceId, | |
| long authorization, | |
| ProxyBeginExFW beginEx) | |
| { | |
| final TcpOptionsConfig options = binding.options; | |
| public InetSocketAddress resolve( | |
| long traceId, | |
| long authorization, | |
| ProxyBeginExFW beginEx) | |
| { |
| private final LongConsumer recordUsage; | ||
|
|
||
| private int usage; | ||
| private volatile int usage; |
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.
Did we change this to volatile to handle access from engine boss thread during tcp accept?
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.
No sorry I was debugging and forgot to remove it
| @Override | ||
| public void detachAll() | ||
| { | ||
| serversById.values().forEach(CloseHelper::quietCloseAll); | ||
| serversById.clear(); | ||
| } |
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.
Please remove this method.
| } | ||
|
|
||
| public void detach( | ||
| private void detachNamespace( |
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.
Please move this private method down below attachNamespace.
| private void attachNamespace( | ||
| NamespaceConfig namespace) | ||
| { | ||
| namespaces.add(namespace); |
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 is good.
We also need symmetrical namespaces.remove(namespace); in detachNamespace method.
Note that namespaces can be added and removed while engine is still running, so detachNamespace is not only for doClose case, that's why we need to make sure it is kept accurate.
| public void attachNow( | ||
| NamespaceConfig namespace) | ||
| { | ||
| attach(namespace).join(); | ||
| } | ||
|
|
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 still need attachNow and detachNow? If not, let's remove them.
|
|
||
| public class EngineBoss implements EngineController, Agent | ||
| { | ||
| private static final String AGENT_NAME = "EngineBoss"; |
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.
| private static final String AGENT_NAME = "EngineBoss"; | |
| private static final String AGENT_NAME = "engine/boss"; |
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 agentName to this.agentName = String.format("engine/worker#%d", index);
Fixes #1495