public void serialize( Collection<StorageCommand> commands ) throws IOException { for ( StorageCommand command : commands ) { serializer.visit( command ); } }
@Override public boolean accept( Visitor<StorageCommand,IOException> visitor ) throws IOException { for ( StorageCommand command : commands ) { if ( visitor.visit( command ) ) { return true; } } return false; }
/** * Visits this store, and any other store managed by this store. * TODO this could, and probably should, replace all override-and-do-the-same-thing-to-all-my-managed-stores * methods like: * {@link #makeStoreOk()}, * {@link #close()} (where that method could be deleted all together and do a visit in {@link #close()}), * {@link #logIdUsage(Logger)}, * {@link #logVersions(Logger)} * For a good samaritan to pick up later. */ void visitStore( Visitor<CommonAbstractStore<RECORD,HEADER>,RuntimeException> visitor ) { visitor.visit( this ); }
/** * Visit all locks. * <p/> * The supplied visitor may not block. * * @param visitor visitor for visiting each lock. */ public void accept( Visitor<RWLock,RuntimeException> visitor ) { synchronized ( resourceLockMap ) { for ( RWLock lock : resourceLockMap.values() ) { if ( visitor.visit( lock ) ) { break; } } } }
@Override public void run() throws IndexPopulationFailedKernelException { for ( EntityUpdates update : updates ) { if ( stop ) { return; } visitor.visit( update ); } }
@Override public void run() throws IndexPopulationFailedKernelException { for ( EntityUpdates update : updates ) { if ( stop ) { return; } visitor.visit( update ); } }
@Override public void acceptDiagnosticsVisitor( Object visitor ) { Visitor<? super DiagnosticsProvider, ? extends RuntimeException> target = Visitor.SafeGenerics.castOrNull( DiagnosticsProvider.class, RuntimeException.class, visitor ); if ( target != null ) { for ( DiagnosticsProvider provider : providers ) { target.visit( provider ); } } } } );
private void scanAllFields( int pf_flags, Visitor<PageCursor,IOException> visitor ) { try ( PageCursor cursor = pagedFile.io( 0, pf_flags ) ) { if ( cursor.next() ) { visitor.visit( cursor ); } } catch ( IOException e ) { throw new UnderlyingStorageException( e ); } }
private void writeSomeData( File file, Visitor<ByteBuffer, IOException> visitor ) throws IOException { try ( StoreChannel channel = fileSystemRule.get().open( file, OpenMode.READ_WRITE ) ) { ByteBuffer buffer = ByteBuffer.allocate( 1024 ); visitor.visit( buffer ); buffer.flip(); channel.write( buffer ); } }
@Override public boolean process( StorageNodeCursor cursor ) throws FAILURE { long[] labels = cursor.labels(); if ( labels.length == 0 && labelIds.length != 0 ) { // This node has no labels at all return false; } if ( labelUpdateVisitor != null ) { // Notify the label update visitor labelUpdateVisitor.visit( labelChanges( cursor.entityReference(), EMPTY_LONG_ARRAY, labels ) ); } if ( propertyUpdatesVisitor != null && containsAnyEntityToken( labelIds, labels ) ) { // Notify the property update visitor EntityUpdates.Builder updates = EntityUpdates.forEntity( cursor.entityReference() ).withTokens( labels ); if ( hasRelevantProperty( cursor, updates ) ) { return propertyUpdatesVisitor.visit( updates.build() ); } } return false; } }
@Override public <EXCEPTION extends Exception> void scanAllRecords( Visitor<RECORD,EXCEPTION> visitor ) throws EXCEPTION { try ( PageCursor cursor = openPageCursorForReading( 0 ) ) { RECORD record = newRecord(); long highId = getHighId(); for ( long id = getNumberOfReservedLowIds(); id < highId; id++ ) { getRecordByCursor( id, record, CHECK, cursor ); if ( record.inUse() ) { visitor.visit( record ); } } } }
@Override protected boolean process( StorageRelationshipScanCursor cursor ) throws FAILURE { int reltype = cursor.type(); if ( propertyUpdatesVisitor != null && containsAnyEntityToken( relationshipTypeIds, reltype ) ) { // Notify the property update visitor EntityUpdates.Builder updates = EntityUpdates.forEntity( cursor.entityReference() ).withTokens( reltype ); if ( hasRelevantProperty( cursor, updates ) ) { return propertyUpdatesVisitor.visit( updates.build() ); } } return false; } }
NodeRecord after = new NodeRecord( nodeId ); after.setInUse( true ); visitor.visit( new Command.NodeCommand( new NodeRecord( nodeId ), after ) ); return null; } );
private boolean visitPropertyRecordChain( long firstPropertyRecordId, Visitor<PropertyRecord,RuntimeException> visitor ) throws CircularPropertyRecordChainException { if ( Record.NO_NEXT_PROPERTY.is( firstPropertyRecordId ) ) { return false; } MutableLongSet visitedPropertyRecordIds = new LongHashSet( 8 ); visitedPropertyRecordIds.add( firstPropertyRecordId ); long nextProp = firstPropertyRecordId; while ( !Record.NO_NEXT_PROPERTY.is( nextProp ) ) { PropertyRecord propRecord = propertyStore.getRecord( nextProp, propertyStore.newRecord(), FORCE ); nextProp = propRecord.getNextProp(); if ( !Record.NO_NEXT_PROPERTY.is( nextProp ) && !visitedPropertyRecordIds.add( nextProp ) ) { throw new CircularPropertyRecordChainException( propRecord ); } if ( visitor.visit( propRecord ) ) { return true; } } return false; }
private void writeSomeData( File file, Visitor<Pair<LogEntryWriter,Consumer<LogPositionMarker>>,IOException> visitor ) throws IOException { try ( LogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel( fileSystemRule.get().open( file, OpenMode.READ_WRITE ), logVersion, CURRENT_LOG_VERSION ); PositionAwarePhysicalFlushableChannel writableLogChannel = new PositionAwarePhysicalFlushableChannel( versionedStoreChannel ) ) { writeLogHeader( writableLogChannel, logVersion, 2L ); Consumer<LogPositionMarker> consumer = marker -> { try { writableLogChannel.getCurrentPosition( marker ); } catch ( IOException e ) { throw new RuntimeException( e ); } }; LogEntryWriter first = new LogEntryWriter( writableLogChannel ); visitor.visit( Pair.of( first, consumer ) ); } } }
public void serialize( Collection<StorageCommand> commands ) throws IOException { for ( StorageCommand command : commands ) { serializer.visit( command ); } }
@Override public boolean accept( Visitor<StorageCommand,IOException> visitor ) throws IOException { for ( StorageCommand command : commands ) { if ( visitor.visit( command ) ) { return true; } } return false; }
/** * Visits this store, and any other store managed by this store. * TODO this could, and probably should, replace all override-and-do-the-same-thing-to-all-my-managed-stores * methods like: * {@link #makeStoreOk()}, * {@link #close()} (where that method could be deleted all together and do a visit in {@link #close()}), * {@link #logIdUsage(Logger)}, * {@link #logVersions(Logger)} * For a good samaritan to pick up later. */ void visitStore( Visitor<CommonAbstractStore<RECORD,HEADER>,RuntimeException> visitor ) { visitor.visit( this ); }
synchronized void visit( Visitor<SegmentFile,RuntimeException> visitor ) { ListIterator<SegmentFile> itr = allSegments.listIterator(); boolean terminate = false; while ( itr.hasNext() && !terminate ) { terminate = visitor.visit( itr.next() ); } }
synchronized void visit( Visitor<SegmentFile,RuntimeException> visitor ) { ListIterator<SegmentFile> itr = allSegments.listIterator(); boolean terminate = false; while ( itr.hasNext() && !terminate ) { terminate = visitor.visit( itr.next() ); } }