use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithRealNetworkTest method testClientPortConnection.
@Test
public void testClientPortConnection() {
final Config config1 = new Config();
config1.getGroupConfig().setName("foo");
config1.getNetworkConfig().setPort(5701);
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config1);
instance1.getMap("map").put("key", "value");
final Config config2 = new Config();
config2.getGroupConfig().setName("bar");
config2.getNetworkConfig().setPort(5702);
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config2);
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getGroupConfig().setName("bar");
final HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
final IMap<Object, Object> map = client.getMap("map");
assertNull(map.put("key", "value"));
assertEquals(1, map.size());
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientServiceTest method testNumberOfClients_afterUnAuthenticatedClient_withTwoNode.
@Test(timeout = 120000)
public void testNumberOfClients_afterUnAuthenticatedClient_withTwoNode() {
final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getGroupConfig().setPassword("wrongPassword");
try {
hazelcastFactory.newHazelcastClient(clientConfig);
} catch (IllegalStateException ignored) {
}
assertEquals(0, instance1.getClientService().getConnectedClients().size());
assertEquals(0, instance2.getClientService().getConnectedClients().size());
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientMaxAllowedInvocationTest method testMaxAllowed_withUnfinishedCallback.
@Test(expected = HazelcastOverloadException.class)
public void testMaxAllowed_withUnfinishedCallback() throws ExecutionException, InterruptedException {
int MAX_ALLOWED = 10;
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProperty(ClientProperty.MAX_CONCURRENT_INVOCATIONS.getName(), String.valueOf(MAX_ALLOWED));
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
String name = randomString();
IMap map = client.getMap(name);
IExecutorService executorService = client.getExecutorService(randomString());
for (int i = 0; i < MAX_ALLOWED - 1; i++) {
executorService.submit(new SleepyProcessor(Integer.MAX_VALUE));
}
ClientDelegatingFuture future = (ClientDelegatingFuture) executorService.submit(new SleepyProcessor(2000));
CountDownLatch countDownLatch = new CountDownLatch(1);
future.andThenInternal(new SleepyCallback(countDownLatch), false);
future.get();
try {
map.get(1);
} catch (HazelcastOverloadException e) {
throw e;
} finally {
countDownLatch.countDown();
}
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientMaxAllowedInvocationTest method testMaxAllowed_withSyncOperation.
@Test(expected = HazelcastOverloadException.class)
public void testMaxAllowed_withSyncOperation() {
int MAX_ALLOWED = 10;
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProperty(ClientProperty.MAX_CONCURRENT_INVOCATIONS.getName(), String.valueOf(MAX_ALLOWED));
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IMap map = client.getMap(randomString());
IExecutorService executorService = client.getExecutorService(randomString());
for (int i = 0; i < MAX_ALLOWED; i++) {
executorService.submit(new SleepyProcessor(Integer.MAX_VALUE));
}
map.get(2);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientNearCacheConfigTest method testSpecificNearCacheConfig_whenAsteriskAtTheEnd.
@Test
public void testSpecificNearCacheConfig_whenAsteriskAtTheEnd() {
final ClientConfig clientConfig = new ClientConfig();
final NearCacheConfig genericNearCacheConfig = new NearCacheConfig();
genericNearCacheConfig.setName("map*");
clientConfig.addNearCacheConfig(genericNearCacheConfig);
final NearCacheConfig specificNearCacheConfig = new NearCacheConfig();
specificNearCacheConfig.setName("mapStudent*");
clientConfig.addNearCacheConfig(specificNearCacheConfig);
final NearCacheConfig mapFoo = clientConfig.getNearCacheConfig("mapFoo");
final NearCacheConfig mapStudentFoo = clientConfig.getNearCacheConfig("mapStudentFoo");
assertEquals(genericNearCacheConfig, mapFoo);
assertEquals(specificNearCacheConfig, mapStudentFoo);
}
Aggregations