Search in sources :

Example 1 with ProxyManager

use of com.hazelcast.client.impl.spi.ProxyManager 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 2 with ProxyManager

use of com.hazelcast.client.impl.spi.ProxyManager 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)2 ProxyManager (com.hazelcast.client.impl.spi.ProxyManager)2 ClientMetricsConfig (com.hazelcast.client.config.ClientMetricsConfig)1 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1 TcpClientConnection (com.hazelcast.client.impl.connection.tcp.TcpClientConnection)1 TcpClientConnectionManager (com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientStatisticsCodec (com.hazelcast.client.impl.protocol.codec.ClientStatisticsCodec)1 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)1 ClientQueryCacheEventService (com.hazelcast.client.map.impl.querycache.subscriber.ClientQueryCacheEventService)1 BuildInfoProvider (com.hazelcast.instance.BuildInfoProvider)1 Gauge (com.hazelcast.internal.metrics.Gauge)1 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)1 MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)1 MetricsCollector (com.hazelcast.internal.metrics.collectors.MetricsCollector)1 CompositeMetricsCollector (com.hazelcast.internal.metrics.impl.CompositeMetricsCollector)1 MetricsCompressor (com.hazelcast.internal.metrics.impl.MetricsCompressor)1 PublisherMetricsCollector (com.hazelcast.internal.metrics.impl.PublisherMetricsCollector)1 JmxPublisher (com.hazelcast.internal.metrics.jmx.JmxPublisher)1 NearCacheStatsImpl (com.hazelcast.internal.monitor.impl.NearCacheStatsImpl)1