public void serialize( TransactionRepresentation tx ) throws IOException { tx.accept( serializer ); }
@Override public boolean accept( Visitor<StorageCommand,IOException> visitor ) throws IOException { return transactionRepresentation.accept( visitor ); }
public void accept( Visitor<StorageCommand, IOException> visitor ) throws IOException { transactionRepresentation.accept( visitor ); }
private static int findCutoffIndex( Collection<TransactionRepresentation> transactions ) throws IOException { Iterator<TransactionRepresentation> iterator = transactions.iterator(); for ( int i = 0; iterator.hasNext(); i++ ) { TransactionRepresentation tx = iterator.next(); CommandExtractor extractor = new CommandExtractor(); tx.accept( extractor ); List<StorageCommand> commands = extractor.getCommands(); List<StorageCommand> nodeCommands = commands.stream() .filter( command -> command instanceof NodeCommand ).collect( toList() ); if ( nodeCommands.size() == 1 ) { return i; } } throw new AssertionError( "Couldn't find the transaction which would be the cut-off point" ); }
private static TransactionToApply newTransactionThatFailsWith( Exception error ) throws IOException { TransactionRepresentation transaction = mock( TransactionRepresentation.class ); when( transaction.additionalHeader() ).thenReturn( new byte[0] ); // allow to build validated index updates but fail on actual tx application doThrow( error ).when( transaction ).accept( any() ); long txId = ThreadLocalRandom.current().nextLong( 0, 1000 ); TransactionToApply txToApply = new TransactionToApply( transaction ); FakeCommitment commitment = new FakeCommitment( txId, mock( TransactionIdStore.class ) ); commitment.setHasExplicitIndexChanges( false ); txToApply.commitment( commitment, txId ); return txToApply; }
private void applyExternalTransaction( long transactionId, Command...commands ) throws Exception { LockService lockService = mock( LockService.class ); when( lockService.acquireNodeLock( anyLong(), any(LockService.LockType.class) )).thenReturn( LockService.NO_LOCK ); when( lockService.acquireRelationshipLock( anyLong(), any(LockService.LockType.class) )).thenReturn( LockService.NO_LOCK ); NeoStoreBatchTransactionApplier applier = new NeoStoreBatchTransactionApplier( neoStores, mock( CacheAccessBackDoor.class ), lockService ); TransactionRepresentation tx = new PhysicalTransactionRepresentation( Arrays.asList( commands ) ); CommandHandlerContract.apply( applier, txApplier -> { tx.accept( txApplier ); return false; }, new TransactionToApply( tx, transactionId ) ); }
/** * Simply calls through to the {@link TransactionRepresentation#accept(Visitor)} method for each {@link * TransactionToApply} given. This assumes that the {@link BatchTransactionApplier} will return {@link * TransactionApplier}s which actually do the work and that the transaction has all the relevant data. * * @param applier to use * @param transactions to apply */ public static void apply( BatchTransactionApplier applier, TransactionToApply... transactions ) throws Exception { for ( TransactionToApply tx : transactions ) { try ( TransactionApplier txApplier = applier.startTx( tx, new LockGroup() ) ) { tx.transactionRepresentation().accept( txApplier ); } } applier.close(); }
private Iterable<EntityUpdates> indexUpdatesOf( NeoStores neoStores, TransactionRepresentation transaction ) throws IOException { PropertyCommandsExtractor extractor = new PropertyCommandsExtractor(); transaction.accept( extractor ); CollectingIndexingUpdateService indexingUpdateService = new CollectingIndexingUpdateService(); OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( neoStores.getNodeStore(), neoStores.getRelationshipStore(), indexingUpdateService, new PropertyPhysicalToLogicalConverter( neoStores.getPropertyStore() ) ); onlineIndexUpdates.feed( extractor.propertyCommandsByNodeIds(), extractor.propertyCommandsByRelationshipIds(), extractor.nodeCommandsById(), extractor.relationshipCommandsById() ); return indexingUpdateService.entityUpdatesList; }
private void verifyIndex( TransactionToApply tx ) throws Exception { try ( IndexReader reader = index.newReader() ) { NodeVisitor visitor = new NodeVisitor(); for ( int i = 0; tx != null; i++ ) { tx.transactionRepresentation().accept( visitor.clear() ); Value propertyValue = propertyValue( id, base + i ); IndexQuery.ExactPredicate query = IndexQuery.exact( descriptor.getPropertyId(), propertyValue ); LongIterator hits = reader.query( query ); assertEquals( "Index doesn't contain " + visitor.nodeId + " " + propertyValue, visitor.nodeId, hits.next() ); assertFalse( hits.hasNext() ); tx = tx.next(); } } } }
transaction.getAuthorId(), transactionChecksum, transaction.getTimeCommitted() ); transaction.accept( indexCommandDetector ); boolean hasExplicitIndexChanges = indexCommandDetector.hasWrittenAnyExplicitIndexCommand(); if ( hasExplicitIndexChanges )
@Override public boolean accept( Visitor<StorageCommand,IOException> visitor ) throws IOException { return transactionRepresentation.accept( visitor ); }
public void accept( Visitor<StorageCommand, IOException> visitor ) throws IOException { transactionRepresentation.accept( visitor ); }
public void serialize( TransactionRepresentation tx ) throws IOException { tx.accept( serializer ); }
transaction.getAuthorId(), transactionChecksum, transaction.getTimeCommitted() ); transaction.accept( indexCommandDetector ); boolean hasExplicitIndexChanges = indexCommandDetector.hasWrittenAnyExplicitIndexCommand(); if ( hasExplicitIndexChanges )