Skip to content
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-8670 Standalone Server Cache Storage #5666

Merged

Conversation

tristantarrant
Copy link
Member

@tristantarrant tristantarrant commented Jan 10, 2018

@tristantarrant tristantarrant added this to the 9.2.0.CR1 milestone Jan 10, 2018
Copy link
Member

@galderz galderz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor comment.

@@ -1027,6 +1028,14 @@ else if (ch == 'f')
return out.toString();
}

public static <T> Supplier<T> getInstanceSupplier(Class<T> klass) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Function instead of Supplier? By using a Supplier, you're capturing a variable outside the lambda (klass). Could you have a Function that takes Class<T> and returns T? Then the function would be pure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in the context of the server LocalConfigurationStorage, I need to be able to set a bunch of context.

return () -> getInstance(klass);
}

public static <T> Supplier<T> getInstanceSupplier(String className, ClassLoader classLoader) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing but with a BiFunction.

@galderz
Copy link
Member

galderz commented Jan 15, 2018

Needs rebase

@tristantarrant tristantarrant force-pushed the ISPN-8670/standalone_cache_admin branch 2 times, most recently from 12d0dfd to 7dca1d1 Compare January 15, 2018 20:36
@tristantarrant
Copy link
Member Author

Failures are unrelated

- add an enum-based ConfigurationStorage type for cleaner API/XML configuration
- rename the EmbeddedLocalConfigurationStorage to OverlayLocalConfigurationStorage (as it can be used for servers too)
- add a VolatileLocalConfigurationStorage
Copy link
Contributor

@ryanemerson ryanemerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, just a few minor remarks.

public class StandaloneServerLocalConfigurationStorage implements ServerLocalConfigurationStorage {
private static final String[] CACHE_MODES = {"local-cache", "invalidation-cache", "replicated-cache", "distributed-cache", "scattered-cache"};
private ModelControllerClient modelControllerClient;
PathAddress rootPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be private

private static final String[] CACHE_MODES = {"local-cache", "invalidation-cache", "replicated-cache", "distributed-cache", "scattered-cache"};
private ModelControllerClient modelControllerClient;
PathAddress rootPath;
private EmbeddedCacheManager embeddedCacheManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never used

}
// Nothing found
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we prevent caches/templates of different types having the same name? If not then this method will always retrieve the first template encountered based upon the CACHE_MODES order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should prevent it (that's the behaviour in embedded anyway), but this is not the PR to do it

String cacheMode = findCacheMode(name, false);

if (cacheMode == null) {
throw new CacheConfigurationException("No such cache");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"No Such ..." doesn't sound right to me (although I think we have similar messages elsewhere), "Cache '%s' does not exist", name is more informative and clear IMO. The same also applies in createCache(..).

this.globalConfiguration = cacheManager.getCacheManagerConfiguration();
this.cacheManager = cacheManager;
this.parserRegistry = new ParserRegistry();
public OverlayLocalConfigurationStorage() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant constructor

protected GlobalConfiguration globalConfiguration;

public VolatileLocalConfigurationStorage() {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant constructor

private ConcurrentHashSet<String> persistentCaches = new ConcurrentHashSet<>();

public OverlayLocalConfigurationStorage() {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant constructor

globalStateBuilder.setConfigurationStorageClass(StandaloneServerLocalConfigurationStorage.class.getName());
break;
case DOMAIN_SERVER:
// TODO: warn that we won't be persisting the changes to the server model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is sufficient

@tristantarrant
Copy link
Member Author

@ryanemerson I have addressed all issues. I have also converted the "throw new" to use i18n messages.

@tristantarrant
Copy link
Member Author

Failures unrelated

@ryanemerson ryanemerson merged commit 59cd718 into infinispan:master Jan 17, 2018
@ryanemerson
Copy link
Contributor

@tristantarrant Merged, thanks!

@tristantarrant tristantarrant deleted the ISPN-8670/standalone_cache_admin branch January 21, 2020 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants