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

CachingProvider no longer resolves URI as instance name #15995

Merged

Conversation

@vbekiaris
Copy link
Contributor

vbekiaris commented Nov 13, 2019

Reasoning: in this config mode, URI is used both as namespace for the
cache manager and as a means to locate a running HZ instance. With
moby naming auto generating instance names in 4.0 (when not explicitly
set in configuration), the following snippet when executed from 2
processes will result in creation of two separate Cache instances which
is probably not what a user would expect:

System.setProperty("hazelcast.jcache.provider.type", "server");
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
CachingProvider provider = Caching.getCachingProvider();
Cache cache = provider.getCacheManager(new URI(hz.getName()), null)
  .createCache("test", new CacheConfig());
System.out.println(cache.get("a"));
cache.put("a", "b");

The ability to use an existing HazelcastInstance identified by instance
name is still available by using Properties via
CachingProvider#getCacheManager(URI, ClassLoader, Properties). This way
to integrate with existing hazelcast instances is unambiguous and
explicit.

Reasoning: in this config mode, URI is used both as namespace for the
cache manager and as a means to locate a running HZ instance. With
moby naming auto generating instance names in 4.0 (when not explicitly
set in configuration), the following snippet when executed from 2
processes will result in creation of two separate Cache instances which
is probably not what a user would expect:

System.setProperty("hazelcast.jcache.provider.type", "server");
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
CachingProvider provider = Caching.getCachingProvider();
Cache cache = provider.getCacheManager(new URI(hz.getName()), null)
  .createCache("test", new CacheConfig());
System.out.println(cache.get("a"));
cache.put("a", "b");

The ability to use an existing HazelcastInstance identified by instance
name is still available by using Properties via
CachingProvider#getCacheManager(URI, ClassLoader, Properties). This way
to integrate with existing hazelcast instances is unambiguous and
explicit.
@vbekiaris

This comment has been minimized.

Copy link
Contributor Author

vbekiaris commented Nov 13, 2019

run-lab-run

@vbekiaris vbekiaris marked this pull request as ready for review Nov 13, 2019
@vbekiaris vbekiaris requested a review from hazelcast/clients as a code owner Nov 13, 2019
@sancar
sancar approved these changes Nov 14, 2019
Copy link
Member

sancar left a comment

Ok for the client side changes.

@vbekiaris vbekiaris merged commit 9063ee2 into hazelcast:master Nov 15, 2019
1 check passed
1 check passed
default Test PASSed.
Details
@vbekiaris vbekiaris deleted the vbekiaris:fixes/4.0/remove-uri-as-instancename branch Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.