public IdSequence idGenerator( StoreType type ) { return types[type.ordinal()]; }
@Override protected CommonAbstractStore underlyingObjectToObject( StoreType type ) { return (CommonAbstractStore) stores[type.ordinal()]; } } );
public void assertOpen() { if ( stores[StoreType.NODE.ordinal()] == null ) { throw new IllegalStateException( "Database has been shutdown" ); } }
@Override public boolean test( StoreType type ) { return type.isRecordStore() && stores[type.ordinal()] != null; } };
private Object openStore( StoreType type ) { int storeIndex = type.ordinal(); Object store = type.open( this ); stores[storeIndex] = store; return store; }
private void closeStore( StoreType type ) { int i = type.ordinal(); if ( stores[i] != null ) { try { type.close( stores[i] ); } finally { stores[i] = null; } } }
/** * Returns specified store by type from already opened store array. Will open a new store if can't find any. * Should be used only during construction of stores. * * @see #getStore * @param storeType store type to get or create * @return store of requested type */ private Object getOrCreateStore( StoreType storeType ) { Object store = stores[storeType.ordinal()]; if ( store == null ) { store = openStore( storeType ); } return store; }
/** * Returns specified store by type from already opened store array. If store is not opened exception will be * thrown. * * @see #getOrCreateStore * @param storeType store type to retrieve * @return store of requested type * @throws IllegalStateException if opened store not found */ private Object getStore( StoreType storeType ) { Object store = stores[storeType.ordinal()]; if ( store == null ) { String message = ArrayUtil.contains( initializedStores, storeType ) ? STORE_ALREADY_CLOSED_MESSAGE : String.format( STORE_NOT_INITIALIZED_TEMPLATE, storeType.name() ); throw new IllegalStateException( message ); } return store; }
public RenewableBatchIdSequences( NeoStores stores, int batchSize ) { for ( StoreType type : StoreType.values() ) { if ( type.isRecordStore() ) { RecordStore<AbstractBaseRecord> store = stores.getRecordStore( type ); if ( type.isLimitedIdStore() || batchSize == 1 ) { // This is a token store or otherwise meta-data store, so let's not add batching for it types[type.ordinal()] = store; } else { // This is a normal record store where id batching is beneficial types[type.ordinal()] = new RenewableBatchIdSequence( store, batchSize, store::freeId ); } } } }
public void flush( IOLimiter limiter ) { try { CountsTracker counts = (CountsTracker) stores[StoreType.COUNTS.ordinal()]; if ( counts != null ) { counts.rotate( getMetaDataStore().getLastCommittedTransactionId() ); } pageCache.flushAndForce( limiter ); } catch ( IOException e ) { throw new UnderlyingStorageException( "Failed to flush", e ); } }
public IdSequence idGenerator( StoreType type ) { return types[type.ordinal()]; }
@Override protected CommonAbstractStore underlyingObjectToObject( StoreType type ) { return (CommonAbstractStore) stores[type.ordinal()]; } } );
public void assertOpen() { if ( stores[StoreType.NODE.ordinal()] == null ) { throw new IllegalStateException( "Database has been shutdown" ); } }
@Override public boolean test( StoreType type ) { return type.isRecordStore() && stores[type.ordinal()] != null; } };
private Object openStore( StoreType type ) { int storeIndex = type.ordinal(); Object store = type.open( this ); stores[storeIndex] = store; return store; }
private void closeStore( StoreType type ) { int i = type.ordinal(); if ( stores[i] != null ) { try { type.close( stores[i] ); } finally { stores[i] = null; } } }
/** * Returns specified store by type from already opened store array. Will open a new store if can't find any. * Should be used only during construction of stores. * * @see #getStore * @param storeType store type to get or create * @return store of requested type */ private Object getOrCreateStore( StoreType storeType ) { Object store = stores[storeType.ordinal()]; if ( store == null ) { store = openStore( storeType ); } return store; }
/** * Returns specified store by type from already opened store array. If store is not opened exception will be * thrown. * * @see #getOrCreateStore * @param storeType store type to retrieve * @return store of requested type * @throws IllegalStateException if opened store not found */ private Object getStore( StoreType storeType ) { Object store = stores[storeType.ordinal()]; if ( store == null ) { String message = ArrayUtil.contains( initializedStores, storeType ) ? STORE_ALREADY_CLOSED_MESSAGE : String.format( STORE_NOT_INITIALIZED_TEMPLATE, storeType.name() ); throw new IllegalStateException( message ); } return store; }
public RenewableBatchIdSequences( NeoStores stores, int batchSize ) { for ( StoreType type : StoreType.values() ) { if ( type.isRecordStore() ) { RecordStore<AbstractBaseRecord> store = stores.getRecordStore( type ); if ( type.isLimitedIdStore() || batchSize == 1 ) { // This is a token store or otherwise meta-data store, so let's not add batching for it types[type.ordinal()] = store; } else { // This is a normal record store where id batching is beneficial types[type.ordinal()] = new RenewableBatchIdSequence( store, batchSize, store::freeId ); } } } }
public void flush( IOLimiter limiter ) { try { CountsTracker counts = (CountsTracker) stores[StoreType.COUNTS.ordinal()]; if ( counts != null ) { counts.rotate( getMetaDataStore().getLastCommittedTransactionId() ); } pageCache.flushAndForce( limiter ); } catch ( IOException e ) { throw new UnderlyingStorageException( "Failed to flush", e ); } }