-
Notifications
You must be signed in to change notification settings - Fork 556
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
Allow AtomixCluster to be autowired everywhere #10354
Conversation
Instead of having multiple Atomix factories, it makes more sense to simply eschew going through layers of intermediate configuration classes and builders, and simply have each application map its configuration to the general Atomix `ClusterConfig`, from which we can create a cluster easily. This will greatly simplify injecting the cluster in the broker later on.
import org.springframework.core.env.PropertiesPropertySource; | ||
import org.springframework.core.env.StandardEnvironment; | ||
|
||
final class WorkingDirectoryConfigurationTest { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces
Super cool, since the SystemContext is in charge of initializing the configuration in tests, most tests fail to build a cluster (since we want to inject the cluster). |
0086464
to
53469ef
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.
Great 🚀 That was a lot of changes, but in the good direction. Thanks.
atomix/cluster/src/main/java/io/atomix/cluster/discovery/BootstrapDiscoveryProvider.java
Outdated
Show resolved
Hide resolved
atomix/cluster/src/main/java/io/atomix/cluster/protocol/SwimMembershipProtocol.java
Outdated
Show resolved
Hide resolved
dist/src/main/java/io/camunda/zeebe/broker/WorkingDirectoryConfiguration.java
Outdated
Show resolved
Hide resolved
dist/src/main/java/io/camunda/zeebe/broker/BrokerClusterConfiguration.java
Show resolved
Hide resolved
Yes, sorry, this was much more changes than I wanted, and I had to find a balance between fully moving everything shared between broker/gateway to dist and not creating too much work. At the same time, it highlighted that if we will do more with Spring, we may want to learn more about how it works 😄 |
Resolve the working directory via configuration, as it will be required to initialize the messaging configuration for `AtomixCluster` down the line.
Refactors to allow the cluster services to be created outside of the broker, and injected directly, though not yet started. This reduces the cluster step to just starting the cluster. To simplify testing, temporary factories are added, mostly because many tests expect to be able to modify the cluster services by modifying the `BrokerCfg`. Most of `ClusterConfigFactory` should be transferable to the `dist` module once this is not true anymore.
53469ef
to
41bed32
Compare
152b82f
to
870286d
Compare
bors merge |
Build succeeded: |
10357: Allow reuse of shared actuators depending on BrokerClient r=npepinpe a=npepinpe ## Description This PR provides the last remaining bit to #9996 by having each application provide a `BrokerClient` bean, allowing us to create shared actuators which do not need any bridge. To showcase, the `RebalancingService` was collapsed into a single class. ## Related issues closes #9996 depends on #10354 Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
Description
This PR extracts building the
AtomixCluster
from the broker into thedist
module. Unfortunately, because many of our testing utilities break all kinds of abstraction, and our tests still heavily rely on modifying the cluster via theBrokerCfg
, mapping theBrokerCfg
to theAtomixCluster
is still done in thebroker
module. However, everything is prepared to eventually move this out to the dist module itself, such that our configuration would simply instantiate the AtomixClusterConfig
type, and later inject aAtomixCluster
in the broker. See theStandaloneGateway
as an example; there is plenty of opportunity to DRY it up once both are simply configuringClusterConfig
directly, and it will remove intermediate layers of builders/config.In order to achieve that at the moment, since the network configuration relies on being initialized with the right broker base path, I also had to pull up the working directory into its own configuration, such that it can be autowired as well. This is a little more abstraction than I'd like, but it's due to how the
BrokerCfg
is still the central point for all the components, even those not specific to the broker.The broker configuration is thus not initialized in the system context or broker anymore, but is given to the broker already initialized. This is done via the Spring configuration
BrokerConfiguration
. It uses two beans to do this, which I dislike, but I'm not sure what's the best way to do this. I generally dislike that the configuration must be initialized anyway, it's very brittle and easy to forget, so I'd rather figure a way to avoid this in the future. I would propose a follow up which removes this, and instead enforces that we create the broker config either passing the base already, or using a factory method which does this. I can also do it here, but it will increase how much changes are here.I think in the future the cluster services should be started before the broker itself, but we can figure this out later. For now, it means that if the actuator wants to make use of them before the broker finishes starting, it will fail - this is something we can handle semi-gracefully, so I would leave it as is.
Related issues
related to #9996
Definition of Done
Not all items need to be done depending on the issue and the pull request.
Code changes:
backport stable/1.3
) to the PR, in case that fails you need to create backports manually.Testing:
Documentation:
Please refer to our review guidelines.