Search in sources :

Example 1 with LogProvider

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

the class GraphStoreFixture method directStoreAccess.

public DirectStoreAccess directStoreAccess() {
    if (directStoreAccess == null) {
        fileSystem = new DefaultFileSystemAbstraction();
        PageCache pageCache = getPageCache(fileSystem);
        LogProvider logProvider = NullLogProvider.getInstance();
        StoreFactory storeFactory = new StoreFactory(directory, pageCache, fileSystem, logProvider);
        neoStore = storeFactory.openAllNeoStores();
        StoreAccess nativeStores;
        if (keepStatistics) {
            AccessStatistics accessStatistics = new AccessStatistics();
            statistics = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.getInstance());
            nativeStores = new AccessStatsKeepingStoreAccess(neoStore, accessStatistics);
        } else {
            statistics = Statistics.NONE;
            nativeStores = new StoreAccess(neoStore);
        }
        nativeStores.initialize();
        Config config = Config.empty();
        OperationalMode operationalMode = OperationalMode.single;
        IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores());
        Dependencies dependencies = new Dependencies();
        dependencies.satisfyDependencies(Config.defaults(), fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
        KernelContext kernelContext = new SimpleKernelContext(directory, UNKNOWN, dependencies);
        LabelScanStore labelScanStore = startLabelScanStore(config, dependencies, kernelContext);
        directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, createIndexes(fileSystem, config, operationalMode));
    }
    return directStoreAccess;
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) OperationalMode(org.neo4j.kernel.impl.factory.OperationalMode) NullLogProvider(org.neo4j.logging.NullLogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) LogProvider(org.neo4j.logging.LogProvider) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) IndexStoreView(org.neo4j.kernel.impl.api.index.IndexStoreView) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) Dependencies(org.neo4j.kernel.impl.util.Dependencies) PageCache(org.neo4j.io.pagecache.PageCache) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext)

Example 2 with LogProvider

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

the class ObservedClusterMembersTest method clusterConfiguration.

private ClusterConfiguration clusterConfiguration(URI... uris) {
    LogProvider logProvider = FormattedLogProvider.toOutputStream(System.out);
    ClusterConfiguration toReturn = new ClusterConfiguration("neo4j.ha", logProvider, asList(uris));
    toReturn.joined(clusterId1, clusterUri1);
    toReturn.joined(clusterId2, clusterUri2);
    if (uris.length == 3) {
        toReturn.joined(clusterId3, clusterUri3);
    }
    return toReturn;
}
Also used : LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) ClusterConfiguration(org.neo4j.cluster.protocol.cluster.ClusterConfiguration)

Example 3 with LogProvider

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

the class TransactionHandleTest method shouldLogMessageIfCommitErrorOccurs.

@Test
public void shouldLogMessageIfCommitErrorOccurs() throws Exception {
    // given
    TransitionalPeriodTransactionMessContainer kernel = mockKernel();
    TransitionalTxManagementKernelTransaction transactionContext = kernel.newTransaction(explicit, AUTH_DISABLED, -1);
    doThrow(new NullPointerException()).when(transactionContext).commit();
    LogProvider logProvider = mock(LogProvider.class);
    Log log = mock(Log.class);
    when(logProvider.getLog(TransactionHandle.class)).thenReturn(log);
    TransactionRegistry registry = mock(TransactionRegistry.class);
    QueryExecutionEngine engine = mock(QueryExecutionEngine.class);
    Result executionResult = mock(Result.class);
    TransactionalContext transactionalContext = prepareKernelWithQuerySession(kernel);
    when(engine.executeQuery("query", map(), transactionalContext)).thenReturn(executionResult);
    when(registry.begin(any(TransactionHandle.class))).thenReturn(1337L);
    GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
    TransactionHandle handle = new TransactionHandle(kernel, engine, queryService, registry, uriScheme, false, AUTH_DISABLED, anyLong(), logProvider);
    ExecutionResultSerializer output = mock(ExecutionResultSerializer.class);
    // when
    Statement statement = new Statement("query", map(), false, (ResultDataContent[]) null);
    handle.commit(statements(statement), output, mock(HttpServletRequest.class));
    // then
    verify(log).error(eq("Failed to commit transaction."), any(NullPointerException.class));
    verify(registry).forget(1337L);
    InOrder outputOrder = inOrder(output);
    outputOrder.verify(output).statementResult(executionResult, false, (ResultDataContent[]) null);
    outputOrder.verify(output).notifications(anyCollectionOf(Notification.class));
    outputOrder.verify(output).errors(argThat(hasErrors(Status.Transaction.TransactionCommitFailed)));
    outputOrder.verify(output).finish();
    verifyNoMoreInteractions(output);
}
Also used : InOrder(org.mockito.InOrder) Log(org.neo4j.logging.Log) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) Notification(org.neo4j.graphdb.Notification) Result(org.neo4j.graphdb.Result) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) HttpServletRequest(javax.servlet.http.HttpServletRequest) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) Test(org.junit.Test)

Example 4 with LogProvider

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

the class DumpSegmentedRaftLog method dump.

private int dump(String filenameOrDirectory, PrintStream out) throws IOException, DamagedLogStorageException, DisposedException {
    LogProvider logProvider = NullLogProvider.getInstance();
    final int[] logsFound = { 0 };
    FileNames fileNames = new FileNames(new File(filenameOrDirectory));
    ReaderPool readerPool = new ReaderPool(0, logProvider, fileNames, fileSystem, Clocks.systemClock());
    RecoveryProtocol recoveryProtocol = new RecoveryProtocol(fileSystem, fileNames, readerPool, marshal, logProvider);
    Segments segments = recoveryProtocol.run().segments;
    segments.visit((segment) -> {
        logsFound[0]++;
        out.println("=== " + segment.getFilename() + " ===");
        SegmentHeader header = segment.header();
        out.println(header.toString());
        try (IOCursor<EntryRecord> cursor = segment.getCursor(header.prevIndex() + 1)) {
            while (cursor.next()) {
                out.println(cursor.get().toString());
            }
        } catch (DisposedException e) {
            e.printStackTrace();
            System.exit(-1);
            return true;
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(-1);
            return true;
        }
        return false;
    });
    return logsFound[0];
}
Also used : LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) EntryRecord(org.neo4j.causalclustering.core.consensus.log.EntryRecord) IOException(java.io.IOException) File(java.io.File)

Example 5 with LogProvider

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

the class FlatFileStressBase method setup.

@Before
public void setup() throws Throwable {
    Config config = Config.defaults();
    LogProvider logProvider = NullLogProvider.getInstance();
    JobScheduler jobScheduler = new NoopJobScheduler();
    userRepository = CommunitySecurityModule.getUserRepository(config, logProvider, getFileSystem());
    roleRepository = EnterpriseSecurityModule.getRoleRepository(config, logProvider, getFileSystem());
    flatFileRealm = new InternalFlatFileRealm(userRepository, roleRepository, new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), 3), jobScheduler, CommunitySecurityModule.getInitialUserRepository(config, logProvider, getFileSystem()), EnterpriseSecurityModule.getDefaultAdminRepository(config, logProvider, getFileSystem()));
    flatFileRealm.init();
    flatFileRealm.start();
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) RateLimitedAuthenticationStrategy(org.neo4j.server.security.auth.RateLimitedAuthenticationStrategy) Config(org.neo4j.kernel.configuration.Config) InternalFlatFileRealm(org.neo4j.server.security.enterprise.auth.InternalFlatFileRealm) BasicPasswordPolicy(org.neo4j.server.security.auth.BasicPasswordPolicy) Before(org.junit.Before)

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