use of org.agrona.collections.MutableLong in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateLiveRecordingAndMergeBeforeDataFlows.
@Test
@InterruptAfter(10)
public void shouldReplicateLiveRecordingAndMergeBeforeDataFlows() {
final String messagePrefix = "Message-Prefix-";
final int messageCount = 10;
final long srcRecordingId;
final long subscriptionId = srcAeronArchive.startRecording(LIVE_CHANNEL, LIVE_STREAM_ID, LOCAL);
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter;
try (Publication publication = srcAeron.addPublication(LIVE_CHANNEL, LIVE_STREAM_ID)) {
final CountersReader srcCounters = srcAeron.countersReader();
final int counterId = awaitRecordingCounterId(srcCounters, publication.sessionId());
srcRecordingId = RecordingPos.getRecordingId(srcCounters, counterId);
final MutableLong dstRecordingId = new MutableLong();
adapter = newRecordingSignalAdapter(signalRef, dstRecordingId);
dstAeronArchive.replicate(srcRecordingId, NULL_VALUE, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, LIVE_CHANNEL);
assertEquals(RecordingSignal.REPLICATE, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.EXTEND, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.MERGE, awaitSignal(signalRef, adapter));
final CountersReader dstCounters = dstAeron.countersReader();
final int dstCounterId = RecordingPos.findCounterIdByRecording(dstCounters, dstRecordingId.get());
offer(publication, messageCount, messagePrefix);
awaitPosition(dstCounters, dstCounterId, publication.position());
}
srcAeronArchive.stopRecording(subscriptionId);
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
}
use of org.agrona.collections.MutableLong in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateLiveRecordingAndMerge.
@Test
@InterruptAfter(10)
public void shouldReplicateLiveRecordingAndMerge() {
final String messagePrefix = "Message-Prefix-";
final int messageCount = 10;
final long srcRecordingId;
final long subscriptionId = srcAeronArchive.startRecording(LIVE_CHANNEL, LIVE_STREAM_ID, LOCAL);
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter;
try (Publication publication = srcAeron.addPublication(LIVE_CHANNEL, LIVE_STREAM_ID)) {
final CountersReader srcCounters = srcAeron.countersReader();
final int counterId = awaitRecordingCounterId(srcCounters, publication.sessionId());
srcRecordingId = RecordingPos.getRecordingId(srcCounters, counterId);
offer(publication, messageCount, messagePrefix);
awaitPosition(srcCounters, counterId, publication.position());
final MutableLong dstRecordingId = new MutableLong();
adapter = newRecordingSignalAdapter(signalRef, dstRecordingId);
dstAeronArchive.replicate(srcRecordingId, NULL_VALUE, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, LIVE_CHANNEL);
offer(publication, messageCount, messagePrefix);
assertEquals(RecordingSignal.REPLICATE, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.EXTEND, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.MERGE, awaitSignal(signalRef, adapter));
final CountersReader dstCounters = dstAeron.countersReader();
final int dstCounterId = RecordingPos.findCounterIdByRecording(dstCounters, dstRecordingId.get());
offer(publication, messageCount, messagePrefix);
awaitPosition(dstCounters, dstCounterId, publication.position());
}
srcAeronArchive.stopRecording(subscriptionId);
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
}
use of org.agrona.collections.MutableLong in project aeron by real-logic.
the class ArchiveAuthenticationTest method shouldBeAbleToRecordWithAuthenticateOnConnectRequestWithCredentials.
@Test
@InterruptAfter(10)
public void shouldBeAbleToRecordWithAuthenticateOnConnectRequestWithCredentials() {
final MutableLong authenticatorSessionId = new MutableLong(-1L);
final CredentialsSupplier credentialsSupplier = spy(new CredentialsSupplier() {
public byte[] encodedCredentials() {
return encodedCredentials;
}
public byte[] onChallenge(final byte[] encodedChallenge) {
fail();
return null;
}
});
final Authenticator authenticator = spy(new Authenticator() {
public void onConnectRequest(final long sessionId, final byte[] encodedCredentials, final long nowMs) {
authenticatorSessionId.value = sessionId;
assertEquals(CREDENTIALS_STRING, new String(encodedCredentials));
}
public void onChallengeResponse(final long sessionId, final byte[] encodedCredentials, final long nowMs) {
fail();
}
public void onConnectedSession(final SessionProxy sessionProxy, final long nowMs) {
assertEquals(sessionProxy.sessionId(), authenticatorSessionId.value);
sessionProxy.authenticate(PRINCIPAL_STRING.getBytes());
}
public void onChallengedSession(final SessionProxy sessionProxy, final long nowMs) {
fail();
}
});
launchArchivingMediaDriver(() -> authenticator);
connectClient(credentialsSupplier);
assertEquals(aeronArchive.controlSessionId(), authenticatorSessionId.value);
createRecording();
}
use of org.agrona.collections.MutableLong in project aeron by real-logic.
the class ListRecordingsForUriSessionTest method shouldSend2DescriptorsAndRecordingUnknown.
@Test
public void shouldSend2DescriptorsAndRecordingUnknown() {
final ListRecordingsForUriSession session = new ListRecordingsForUriSession(correlationId, 1, 5, LOCALHOST_BYTES, 1, catalog, controlResponseProxy, controlSession, descriptorBuffer, recordingDescriptorDecoder);
final MutableLong counter = new MutableLong(1);
when(controlSession.sendDescriptor(eq(correlationId), any(), eq(controlResponseProxy))).then(verifySendDescriptor(counter));
assertEquals(2, session.doWork());
verify(controlSession, times(2)).sendDescriptor(eq(correlationId), any(), eq(controlResponseProxy));
verify(controlSession).sendRecordingUnknown(eq(correlationId), eq(5L), eq(controlResponseProxy));
}
use of org.agrona.collections.MutableLong in project aeron by real-logic.
the class ClusterTool method nextBackupQueryDeadlineMs.
/**
* Get the deadline time (MS) for the next cluster backup query.
*
* @param markFile for the cluster component.
* @return the deadline time (MS) for the next cluster backup query, or {@link Aeron#NULL_VALUE} not available.
*/
public static long nextBackupQueryDeadlineMs(final ClusterMarkFile markFile) {
final String aeronDirectoryName = markFile.decoder().aeronDirectory();
final MutableLong nextQueryMs = new MutableLong(NULL_VALUE);
try (Aeron aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(aeronDirectoryName))) {
aeron.countersReader().forEach((counterId, typeId, keyBuffer, label) -> {
if (ClusterBackup.QUERY_DEADLINE_TYPE_ID == typeId) {
nextQueryMs.set(aeron.countersReader().getCounterValue(counterId));
}
});
}
return nextQueryMs.get();
}
Aggregations