private void registerMetrics(PooledByteBufAllocator allocator) { PooledByteBufAllocatorMetric pooledAllocatorMetric = allocator.metric(); // Register general metrics. allMetrics.put(MetricRegistry.name(metricPrefix, "usedHeapMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedHeapMemory()); allMetrics.put(MetricRegistry.name(metricPrefix, "usedDirectMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedDirectMemory()); if (verboseMetricsEnabled) { int directArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.directArenas()) { registerArenaMetric(metric, "directArena" + directArenaIndex); directArenaIndex++; } int heapArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.heapArenas()) { registerArenaMetric(metric, "heapArena" + heapArenaIndex); heapArenaIndex++; } } }
public NettyMemoryMetrics(PooledByteBufAllocator pooledAllocator, String metricPrefix, TransportConf conf) { this.pooledAllocator = pooledAllocator; this.allMetrics = new HashMap<>(); this.metricPrefix = metricPrefix; this.verboseMetricsEnabled = conf.verboseMetrics(); registerMetrics(this.pooledAllocator); }
.childOption(ChannelOption.ALLOCATOR, allocator); this.metrics = new NettyMemoryMetrics( allocator, conf.getModuleName() + "-server", conf);
.childOption(ChannelOption.ALLOCATOR, allocator); this.metrics = new NettyMemoryMetrics( allocator, conf.getModuleName() + "-server", conf);
public TransportClientFactory( TransportContext context, List<TransportClientBootstrap> clientBootstraps) { this.context = Preconditions.checkNotNull(context); this.conf = context.getConf(); this.clientBootstraps = Lists.newArrayList(Preconditions.checkNotNull(clientBootstraps)); this.connectionPool = new ConcurrentHashMap<>(); this.numConnectionsPerPeer = conf.numConnectionsPerPeer(); this.rand = new Random(); IOMode ioMode = IOMode.valueOf(conf.ioMode()); this.socketChannelClass = NettyUtils.getClientChannelClass(ioMode); this.workerGroup = NettyUtils.createEventLoop( ioMode, conf.clientThreads(), conf.getModuleName() + "-client"); this.pooledAllocator = NettyUtils.createPooledByteBufAllocator( conf.preferDirectBufs(), false /* allowCache */, conf.clientThreads()); this.metrics = new NettyMemoryMetrics( this.pooledAllocator, conf.getModuleName() + "-client", conf); }
public NettyMemoryMetrics(PooledByteBufAllocator pooledAllocator, String metricPrefix, TransportConf conf) { this.pooledAllocator = pooledAllocator; this.allMetrics = new HashMap<>(); this.metricPrefix = metricPrefix; this.verboseMetricsEnabled = conf.verboseMetrics(); registerMetrics(this.pooledAllocator); }
private void registerMetrics(PooledByteBufAllocator allocator) { PooledByteBufAllocatorMetric pooledAllocatorMetric = allocator.metric(); // Register general metrics. allMetrics.put(MetricRegistry.name(metricPrefix, "usedHeapMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedHeapMemory()); allMetrics.put(MetricRegistry.name(metricPrefix, "usedDirectMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedDirectMemory()); if (verboseMetricsEnabled) { int directArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.directArenas()) { registerArenaMetric(metric, "directArena" + directArenaIndex); directArenaIndex++; } int heapArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.heapArenas()) { registerArenaMetric(metric, "heapArena" + heapArenaIndex); heapArenaIndex++; } } }
public TransportClientFactory( TransportContext context, List<TransportClientBootstrap> clientBootstraps) { this.context = Preconditions.checkNotNull(context); this.conf = context.getConf(); this.clientBootstraps = Lists.newArrayList(Preconditions.checkNotNull(clientBootstraps)); this.connectionPool = new ConcurrentHashMap<>(); this.numConnectionsPerPeer = conf.numConnectionsPerPeer(); this.rand = new Random(); IOMode ioMode = IOMode.valueOf(conf.ioMode()); this.socketChannelClass = NettyUtils.getClientChannelClass(ioMode); this.workerGroup = NettyUtils.createEventLoop( ioMode, conf.clientThreads(), conf.getModuleName() + "-client"); this.pooledAllocator = NettyUtils.createPooledByteBufAllocator( conf.preferDirectBufs(), false /* allowCache */, conf.clientThreads()); this.metrics = new NettyMemoryMetrics( this.pooledAllocator, conf.getModuleName() + "-client", conf); }