Search in sources :

Example 11 with TokenHolders

use of org.neo4j.token.TokenHolders in project neo4j by neo4j.

the class RecordStorageEngineFactory method loadSchemaRules.

@Override
public List<SchemaRule> loadSchemaRules(FileSystemAbstraction fs, PageCache pageCache, Config config, DatabaseLayout databaseLayout, CursorContext cursorContext) {
    StoreFactory factory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.nullLogProvider(), PageCacheTracer.NULL, readOnly());
    try (NeoStores stores = factory.openNeoStores(false, StoreType.SCHEMA, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY)) {
        stores.start(cursorContext);
        TokenHolders tokenHolders = tokenHoldersForSchemaStore(stores, new ReadOnlyTokenCreator(), cursorContext);
        List<SchemaRule> rules = new ArrayList<>();
        new SchemaStorage(stores.getSchemaStore(), tokenHolders, () -> KernelVersion.LATEST).getAll(cursorContext).forEach(rules::add);
        return rules;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) ArrayList(java.util.ArrayList) SchemaRule(org.neo4j.internal.schema.SchemaRule) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) TokenHolders(org.neo4j.token.TokenHolders) ReadOnlyTokenCreator(org.neo4j.token.ReadOnlyTokenCreator)

Example 12 with TokenHolders

use of org.neo4j.token.TokenHolders in project neo4j by neo4j.

the class RecordStorageEngineFactory method createMigrationTargetSchemaRuleAccess.

