use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method getClientConfigWithNearCacheInvalidationEnabled.
private ClientConfig getClientConfigWithNearCacheInvalidationEnabled() {
ClientConfig config = new ClientConfig();
NearCacheConfig nnc = new NearCacheConfig();
nnc.setInvalidateOnChange(true);
nnc.setInMemoryFormat(InMemoryFormat.OBJECT);
config.addNearCacheConfig(nnc);
return config;
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testNearCacheInvalidation_withClear.
@Test
public void testNearCacheInvalidation_withClear() {
hazelcastFactory.newHazelcastInstance();
ClientConfig config = getClientConfigWithNearCacheInvalidationEnabled();
HazelcastInstance client1 = hazelcastFactory.newHazelcastClient(config);
HazelcastInstance client2 = hazelcastFactory.newHazelcastClient(config);
String mapName = randomString();
final ReplicatedMap<Integer, Integer> replicatedMap1 = client1.getReplicatedMap(mapName);
replicatedMap1.put(1, 1);
// puts key 1 to Near Cache
replicatedMap1.get(1);
ReplicatedMap replicatedMap2 = client2.getReplicatedMap(mapName);
// this should invalidate Near Cache of replicatedMap1
replicatedMap2.clear();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(null, replicatedMap1.get(1));
}
});
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testNearCacheInvalidation.
@Test
public void testNearCacheInvalidation() {
String mapName = randomString();
ClientConfig config = getClientConfigWithNearCacheInvalidationEnabled();
hazelcastFactory.newHazelcastInstance();
HazelcastInstance client1 = hazelcastFactory.newHazelcastClient(config);
HazelcastInstance client2 = hazelcastFactory.newHazelcastClient(config);
final ReplicatedMap<Integer, Integer> replicatedMap1 = client1.getReplicatedMap(mapName);
replicatedMap1.put(1, 1);
// puts key 1 to Near Cache
replicatedMap1.get(1);
ReplicatedMap<Integer, Integer> replicatedMap2 = client2.getReplicatedMap(mapName);
// this should invalidate Near Cache of replicatedMap1
replicatedMap2.put(1, 2);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(2, (int) replicatedMap1.get(1));
}
});
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testClientPortableWithoutRegisteringToNode.
@Test
public void testClientPortableWithoutRegisteringToNode() {
hazelcastFactory.newHazelcastInstance(buildConfig(InMemoryFormat.BINARY, 0));
SerializationConfig serializationConfig = new SerializationConfig();
serializationConfig.addPortableFactory(5, new PortableFactory() {
public Portable create(int classId) {
return new SamplePortable();
}
});
ClientConfig clientConfig = new ClientConfig();
clientConfig.setSerializationConfig(serializationConfig);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
ReplicatedMap<Integer, SamplePortable> sampleMap = client.getReplicatedMap(randomString());
sampleMap.put(1, new SamplePortable(666));
SamplePortable samplePortable = sampleMap.get(1);
assertEquals(666, samplePortable.a);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class QuorumTestUtil method getClientConfig.
public static ClientConfig getClientConfig(HazelcastInstance instance) {
ClientConfig clientConfig = new ClientConfig();
Address address = getNode(instance).address;
clientConfig.getNetworkConfig().addAddress(address.getHost() + ":" + address.getPort());
clientConfig.getGroupConfig().setName(instance.getConfig().getGroupConfig().getName());
return clientConfig;
}
Aggregations