org.agrona.concurrent.SystemEpochClock Java Examples

The following examples show how to use org.agrona.concurrent.SystemEpochClock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterTool.java    From aeron with Apache License 2.0 6 votes vote down vote up
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.");
    }
}
 
Example #2
Source File: LibraryPoller.java    From artio with Apache License 2.0 5 votes vote down vote up
private SessionProxy sessionProxy(final long connectionId)
{
    return configuration.sessionProxyFactory().make(
        configuration.sessionBufferSize(),
        transport.outboundPublication(),
        sessionIdStrategy,
        configuration.sessionCustomisationStrategy(),
        new SystemEpochClock(),
        connectionId,
        libraryId,
        LangUtil::rethrowUnchecked,
        configuration.sessionEpochFractionFormat());
}
 
Example #3
Source File: FixLibrary.java    From artio with Apache License 2.0 5 votes vote down vote up
FixLibrary(final LibraryConfiguration configuration)
{
    this.configuration = configuration;
    scheduler = configuration.scheduler();
    configuration.conclude();

    try
    {
        scheduler.configure(configuration.aeronContext());
        init(configuration);
        final LibraryTimers timers = new LibraryTimers(configuration.clock());
        initMonitoringAgent(timers.all(), configuration, null);

        final LibraryTransport transport = new LibraryTransport(configuration, fixCounters, aeron);
        poller = new LibraryPoller(
            configuration, timers, fixCounters, transport, this, new SystemEpochClock());
    }
    catch (final Exception e)
    {
        try
        {
            closeAnythingHoldingFileHandles();
            deleteFiles();
        }
        catch (final Exception innerException)
        {
            innerException.addSuppressed(e);
            throw innerException;
        }
        throw e;
    }
}
 
Example #4
Source File: MarkFileTest.java    From agrona with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldWaitForMarkFileToContainEnoughDataForVersionCheck() throws IOException
{
    final String filename = "markfile.dat";
    final Path markFilePath = directory.toPath().resolve(filename);
    Files.createFile(markFilePath);

    try (FileChannel channel = FileChannel.open(markFilePath, StandardOpenOption.WRITE))
    {
        channel.write(ByteBuffer.allocate(1));
    }

    assertThrows(IllegalStateException.class,
        () -> new MarkFile(directory, filename, 0, 16, 10, new SystemEpochClock(), v -> {}, msg -> {}));
}
 
Example #5
Source File: ArchiveTest.java    From aeron with Apache License 2.0 4 votes vote down vote up
private static Catalog openCatalog(final Context archiveCtx)
{
    final IntConsumer intConsumer = (version) -> {};
    return new Catalog(new File(archiveCtx.archiveDirectoryName()), new SystemEpochClock(), true, intConsumer);
}