Java Code Examples for com.yammer.metrics.Metrics#newMeter()
The following examples show how to use
com.yammer.metrics.Metrics#newMeter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HdfsDirectory.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
protected MetricsGroup createNewMetricsGroup(String scope) { MetricName readRandomAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Random Latency in \u00B5s", scope); MetricName readStreamAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Latency in \u00B5s", scope); MetricName writeAcccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Latency in \u00B5s", scope); MetricName readRandomThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Random Throughput", scope); MetricName readStreamThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Throughput", scope); MetricName readSeekName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Seeks", scope); MetricName writeThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Throughput", scope); MetricName totalHdfsBlocks = new MetricName(ORG_APACHE_BLUR, HDFS, "Hdfs Blocks Total", scope); MetricName localHdfsBlocks = new MetricName(ORG_APACHE_BLUR, HDFS, "Hdfs Blocks Local", scope); Histogram readRandomAccess = Metrics.newHistogram(readRandomAccessName); Histogram readStreamAccess = Metrics.newHistogram(readStreamAccessName); Histogram writeAccess = Metrics.newHistogram(writeAcccessName); Meter readRandomThroughput = Metrics.newMeter(readRandomThroughputName, "Read Random Bytes", TimeUnit.SECONDS); Meter readStreamThroughput = Metrics.newMeter(readStreamThroughputName, "Read Stream Bytes", TimeUnit.SECONDS); Meter readStreamSeek = Metrics.newMeter(readSeekName, "Read Stream Seeks", TimeUnit.SECONDS); Meter writeThroughput = Metrics.newMeter(writeThroughputName, "Write Bytes", TimeUnit.SECONDS); Counter totalHdfsBlock = Metrics.newCounter(totalHdfsBlocks); Counter localHdfsBlock = Metrics.newCounter(localHdfsBlocks); return new MetricsGroup(readRandomAccess, readStreamAccess, writeAccess, readRandomThroughput, readStreamThroughput, readStreamSeek, writeThroughput, totalHdfsBlock, localHdfsBlock); }
Example 2
Source File: DirectSolrClassicInputDocumentWriter.java From hbase-indexer with Apache License 2.0 | 6 votes |
public DirectSolrClassicInputDocumentWriter(String indexName, List<SolrClient> solrServers) { this.solrServers = solrServers; indexAddMeter = Metrics.newMeter(metricName(getClass(), "Index adds", indexName), "Documents added to Solr index", TimeUnit.SECONDS); indexDeleteMeter = Metrics.newMeter(metricName(getClass(), "Index deletes", indexName), "Documents deleted from Solr index", TimeUnit.SECONDS); solrAddErrorMeter = Metrics.newMeter(metricName(getClass(), "Solr add errors", indexName), "Documents not added to Solr due to Solr errors", TimeUnit.SECONDS); solrDeleteErrorMeter = Metrics.newMeter(metricName(getClass(), "Solr delete errors", indexName), "Documents not deleted from Solr due to Solr errors", TimeUnit.SECONDS); documentAddErrorMeter = Metrics.newMeter(metricName(getClass(), "Document add errors", indexName), "Documents not added to Solr due to document errors", TimeUnit.SECONDS); documentDeleteErrorMeter = Metrics.newMeter(metricName(getClass(), "Document delete errors", indexName), "Documents not deleted from Solr due to document errors", TimeUnit.SECONDS); }
Example 3
Source File: IncomingSmtpSummary.java From mireka with Apache License 2.0 | 6 votes |
@PostConstruct public void register() { mailTransactions = Metrics.newMeter(metricName("mailTransactions"), "transactions", TimeUnit.MINUTES); rcptCommands = Metrics.newMeter(metricName("rcptCommands"), "commands", TimeUnit.MINUTES); dataCommands = Metrics.newMeter(metricName("dataCommands"), "commands", TimeUnit.MINUTES); acceptedMessages = Metrics.newMeter(metricName("acceptedMessages"), "messages", TimeUnit.MINUTES); messageRecipients = Metrics.newMeter(metricName("messageRecipients"), "recipients", TimeUnit.MINUTES); }
Example 4
Source File: DirectSolrInputDocumentWriter.java From hbase-indexer with Apache License 2.0 | 6 votes |
public DirectSolrInputDocumentWriter(String indexName, SolrClient solrServer) { this.solrServer = solrServer; indexAddMeter = Metrics.newMeter(metricName(getClass(), "Index adds", indexName), "Documents added to Solr index", TimeUnit.SECONDS); indexDeleteMeter = Metrics.newMeter(metricName(getClass(), "Index deletes", indexName), "Documents deleted from Solr index", TimeUnit.SECONDS); solrAddErrorMeter = Metrics.newMeter(metricName(getClass(), "Solr add errors", indexName), "Documents not added to Solr due to Solr errors", TimeUnit.SECONDS); solrDeleteErrorMeter = Metrics.newMeter(metricName(getClass(), "Solr delete errors", indexName), "Documents not deleted from Solr due to Solr errors", TimeUnit.SECONDS); documentAddErrorMeter = Metrics.newMeter(metricName(getClass(), "Document add errors", indexName), "Documents not added to Solr due to document errors", TimeUnit.SECONDS); documentDeleteErrorMeter = Metrics.newMeter(metricName(getClass(), "Document delete errors", indexName), "Documents not deleted from Solr due to document errors", TimeUnit.SECONDS); }
Example 5
Source File: FileCacheMetrics.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public FileCacheMetrics() { hits = Metrics.newMeter(factory.createMetricName("Hits"), "hits", TimeUnit.SECONDS); requests = Metrics.newMeter(factory.createMetricName("Requests"), "requests", TimeUnit.SECONDS); hitRate = Metrics.newGauge(factory.createMetricName("HitRate"), new RatioGauge() { protected double getNumerator() { return hits.count(); } protected double getDenominator() { return requests.count(); } }); size = Metrics.newGauge(factory.createMetricName("Size"), new Gauge<Long>() { public Long value() { return FileCacheService.instance.sizeInBytes(); } }); }
Example 6
Source File: BufferStore.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
private BufferStore(int bufferSize, int count) { _bufferSize = bufferSize; _created = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, LUCENE, bufferSize + " " + SIZE_ALLOCATED, INTERNAL_BUFFERS), INTERNAL_BUFFERS, TimeUnit.SECONDS); _lost = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, LUCENE, bufferSize + " " + LOST, INTERNAL_BUFFERS), INTERNAL_BUFFERS, TimeUnit.SECONDS); _buffers = setupBuffers(bufferSize, count, _created); }
Example 7
Source File: ControllerServerEventHandler.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
public ControllerServerEventHandler() { Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, BLUR, "Connections"), new Gauge<Long>() { @Override public Long value() { return null; } }); _connectionMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Connections/s"), "Connections/s", TimeUnit.SECONDS); }
Example 8
Source File: IndexManager.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
public IndexManager(IndexServer indexServer, ClusterStatus clusterStatus, BlurFilterCache filterCache, int maxHeapPerRowFetch, int fetchCount, int threadCount, int mutateThreadCount, int facetThreadCount, DeepPagingCache deepPagingCache, MemoryAllocationWatcher memoryAllocationWatcher, QueryStatusManager statusManager) { _statusManager = statusManager; _memoryAllocationWatcher = memoryAllocationWatcher; _deepPagingCache = deepPagingCache; _indexServer = indexServer; _clusterStatus = clusterStatus; _filterCache = filterCache; MetricName metricName1 = new MetricName(ORG_APACHE_BLUR, BLUR, "External Queries/s"); MetricName metricName2 = new MetricName(ORG_APACHE_BLUR, BLUR, "Internal Queries/s"); MetricName metricName3 = new MetricName(ORG_APACHE_BLUR, BLUR, "Fetch Timer"); _queriesExternalMeter = Metrics.newMeter(metricName1, "External Queries/s", TimeUnit.SECONDS); _queriesInternalMeter = Metrics.newMeter(metricName2, "Internal Queries/s", TimeUnit.SECONDS); _fetchTimer = Metrics.newTimer(metricName3, TimeUnit.MICROSECONDS, TimeUnit.SECONDS); if (threadCount == 0) { throw new RuntimeException("Thread Count cannot be 0."); } _threadCount = threadCount; if (mutateThreadCount == 0) { throw new RuntimeException("Mutate Thread Count cannot be 0."); } _mutateThreadCount = mutateThreadCount; _fetchCount = fetchCount; _maxHeapPerRowFetch = maxHeapPerRowFetch; _executor = Executors.newThreadPool("index-manager", _threadCount); _mutateExecutor = Executors.newThreadPool("index-manager-mutate", _mutateThreadCount); if (facetThreadCount < 1) { _facetExecutor = null; } else { _facetExecutor = Executors.newThreadPool(new SynchronousQueue<Runnable>(), "facet-execution", facetThreadCount); } LOG.info("Init Complete"); }
Example 9
Source File: TransmitterSummary.java From mireka with Apache License 2.0 | 5 votes |
@PostConstruct public void register() { try { ObjectName objectName = new ObjectName("mireka:type=TransmitterTraffic,name=" + name); ManagementFactory.getPlatformMBeanServer().registerMBean(this, objectName); } catch (JMException e) { throw new RuntimeException(e); } mailTransactions = Metrics.newMeter(metricName("mailTransactions"), "transactions", TimeUnit.MINUTES); successfulMailTransactions = Metrics.newMeter(metricName("successfulMailTransactions"), "transactions", TimeUnit.MINUTES); failures = Metrics.newMeter(metricName("failures"), "transactions", TimeUnit.MINUTES); permanentFailures = Metrics.newMeter(metricName("permanentFailures"), "transactions", TimeUnit.MINUTES); transientFailures = Metrics.newMeter(metricName("transientFailures"), "transactions", TimeUnit.MINUTES); partialFailures = Metrics.newMeter(metricName("partialFailures"), "transactions", TimeUnit.MINUTES); errors = Metrics.newMeter(metricName("errors"), "transactions", TimeUnit.MINUTES); }
Example 10
Source File: ClientRequestMetrics.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public ClientRequestMetrics(String scope) { super("ClientRequest", scope); timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS); unavailables = Metrics.newMeter(factory.createMetricName("Unavailables"), "unavailables", TimeUnit.SECONDS); }
Example 11
Source File: IndexingEventListener.java From hbase-indexer with Apache License 2.0 | 5 votes |
/** * Instantiate with the underlying indexer, and the name of the table for which events are to be intercepted. * * @param indexer indexer engine that will create index documents from incoming event data * @param targetTableNameExpression name of the table for which updates are to be indexed * @param targetTableIsRegex flag to determine if the table name expression is a regular expression or not */ public IndexingEventListener(Indexer indexer, final String targetTableNameExpression, boolean targetTableIsRegex) { this.indexer = indexer; incomingEventsMeter = Metrics.newMeter(metricName(getClass(), "Incoming events", indexer.getName()), "Rate of incoming SEP events", TimeUnit.SECONDS); applicableEventsMeter = Metrics.newMeter(metricName(getClass(), "Applicable events", indexer.getName()), "Rate of incoming SEP events that are considered applicable", TimeUnit.SECONDS); if (targetTableIsRegex) { final Pattern tableNamePattern = Pattern.compile(targetTableNameExpression); tableEqualityPredicate = new Predicate<SepEvent>() { @Override public boolean apply(@Nullable SepEvent event) { return tableNamePattern.matcher(new String(event.getTable(), Charsets.UTF_8)).matches(); } }; } else { final byte[] tableNameBytes = Bytes.toBytes(targetTableNameExpression); tableEqualityPredicate = new Predicate<SepEvent>() { @Override public boolean apply(@Nullable SepEvent event) { return Bytes.equals(tableNameBytes, event.getTable()); } }; } }
Example 12
Source File: MeterPool.java From common-kafka with Apache License 2.0 | 5 votes |
/** * Returns the meter corresponding to the given scope. * * @param scope The scope of the meter to return. * * @return a {@link Meter} with the given scope. * * @throws IllegalArgumentException * if {@code scope} is {@code null}. */ public Meter getMeter(String scope) { if (scope == null) { throw new IllegalArgumentException("scope cannot be null"); } Meter meter = meters.get(scope); if (meter == null) { meter = Metrics.newMeter(clazz, name, scope, name, TimeUnit.SECONDS); Meter existing = meters.putIfAbsent(scope, meter); if (existing != null) { meter = existing; } } return meter; }
Example 13
Source File: CacheMetrics.java From stratio-cassandra with Apache License 2.0 | 4 votes |
/** * Create metrics for given cache. * * @param type Type of Cache to identify metrics. * @param cache Cache to measure metrics */ public CacheMetrics(String type, final ICache cache) { MetricNameFactory factory = new DefaultNameFactory("Cache", type); capacity = Metrics.newGauge(factory.createMetricName("Capacity"), new Gauge<Long>() { public Long value() { return cache.capacity(); } }); hits = Metrics.newMeter(factory.createMetricName("Hits"), "hits", TimeUnit.SECONDS); requests = Metrics.newMeter(factory.createMetricName("Requests"), "requests", TimeUnit.SECONDS); hitRate = Metrics.newGauge(factory.createMetricName("HitRate"), new RatioGauge() { protected double getNumerator() { return hits.count(); } protected double getDenominator() { return requests.count(); } }); size = Metrics.newGauge(factory.createMetricName("Size"), new Gauge<Long>() { public Long value() { return cache.weightedSize(); } }); entries = Metrics.newGauge(factory.createMetricName("Entries"), new Gauge<Integer>() { public Integer value() { return cache.size(); } }); }
Example 14
Source File: ConnectionMetrics.java From stratio-cassandra with Apache License 2.0 | 4 votes |
/** * Create metrics for given connection pool. * * @param ip IP address to use for metrics label * @param connectionPool Connection pool */ public ConnectionMetrics(InetAddress ip, final OutboundTcpConnectionPool connectionPool) { // ipv6 addresses will contain colons, which are invalid in a JMX ObjectName address = ip.getHostAddress().replace(':', '.'); factory = new DefaultNameFactory("Connection", address); commandPendingTasks = Metrics.newGauge(factory.createMetricName("CommandPendingTasks"), new Gauge<Integer>() { public Integer value() { return connectionPool.cmdCon.getPendingMessages(); } }); commandCompletedTasks = Metrics.newGauge(factory.createMetricName("CommandCompletedTasks"), new Gauge<Long>() { public Long value() { return connectionPool.cmdCon.getCompletedMesssages(); } }); commandDroppedTasks = Metrics.newGauge(factory.createMetricName("CommandDroppedTasks"), new Gauge<Long>() { public Long value() { return connectionPool.cmdCon.getDroppedMessages(); } }); responsePendingTasks = Metrics.newGauge(factory.createMetricName("ResponsePendingTasks"), new Gauge<Integer>() { public Integer value() { return connectionPool.ackCon.getPendingMessages(); } }); responseCompletedTasks = Metrics.newGauge(factory.createMetricName("ResponseCompletedTasks"), new Gauge<Long>() { public Long value() { return connectionPool.ackCon.getCompletedMesssages(); } }); timeouts = Metrics.newMeter(factory.createMetricName("Timeouts"), "timeouts", TimeUnit.SECONDS); }
Example 15
Source File: NioUdtByteRendezvousChannelTest.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
/** * verify basic echo byte rendezvous */ @Test(timeout = 10 * 1000) public void basicEcho() throws Exception { final int messageSize = 64 * 1024; final int transferLimit = messageSize * 16; final Meter rate1 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final Meter rate2 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final InetSocketAddress addr1 = UnitHelp.localSocketAddress(); final InetSocketAddress addr2 = UnitHelp.localSocketAddress(); final EchoByteHandler handler1 = new EchoByteHandler(rate1, messageSize); final EchoByteHandler handler2 = new EchoByteHandler(rate2, messageSize); final NioEventLoopGroup group1 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.BYTE_PROVIDER); final NioEventLoopGroup group2 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.BYTE_PROVIDER); final Bootstrap boot1 = new Bootstrap(); boot1.group(group1) .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS) .localAddress(addr1) .remoteAddress(addr2) .handler(handler1); final Bootstrap boot2 = new Bootstrap(); boot2.group(group1) .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS) .localAddress(addr2) .remoteAddress(addr1) .handler(handler2); final ChannelFuture connectFuture1 = boot1.connect(); final ChannelFuture connectFuture2 = boot2.connect(); while (handler1.meter().count() < transferLimit && handler2.meter().count() < transferLimit) { log.info("progress : {} {}", handler1.meter().count(), handler2 .meter().count()); Thread.sleep(1000); } connectFuture1.channel().close().sync(); connectFuture2.channel().close().sync(); log.info("handler1 : {}", handler1.meter().count()); log.info("handler2 : {}", handler2.meter().count()); assertTrue(handler1.meter().count() >= transferLimit); assertTrue(handler2.meter().count() >= transferLimit); assertEquals(handler1.meter().count(), handler2.meter().count()); group1.shutdownGracefully(); group2.shutdownGracefully(); group1.terminationFuture().sync(); group2.terminationFuture().sync(); }
Example 16
Source File: NioUdtMessageRendezvousChannelTest.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
/** * verify basic echo message rendezvous * * FIXME: Re-enable after making it pass on Windows without unncessary tight loop. * https://github.com/netty/netty/issues/2853 */ @Test(timeout = 10 * 1000) @Ignore public void basicEcho() throws Exception { final int messageSize = 64 * 1024; final int transferLimit = messageSize * 16; final Meter rate1 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final Meter rate2 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final InetSocketAddress addr1 = UnitHelp.localSocketAddress(); final InetSocketAddress addr2 = UnitHelp.localSocketAddress(); final EchoMessageHandler handler1 = new EchoMessageHandler(rate1, messageSize); final EchoMessageHandler handler2 = new EchoMessageHandler(rate2, messageSize); final NioEventLoopGroup group1 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER); final NioEventLoopGroup group2 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER); final Bootstrap boot1 = new Bootstrap(); boot1.group(group1) .channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS) .localAddress(addr1).remoteAddress(addr2).handler(handler1); final Bootstrap boot2 = new Bootstrap(); boot2.group(group2) .channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS) .localAddress(addr2).remoteAddress(addr1).handler(handler2); final ChannelFuture connectFuture1 = boot1.connect(); final ChannelFuture connectFuture2 = boot2.connect(); while (handler1.meter().count() < transferLimit && handler2.meter().count() < transferLimit) { log.info("progress : {} {}", handler1.meter().count(), handler2 .meter().count()); Thread.sleep(1000); } connectFuture1.channel().close().sync(); connectFuture2.channel().close().sync(); log.info("handler1 : {}", handler1.meter().count()); log.info("handler2 : {}", handler2.meter().count()); assertTrue(handler1.meter().count() >= transferLimit); assertTrue(handler2.meter().count() >= transferLimit); assertEquals(handler1.meter().count(), handler2.meter().count()); group1.shutdownGracefully(); group2.shutdownGracefully(); group1.terminationFuture().sync(); group2.terminationFuture().sync(); }
Example 17
Source File: BlockCache.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public BlockCache(boolean directAllocation, long totalMemory, int slabSize) { _numberOfBlocksPerSlab = slabSize / _blockSize; _numberOfSlabs = (int) (totalMemory / slabSize); _directAllocation = directAllocation; _slabs = new ByteBuffer[_numberOfSlabs]; _locks = new BlockLocks[_numberOfSlabs]; _lockCounters = new AtomicInteger[_numberOfSlabs]; _maxEntries = (_numberOfBlocksPerSlab * _numberOfSlabs) - 1; for (int i = 0; i < _numberOfSlabs; i++) { if (!lazy) { if (_directAllocation) { _slabs[i] = ByteBuffer.allocateDirect(_numberOfBlocksPerSlab * _blockSize); } else { _slabs[i] = ByteBuffer.allocate(_numberOfBlocksPerSlab * _blockSize); } } _locks[i] = new BlockLocks(_numberOfBlocksPerSlab); _lockCounters[i] = new AtomicInteger(); } evictions = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE, EVICTION), EVICTION, TimeUnit.SECONDS); Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, CACHE, ENTRIES), new Gauge<Long>() { @Override public Long value() { return (long) getSize(); } }); Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, CACHE, SIZE), new Gauge<Long>() { @Override public Long value() { return ((long) getSize()) * (long) _8K; } }); EvictionListener<BlockCacheKey, BlockCacheLocation> listener = new EvictionListener<BlockCacheKey, BlockCacheLocation>() { @Override public void onEviction(BlockCacheKey key, BlockCacheLocation location) { releaseLocation(location); evictions.mark(); } }; _cache = new ConcurrentLinkedHashMap.Builder<BlockCacheKey, BlockCacheLocation>() .maximumWeightedCapacity(_maxEntries).listener(listener).build(); }
Example 18
Source File: NioUdtByteRendezvousChannelTest.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
/** * verify basic echo byte rendezvous */ @Test(timeout = 10 * 1000) public void basicEcho() throws Exception { final int messageSize = 64 * 1024; final int transferLimit = messageSize * 16; final Meter rate1 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final Meter rate2 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final InetSocketAddress addr1 = UnitHelp.localSocketAddress(); final InetSocketAddress addr2 = UnitHelp.localSocketAddress(); final EchoByteHandler handler1 = new EchoByteHandler(rate1, messageSize); final EchoByteHandler handler2 = new EchoByteHandler(rate2, messageSize); final NioEventLoopGroup group1 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.BYTE_PROVIDER); final NioEventLoopGroup group2 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.BYTE_PROVIDER); final Bootstrap boot1 = new Bootstrap(); boot1.group(group1) .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS) .localAddress(addr1) .remoteAddress(addr2) .handler(handler1); final Bootstrap boot2 = new Bootstrap(); boot2.group(group1) .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS) .localAddress(addr2) .remoteAddress(addr1) .handler(handler2); final ChannelFuture connectFuture1 = boot1.connect(); final ChannelFuture connectFuture2 = boot2.connect(); while (handler1.meter().count() < transferLimit && handler2.meter().count() < transferLimit) { log.info("progress : {} {}", handler1.meter().count(), handler2 .meter().count()); Thread.sleep(1000); } connectFuture1.channel().close().sync(); connectFuture2.channel().close().sync(); log.info("handler1 : {}", handler1.meter().count()); log.info("handler2 : {}", handler2.meter().count()); assertTrue(handler1.meter().count() >= transferLimit); assertTrue(handler2.meter().count() >= transferLimit); assertEquals(handler1.meter().count(), handler2.meter().count()); group1.shutdownGracefully(); group2.shutdownGracefully(); group1.terminationFuture().sync(); group2.terminationFuture().sync(); }
Example 19
Source File: BaseCacheValueBufferPool.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public BaseCacheValueBufferPool(STORE store) { _store = store; _created = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, CREATED), CREATED, TimeUnit.SECONDS); _reused = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, REUSED), REUSED, TimeUnit.SECONDS); _detroyed = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, DESTROYED), DESTROYED, TimeUnit.SECONDS); }
Example 20
Source File: NioUdtMessageRendezvousChannelTest.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
/** * verify basic echo message rendezvous * * FIXME: Re-enable after making it pass on Windows without unncessary tight loop. * https://github.com/netty/netty/issues/2853 */ @Test(timeout = 10 * 1000) @Ignore public void basicEcho() throws Exception { final int messageSize = 64 * 1024; final int transferLimit = messageSize * 16; final Meter rate1 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final Meter rate2 = Metrics.newMeter( NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes", TimeUnit.SECONDS); final InetSocketAddress addr1 = UnitHelp.localSocketAddress(); final InetSocketAddress addr2 = UnitHelp.localSocketAddress(); final EchoMessageHandler handler1 = new EchoMessageHandler(rate1, messageSize); final EchoMessageHandler handler2 = new EchoMessageHandler(rate2, messageSize); final NioEventLoopGroup group1 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER); final NioEventLoopGroup group2 = new NioEventLoopGroup( 1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER); final Bootstrap boot1 = new Bootstrap(); boot1.group(group1) .channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS) .localAddress(addr1).remoteAddress(addr2).handler(handler1); final Bootstrap boot2 = new Bootstrap(); boot2.group(group2) .channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS) .localAddress(addr2).remoteAddress(addr1).handler(handler2); final ChannelFuture connectFuture1 = boot1.connect(); final ChannelFuture connectFuture2 = boot2.connect(); while (handler1.meter().count() < transferLimit && handler2.meter().count() < transferLimit) { log.info("progress : {} {}", handler1.meter().count(), handler2 .meter().count()); Thread.sleep(1000); } connectFuture1.channel().close().sync(); connectFuture2.channel().close().sync(); log.info("handler1 : {}", handler1.meter().count()); log.info("handler2 : {}", handler2.meter().count()); assertTrue(handler1.meter().count() >= transferLimit); assertTrue(handler2.meter().count() >= transferLimit); assertEquals(handler1.meter().count(), handler2.meter().count()); group1.shutdownGracefully(); group2.shutdownGracefully(); group1.terminationFuture().sync(); group2.terminationFuture().sync(); }