public ClientSession getClientSession(final long clusterSessionId) { return sessionByIdMap.get(clusterSessionId); }
public void onCloseSession(final long controlSessionId) { final ControlSession session = controlSessionByIdMap.get(controlSessionId); if (null != session) { session.abort(); } }
void onSessionMessage( final long clusterSessionId, final long timestampMs, final DirectBuffer buffer, final int offset, final int length, final Header header) { clusterTimeMs = timestampMs; final ClientSession clientSession = sessionByIdMap.get(clusterSessionId); service.onSessionMessage(clientSession, timestampMs, buffer, offset, length, header); }
public void onNewSubscription(final long correlationId, final int statusIndicatorId) { final Subscription subscription = (Subscription)resourceByRegIdMap.get(correlationId); subscription.channelStatusId(statusIndicatorId); }
private ControlSession getControlSession(final long controlSessionId, final long correlationId) { final ControlSession controlSession = controlSessionByIdMap.get(controlSessionId); if (controlSession == null) { throw new ArchiveException( "unknown controlSessionId=" + controlSessionId + " for correlationId=" + correlationId); } return controlSession; } }
public void onSessionKeepAlive(final long clusterSessionId, final long leadershipTermId) { if (Cluster.Role.LEADER == role && leadershipTermId == this.leadershipTermId) { final ClusterSession session = sessionByIdMap.get(clusterSessionId); if (null != session && session.state() == OPEN) { session.timeOfLastActivityMs(clusterTimeMs); } } }
@SuppressWarnings("unused") void onReplaySessionMessage( final long clusterSessionId, final long timestamp, final DirectBuffer buffer, final int offset, final int length, final Header header) { clusterTimeMs(timestamp); sessionByIdMap.get(clusterSessionId).timeOfLastActivityMs(timestamp); }
Counter addCounter(final int typeId, final String label) { clientLock.lock(); try { ensureActive(); ensureNotReentrant(); if (label.length() > CountersManager.MAX_LABEL_LENGTH) { throw new IllegalArgumentException("label length exceeds MAX_LABEL_LENGTH: " + label.length()); } final long registrationId = driverProxy.addCounter(typeId, label); awaitResponse(registrationId); return (Counter)resourceByRegIdMap.get(registrationId); } finally { clientLock.unlock(); } }
private LogBuffers logBuffers(final long registrationId, final String logFileName) { LogBuffers logBuffers = logBuffersByIdMap.get(registrationId); if (null == logBuffers) { logBuffers = logBuffersFactory.map(logFileName); logBuffersByIdMap.put(registrationId, logBuffers); } logBuffers.incRef(); return logBuffers; }
public void onSessionClose(final long clusterSessionId) { final ClusterSession session = sessionByIdMap.get(clusterSessionId); if (null != session && Cluster.Role.LEADER == role) { session.close(CloseReason.CLIENT_ACTION); if (logPublisher.appendSessionClose(session, leadershipTermId, clusterTimeMs)) { sessionByIdMap.remove(clusterSessionId); } } }
void getRecordingPosition(final long correlationId, final ControlSession controlSession, final long recordingId) { final RecordingSession recordingSession = recordingSessionByIdMap.get(recordingId); final long position = null == recordingSession ? NULL_POSITION : recordingSession.recordingPosition().get(); controlSession.sendOkResponse(correlationId, position, controlResponseProxy); }
ConcurrentPublication addPublication(final String channel, final int streamId) { clientLock.lock(); try { ensureActive(); ensureNotReentrant(); stashedChannel = channel; final long registrationId = driverProxy.addPublication(channel, streamId); awaitResponse(registrationId); return (ConcurrentPublication)resourceByRegIdMap.get(registrationId); } finally { clientLock.unlock(); } }
ExclusivePublication addExclusivePublication(final String channel, final int streamId) { clientLock.lock(); try { ensureActive(); ensureNotReentrant(); stashedChannel = channel; final long registrationId = driverProxy.addExclusivePublication(channel, streamId); awaitResponse(registrationId); return (ExclusivePublication)resourceByRegIdMap.get(registrationId); } finally { clientLock.unlock(); } }
void stopReplay(final long correlationId, final ControlSession controlSession, final long replaySessionId) { final ReplaySession replaySession = replaySessionByIdMap.get(replaySessionId); if (null == replaySession) { final String errorMessage = "replay session not known for " + replaySessionId; controlSession.sendErrorResponse(correlationId, UNKNOWN_REPLAY, errorMessage, controlResponseProxy); } else { replaySession.abort(); controlSession.sendOkResponse(correlationId, controlResponseProxy); } }
public boolean closeSession(final long clusterSessionId) { final ClientSession clientSession = sessionByIdMap.get(clusterSessionId); if (clientSession == null) { throw new ClusterException("unknown clusterSessionId: " + clusterSessionId); } if (clientSession.isClosing()) { return true; } if (consensusModuleProxy.closeSession(clusterSessionId)) { clientSession.markClosing(); return true; } return false; }
private void fileChunk( final long correlationId, final long chunkOffset, final long chunkLength, final DirectBuffer buffer, final int offset) { final UnsafeBuffer fileBuffer = fileSessionByIdMap.get(correlationId); buffer.getBytes(offset + CHUNK_PAYLOAD_OFFSET, fileBuffer, (int)chunkOffset, (int)chunkLength); if ((chunkOffset + chunkLength) >= fileBuffer.capacity()) { fileSessionByIdMap.remove(correlationId); IoUtil.unmap(fileBuffer.byteBuffer()); } }
public ControlledFragmentAssembler.Action onIngressMessage( final long leadershipTermId, final long clusterSessionId, final DirectBuffer buffer, final int offset, final int length) { if (leadershipTermId != this.leadershipTermId || Cluster.Role.LEADER != role) { return ControlledFragmentHandler.Action.CONTINUE; } final ClusterSession session = sessionByIdMap.get(clusterSessionId); if (null == session || session.state() == CLOSED) { return ControlledFragmentHandler.Action.CONTINUE; } if (session.state() == OPEN && logPublisher.appendMessage(leadershipTermId, clusterSessionId, clusterTimeMs, buffer, offset, length)) { session.timeOfLastActivityMs(clusterTimeMs); return ControlledFragmentHandler.Action.CONTINUE; } return ControlledFragmentHandler.Action.ABORT; }
public void onUnavailableImage(final long correlationId, final long subscriptionRegistrationId, final int streamId) { final Subscription subscription = (Subscription)resourceByRegIdMap.get(subscriptionRegistrationId); if (null != subscription) { final Image image = subscription.removeImage(correlationId); if (null != image) { final UnavailableImageHandler handler = subscription.unavailableImageHandler(); if (null != handler) { isInCallback = true; try { handler.onUnavailableImage(image); } catch (final Throwable ex) { handleError(ex); } finally { isInCallback = false; } } } } }
void onServiceCloseSession(final long clusterSessionId) { final ClusterSession session = sessionByIdMap.get(clusterSessionId); if (null != session) { if (session.isResponsePublicationConnected()) { egressPublisher.sendEvent( session, leadershipTermId, leaderMember.id(), EventCode.ERROR, SESSION_TERMINATED_MSG); } session.close(CloseReason.SERVICE_ACTION); if (Cluster.Role.LEADER == role && logPublisher.appendSessionClose(session, leadershipTermId, clusterTimeMs)) { sessionByIdMap.remove(clusterSessionId); } } }
final String sourceIdentity) final Subscription subscription = (Subscription)resourceByRegIdMap.get(subscriptionRegistrationId); if (null != subscription)