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

IGNITE-13809 Adds thin client support to ignite-spring-cache. #46

Closed
wants to merge 6 commits into from

Conversation

petrov-mg
Copy link
Contributor

No description provided.

@petrov-mg petrov-mg force-pushed the IGNITE-13809 branch 2 times, most recently from a028f7a to a1e3d2d Compare February 19, 2021 16:47
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
* <bean id="igniteClient" class="org.apache.ignite.IgniteClientSpringBean">
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a note that this option available only in AI 2.11 and later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* is not found among the configurations specified by this method, the default configuration with the requested
* name will be used.
*/
public IgniteClientSpringCacheManager setCacheConfigurations(ClientCacheConfiguration... cfgs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we use different approaches for thin and thick clients? Can we use one dynamic configuration and create new caches based on this configuration changing only the cache name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first I was stuck with ClientCacheConfiguration not implementing copy constructor as CacheConfiguration does.
Then I thought it would be quite useful to be able to provide a unique configuration for each cache, rather than one for all. I think it's not a problem to add dynamic configuration approach for IgniteClientSpringCacheManager but the current approach includes it. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unique configuration for each cache can be defined in Ignite node configuration.
The current approach doesn't include a dynamic cache configuration approach, you should always set cache configuration explicitly for each cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, I spoke too soon. It's not finished yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

return ccfgs == null ? Collections.emptyList() : ccfgs.values();
/** Gets dynamic Ignite cache configuration template. */
public ClientCacheConfiguration getDynamicCacheConfiguration() {
return dynamicCacheCfg == null ? null : dynamicCacheCfg.setName(null); // To avoid copying the dynamic cache configuration each time as we only change its name.
Copy link
Contributor

Choose a reason for hiding this comment

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

The line is too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}
public IgniteClientSpringCacheManager setDynamicCacheConfiguration(ClientCacheConfiguration dynamicCacheCfg) {
this.dynamicCacheCfg = dynamicCacheCfg;

return this;
}

/** {@inheritDoc} */
@Override protected SpringCache createCache(String name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this method can be invoked concurrently, but if it can, it's better to make it synchronized since there can be a race between name modification and cache creation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving it unsynchronized anyway is too dangerous. I did not think about that. Thank you. Done.

import static org.apache.ignite.configuration.ClientConnectorConfiguration.DFLT_PORT;

/** Tests Spring Cache manager implementation that uses thin client to connect to the Ignite cluster. */
public class IgniteClientSpringCacheManagerTest extends GridSpringCacheManagerAbstractTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add this test to IgniteSpringCacheTestSuite

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@asfgit asfgit closed this in d9559d4 Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants