private void validateMaxConcurrentRecordings( final long correlationId, final ControlSession controlSession, final String originalChannel, final Image image) { if (recordingSessionByIdMap.size() >= maxConcurrentRecordings) { final String msg = "max concurrent recordings reached, cannot record " + image.subscription().streamId() + ":" + originalChannel; controlSession.attemptErrorResponse(correlationId, MAX_RECORDINGS, msg, controlResponseProxy); throw new ArchiveException(msg); } }
public void onSessionConnect( final long correlationId, final int responseStreamId, final String responseChannel, final byte[] encodedCredentials) { if (Cluster.Role.LEADER != role) { final ClusterSession session = new ClusterSession(Aeron.NULL_VALUE, responseStreamId, responseChannel); session.lastActivity(cachedTimeMs, correlationId); session.connect(aeron); redirectSessions.add(session); } else { final ClusterSession session = new ClusterSession(nextSessionId++, responseStreamId, responseChannel); session.lastActivity(clusterTimeMs, correlationId); session.connect(aeron); if (pendingSessions.size() + sessionByIdMap.size() < ctx.maxConcurrentSessions()) { authenticator.onConnectRequest(session.id(), encodedCredentials, clusterTimeMs); pendingSessions.add(session); } else { rejectedSessions.add(session); } } }
final SourceLocation sourceLocation) if (recordingSessionByIdMap.size() >= maxConcurrentRecordings)
final SourceLocation sourceLocation) if (recordingSessionByIdMap.size() >= maxConcurrentRecordings)
@DoNotSub public int size() { return Long2ObjectHashMap.this.size(); }
/** * Compact the {@link Map} 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))); }
/** * Compact the {@link Map} 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(BitUtil.findNextPositivePowerOfTwo(idealCapacity)); }
private void validateMaxConcurrentRecordings( final long correlationId, final ControlSession controlSession, final String originalChannel, final Image image) { if (recordingSessionByIdMap.size() >= maxConcurrentRecordings) { final String msg = "max concurrent recordings reached, cannot record " + image.subscription().streamId() + ":" + originalChannel; controlSession.attemptErrorResponse(correlationId, MAX_RECORDINGS, msg, controlResponseProxy); throw new ArchiveException(msg); } }
public void endMonitoringOfSocketIdentifier(final long socketIdentifier) { while (true) { final Long2ObjectHashMap<InetSocketAddress> candidateSnapshot = candidateSockets.get(); final Long2ObjectHashMap<InetSocketAddress> updated = new Long2ObjectHashMap<>(candidateSnapshot.size(), AGRONA_DEFAULT_LOAD_FACTOR); final Long2ObjectHashMap<InetSocketAddress>.KeyIterator keyIterator = candidateSnapshot.keySet().iterator(); while(keyIterator.hasNext()) { final long key = keyIterator.nextLong(); if(key != socketIdentifier) { updated.put(key, candidateSnapshot.get(key)); } } if (candidateSockets.compareAndSet(candidateSnapshot, updated)) { break; } } }
public void onSessionConnect( final long correlationId, final int responseStreamId, final String responseChannel, final byte[] encodedCredentials) { if (Cluster.Role.LEADER != role) { final ClusterSession session = new ClusterSession(Aeron.NULL_VALUE, responseStreamId, responseChannel); session.lastActivity(cachedTimeMs, correlationId); session.connect(aeron); redirectSessions.add(session); } else { final ClusterSession session = new ClusterSession(nextSessionId++, responseStreamId, responseChannel); session.lastActivity(clusterTimeMs, correlationId); session.connect(aeron); if (pendingSessions.size() + sessionByIdMap.size() < ctx.maxConcurrentSessions()) { authenticator.onConnectRequest(session.id(), encodedCredentials, clusterTimeMs); pendingSessions.add(session); } else { rejectedSessions.add(session); } } }
public void beginMonitoringSocketIdentifier(final InetSocketAddress socketAddress, final long socketIdentifier) { while (true) { final Long2ObjectHashMap<InetSocketAddress> candidateSnapshot = candidateSockets.get(); final Long2ObjectHashMap<InetSocketAddress> updated = new Long2ObjectHashMap<>(candidateSnapshot.size(), AGRONA_DEFAULT_LOAD_FACTOR); final Long2ObjectHashMap<InetSocketAddress>.KeyIterator keyIterator = candidateSnapshot.keySet().iterator(); while(keyIterator.hasNext()) { final long key = keyIterator.nextLong(); updated.put(key, candidateSnapshot.get(key)); } updated.put(socketIdentifier, socketAddress); if (candidateSockets.compareAndSet(candidateSnapshot, updated)) { break; } } }
final SourceLocation sourceLocation) if (recordingSessionByIdMap.size() >= maxConcurrentRecordings)
final SourceLocation sourceLocation) if (recordingSessionByIdMap.size() >= maxConcurrentRecordings)