APISonar


org.agrona.concurrent.EpochClock.time

> org > agrona > concurrent > EpochClock > time
org APIs agrona APIs concurrent APIs EpochClock APIs time APIs

Example 1
private final EpochClock clock = mock(EpochClock.class);

    public void shouldReadFirstObservation()
    {
        final ErrorConsumer consumer = mock(ErrorConsumer.class);

        final long timestamp = 7;
        final RuntimeException error = new RuntimeException("Test Error");

        when(clock.time()).thenReturn(timestamp);

        log.record(error);

        assertThat(ErrorLogReader.read(buffer, consumer), is(1));

        verify(consumer).accept(eq(1), eq(timestamp), eq(timestamp), any(String.class));
    }
Example 2
private final EpochClock epochClock;

    private void checkDriverHeartbeat()
    {
        final long now = epochClock.time();
        final long currentDriverKeepaliveTime = driverProxy.timeOfLastDriverKeepalive();

        if (driverActive && (now > (currentDriverKeepaliveTime + driverTimeoutMs)))
        {
            driverActive = false;

            final String msg = String.format("Driver has been inactive for over %dms", driverTimeoutMs);
            errorHandler.onError(new DriverTimeoutException(msg));
        }
    }
Example 3
private final EpochClock epochClock;

    boolean isPublicationConnected(final long timeOfLastStatusMessage)
    {
        return (epochClock.time() <= (timeOfLastStatusMessage + publicationConnectionTimeoutMs));
    }
Example 4
private final EpochClock epochClock;

    private boolean hasGoneInactive()
    {
        return activityDeadlineMs != Aeron.NULL_VALUE && epochClock.time() > activityDeadlineMs;
    }
Example 5
private final EpochClock epochClock;

    public void onStatusMessage(
        final int termId, final int termOffset, final int receiverWindowLength, final InetSocketAddress srcAddress)
    {
        final long position = flowControl.onStatusMessage(termId, termOffset, receiverWindowLength, srcAddress);
        senderPositionLimit(position);

        final long now = epochClock.time();
        LogBufferDescriptor.timeOfLastStatusMessage(rawLog.logMetaData(), now);
    }
Example 6
private final EpochClock mockEpochClock = mock(EpochClock.class);

    public void shouldTimeoutIfConnectSentButPublicationNotConnected()
    {
        when(mockEpochClock.time()).thenReturn(0L);
        when(mockControlPublication.isClosed()).thenReturn(false);
        when(mockControlPublication.isConnected()).thenReturn(false);

        session.doWork();

        when(mockEpochClock.time()).thenReturn(ControlSession.TIMEOUT_MS + 1L);
        session.doWork();
        assertTrue(session.isDone());
    }
Example 7
private final EpochClock epochClock;

    public void onStart()
    {
        backupArchive = AeronArchive.connect(ctx.archiveContext().clone());
        stateCounter.setOrdered(INIT.code());
        nextQueryDeadlineMsCounter.setOrdered(epochClock.time() - 1);
    }
Example 8
private final EpochClock epochClock;

    public void onUnavailableCounter(
        final CountersReader countersReader, final long registrationId, final int counterId)
    {
        if (counterId == liveLogRecCounterId ||
            (null != snapshotRetrieveMonitor && counterId == snapshotRetrieveMonitor.counterId))
        {
            if (null != eventsListener)
            {
                eventsListener.onPossibleClusterFailure();
            }

            state(RESET_BACKUP, epochClock.time());
        }
    }
Example 9
private final EpochClock epochClock;

    void closeRecordingSession(final RecordingSession session)
    {
        recordingSessionByIdMap.remove(session.sessionId());
        closeSession(session);

        final AtomicCounter position = recordingPositionByIdMap.remove(session.sessionId());
        Catalog.wrapDescriptorEncoder(recordingDescriptorEncoder, session.descriptorBuffer());
        recordingDescriptorEncoder.stopPosition(position.get());
        recordingDescriptorEncoder.stopTimestamp(epochClock.time());

        UnsafeAccess.UNSAFE.storeFence();

        position.close();
    }
Example 10
private final EpochClock epochClock;

    public void free(final int counterId)
    {
        final int recordOffset = metaDataOffset(counterId);

        metaDataBuffer.putIntOrdered(recordOffset, RECORD_RECLAIMED);
        metaDataBuffer.setMemory(recordOffset + KEY_OFFSET, MAX_KEY_LENGTH, (byte)0);
        metaDataBuffer.putLong(
            recordOffset + FREE_FOR_REUSE_DEADLINE_OFFSET, epochClock.time() + freeToReuseTimeoutMs);
        freeList.addInt(counterId);
    }