@Override protected SchemaStore getStore( NeoStores neoStores ) { return neoStores.getSchemaStore(); }
@Override public boolean visitSchemaRuleCommand( SchemaRuleCommand command ) { SchemaStore schemaStore = neoStores.getSchemaStore(); for ( DynamicRecord record : command.getRecordsAfter() ) { track( schemaStore, record ); } return false; }
@Override public void loadSchemaCache() { List<SchemaRule> schemaRules = Iterators.asList( neoStores.getSchemaStore().loadAllSchemaRules() ); schemaCache.load( schemaRules ); }
@Before public void setup() { when( neoStores.getMetaDataStore() ).thenReturn( metaDataStore ); when( neoStores.getNodeStore() ).thenReturn( nodeStore ); when( neoStores.getRelationshipStore() ).thenReturn( relationshipStore ); when( neoStores.getPropertyStore() ).thenReturn( propertyStore ); when( neoStores.getRelationshipGroupStore() ).thenReturn( relationshipGroupStore ); when( neoStores.getRelationshipTypeTokenStore() ).thenReturn( relationshipTypeTokenStore ); when( neoStores.getLabelTokenStore() ).thenReturn( labelTokenStore ); when( neoStores.getPropertyKeyTokenStore() ).thenReturn( propertyKeyTokenStore ); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); when( nodeStore.getDynamicLabelStore() ).thenReturn( dynamicLabelStore ); when( lockService.acquireNodeLock( anyLong(), any() ) ) .thenReturn( LockService.NO_LOCK ); when( lockService.acquireRelationshipLock( anyLong(), any() ) ) .thenReturn( LockService.NO_LOCK ); when( transactionToApply.transactionId() ).thenReturn( transactionId ); }
@Test public void shouldDropSchemaRuleFromIndex() throws Exception { // GIVEN SchemaRecord beforeRecords = serialize( rule, id, true, true); SchemaRecord afterRecords = serialize( rule, id, false, false); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); // WHEN visitSchemaRuleCommand( indexApplier, new SchemaRuleCommand( beforeRecords, afterRecords, rule ) ); // THEN verify( indexes ).dropIndex( rule ); }
public Loaders( NeoStores neoStores ) { this( neoStores.getNodeStore(), neoStores.getPropertyStore(), neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore(), neoStores.getPropertyKeyTokenStore(), neoStores.getRelationshipTypeTokenStore(), neoStores.getLabelTokenStore(), neoStores.getSchemaStore() ); }
@Test public void shouldCreateIndexForCreatedSchemaRule() throws Exception { // GIVEN SchemaRecord beforeRecords = serialize( rule, id, false, false); SchemaRecord afterRecords = serialize( rule, id, true, true); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); // WHEN visitSchemaRuleCommand( indexApplier, new SchemaRuleCommand( beforeRecords, afterRecords, rule ) ); // THEN verify( indexes ).createIndexes( rule ); }
public DirectRecordAccessSet( NeoStores neoStores ) { this( neoStores.getNodeStore(), neoStores.getPropertyStore(), neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore(), neoStores.getPropertyKeyTokenStore(), neoStores.getRelationshipTypeTokenStore(), neoStores.getLabelTokenStore(), neoStores.getSchemaStore() ); }
TransactionRecordState( NeoStores neoStores, IntegrityValidator integrityValidator, RecordChangeSet recordChangeSet, long lastCommittedTxWhenTransactionStarted, ResourceLocker locks, RelationshipCreator relationshipCreator, RelationshipDeleter relationshipDeleter, PropertyCreator propertyCreator, PropertyDeleter propertyDeleter ) { this.neoStores = neoStores; this.nodeStore = neoStores.getNodeStore(); this.relationshipStore = neoStores.getRelationshipStore(); this.propertyStore = neoStores.getPropertyStore(); this.relationshipGroupStore = neoStores.getRelationshipGroupStore(); this.metaDataStore = neoStores.getMetaDataStore(); this.schemaStore = neoStores.getSchemaStore(); this.integrityValidator = integrityValidator; this.recordChangeSet = recordChangeSet; this.lastCommittedTxWhenTransactionStarted = lastCommittedTxWhenTransactionStarted; this.locks = locks; this.relationshipCreator = relationshipCreator; this.relationshipDeleter = relationshipDeleter; this.propertyCreator = propertyCreator; this.propertyDeleter = propertyDeleter; }
private List<StoreIndexDescriptor> getIndexRules( NeoStores neoStores ) { return Iterators.asList( new SchemaStorage( neoStores.getSchemaStore() ).indexesGetAll() ); }
@Test public void shouldDropSchemaRuleFromStore() throws Exception { // GIVEN SchemaRecord beforeRecords = serialize( rule, id, true, true); SchemaRecord afterRecords = serialize( rule, id, false, false); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); // WHEN visitSchemaRuleCommand( storeApplier, new SchemaRuleCommand( beforeRecords, afterRecords, rule ) ); // THEN verify( schemaStore ).updateRecord( Iterables.first( afterRecords ) ); }
@Test public void shouldWriteCreatedSchemaRuleToStore() throws Exception { // GIVEN SchemaRecord beforeRecords = serialize( rule, id, false, false); SchemaRecord afterRecords = serialize( rule, id, true, true); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); // WHEN visitSchemaRuleCommand( storeApplier, new SchemaRuleCommand( beforeRecords, afterRecords, rule ) ); // THEN verify( schemaStore ).updateRecord( Iterables.first( afterRecords ) ); }
@Override public void indexPopulationScanComplete() { monitorCalled.set( true ); db.getDependencyResolver().resolveDependency( RecordStorageEngine.class ).testAccessNeoStores() .getSchemaStore().flush(); storeInNeedOfRecovery[0] = fs.snapshot(); } } );
@Test public void shouldValidateConstraintIndexAsPartOfExtraction() throws Throwable { // GIVEN NeoStores neoStores = neoStoresRule.builder().build(); TransactionRecordState recordState = newTransactionRecordState( neoStores ); final long indexId = neoStores.getSchemaStore().nextId(); final long constraintId = neoStores.getSchemaStore().nextId(); recordState.createSchemaRule( constraintRule( constraintId, uniqueForLabel( 1, 1 ), indexId ) ); // WHEN recordState.extractCommands( new ArrayList<>() ); // THEN verify( integrityValidator ).validateSchemaRule( any() ); }
@Test public void shouldSetLatestConstraintRule() throws Exception { // Given SchemaRecord beforeRecords = serialize( rule, id, true, true); SchemaRecord afterRecords = serialize( rule, id, true, false); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); when( neoStores.getMetaDataStore() ).thenReturn( metaDataStore ); ConstraintRule schemaRule = ConstraintRule.constraintRule( id, ConstraintDescriptorFactory.uniqueForLabel( labelId, propertyKey ), 0 ); // WHEN visitSchemaRuleCommand( storeApplier, new SchemaRuleCommand( beforeRecords, afterRecords, schemaRule ) ); // THEN verify( schemaStore ).updateRecord( Iterables.first( afterRecords ) ); verify( metaDataStore ).setLatestConstraintIntroducingTx( txId ); }
@Test public void shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk() throws Exception { // GIVEN SchemaRecord beforeRecords = serialize( rule, id, true, true); SchemaRecord afterRecords = serialize( rule, id, false, false); SchemaRuleCommand command = new SchemaRuleCommand( beforeRecords, afterRecords, rule ); InMemoryClosableChannel buffer = new InMemoryClosableChannel(); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); // WHEN command.serialize( buffer ); Command readCommand = reader.read( buffer ); // THEN assertThat( readCommand, instanceOf( SchemaRuleCommand.class ) ); assertSchemaRule( (SchemaRuleCommand)readCommand ); }
@Test public void shouldWriteSchemaRuleToLog() throws Exception { // GIVEN SchemaRecord beforeRecords = serialize( rule, id, false, false); SchemaRecord afterRecords = serialize( rule, id, true, true); SchemaRuleCommand command = new SchemaRuleCommand( beforeRecords, afterRecords, rule ); InMemoryClosableChannel buffer = new InMemoryClosableChannel(); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); // WHEN command.serialize( buffer ); Command readCommand = reader.read( buffer ); // THEN assertThat( readCommand, instanceOf( SchemaRuleCommand.class ) ); assertSchemaRule( (SchemaRuleCommand)readCommand ); }
private void createStore( DatabaseLayout migrationDirectoryStructure, RecordFormats newFormat ) { IdGeneratorFactory idGeneratorFactory = new ReadOnlyIdGeneratorFactory( fileSystem ); NullLogProvider logProvider = NullLogProvider.getInstance(); StoreFactory storeFactory = new StoreFactory( migrationDirectoryStructure, config, idGeneratorFactory, pageCache, fileSystem, newFormat, logProvider, EmptyVersionContextSupplier.EMPTY ); try ( NeoStores neoStores = storeFactory.openAllNeoStores( true ) ) { neoStores.getMetaDataStore(); neoStores.getLabelTokenStore(); neoStores.getNodeStore(); neoStores.getPropertyStore(); neoStores.getRelationshipGroupStore(); neoStores.getRelationshipStore(); neoStores.getSchemaStore(); } }
@Before public void before() { config = Config.defaults(); DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory( fs.get() ); storeFactory = new StoreFactory( testDirectory.databaseLayout(), config, idGeneratorFactory, pageCacheRule.getPageCache( fs.get() ), fs.get(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); neoStores = storeFactory.openAllNeoStores( true ); store = neoStores.getSchemaStore(); }
@BeforeClass public static void initStorage() throws Exception { try ( Transaction transaction = db.beginTx() ) { TokenWrite tokenWrite = getTransaction().tokenWrite(); tokenWrite.propertyKeyGetOrCreateForName( PROP1 ); tokenWrite.propertyKeyGetOrCreateForName( PROP2 ); tokenWrite.labelGetOrCreateForName( LABEL1 ); tokenWrite.labelGetOrCreateForName( LABEL2 ); tokenWrite.relationshipTypeGetOrCreateForName( TYPE1 ); transaction.success(); } SchemaStore schemaStore = resolveDependency( RecordStorageEngine.class ).testAccessNeoStores().getSchemaStore(); storage = new SchemaStorage( schemaStore ); }