@Test public void shouldRecordFirstObservation() { final long timestamp = 7; final int offset = 0; final RuntimeException error = new RuntimeException("Test Error"); when(clock.time()).thenReturn(timestamp); assertTrue(log.record(error)); final InOrder inOrder = inOrder(buffer); inOrder.verify(buffer).putBytes(eq(offset + ENCODED_ERROR_OFFSET), any(byte[].class)); inOrder.verify(buffer).putLong(offset + FIRST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); inOrder.verify(buffer).putIntOrdered(eq(offset + LENGTH_OFFSET), anyInt()); inOrder.verify(buffer).getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); inOrder.verify(buffer).putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); }
public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; }
DistinctErrorLog { public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; } }
DistinctErrorLog { public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; } DistinctErrorLog(final AtomicBuffer buffer, final EpochClock clock);  DistinctErrorLog(final AtomicBuffer buffer, final EpochClock clock, final Charset charset); }
DistinctErrorLog { public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; } DistinctErrorLog(final AtomicBuffer buffer, final EpochClock clock);  DistinctErrorLog(final AtomicBuffer buffer, final EpochClock clock, final Charset charset); AtomicBuffer buffer(); Charset charset(); boolean record(final Throwable observation); }
DistinctErrorLog { public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; } DistinctErrorLog(final AtomicBuffer buffer, final EpochClock clock);  DistinctErrorLog(final AtomicBuffer buffer, final EpochClock clock, final Charset charset); AtomicBuffer buffer(); Charset charset(); boolean record(final Throwable observation); static final int LENGTH_OFFSET; static final int OBSERVATION_COUNT_OFFSET; static final int LAST_OBSERVATION_TIMESTAMP_OFFSET; static final int FIRST_OBSERVATION_TIMESTAMP_OFFSET; static final int ENCODED_ERROR_OFFSET; static final int RECORD_ALIGNMENT; }