Search in sources :

Example 61 with LogProvider

use of org.neo4j.logging.LogProvider in project neo4j by neo4j.

the class NeoStoreOpenFailureTest method mustCloseAllStoresIfNeoStoresFailToOpen.

@Test
@DisabledForRoot
void mustCloseAllStoresIfNeoStoresFailToOpen() {
    Config config = Config.defaults();
    IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName());
    LogProvider logProvider = NullLogProvider.getInstance();
    RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
    RecordFormatPropertyConfigurator.configureRecordFormat(formats, config);
    boolean create = true;
    StoreType[] storeTypes = StoreType.values();
    ImmutableSet<OpenOption> openOptions = immutable.empty();
    NeoStores neoStores = new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions);
    Path schemaStore = neoStores.getSchemaStore().getStorageFile();
    neoStores.close();
    // Make the schema store inaccessible, to sabotage the next initialisation we'll do.
    assumeTrue(schemaStore.toFile().setReadable(false));
    assumeTrue(schemaStore.toFile().setWritable(false));
    assertThrows(RuntimeException.class, () -> new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions));
    // We verify that the successfully opened stores were closed again by the failed NeoStores open,
    // by closing the page cache, which will throw if not all files have been unmapped.
    pageCache.close();
}
Also used : Path(java.nio.file.Path) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) OpenOption(java.nio.file.OpenOption) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) Test(org.junit.jupiter.api.Test) DisabledForRoot(org.neo4j.test.extension.DisabledForRoot)

Example 62 with LogProvider

use of org.neo4j.logging.LogProvider in project neo4j by neo4j.

the class CommonAbstractStoreTest method newStore.

private TheStore newStore() {
    LogProvider log = NullLogProvider.getInstance();
    TheStore store = new TheStore(storeFile, idStoreFile, config, idType, idGeneratorFactory, mockedPageCache, log, recordFormat, immutable.empty());
    store.initialise(false, NULL);
    return store;
}
Also used : NullLogProvider(org.neo4j.logging.NullLogProvider) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) LogProvider(org.neo4j.logging.LogProvider)

Example 63 with LogProvider

use of org.neo4j.logging.LogProvider in project neo4j by neo4j.

the class MetaDataStoreTest method newMetaDataStore.

private MetaDataStore newMetaDataStore(PageCacheTracer pageCacheTracer) {
    LogProvider logProvider = NullLogProvider.getInstance();
    StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCacheWithFakeOverflow, fs, logProvider, pageCacheTracer, writable());
    return storeFactory.openNeoStores(true, StoreType.META_DATA).getMetaDataStore();
}
Also used : NullLogProvider(org.neo4j.logging.NullLogProvider) LogProvider(org.neo4j.logging.LogProvider) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory)

Example 64 with LogProvider

use of org.neo4j.logging.LogProvider in project neo4j by neo4j.

the class LockWorkFailureDump method dumpState.

public Path dumpState(Locks lm, LockWorker... workers) throws IOException {
    try (OutputStream out = Files.newOutputStream(file)) {
        LogProvider logProvider = new Log4jLogProvider(out);
        // * locks held by the lock manager
        lm.accept(new DumpLocksVisitor(logProvider.getLog(LockWorkFailureDump.class)));
        // * rag manager state;
        // * workers state
        Log log = logProvider.getLog(getClass());
        for (LockWorker worker : workers) {
            // - what each is doing and have up to now
            log.info("Worker %s", worker);
        }
        return file;
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider) Log(org.neo4j.logging.Log) Log4jLogProvider(org.neo4j.logging.log4j.Log4jLogProvider) OutputStream(java.io.OutputStream)

Example 65 with LogProvider

use of org.neo4j.logging.LogProvider in project neo4j by neo4j.

the class RelationshipGroupGetterTest method openStore.

@BeforeEach
void openStore() {
    LogProvider logProvider = NullLogProvider.getInstance();
    StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, logProvider, PageCacheTracer.NULL, writable());
    stores = storeFactory.openNeoStores(true, StoreType.RELATIONSHIP_GROUP, StoreType.NODE, StoreType.NODE_LABEL);
    groupStore = spy(stores.getRelationshipGroupStore());
    NodeStore nodeStore = stores.getNodeStore();
    groupRecords = new DirectRecordAccess<>(groupStore, Loaders.relationshipGroupLoader(groupStore, NULL));
    nodeRecords = new DirectRecordAccess<>(nodeStore, Loaders.nodeLoader(nodeStore, NULL));
    groupGetter = new RelationshipGroupGetter(groupStore, NULL);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) NodeStore(org.neo4j.kernel.impl.store.NodeStore) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

LogProvider (org.neo4j.logging.LogProvider)65 NullLogProvider (org.neo4j.logging.NullLogProvider)26 Config (org.neo4j.kernel.configuration.Config)16 File (java.io.File)15 Test (org.junit.Test)15 Log (org.neo4j.logging.Log)14 FormattedLogProvider (org.neo4j.logging.FormattedLogProvider)11 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)10 OnDemandJobScheduler (org.neo4j.test.OnDemandJobScheduler)9 Config (org.neo4j.configuration.Config)7 LogService (org.neo4j.kernel.impl.logging.LogService)7 DummyRaftableContentSerializer (org.neo4j.causalclustering.core.consensus.log.DummyRaftableContentSerializer)6 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)6 Monitors (org.neo4j.kernel.monitoring.Monitors)6 DependencyResolver (org.neo4j.graphdb.DependencyResolver)5 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)5 RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)5 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 NeoStores (org.neo4j.kernel.impl.store.NeoStores)4