public static SchemaRuleMigrationAccess createMigrationTargetSchemaRuleAccess(NeoStores stores, CursorContext cursorContext, MemoryTracker memoryTracker) {
    SchemaStore dstSchema = stores.getSchemaStore();
    TokenCreator propertyKeyTokenCreator = (name, internal) -> {
        PropertyKeyTokenStore keyTokenStore = stores.getPropertyKeyTokenStore();
        DynamicStringStore nameStore = keyTokenStore.getNameStore();
        byte[] bytes = PropertyStore.encodeString(name);
        List<DynamicRecord> nameRecords = new ArrayList<>();
        AbstractDynamicStore.allocateRecordsFromBytes(nameRecords, bytes, nameStore, cursorContext, memoryTracker);
        nameRecords.forEach(record -> nameStore.prepareForCommit(record, cursorContext));
        nameRecords.forEach(record -> nameStore.updateRecord(record, cursorContext));
        nameRecords.forEach(record -> nameStore.setHighestPossibleIdInUse(record.getId()));
        int nameId = Iterables.first(nameRecords).getIntId();
        PropertyKeyTokenRecord keyTokenRecord = keyTokenStore.newRecord();
        long tokenId = keyTokenStore.nextId(cursorContext);
        keyTokenRecord.setId(tokenId);
        keyTokenRecord.initialize(true, nameId);
        keyTokenRecord.setInternal(internal);
        keyTokenRecord.setCreated();
        keyTokenStore.prepareForCommit(keyTokenRecord, cursorContext);
        keyTokenStore.updateRecord(keyTokenRecord, cursorContext);
        keyTokenStore.setHighestPossibleIdInUse(keyTokenRecord.getId());
        return Math.toIntExact(tokenId);
    };
    TokenHolders dstTokenHolders = tokenHoldersForSchemaStore(stores, propertyKeyTokenCreator, cursorContext);
    return new SchemaRuleMigrationAccessImpl(stores, new SchemaStorage(dstSchema, dstTokenHolders, () -> KernelVersion.LATEST), cursorContext, memoryTracker);
}
Also used : Arrays(java.util.Arrays) Sets.immutable(org.eclipse.collections.api.factory.Sets.immutable) SchemaRule(org.neo4j.internal.schema.SchemaRule) PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) CursorContext(org.neo4j.io.pagecache.context.CursorContext) TokenCreator(org.neo4j.token.TokenCreator) AbstractDynamicStore(org.neo4j.kernel.impl.store.AbstractDynamicStore) Config(org.neo4j.configuration.Config) RecordStoreVersion(org.neo4j.kernel.impl.storemigration.RecordStoreVersion) NullLogProvider(org.neo4j.logging.NullLogProvider) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ScanOnOpenReadOnlyIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory) ConstraintRuleAccessor(org.neo4j.storageengine.api.ConstraintRuleAccessor) ReadOnlyTokenCreator(org.neo4j.token.ReadOnlyTokenCreator) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) Path(java.nio.file.Path) PageCache(org.neo4j.io.pagecache.PageCache) StorageFilesState(org.neo4j.storageengine.api.StorageFilesState) StorageEngine(org.neo4j.storageengine.api.StorageEngine) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) Set(java.util.Set) UUID(java.util.UUID) LockService(org.neo4j.lock.LockService) DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) DbmsReadOnlyChecker(org.neo4j.configuration.helpers.DbmsReadOnlyChecker) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) StoreType(org.neo4j.kernel.impl.store.StoreType) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) Optional(java.util.Optional) ServiceProvider(org.neo4j.annotations.service.ServiceProvider) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) StoreVersion(org.neo4j.storageengine.api.StoreVersion) IdController(org.neo4j.internal.id.IdController) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) RecordStorageMigrator(org.neo4j.kernel.impl.storemigration.RecordStorageMigrator) KernelVersion(org.neo4j.kernel.KernelVersion) LogProvider(org.neo4j.logging.LogProvider) RecordFormatSelector(org.neo4j.kernel.impl.store.format.RecordFormatSelector) ArrayList(java.util.ArrayList) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) TokenHolder(org.neo4j.token.api.TokenHolder) IndexConfigCompleter(org.neo4j.internal.schema.IndexConfigCompleter) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Iterables(org.neo4j.internal.helpers.collection.Iterables) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) StoreId(org.neo4j.storageengine.api.StoreId) JobScheduler(org.neo4j.scheduler.JobScheduler) MemoryTracker(org.neo4j.memory.MemoryTracker) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) SchemaRuleMigrationAccess(org.neo4j.storageengine.migration.SchemaRuleMigrationAccess) RecordFormatSelector.selectForStoreOrConfig(org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectForStoreOrConfig) CommandReaderFactory(org.neo4j.storageengine.api.CommandReaderFactory) IdGeneratorMigrator(org.neo4j.kernel.impl.storemigration.IdGeneratorMigrator) RecordFormatSelector.selectForVersion(org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectForVersion) IOException(java.io.IOException) StoreMigrationParticipant(org.neo4j.storageengine.migration.StoreMigrationParticipant) DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) LogService(org.neo4j.logging.internal.LogService) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) MetadataProvider(org.neo4j.storageengine.api.MetadataProvider) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) Collectors.toList(java.util.stream.Collectors.toList) TokenHolders(org.neo4j.token.TokenHolders) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) SchemaState(org.neo4j.internal.schema.SchemaState) RecordStoreRollingUpgradeCompatibility(org.neo4j.kernel.impl.storemigration.RecordStoreRollingUpgradeCompatibility) BatchImporterFactory(org.neo4j.internal.batchimport.BatchImporterFactory) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) META_DATA(org.neo4j.kernel.impl.store.StoreType.META_DATA) RecordStoreVersionCheck(org.neo4j.kernel.impl.storemigration.RecordStoreVersionCheck) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) RollingUpgradeCompatibility(org.neo4j.storageengine.migration.RollingUpgradeCompatibility) PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) TokenHolders(org.neo4j.token.TokenHolders) TokenCreator(org.neo4j.token.TokenCreator) ReadOnlyTokenCreator(org.neo4j.token.ReadOnlyTokenCreator) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 13 with TokenHolders

use of org.neo4j.token.TokenHolders in project neo4j by neo4j.

the class Recovery method performRecovery.

