/** * @return last known good position, which is a {@link LogPosition} after a {@link CheckPoint} or * a {@link LogEntryCommit}. */ @Override public LogPosition position() { return lastGoodPositionMarker.newPosition(); } }
protected IOException unknownCommandType( byte commandType, ReadableChannel channel ) throws IOException { String message = "Unknown command type[" + commandType + "]"; if ( channel instanceof PositionAwareChannel ) { PositionAwareChannel logChannel = (PositionAwareChannel) channel; LogPositionMarker position = new LogPositionMarker(); logChannel.getCurrentPosition( position ); message += " near " + position.newPosition(); } return new IOException( message ); } }
@Test public void shouldReturnUnspecifiedIfNothingHasBeenMarked() { // given final LogPositionMarker marker = new LogPositionMarker(); // when final LogPosition logPosition = marker.newPosition(); // given assertEquals(LogPosition.UNSPECIFIED, logPosition); }
@Test public void shouldReturnTheMarkedPosition() { // given final LogPositionMarker marker = new LogPositionMarker(); // when marker.mark( 1, 2 ); final LogPosition logPosition = marker.newPosition(); // given assertEquals(new LogPosition( 1, 2 ), logPosition); }
@Test public void shouldReturnUnspecifiedWhenAskedTo() { // given final LogPositionMarker marker = new LogPositionMarker(); // when marker.mark( 1, 2 ); marker.unspecified(); final LogPosition logPosition = marker.newPosition(); // given assertEquals(LogPosition.UNSPECIFIED, logPosition); } }
LogPosition position = positionMarker.newPosition(); e = withMessage( e, e.getMessage() + ". At position " + position + " and entry version " + version );
rotations.get() < LIMIT_ROTATIONS; reads++ ) try ( ReadableLogChannel reader = logFile.getReader( startPosition.newPosition() ) )
LogPosition logPositionBeforeCommit = writer.getCurrentPosition( positionMarker ).newPosition(); transactionLogWriter.append( transaction, transactionId ); LogPosition logPositionAfterCommit = writer.getCurrentPosition( positionMarker ).newPosition();
@Test public void shouldSeeCorrectPositionEvenBeforeEmptyingDataIntoChannel() throws Exception { // GIVEN final File file = new File( directory.directory(), "file" ); StoreChannel storeChannel = fileSystemRule.get().open( file, OpenMode.READ_WRITE ); PhysicalLogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel( storeChannel, 1, (byte) -1 /* ignored */ ); PositionAwarePhysicalFlushableChannel channel = new PositionAwarePhysicalFlushableChannel( versionedStoreChannel ); LogPositionMarker positionMarker = new LogPositionMarker(); LogPosition initialPosition = channel.getCurrentPosition( positionMarker ).newPosition(); // WHEN channel.putLong( 67 ); channel.putInt( 1234 ); LogPosition positionAfterSomeData = channel.getCurrentPosition( positionMarker ).newPosition(); // THEN assertEquals( 12, positionAfterSomeData.getByteOffset() - initialPosition.getByteOffset() ); channel.close(); }
for ( Entry entry : entries ) LogPosition currentPosition = writeChannel.getCurrentPosition( positionMarker ).newPosition(); positions.put( entry, currentPosition ); if ( entry instanceof StartEntry )
LogPosition lastCommittedTxPosition = marker.newPosition(); writer.writeStartEntry( 0, 1, 2L, 3L, new byte[0] ); lastCommittedTxStartEntry = new LogEntryStart( 0, 1, 2L, 3L, new byte[0], lastCommittedTxPosition ); expectedStartEntry = new LogEntryStart( 0, 1, 6L, 4L, new byte[0], marker.newPosition() );
writer.writeCheckPointEntry( marker.newPosition() );
}, mark.newPosition() ); assertTrue( called.get() );
LogPositionMarker positionMarker = new LogPositionMarker(); writer.getCurrentPosition( positionMarker ); LogPosition position1 = positionMarker.newPosition(); int intValue = 45; long longValue = 4854587; writer.prepareForFlush().flush(); writer.getCurrentPosition( positionMarker ); LogPosition position2 = positionMarker.newPosition(); long longValue2 = 123456789L; writer.putLong( longValue2 );
@Test public void shouldWriteSomeDataIntoTheLog() throws Exception { // GIVEN String name = "log"; FileSystemAbstraction fs = fileSystemRule.get(); LogFiles logFiles = LogFilesBuilder.builder( directory.databaseLayout(), fs ) .withTransactionIdStore( transactionIdStore ) .withLogVersionRepository( logVersionRepository ).build(); life.start(); life.add( logFiles ); // WHEN FlushablePositionAwareChannel writer = logFiles.getLogFile().getWriter(); LogPositionMarker positionMarker = new LogPositionMarker(); writer.getCurrentPosition( positionMarker ); int intValue = 45; long longValue = 4854587; writer.putInt( intValue ); writer.putLong( longValue ); writer.prepareForFlush().flush(); // THEN try ( ReadableClosableChannel reader = logFiles.getLogFile().getReader( positionMarker.newPosition() ) ) { assertEquals( intValue, reader.getInt() ); assertEquals( longValue, reader.getLong() ); } }
/** * @return last known good position, which is a {@link LogPosition} after a {@link CheckPoint} or * a {@link LogEntryCommit}. */ @Override public LogPosition position() { return lastGoodPositionMarker.newPosition(); } }
protected IOException unknownCommandType( byte commandType, ReadableChannel channel ) throws IOException { String message = "Unknown command type[" + commandType + "]"; if ( channel instanceof PositionAwareChannel ) { PositionAwareChannel logChannel = (PositionAwareChannel) channel; LogPositionMarker position = new LogPositionMarker(); logChannel.getCurrentPosition( position ); message += " near " + position.newPosition(); } return new IOException( message ); } }
LogPosition position = positionMarker.newPosition(); e = withMessage( e, e.getMessage() + ". At position " + position + " and entry version " + version );
LogPosition logPositionBeforeCommit = writer.getCurrentPosition( positionMarker ).newPosition(); transactionLogWriter.append( transaction, transactionId ); LogPosition logPositionAfterCommit = writer.getCurrentPosition( positionMarker ).newPosition();