use of io.aeron.driver.buffer.RawLog in project Aeron by real-logic.
the class DriverConductorTest method shouldTimeoutPublicationWithNoKeepaliveButNotFlushed.
@Test
public void shouldTimeoutPublicationWithNoKeepaliveButNotFlushed() throws Exception {
driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1);
driverConductor.doWork();
final ArgumentCaptor<NetworkPublication> captor = ArgumentCaptor.forClass(NetworkPublication.class);
verify(senderProxy, times(1)).newNetworkPublication(captor.capture());
final NetworkPublication publication = captor.getValue();
final int termId = 101;
final int index = LogBufferDescriptor.indexByTerm(termId, termId);
final RawLog rawLog = publication.rawLog();
final TermAppender appender = new TermAppender(rawLog.termBuffers()[index], rawLog.metaData(), index);
final UnsafeBuffer srcBuffer = new UnsafeBuffer(new byte[256]);
final HeaderWriter headerWriter = new HeaderWriter(createDefaultHeader(publication.sessionId(), STREAM_ID_1, termId));
final StatusMessageFlyweight msg = mock(StatusMessageFlyweight.class);
when(msg.consumptionTermId()).thenReturn(termId);
when(msg.consumptionTermOffset()).thenReturn(0);
when(msg.receiverWindowLength()).thenReturn(10);
publication.onStatusMessage(msg, new InetSocketAddress("localhost", 4059));
appender.appendUnfragmentedMessage(headerWriter, srcBuffer, 0, 256, null);
doWorkUntil(() -> nanoClock.nanoTime() >= PUBLICATION_LINGER_NS + CLIENT_LIVENESS_TIMEOUT_NS * 2);
assertTrue(publication.hasReachedEndOfLife());
verify(senderProxy).removeNetworkPublication(eq(publication));
assertNull(driverConductor.senderChannelEndpoint(UdpChannel.parse(CHANNEL_4000)));
}
use of io.aeron.driver.buffer.RawLog in project Aeron by real-logic.
the class DriverConductor method newNetworkPublicationLog.
private RawLog newNetworkPublicationLog(final int sessionId, final int streamId, final int initialTermId, final UdpChannel udpChannel, final long registrationId, final int termBufferLength) {
final RawLog rawLog = rawLogFactory.newNetworkPublication(udpChannel.canonicalForm(), sessionId, streamId, registrationId, termBufferLength);
final UnsafeBuffer logMetaData = rawLog.metaData();
storeDefaultFrameHeader(logMetaData, createDefaultHeader(sessionId, streamId, initialTermId));
initialiseTailWithTermId(logMetaData, 0, initialTermId);
initialTermId(logMetaData, initialTermId);
mtuLength(logMetaData, context.mtuLength());
correlationId(logMetaData, registrationId);
timeOfLastStatusMessage(logMetaData, 0);
return rawLog;
}
use of io.aeron.driver.buffer.RawLog in project Aeron by real-logic.
the class DriverConductor method newIpcPublicationLog.
private RawLog newIpcPublicationLog(final int termBufferLength, final int sessionId, final int streamId, final int initialTermId, final long registrationId) {
final RawLog rawLog = rawLogFactory.newIpcPublication(sessionId, streamId, registrationId, termBufferLength);
final UnsafeBuffer logMetaData = rawLog.metaData();
storeDefaultFrameHeader(logMetaData, createDefaultHeader(sessionId, streamId, initialTermId));
initialiseTailWithTermId(logMetaData, 0, initialTermId);
initialTermId(logMetaData, initialTermId);
mtuLength(logMetaData, computeMaxMessageLength(termBufferLength));
correlationId(logMetaData, registrationId);
timeOfLastStatusMessage(logMetaData, 0);
return rawLog;
}
use of io.aeron.driver.buffer.RawLog in project Aeron by real-logic.
the class DriverConductor method newPublicationImageLog.
private RawLog newPublicationImageLog(final int sessionId, final int streamId, final int initialTermId, final int termBufferLength, final int senderMtuLength, final UdpChannel udpChannel, final long correlationId) {
final RawLog rawLog = rawLogFactory.newNetworkedImage(udpChannel.canonicalForm(), sessionId, streamId, correlationId, termBufferLength);
final UnsafeBuffer logMetaData = rawLog.metaData();
storeDefaultFrameHeader(logMetaData, createDefaultHeader(sessionId, streamId, initialTermId));
initialTermId(logMetaData, initialTermId);
mtuLength(logMetaData, senderMtuLength);
correlationId(logMetaData, correlationId);
timeOfLastStatusMessage(logMetaData, 0);
return rawLog;
}
use of io.aeron.driver.buffer.RawLog in project aeron by real-logic.
the class DriverConductorTest method shouldTimeoutPublicationWithNoKeepaliveButNotDrained.
@Test
public void shouldTimeoutPublicationWithNoKeepaliveButNotDrained() {
driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1);
driverConductor.doWork();
final ArgumentCaptor<NetworkPublication> captor = ArgumentCaptor.forClass(NetworkPublication.class);
verify(senderProxy, times(1)).newNetworkPublication(captor.capture());
final NetworkPublication publication = captor.getValue();
final int termId = 101;
final int index = LogBufferDescriptor.indexByTerm(termId, termId);
final RawLog rawLog = publication.rawLog();
LogBufferDescriptor.rawTail(rawLog.metaData(), index, LogBufferDescriptor.packTail(termId, 0));
final TermAppender appender = new TermAppender(rawLog.termBuffers()[index], rawLog.metaData(), index);
final UnsafeBuffer srcBuffer = new UnsafeBuffer(new byte[256]);
final HeaderWriter headerWriter = HeaderWriter.newInstance(createDefaultHeader(SESSION_ID, STREAM_ID_1, termId));
final StatusMessageFlyweight msg = mock(StatusMessageFlyweight.class);
when(msg.consumptionTermId()).thenReturn(termId);
when(msg.consumptionTermOffset()).thenReturn(0);
when(msg.receiverWindowLength()).thenReturn(10);
publication.onStatusMessage(msg, new InetSocketAddress("localhost", 4059));
appender.appendUnfragmentedMessage(headerWriter, srcBuffer, 0, 256, null, termId);
assertThat(publication.state(), is(NetworkPublication.State.ACTIVE));
doWorkUntil(() -> nanoClock.nanoTime() >= CLIENT_LIVENESS_TIMEOUT_NS * 2, (timeNs) -> {
publication.onStatusMessage(msg, new InetSocketAddress("localhost", 4059));
publication.updateHasReceivers(timeNs);
});
assertThat(publication.state(), anyOf(is(NetworkPublication.State.DRAINING), is(NetworkPublication.State.LINGER)));
final long endTime = nanoClock.nanoTime() + PUBLICATION_CONNECTION_TIMEOUT_NS + TIMER_INTERVAL_NS;
doWorkUntil(() -> nanoClock.nanoTime() >= endTime, publication::updateHasReceivers);
assertThat(publication.state(), anyOf(is(NetworkPublication.State.LINGER), is(NetworkPublication.State.CLOSING)));
currentTimeNs += TIMER_INTERVAL_NS + PUBLICATION_LINGER_NS;
driverConductor.doWork();
assertThat(publication.state(), is(NetworkPublication.State.CLOSING));
verify(senderProxy).removeNetworkPublication(eq(publication));
assertNull(driverConductor.senderChannelEndpoint(UdpChannel.parse(CHANNEL_4000)));
}
Aggregations