/**
 * Performs recovery of database described by provided layout.
 *
 * @param fs database filesystem
 * @param pageCache page cache used to perform database recovery.
 * @param tracers underlying operation tracers
 * @param config custom configuration
 * @param databaseLayout database to recover layout.
 * @param storageEngineFactory {@link StorageEngineFactory} for the storage to recover.
 * @param logProvider log provider
 * @param globalMonitors global server monitors
 * @param extensionFactories extension factories for extensions that should participate in recovery
 * @param providedLogFiles log files from database
 * @param forceRunRecovery to force recovery to run even if the usual checks indicates that it's not required.
 * In specific cases, like after store copy there's always a need for doing a recovery or at least to start the db, checkpoint and shut down,
 * even if the normal "is recovery required" checks says that recovery isn't required.
 * @throws IOException on any unexpected I/O exception encountered during recovery.
 */
public static void performRecovery(FileSystemAbstraction fs, PageCache pageCache, DatabaseTracers tracers, Config config, DatabaseLayout databaseLayout, StorageEngineFactory storageEngineFactory, boolean forceRunRecovery, LogProvider logProvider, Monitors globalMonitors, Iterable<ExtensionFactory<?>> extensionFactories, Optional<LogFiles> providedLogFiles, RecoveryStartupChecker startupChecker, MemoryTracker memoryTracker, Clock clock) throws IOException {
    Log recoveryLog = logProvider.getLog(Recovery.class);
    if (!forceRunRecovery && !isRecoveryRequired(fs, pageCache, databaseLayout, storageEngineFactory, config, providedLogFiles, memoryTracker)) {
        return;
    }
    checkAllFilesPresence(databaseLayout, fs, pageCache, storageEngineFactory);
    LifeSupport recoveryLife = new LifeSupport();
    Monitors monitors = new Monitors(globalMonitors, logProvider);
    DatabasePageCache databasePageCache = new DatabasePageCache(pageCache, IOController.DISABLED);
    SimpleLogService logService = new SimpleLogService(logProvider);
    VersionAwareLogEntryReader logEntryReader = new VersionAwareLogEntryReader(storageEngineFactory.commandReaderFactory());
    DatabaseReadOnlyChecker readOnlyChecker = writable();
    DatabaseSchemaState schemaState = new DatabaseSchemaState(logProvider);
    JobScheduler scheduler = JobSchedulerFactory.createInitialisedScheduler();
    VersionContextSupplier versionContextSupplier = EmptyVersionContextSupplier.EMPTY;
    DatabaseHealth databaseHealth = new DatabaseHealth(PanicEventGenerator.NO_OP, recoveryLog);
    TokenHolders tokenHolders = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), TYPE_RELATIONSHIP_TYPE));
    RecoveryCleanupWorkCollector recoveryCleanupCollector = new GroupingRecoveryCleanupWorkCollector(scheduler, INDEX_CLEANUP, INDEX_CLEANUP_WORK, databaseLayout.getDatabaseName());
    DatabaseExtensions extensions = instantiateRecoveryExtensions(databaseLayout, fs, config, logService, databasePageCache, scheduler, DbmsInfo.TOOL, monitors, tokenHolders, recoveryCleanupCollector, readOnlyChecker, extensionFactories, tracers.getPageCacheTracer());
    DefaultIndexProviderMap indexProviderMap = new DefaultIndexProviderMap(extensions, config);
    StorageEngine storageEngine = storageEngineFactory.instantiate(fs, databaseLayout, config, databasePageCache, tokenHolders, schemaState, getConstraintSemantics(), indexProviderMap, NO_LOCK_SERVICE, new DefaultIdGeneratorFactory(fs, recoveryCleanupCollector, databaseLayout.getDatabaseName()), new DefaultIdController(), databaseHealth, logService.getInternalLogProvider(), recoveryCleanupCollector, tracers.getPageCacheTracer(), true, readOnlyChecker, memoryTracker);
    // Schema indexes
    FullScanStoreView fullScanStoreView = new FullScanStoreView(NO_LOCK_SERVICE, storageEngine::newReader, config, scheduler);
    IndexStoreViewFactory indexStoreViewFactory = new IndexStoreViewFactory(config, storageEngine::newReader, NO_LOCKS, fullScanStoreView, NO_LOCK_SERVICE, logProvider);
    IndexStatisticsStore indexStatisticsStore = new IndexStatisticsStore(databasePageCache, databaseLayout, recoveryCleanupCollector, readOnlyChecker, tracers.getPageCacheTracer());
    IndexingService indexingService = Database.buildIndexingService(storageEngine, schemaState, indexStoreViewFactory, indexStatisticsStore, config, scheduler, indexProviderMap, tokenHolders, logProvider, logProvider, monitors.newMonitor(IndexingService.Monitor.class), tracers.getPageCacheTracer(), memoryTracker, databaseLayout.getDatabaseName(), readOnlyChecker);
    MetadataProvider metadataProvider = storageEngine.metadataProvider();
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependencies(databaseLayout, config, databasePageCache, fs, logProvider, tokenHolders, schemaState, getConstraintSemantics(), NO_LOCK_SERVICE, databaseHealth, new DefaultIdGeneratorFactory(fs, recoveryCleanupCollector, databaseLayout.getDatabaseName()), new DefaultIdController(), readOnlyChecker, versionContextSupplier, logService, metadataProvider);
    LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(logEntryReader).withConfig(config).withDependencies(dependencies).withMemoryTracker(memoryTracker).build();
    boolean failOnCorruptedLogFiles = config.get(GraphDatabaseInternalSettings.fail_on_corrupted_log_files);
    validateStoreId(logFiles, storageEngine.getStoreId(), config);
    TransactionMetadataCache metadataCache = new TransactionMetadataCache();
    PhysicalLogicalTransactionStore transactionStore = new PhysicalLogicalTransactionStore(logFiles, metadataCache, logEntryReader, monitors, failOnCorruptedLogFiles);
    BatchingTransactionAppender transactionAppender = new BatchingTransactionAppender(logFiles, LogRotation.NO_ROTATION, metadataCache, metadataProvider, databaseHealth);
    LifeSupport schemaLife = new LifeSupport();
    schemaLife.add(storageEngine.schemaAndTokensLifecycle());
    schemaLife.add(indexingService);
    var doParallelRecovery = config.get(GraphDatabaseInternalSettings.do_parallel_recovery);
    TransactionLogsRecovery transactionLogsRecovery = transactionLogRecovery(fs, metadataProvider, monitors.newMonitor(RecoveryMonitor.class), monitors.newMonitor(RecoveryStartInformationProvider.Monitor.class), logFiles, storageEngine, transactionStore, metadataProvider, schemaLife, databaseLayout, failOnCorruptedLogFiles, recoveryLog, startupChecker, tracers.getPageCacheTracer(), memoryTracker, doParallelRecovery);
    CheckPointerImpl.ForceOperation forceOperation = new DefaultForceOperation(indexingService, storageEngine);
    var checkpointAppender = logFiles.getCheckpointFile().getCheckpointAppender();
    CheckPointerImpl checkPointer = new CheckPointerImpl(metadataProvider, RecoveryThreshold.INSTANCE, forceOperation, LogPruning.NO_PRUNING, checkpointAppender, databaseHealth, logProvider, tracers, IOController.DISABLED, new StoreCopyCheckPointMutex(), versionContextSupplier, clock);
    recoveryLife.add(scheduler);
    recoveryLife.add(recoveryCleanupCollector);
    recoveryLife.add(extensions);
    recoveryLife.add(indexProviderMap);
    recoveryLife.add(storageEngine);
    recoveryLife.add(new MissingTransactionLogsCheck(databaseLayout, config, fs, logFiles, recoveryLog));
    recoveryLife.add(logFiles);
    recoveryLife.add(transactionLogsRecovery);
    recoveryLife.add(transactionAppender);
    recoveryLife.add(checkPointer);
    try {
        recoveryLife.start();
        if (databaseHealth.isHealthy()) {
            checkPointer.forceCheckPoint(new SimpleTriggerInfo("Recovery completed."));
        }
    } finally {
        recoveryLife.shutdown();
    }
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) CheckPointerImpl(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointerImpl) SimpleLogService(org.neo4j.logging.internal.SimpleLogService) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) GroupingRecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.GroupingRecoveryCleanupWorkCollector) StorageEngine(org.neo4j.storageengine.api.StorageEngine) StorageEngineFactory.selectStorageEngine(org.neo4j.storageengine.api.StorageEngineFactory.selectStorageEngine) DatabasePageCache(org.neo4j.dbms.database.DatabasePageCache) VersionContextSupplier(org.neo4j.io.pagecache.context.VersionContextSupplier) EmptyVersionContextSupplier(org.neo4j.io.pagecache.context.EmptyVersionContextSupplier) DefaultIdController(org.neo4j.internal.id.DefaultIdController) SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) DatabaseSchemaState(org.neo4j.kernel.impl.api.DatabaseSchemaState) FullScanStoreView(org.neo4j.kernel.impl.transaction.state.storeview.FullScanStoreView) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) StoreCopyCheckPointMutex(org.neo4j.kernel.impl.transaction.log.checkpoint.StoreCopyCheckPointMutex) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) Dependencies(org.neo4j.collection.Dependencies) TokenHolders(org.neo4j.token.TokenHolders) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) JobScheduler(org.neo4j.scheduler.JobScheduler) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) NullLog(org.neo4j.logging.NullLog) Log(org.neo4j.logging.Log) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) DatabaseExtensions(org.neo4j.kernel.extension.DatabaseExtensions) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) GroupingRecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.GroupingRecoveryCleanupWorkCollector) IndexStoreViewFactory(org.neo4j.kernel.impl.transaction.state.storeview.IndexStoreViewFactory) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) MetadataProvider(org.neo4j.storageengine.api.MetadataProvider) Monitors(org.neo4j.monitoring.Monitors) DefaultForceOperation(org.neo4j.kernel.database.DefaultForceOperation) ReadOnlyTokenCreator(org.neo4j.token.ReadOnlyTokenCreator)

