@Test public void getSinglePutMessageTopicSizeTotal() throws Exception { final StoreStatsService storeStatsService = new StoreStatsService(); int num = Runtime.getRuntime().availableProcessors() * 2; for (int j = 0; j < 100; j++) { final AtomicReference<AtomicLong> reference = new AtomicReference<>(null); final CountDownLatch latch = new CountDownLatch(num); final CyclicBarrier barrier = new CyclicBarrier(num); for (int i = 0; i < num; i++) { new Thread(new Runnable() { @Override public void run() { try { barrier.await(); AtomicLong atomicLong = storeStatsService.getSinglePutMessageTopicSizeTotal("test"); if (reference.compareAndSet(null, atomicLong)) { } else if (reference.get() != atomicLong) { throw new RuntimeException("Reference should be same!"); } } catch (InterruptedException | BrokenBarrierException e) { e.printStackTrace(); } finally { latch.countDown(); } } }).start(); } latch.await(); } }
public AtomicLong getSinglePutMessageTopicSizeTotal(String topic) { AtomicLong rs = putMessageTopicSizeTotal.get(topic); if (null == rs) { rs = new AtomicLong(0); AtomicLong previous = putMessageTopicSizeTotal.putIfAbsent(topic, rs); if (previous != null) { rs = previous; } } return rs; }
StoreStatsService extends ServiceThread { public AtomicLong getSinglePutMessageTopicSizeTotal(String topic) { AtomicLong rs = putMessageTopicSizeTotal.get(topic); if (null == rs) { rs = new AtomicLong(0); AtomicLong previous = putMessageTopicSizeTotal.putIfAbsent(topic, rs); if (previous != null) { rs = previous; } } return rs; } }
StoreStatsService extends ServiceThread { public AtomicLong getSinglePutMessageTopicSizeTotal(String topic) { AtomicLong rs = putMessageTopicSizeTotal.get(topic); if (null == rs) { rs = new AtomicLong(0); AtomicLong previous = putMessageTopicSizeTotal.putIfAbsent(topic, rs); if (previous != null) { rs = previous; } } return rs; } StoreStatsService(); }
StoreStatsService extends ServiceThread { public AtomicLong getSinglePutMessageTopicSizeTotal(String topic) { AtomicLong rs = putMessageTopicSizeTotal.get(topic); if (null == rs) { rs = new AtomicLong(0); AtomicLong previous = putMessageTopicSizeTotal.putIfAbsent(topic, rs); if (previous != null) { rs = previous; } } return rs; } StoreStatsService(); long getPutMessageEntireTimeMax(); void setPutMessageEntireTimeMax(long value); long getGetMessageEntireTimeMax(); void setGetMessageEntireTimeMax(long value); long getDispatchMaxBuffer(); void setDispatchMaxBuffer(long value); @Override String toString(); long getPutMessageTimesTotal(); long getPutMessageSizeTotal(); HashMap<String, String> getRuntimeInfo(); void run(); @Override String getServiceName(); AtomicLong getGetMessageTimesTotalFound(); AtomicLong getGetMessageTimesTotalMiss(); AtomicLong getGetMessageTransferedMsgCount(); AtomicLong getPutMessageFailedTimes(); AtomicLong getSinglePutMessageTopicSizeTotal(String topic); AtomicLong getSinglePutMessageTopicTimesTotal(String topic); Map<String, AtomicLong> getPutMessageTopicTimesTotal(); Map<String, AtomicLong> getPutMessageTopicSizeTotal(); }
StoreStatsService extends ServiceThread { public AtomicLong getSinglePutMessageTopicSizeTotal(String topic) { AtomicLong rs = putMessageTopicSizeTotal.get(topic); if (null == rs) { rs = new AtomicLong(0); AtomicLong previous = putMessageTopicSizeTotal.putIfAbsent(topic, rs); if (previous != null) { rs = previous; } } return rs; } StoreStatsService(); long getPutMessageEntireTimeMax(); void setPutMessageEntireTimeMax(long value); long getGetMessageEntireTimeMax(); void setGetMessageEntireTimeMax(long value); long getDispatchMaxBuffer(); void setDispatchMaxBuffer(long value); @Override String toString(); long getPutMessageTimesTotal(); long getPutMessageSizeTotal(); HashMap<String, String> getRuntimeInfo(); void run(); @Override String getServiceName(); AtomicLong getGetMessageTimesTotalFound(); AtomicLong getGetMessageTimesTotalMiss(); AtomicLong getGetMessageTransferedMsgCount(); AtomicLong getPutMessageFailedTimes(); AtomicLong getSinglePutMessageTopicSizeTotal(String topic); AtomicLong getSinglePutMessageTopicTimesTotal(String topic); Map<String, AtomicLong> getPutMessageTopicTimesTotal(); Map<String, AtomicLong> getPutMessageTopicSizeTotal();  }