public int streamCount() { return refCountByStreamIdMap.size() + refCountByStreamIdAndSessionIdMap.size(); }
public long decRefToStreamAndSession(final int streamId, final int sessionId) { final long key = Hashing.compoundKey(streamId, sessionId); final long count = refCountByStreamIdAndSessionIdMap.decrementAndGet(key); if (-1 == count) { refCountByStreamIdAndSessionIdMap.remove(key); throw new IllegalStateException( "could not find stream Id + session Id to decrement: " + streamId + " " + sessionId); } return count; }
public long incRefToStreamAndSession(final int streamId, final int sessionId) { return refCountByStreamIdAndSessionIdMap.incrementAndGet(Hashing.compoundKey(streamId, sessionId)); }
/** * Compact the backing arrays by rehashing with a capacity just larger than current size * and giving consideration to the load factor. */ public void compact() { @DoNotSub final int idealCapacity = (int)Math.round(size() * (1.0d / loadFactor)); rehash(findNextPositivePowerOfTwo(Math.max(MIN_CAPACITY, idealCapacity))); }
public boolean shouldBeClosed() { return refCountByStreamIdMap.isEmpty() && refCountByStreamIdAndSessionIdMap.isEmpty() && !statusIndicator.isClosed(); }
private final AtomicCounter statusIndicator; private final Int2IntCounterMap refCountByStreamIdMap = new Int2IntCounterMap(0); private final Long2LongCounterMap refCountByStreamIdAndSessionIdMap = new Long2LongCounterMap(0); private final MultiRcvDestination multiRcvDestination;
/** * Convenience version of {@link #addAndGet(long, long)} (key, 1). * * @param key for the counter. * @return the new value. */ public long incrementAndGet(final long key) { return addAndGet(key, 1); }
public boolean shouldBeClosed() { return refCountByStreamIdMap.isEmpty() && refCountByStreamIdAndSessionIdMap.isEmpty() && !statusIndicator.isClosed(); }
private final AtomicCounter statusIndicator; private final Int2IntCounterMap refCountByStreamIdMap = new Int2IntCounterMap(0); private final Long2LongCounterMap refCountByStreamIdAndSessionIdMap = new Long2LongCounterMap(0); private final MultiRcvDestination multiRcvDestination;
/** * Convenience version of {@link #addAndGet(long, long)} (key, -1). * * @param key for the counter. * @return the new value. */ public long decrementAndGet(final long key) { return addAndGet(key, -1); }
public long decRefToStreamAndSession(final int streamId, final int sessionId) { final long key = Hashing.compoundKey(streamId, sessionId); final long count = refCountByStreamIdAndSessionIdMap.decrementAndGet(key); if (-1 == count) { refCountByStreamIdAndSessionIdMap.remove(key); throw new IllegalStateException( "could not find stream Id + session Id to decrement: " + streamId + " " + sessionId); } return count; }
public int streamCount() { return refCountByStreamIdMap.size() + refCountByStreamIdAndSessionIdMap.size(); }
public boolean shouldBeClosed() { return refCountByStreamIdMap.isEmpty() && refCountByStreamIdAndSessionIdMap.isEmpty() && !statusIndicator.isClosed(); }
public long incRefToStreamAndSession(final int streamId, final int sessionId) { return refCountByStreamIdAndSessionIdMap.incrementAndGet(Hashing.compoundKey(streamId, sessionId)); }
private final AtomicCounter statusIndicator; private final Int2IntCounterMap refCountByStreamIdMap = new Int2IntCounterMap(0); private final Long2LongCounterMap refCountByStreamIdAndSessionIdMap = new Long2LongCounterMap(0); private final MultiRcvDestination multiRcvDestination;
public long decRefToStreamAndSession(final int streamId, final int sessionId) { final long key = Hashing.compoundKey(streamId, sessionId); final long count = refCountByStreamIdAndSessionIdMap.decrementAndGet(key); if (-1 == count) { refCountByStreamIdAndSessionIdMap.remove(key); throw new IllegalStateException( "could not find stream Id + session Id to decrement: " + streamId + " " + sessionId); } return count; }
public int streamCount() { return refCountByStreamIdMap.size() + refCountByStreamIdAndSessionIdMap.size(); }
public long incRefToStreamAndSession(final int streamId, final int sessionId) { return refCountByStreamIdAndSessionIdMap.incrementAndGet(Hashing.compoundKey(streamId, sessionId)); }