Example 14 with TokenHolders

use of org.neo4j.token.TokenHolders in project neo4j by neo4j.

the class RecordStorageReaderTestBase method before.

@BeforeEach
public void before() throws Throwable {
    this.tokenHolders = new TokenHolders(new DelegatingTokenHolder(new SimpleTokenCreator(), TokenHolder.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new SimpleTokenCreator(), TokenHolder.TYPE_LABEL), new DelegatingTokenHolder(new SimpleTokenCreator(), TokenHolder.TYPE_RELATIONSHIP_TYPE));
    RecordStorageEngineRule.Builder builder = storageEngineRule.getWith(fs, pageCache, databaseLayout).tokenHolders(tokenHolders);
    builder = modify(builder);
    this.storageEngine = builder.build();
    this.storageReader = storageEngine.newReader();
    this.commitReader = storageEngine.newReader();
    this.commitContext = storageEngine.newCommandCreationContext(INSTANCE);
    commitContext.initialize(NULL);
    storageEngineRule.before();
}
Also used : TokenHolders(org.neo4j.token.TokenHolders) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) RecordStorageEngineRule(org.neo4j.test.rule.RecordStorageEngineRule) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with TokenHolders

use of org.neo4j.token.TokenHolders in project neo4j by neo4j.

the class GraphStoreFixture method writableTokenHolders.

