use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.
the class ClientCacheNearCacheLeakTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(CacheConfig<K, V> cacheConfig) {
ClientConfig clientConfig = getClientConfig();
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider provider = createClientCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
NearCacheManager nearCacheManager = ((ClientCacheProxy) clientCache).getContext().getNearCacheManager(clientCache.getServiceName());
String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
ClientContext clientContext = ((ClientProxy) clientCache).getContext();
RepairingTask repairingTask = clientContext.getRepairingTask(CacheService.SERVICE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new ICacheDataStructureAdapter<K, V>(clientCache)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setCacheManager(cacheManager).setRepairingTask(repairingTask);
}
use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.
the class ClientCacheInvalidationMetaDataFetcherTest method getRepairingTask.
@SuppressWarnings("unchecked")
private RepairingTask getRepairingTask(String cacheName, int partition, long givenSequence, UUID givenUuid) {
HazelcastInstance member = factory.newHazelcastInstance();
distortRandomPartitionSequence(getPrefixedName(cacheName), partition, givenSequence, member);
distortRandomPartitionUuid(partition, givenUuid, member);
ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(new NearCacheConfig(cacheName));
HazelcastClientProxy client = (HazelcastClientProxy) factory.newHazelcastClient(clientConfig);
CachingProvider clientCachingProvider = createClientCachingProvider(client);
Cache<Integer, Integer> clientCache = clientCachingProvider.getCacheManager().createCache(cacheName, newCacheConfig());
ClientContext clientContext = ((ClientProxy) clientCache).getContext();
return clientContext.getRepairingTask(SERVICE_NAME);
}
use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.
the class HazelcastClientInstanceImpl method start.
public void start() {
try {
lifecycleService.start();
startMetrics();
invocationService.start();
ClientContext clientContext = new ClientContext(this);
userCodeDeploymentService.start();
Collection<EventListener> configuredListeners = instantiateConfiguredListenerObjects();
clusterService.start(configuredListeners);
clientClusterViewListenerService.start();
connectionManager.start();
startHeartbeat();
startIcmpPing();
connectionManager.connectToCluster();
diagnostics.start();
// static loggers at beginning of file
diagnostics.register(new BuildInfoPlugin(loggingService.getLogger(BuildInfoPlugin.class)));
diagnostics.register(new ConfigPropertiesPlugin(loggingService.getLogger(ConfigPropertiesPlugin.class), properties));
diagnostics.register(new SystemPropertiesPlugin(loggingService.getLogger(SystemPropertiesPlugin.class)));
// periodic loggers
diagnostics.register(new MetricsPlugin(loggingService.getLogger(MetricsPlugin.class), metricsRegistry, properties));
diagnostics.register(new SystemLogPlugin(properties, connectionManager, this, loggingService.getLogger(SystemLogPlugin.class)));
diagnostics.register(new NetworkingImbalancePlugin(properties, connectionManager.getNetworking(), loggingService.getLogger(NetworkingImbalancePlugin.class)));
diagnostics.register(new EventQueuePlugin(loggingService.getLogger(EventQueuePlugin.class), listenerService.getEventExecutor(), properties));
metricsRegistry.provideMetrics(listenerService);
ClientConnectionStrategyConfig connectionStrategyConfig = config.getConnectionStrategyConfig();
boolean asyncStart = connectionStrategyConfig.isAsyncStart();
if (!asyncStart) {
waitForInitialMembershipEvents();
}
connectionManager.tryConnectToAllClusterMembers(!asyncStart);
listenerService.start();
proxyManager.init(config, clientContext);
invocationService.addBackupListener();
loadBalancer.init(getCluster(), config);
clientStatisticsService.start();
clientExtension.afterStart(this);
cpSubsystem.init(clientContext);
addClientConfigAddedListeners(configuredListeners);
sendStateToCluster();
} catch (Throwable e) {
try {
lifecycleService.terminate();
} catch (Throwable t) {
ignore(t);
}
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.
the class NearCacheMetricsProvider method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
descriptor.withPrefix(NEARCACHE_PREFIX);
ClientContext clientContext = proxyManager.getContext();
if (clientContext == null) {
return;
}
clientContext.getNearCacheManagers().values().stream().flatMap(nearCacheManager -> nearCacheManager.listAllNearCaches().stream()).forEach(nearCache -> {
String nearCacheName = nearCache.getName();
NearCacheStatsImpl nearCacheStats = (NearCacheStatsImpl) nearCache.getNearCacheStats();
context.collect(descriptor.copy().withDiscriminator(NEARCACHE_DISCRIMINATOR_NAME, nearCacheName), nearCacheStats);
});
}
use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.
the class ClientMapNearCacheLeakTest method createNearCacheContextBuilder.
private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
ClientConfig clientConfig = getClientConfig();
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
ClientContext clientContext = ((ClientProxy) clientMap).getContext();
RepairingTask repairingTask = clientContext.getRepairingTask(MapService.SERVICE_NAME);
return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setRepairingTask(repairingTask);
}
Aggregations