use of org.agrona.concurrent.EpochClock in project Aeron by real-logic.
the class ArchiveToolTests method checksumRecordingLastSegmentFile.
@Test
void checksumRecordingLastSegmentFile() {
checksumRecording(out, archiveDir, validRecording3, false, crc32(), epochClock);
assertTrue(verifyRecording(out, archiveDir, validRecording3, of(APPLY_CHECKSUM), crc32(), epochClock, (file) -> false));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, VALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
verifyRecording(out, archiveDir, validRecording3, allOf(VerifyOption.class), crc32(), epochClock, (file) -> false);
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, INVALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
}
use of org.agrona.concurrent.EpochClock in project Aeron by real-logic.
the class ArchiveToolTests method checksumRecordingAllSegmentFiles.
@Test
void checksumRecordingAllSegmentFiles() {
checksumRecording(out, archiveDir, validRecording3, true, crc32(), epochClock);
assertTrue(verifyRecording(out, archiveDir, validRecording3, allOf(VerifyOption.class), crc32(), epochClock, (file) -> false));
try (Catalog catalog = openCatalogReadOnly(archiveDir, epochClock)) {
assertRecording(catalog, validRecording3, VALID, 963969455, 7 * TERM_LENGTH + 96, 11 * TERM_LENGTH + 320, 18, 100, 7, 13, "ch2", "src2");
}
}
use of org.agrona.concurrent.EpochClock in project Aeron by real-logic.
the class TestCluster method awaitResponseMessageCount.
public void awaitResponseMessageCount(final int messageCount) {
final EpochClock epochClock = client.context().aeron().context().epochClock();
long heartbeatDeadlineMs = epochClock.time() + TimeUnit.SECONDS.toMillis(1);
long count;
while ((count = responseCount.get()) < messageCount) {
Tests.sleep(1, "count=%d awaiting=%d", count, messageCount);
client.pollEgress();
final long nowMs = epochClock.time();
if (nowMs > heartbeatDeadlineMs) {
client.sendKeepAlive();
heartbeatDeadlineMs = nowMs + TimeUnit.SECONDS.toMillis(1);
}
}
}
use of org.agrona.concurrent.EpochClock in project Aeron by real-logic.
the class TestCluster method awaitServiceState.
public void awaitServiceState(final TestNode node, final Predicate<TestNode> predicate) {
final EpochClock epochClock = client.context().aeron().context().epochClock();
long keepAliveDeadlineMs = epochClock.time() + TimeUnit.SECONDS.toMillis(1);
while (!predicate.test(node)) {
Thread.yield();
if (Thread.interrupted()) {
throw new TimeoutException("timeout while awaiting condition");
}
final long nowMs = epochClock.time();
if (nowMs > keepAliveDeadlineMs) {
client.sendKeepAlive();
keepAliveDeadlineMs = nowMs + TimeUnit.SECONDS.toMillis(1);
}
}
}
use of org.agrona.concurrent.EpochClock in project Aeron by real-logic.
the class ClusterTool method nextBackupQuery.
/**
* Set the time of the next backup query for the cluster backup.
*
* @param out to print the output to.
* @param clusterDir where the cluster is running.
* @param delayMs from the current time for the next backup query.
*/
public static void nextBackupQuery(final PrintStream out, final File clusterDir, final long delayMs) {
if (markFileExists(clusterDir) || TIMEOUT_MS > 0) {
try (ClusterMarkFile markFile = openMarkFile(clusterDir, System.out::println)) {
if (markFile.decoder().componentType() != ClusterComponentType.BACKUP) {
out.println("not a cluster backup node");
} else {
final EpochClock epochClock = SystemEpochClock.INSTANCE;
nextBackupQueryDeadlineMs(markFile, epochClock.time() + delayMs);
out.format("%2$tF %1$tH:%1$tM:%1$tS setting next: %2$tF %2$tH:%2$tM:%2$tS%n", new Date(), new Date(nextBackupQueryDeadlineMs(markFile)));
}
}
} else {
out.println(ClusterMarkFile.FILENAME + " does not exist.");
}
}
Aggregations