public TokenHolders writableTokenHolders() {
    TokenHolder propertyKeyTokens = new DelegatingTokenHolder(buildTokenCreator((name, internal, tx, next) -> {
        int id = next.propertyKey();
        tx.propertyKey(id, name, internal);
        return id;
    }), TokenHolder.TYPE_PROPERTY_KEY);
    TokenHolder labelTokens = new DelegatingTokenHolder(buildTokenCreator((name, internal, tx, next) -> {
        int id = next.label();
        tx.nodeLabel(id, name, internal);
        return id;
    }), TokenHolder.TYPE_LABEL);
    TokenHolder relationshipTypeTokens = new DelegatingTokenHolder(buildTokenCreator((name, internal, tx, next) -> {
        int id = next.relationshipType();
        tx.relationshipType(id, name, internal);
        return id;
    }), TokenHolder.TYPE_RELATIONSHIP_TYPE);
    TokenHolders tokenHolders = new TokenHolders(propertyKeyTokens, labelTokens, relationshipTypeTokens);
    tokenHolders.setInitialTokens(allReadableTokens(directStoreAccess().nativeStores()), NULL);
    return tokenHolders;
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) SchemaRule(org.neo4j.internal.schema.SchemaRule) TokenCreator(org.neo4j.token.TokenCreator) StoreTokens.allReadableTokens(org.neo4j.internal.recordstorage.StoreTokens.allReadableTokens) Preconditions(org.neo4j.util.Preconditions) ThrowingSupplier(org.neo4j.function.ThrowingSupplier) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) NodeLabelsField(org.neo4j.kernel.impl.store.NodeLabelsField) StorageNodeCursor(org.neo4j.storageengine.api.StorageNodeCursor) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) LookupAccessorsFromRunningDb(org.neo4j.consistency.LookupAccessorsFromRunningDb) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) Map(java.util.Map) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) PageCache(org.neo4j.io.pagecache.PageCache) RelationshipGroupDegreesStore(org.neo4j.internal.counts.RelationshipGroupDegreesStore) StorageEngine(org.neo4j.storageengine.api.StorageEngine) IndexProviderMap(org.neo4j.kernel.impl.api.index.IndexProviderMap) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) TestDirectory(org.neo4j.test.rule.TestDirectory) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) StandardCharsets(java.nio.charset.StandardCharsets) InternalTransactionCommitProcess(org.neo4j.kernel.impl.api.InternalTransactionCommitProcess) StoragePropertyCursor(org.neo4j.storageengine.api.StoragePropertyCursor) DirectStoreAccess(org.neo4j.consistency.store.DirectStoreAccess) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) RecordStore(org.neo4j.kernel.impl.store.RecordStore) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) StoreType(org.neo4j.kernel.impl.store.StoreType) ANY_LABEL(org.neo4j.internal.kernel.api.TokenRead.ANY_LABEL) NodeStore(org.neo4j.kernel.impl.store.NodeStore) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) CountsStore(org.neo4j.counts.CountsStore) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) TransactionAppender(org.neo4j.kernel.impl.transaction.log.TransactionAppender) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) System.currentTimeMillis(java.lang.System.currentTimeMillis) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) TokenHolder(org.neo4j.token.api.TokenHolder) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NeoStores(org.neo4j.kernel.impl.store.NeoStores) EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) StorageReader(org.neo4j.storageengine.api.StorageReader) TransactionApplicationMode(org.neo4j.storageengine.api.TransactionApplicationMode) GraphDatabaseInternalSettings(org.neo4j.configuration.GraphDatabaseInternalSettings) DependencyResolver(org.neo4j.common.DependencyResolver) Iterator(java.util.Iterator) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Setting(org.neo4j.graphdb.config.Setting) IOException(java.io.IOException) IndexAccessors(org.neo4j.consistency.checking.index.IndexAccessors) PrefetchingIterator(org.neo4j.internal.helpers.collection.PrefetchingIterator) TokenStore(org.neo4j.kernel.impl.store.TokenStore) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) Consumer(java.util.function.Consumer) CountsAccessor(org.neo4j.counts.CountsAccessor) LongIterator(org.eclipse.collections.api.iterator.LongIterator) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) KernelException(org.neo4j.exceptions.KernelException) TokenHolders(org.neo4j.token.TokenHolders) NamedToken(org.neo4j.token.api.NamedToken) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) CommitEvent(org.neo4j.kernel.impl.transaction.tracing.CommitEvent) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) TokenHolder(org.neo4j.token.api.TokenHolder) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) TokenHolders(org.neo4j.token.TokenHolders) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder)

Aggregations

TokenHolders (org.neo4j.token.TokenHolders)22 DelegatingTokenHolder (org.neo4j.token.DelegatingTokenHolder)12 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)10 NeoStores (org.neo4j.kernel.impl.store.NeoStores)9 PageCache (org.neo4j.io.pagecache.PageCache)8 JobScheduler (org.neo4j.scheduler.JobScheduler)8 SchemaRule (org.neo4j.internal.schema.SchemaRule)7 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 Config (org.neo4j.configuration.Config)6 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)6 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)6 TokenHolder (org.neo4j.token.api.TokenHolder)6 Path (java.nio.file.Path)5 DatabaseReadOnlyChecker.writable (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable)5 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)5 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)5 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)5