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
ISPN-10322 Create unified interface for initializing commands #6834
Conversation
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.
LGTM. Just a minor comment about the function instance variable.
core/src/main/java/org/infinispan/commands/functional/AbstractWriteKeyCommand.java
Outdated
Show resolved
Hide resolved
b5ae46e
to
e7eabfc
Compare
There's still a lot of failures on this branch, but I don't want to waste time resolving them until the general idea is approved. If not, I'll just close the PR. |
Overall I like this approach a lot. |
Overall I like the approach as well as it keeps the code cleaner. I would love to see the perf difference; I am guessing it is negligible though (since it is a megamorphic call now instead but doesn't have the switch statement). |
16e9829
to
e1cdfda
Compare
bad32e1
to
bb9c7d8
Compare
bb9c7d8
to
23f63db
Compare
Updated to apply the approach to all of our modules. @danberindei please take a look when you get a chance as I'm sure you'll be more interested then most. |
run performance tests please |
Performance tests didn't finish successfully. @diegolovison, can you review it? Additional info: |
@ryanemerson blocked by radargun/radargun#603 |
run performance tests please |
23f63db
to
6906799
Compare
@ryanemerson I would say it's a step in the right direction, but it doesn't go far enough! I would like to get rid of the separate remote initialization step completely and instead add a method For local invocation, the invoker already knows the concrete type, so instead of adding a Currently global commands use Further out, I hope to replace the interface |
6906799
to
d467f17
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.
Oops, forgot to press submit
@@ -156,17 +155,12 @@ private void prepareForValidation() { | |||
// Besides, any cache interceptor initialization should only be done once. | |||
// Synchronizes on the cache instance since it's shared between regions with same name. | |||
synchronized (cache) { | |||
PutFromLoadValidator found = findValidator(cache); | |||
PutFromLoadValidator found = cache.getComponentRegistry().getComponent(PutFromLoadValidator.class); | |||
validator = found != null ? found : new PutFromLoadValidator(cache, factory, factory.getPendingPutsCacheConfiguration()); |
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 seems wrong, either the PutFromLoadValidator
is supposed to be registered in the component registry and shared with others using the same cache, or it's not supposed to be registered and we should just create an instance here.
public void init(ComponentRegistry componentRegistry, boolean isRemote) { | ||
Cache cache = componentRegistry.getCache().wired(); | ||
searchFactory = ComponentRegistryUtils.getSearchIntegrator(cache); | ||
queryInterceptor = ComponentRegistryUtils.getQueryInterceptor(cache); |
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 what I don't like about having an interface: ComponentRegistry
can only cache core components, so other modules have to go back to hash map lookups. The effect on performance may be close to nil, but still it's annoying.
this.invoker = componentRegistry.getInterceptorChain().running(); | ||
this.icf = componentRegistry.getInvocationContextFactory().running(); | ||
this.txTable = componentRegistry.getTransactionTableRef().running(); | ||
markTransactionAsRemote(isRemote); |
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 the only place where we need the isRemote
parameter. I'd rather remove the remote
flag from GlobalTransaction
, TBH it always bugged me that the identifier of a transaction is different depending on who you're asking.
@Override | ||
public ModuleCommandInitializer getModuleCommandInitializer() { | ||
return new ModuleCommandInitializer() { | ||
@Inject EmbeddedCacheManager cacheManager; |
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.
As you're removing implementations from other modules I'd rather extend the test implementation here to add a custom command and verify that it keeps working.
server/hotrod/src/main/java/org/infinispan/server/hotrod/LifecycleCallbacks.java
Show resolved
Hide resolved
d467f17
to
e32b3ec
Compare
e32b3ec
to
6c6ae36
Compare
Integrated, thanks Ryan! |
@danberindei @wburns This is an attempt to standardise the way in which we initialise our RPC commands to remove the need for the switch statement in CommandsFactoryImpl. This started when I was bored at the airport, so feel free to tear it apart 😄.
In order to avoid creating a sub-interface, e.g. ComandInitialisationContext, theInitializableCommand#init
method takes in theComponentRegistry
and I have cached the components required throughout core to avoid hash lookups. TheExpose*
commits, was just a logical way of exposing sub-components by managers in order to reduce the amount directly expose by the ComponentRegistry. I'm not sure whether this is a good/bad idea.I have left support forModuleCommandInitializer
as this can be more powerful e.g. hibernateCacheCommandInitializer
. However, if we go with this approach we should probably allModuleCommandExtensions#getModuleCommandInitializer
to return null or provide a default impl that does this.I've only update the core module for now, if this is something to pursue then I will update the other modules that utiliseModuleCommandInitializer
.https://issues.jboss.org/browse/ISPN-10322