use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientNearCacheTestSupport method createNearCacheTest.
protected NearCacheTestContext createNearCacheTest(String cacheName, NearCacheConfig nearCacheConfig, CacheConfig cacheConfig) {
ClientConfig clientConfig = createClientConfig();
clientConfig.addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
//noinspection unchecked
ICache<Object, String> cache = cacheManager.createCache(cacheName, cacheConfig);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(cacheName));
return new NearCacheTestContext(client, cacheManager, nearCacheManager, cache, nearCache);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientExecutorServiceCancelTest method createClient.
private HazelcastInstance createClient(boolean smartRouting) {
ClientConfig config = new ClientConfig();
config.getNetworkConfig().setSmartRouting(smartRouting);
return hazelcastFactory.newHazelcastClient(config);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientDurableExecutionDelayTest method runClient.
private void runClient(Task task, int executions) throws Exception {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setRedoOperation(true);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
DurableExecutorService executor = client.getDurableExecutorService("executor");
for (int i = 0; i < executions; i++) {
Future future = executor.submitToKeyOwner(task, i);
future.get();
Thread.sleep(100);
}
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientHeartbeatTest method testAuthentication_whenHeartbeatResumed.
@Test
public void testAuthentication_whenHeartbeatResumed() throws Exception {
HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
ClientConfig config = new ClientConfig();
config.setProperty(ClientProperty.SHUFFLE_MEMBER_LIST.getName(), "false");
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(config);
HazelcastClientInstanceImpl hazelcastClientInstanceImpl = getHazelcastClientInstanceImpl(client);
final ClusterListenerSupport clientClusterService = (ClusterListenerSupport) hazelcastClientInstanceImpl.getClientClusterService();
final CountDownLatch countDownLatch = new CountDownLatch(2);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
countDownLatch.countDown();
}
});
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
blockMessagesFromInstance(instance2, client);
final HazelcastInstance instance3 = hazelcastFactory.newHazelcastInstance();
hazelcastInstance.shutdown();
//wait for disconnect from instance1 since it is shutdown // CLIENT_DISCONNECTED event
//and wait for connect to from instance3 // CLIENT_CONNECTED event
assertOpenEventually(countDownLatch);
//verify and wait for authentication to 3 is complete
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
String uuid = instance3.getLocalEndpoint().getUuid();
assertEquals(uuid, getClientEngineImpl(instance3).getOwnerUuid(client.getLocalEndpoint().getUuid()));
assertEquals(uuid, getClientEngineImpl(instance2).getOwnerUuid(client.getLocalEndpoint().getUuid()));
assertEquals(uuid, clientClusterService.getPrincipal().getOwnerUuid());
assertEquals(instance3.getCluster().getLocalMember().getAddress(), clientClusterService.getOwnerConnectionAddress());
}
});
//unblock instance 2 for authentication response.
unblockMessagesFromInstance(instance2, client);
//late authentication response from instance2 should not be able to change state in both client and cluster
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
String uuid = instance3.getLocalEndpoint().getUuid();
assertEquals(uuid, getClientEngineImpl(instance3).getOwnerUuid(client.getLocalEndpoint().getUuid()));
assertEquals(uuid, getClientEngineImpl(instance2).getOwnerUuid(client.getLocalEndpoint().getUuid()));
assertEquals(uuid, clientClusterService.getPrincipal().getOwnerUuid());
assertEquals(instance3.getCluster().getLocalMember().getAddress(), clientClusterService.getOwnerConnectionAddress());
}
});
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientLoggerConfigurationTest method testLoggingWithConfiguration.
// Test with programmatic or system property configuration according to boolean parameter.
// the idea of the test is to configure a specific logging type for a client and then
// test its LoggingService produce instances of the expected Logger impl
protected void testLoggingWithConfiguration(boolean programmaticConfiguration) throws IOException {
hazelcastFactory = new TestHazelcastFactory();
Config cg = new Config();
cg.setProperty("hazelcast.logging.type", "jdk");
hazelcastFactory.newHazelcastInstance(cg);
ClientConfig config = new ClientConfig();
if (programmaticConfiguration) {
config.setProperty("hazelcast.logging.type", "log4j2");
} else {
System.setProperty("hazelcast.logging.type", "log4j2");
}
client = hazelcastFactory.newHazelcastClient(config);
ILogger clientLogger = client.getLoggingService().getLogger("loggerName");
// this part is fragile.
// client wraps the actual logger in its own class
ILogger actualLogger = (ILogger) getFromField(clientLogger, "logger");
Class<?> clientLoggerClass = actualLogger.getClass();
ILogger expectedLogger = new Log4j2Factory().getLogger("expectedLogger");
Class<?> expectedLoggerClass = expectedLogger.getClass();
assertSame(expectedLoggerClass, clientLoggerClass);
}
Aggregations