Search in sources :

Example 6 with LogProvider

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

the class EnterpriseBootstrapperTest method debugLoggingEnabledBySetting.

@Test
public void debugLoggingEnabledBySetting() throws Exception {
    // When
    File configFile = tempDir.newFile(ConfigLoader.DEFAULT_CONFIG_FILE_NAME);
    Map<String, String> properties = stringMap(store_internal_log_level.name(), "DEBUG");
    properties.putAll(ServerTestUtils.getDefaultRelativeProperties());
    properties.put("dbms.connector.1.type", "HTTP");
    properties.put("dbms.connector.1.encryption", "NONE");
    properties.put("dbms.connector.1.enabled", "true");
    store(properties, configFile);
    // When
    UncoveredEnterpriseBootstrapper uncoveredEnterpriseBootstrapper = new UncoveredEnterpriseBootstrapper();
    cleanupRule.add(uncoveredEnterpriseBootstrapper);
    ServerBootstrapper.start(uncoveredEnterpriseBootstrapper, "--home-dir", tempDir.newFolder("home-dir").getAbsolutePath(), "--config-dir", configFile.getParentFile().getAbsolutePath());
    // Then
    assertEventually("Server was started", uncoveredEnterpriseBootstrapper::isRunning, is(true), 1, TimeUnit.MINUTES);
    LogProvider userLogProvider = uncoveredEnterpriseBootstrapper.getUserLogProvider();
    assertTrue("Debug logging enabled by setting value.", userLogProvider.getLog(getClass()).isDebugEnabled());
}
Also used : LogProvider(org.neo4j.logging.LogProvider) File(java.io.File) Test(org.junit.Test) BaseBootstrapperTest(org.neo4j.server.BaseBootstrapperTest)

Example 7 with LogProvider

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

the class BackupServiceIT method shouldPrintThatIncrementalBackupIsPerformedAndFallingBackToFull.

@Test
public void shouldPrintThatIncrementalBackupIsPerformedAndFallingBackToFull() throws Exception {
    defaultBackupPortHostParams();
    Config defaultConfig = dbRule.getConfigCopy();
    dbRule.setConfig(GraphDatabaseSettings.keep_logical_logs, "false");
    // have logs rotated on every transaction
    GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
    createAndIndexNode(db, 1);
    // A full backup
    backupService().doFullBackup(BACKUP_HOST, backupPort, backupDir, ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
    // And the log the backup uses is rotated out
    createAndIndexNode(db, 2);
    rotateAndCheckPoint(db);
    createAndIndexNode(db, 3);
    rotateAndCheckPoint(db);
    createAndIndexNode(db, 4);
    rotateAndCheckPoint(db);
    final Log log = mock(Log.class);
    LogProvider logProvider = new LogProvider() {

        @Override
        public Log getLog(Class loggingClass) {
            return log;
        }

        @Override
        public Log getLog(String name) {
            return log;
        }
    };
    backupService(logProvider).doIncrementalBackupOrFallbackToFull(BACKUP_HOST, backupPort, backupDir, ConsistencyCheck.NONE, dbRule.getConfigCopy(), BackupClient.BIG_READ_TIMEOUT, false);
    verify(log).info("Previous backup found, trying incremental backup.");
    verify(log).info("Existing backup is too far out of date, a new full backup will be performed.");
}
Also used : NullLogProvider(org.neo4j.logging.NullLogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) LogProvider(org.neo4j.logging.LogProvider) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Log(org.neo4j.logging.Log) Config(org.neo4j.kernel.configuration.Config) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 8 with LogProvider

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

the class ServerBootstrapperTest method shouldNotThrowNullPointerExceptionIfConfigurationValidationFails.

@Test
public void shouldNotThrowNullPointerExceptionIfConfigurationValidationFails() throws Exception {
    // given
    ServerBootstrapper serverBootstrapper = new ServerBootstrapper() {

        @Override
        protected NeoServer createNeoServer(Config config, GraphDatabaseDependencies dependencies, LogProvider userLogProvider) {
            return mock(NeoServer.class);
        }

        @Nonnull
        @Override
        protected Collection<ConfigurationValidator> configurationValidators() {
            return Collections.emptyList();
        }
    };
    File dir = Files.createTempDirectory("test-server-bootstrapper").toFile();
    dir.deleteOnExit();
    // when
    serverBootstrapper.start(dir, Optional.empty());
    // then no exceptions are thrown and
    assertThat(suppress.getOutputVoice().lines(), not(empty()));
}
Also used : LogProvider(org.neo4j.logging.LogProvider) Config(org.neo4j.kernel.configuration.Config) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) ConfigurationValidator(org.neo4j.kernel.configuration.ConfigurationValidator) File(java.io.File) Test(org.junit.Test)

Example 9 with LogProvider

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

the class SegmentedRaftLogVerificationIT method createRaftLog.

@Override
protected RaftLog createRaftLog() throws Throwable {
    FileSystemAbstraction fsa = fsRule.get();
    File directory = new File(RAFT_LOG_DIRECTORY_NAME);
    fsa.mkdir(directory);
    long rotateAtSizeBytes = 128;
    int readerPoolSize = 8;
    LogProvider logProvider = getInstance();
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(raft_log_pruning_strategy.getDefaultValue(), logProvider).newInstance();
    SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fsa, directory, rotateAtSizeBytes, new DummyRaftableContentSerializer(), logProvider, readerPoolSize, Clocks.systemClock(), new OnDemandJobScheduler(), pruningStrategy);
    newRaftLog.init();
    newRaftLog.start();
    return newRaftLog;
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) File(java.io.File) DummyRaftableContentSerializer(org.neo4j.causalclustering.core.consensus.log.DummyRaftableContentSerializer)

Example 10 with LogProvider

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

the class SegmentedRaftLogContractTest method createRaftLog.

@Override
public RaftLog createRaftLog() {
    File directory = new File(RAFT_LOG_DIRECTORY_NAME);
    FileSystemAbstraction fileSystem = fsRule.get();
    fileSystem.mkdir(directory);
    LogProvider logProvider = getInstance();
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("1 entries", logProvider).newInstance();
    return life.add(new SegmentedRaftLog(fileSystem, directory, 1024, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy));
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) File(java.io.File) DummyRaftableContentSerializer(org.neo4j.causalclustering.core.consensus.log.DummyRaftableContentSerializer)

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