Search in sources :

Example 6 with ClientContext

use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.

the class ClientQueryCacheMemoryLeakTest method assertNoUserListenerLeft.

private static void assertNoUserListenerLeft(String mapName, HazelcastInstance client) {
    ProxyManager proxyManager = ((HazelcastClientProxy) client).client.getProxyManager();
    ClientContext context = proxyManager.getContext();
    ClientQueryCacheContext queryCacheContext = context.getQueryCacheContext();
    SubscriberContext subscriberContext = queryCacheContext.getSubscriberContext();
    QueryCacheEventService eventService = subscriberContext.getEventService();
    assertFalse(hasAnyListenerRegistered(eventService, mapName));
}
Also used : SubscriberContext(com.hazelcast.map.impl.querycache.subscriber.SubscriberContext) QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) ClientQueryCacheEventService(com.hazelcast.client.map.impl.querycache.subscriber.ClientQueryCacheEventService) ClientContext(com.hazelcast.client.impl.spi.ClientContext) ProxyManager(com.hazelcast.client.impl.spi.ProxyManager)

Example 7 with ClientContext

use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.

the class ClientMapInvalidationMetaDataFetcherTest method getRepairingTask.

private RepairingTask getRepairingTask(String mapName, int partition, long givenSequence, UUID givenUuid) {
    Config config = getBaseConfig();
    HazelcastInstance member = factory.newHazelcastInstance(config);
    distortRandomPartitionSequence(mapName, partition, givenSequence, member);
    distortRandomPartitionUuid(partition, givenUuid, member);
    ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(new NearCacheConfig(mapName));
    HazelcastInstance client = factory.newHazelcastClient(clientConfig);
    IMap<Integer, Integer> clientMap = client.getMap(mapName);
    ClientContext clientContext = ((ClientProxy) clientMap).getContext();
    return clientContext.getRepairingTask(SERVICE_NAME);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) ClientContext(com.hazelcast.client.impl.spi.ClientContext) ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 8 with ClientContext

use of com.hazelcast.client.impl.spi.ClientContext in project hazelcast by hazelcast.

the class ClientStatisticsService method addNearCacheStats.

private void addNearCacheStats(final StringBuilder stats) {
    ProxyManager proxyManager = client.getProxyManager();
    ClientContext context = proxyManager.getContext();
    if (context == null) {
        return;
    }
    context.getNearCacheManagers().values().stream().flatMap(nearCacheManager -> nearCacheManager.listAllNearCaches().stream()).forEach(nearCache -> {
        String nearCacheName = nearCache.getName();
        StringBuilder nearCacheNameWithPrefix = getNameWithPrefix(nearCacheName);
        nearCacheNameWithPrefix.append('.');
        NearCacheStatsImpl nearCacheStats = (NearCacheStatsImpl) nearCache.getNearCacheStats();
        String prefix = nearCacheNameWithPrefix.toString();
        addStat(stats, prefix, "creationTime", nearCacheStats.getCreationTime());
        addStat(stats, prefix, "evictions", nearCacheStats.getEvictions());
        addStat(stats, prefix, "hits", nearCacheStats.getHits());
        addStat(stats, prefix, "lastPersistenceDuration", nearCacheStats.getLastPersistenceDuration());
        addStat(stats, prefix, "lastPersistenceKeyCount", nearCacheStats.getLastPersistenceKeyCount());
        addStat(stats, prefix, "lastPersistenceTime", nearCacheStats.getLastPersistenceTime());
        addStat(stats, prefix, "lastPersistenceWrittenBytes", nearCacheStats.getLastPersistenceWrittenBytes());
        addStat(stats, prefix, "misses", nearCacheStats.getMisses());
        addStat(stats, prefix, "ownedEntryCount", nearCacheStats.getOwnedEntryCount());
        addStat(stats, prefix, "expirations", nearCacheStats.getExpirations());
        addStat(stats, prefix, "invalidations", nearCacheStats.getInvalidations());
        addStat(stats, prefix, "invalidationRequests", nearCacheStats.getInvalidationRequests());
        addStat(stats, prefix, "ownedEntryMemoryCost", nearCacheStats.getOwnedEntryMemoryCost());
        String persistenceFailure = nearCacheStats.getLastPersistenceFailure();
        if (persistenceFailure != null && !persistenceFailure.isEmpty()) {
            addStat(stats, prefix, "lastPersistenceFailure", persistenceFailure);
        }
    });
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientStatisticsCodec(com.hazelcast.client.impl.protocol.codec.ClientStatisticsCodec) MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) MetricsCompressor(com.hazelcast.internal.metrics.impl.MetricsCompressor) ConnectionType(com.hazelcast.internal.nio.ConnectionType) BuildInfoProvider(com.hazelcast.instance.BuildInfoProvider) ArrayList(java.util.ArrayList) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) JmxPublisher(com.hazelcast.internal.metrics.jmx.JmxPublisher) ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) ILogger(com.hazelcast.logging.ILogger) ClientContext(com.hazelcast.client.impl.spi.ClientContext) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) Logger(com.hazelcast.logging.Logger) TcpClientConnection(com.hazelcast.client.impl.connection.tcp.TcpClientConnection) NearCacheStatsImpl(com.hazelcast.internal.monitor.impl.NearCacheStatsImpl) MetricsCollector(com.hazelcast.internal.metrics.collectors.MetricsCollector) CompositeMetricsCollector(com.hazelcast.internal.metrics.impl.CompositeMetricsCollector) TcpClientConnectionManager(com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager) Credentials(com.hazelcast.security.Credentials) List(java.util.List) Gauge(com.hazelcast.internal.metrics.Gauge) PublisherMetricsCollector(com.hazelcast.internal.metrics.impl.PublisherMetricsCollector) ProxyManager(com.hazelcast.client.impl.spi.ProxyManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) NearCacheStatsImpl(com.hazelcast.internal.monitor.impl.NearCacheStatsImpl) ClientContext(com.hazelcast.client.impl.spi.ClientContext) ProxyManager(com.hazelcast.client.impl.spi.ProxyManager)

Aggregations

ClientContext (com.hazelcast.client.impl.spi.ClientContext)8 ClientConfig (com.hazelcast.client.config.ClientConfig)4 ClientProxy (com.hazelcast.client.impl.spi.ClientProxy)4 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)3 ProxyManager (com.hazelcast.client.impl.spi.ProxyManager)3 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)2 NearCacheConfig (com.hazelcast.config.NearCacheConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)2 NearCacheStatsImpl (com.hazelcast.internal.monitor.impl.NearCacheStatsImpl)2 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)2 RepairingTask (com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask)2 Data (com.hazelcast.internal.serialization.Data)2 CachingProvider (javax.cache.spi.CachingProvider)2 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)1 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)1 ClientConnectionStrategyConfig (com.hazelcast.client.config.ClientConnectionStrategyConfig)1 ClientMetricsConfig (com.hazelcast.client.config.ClientMetricsConfig)1 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1 TcpClientConnection (com.hazelcast.client.impl.connection.tcp.TcpClientConnection)1