Search in sources :

Example 41 with LogProvider

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

the class SegmentedRaftLogPartialEntryRecoveryTest method createRaftLog.

private SegmentedRaftLog createRaftLog(long rotateAtSize) {
    File directory = new File(RAFT_LOG_DIRECTORY_NAME);
    logDirectory = dir.directory(directory.getName());
    LogProvider logProvider = getInstance();
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("100 entries", logProvider).newInstance();
    return new SegmentedRaftLog(fsRule.get(), logDirectory, rotateAtSize, new CoreReplicatedContentMarshal(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) File(java.io.File)

Example 42 with LogProvider

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

the class ReplayRaftLog method main.

public static void main(String[] args) throws IOException {
    Args arg = Args.parse(args);
    String from = arg.get("from");
    System.out.println("From is " + from);
    String to = arg.get("to");
    System.out.println("to is " + to);
    File logDirectory = new File(from);
    System.out.println("logDirectory = " + logDirectory);
    Config config = Config.embeddedDefaults(stringMap());
    try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        LogProvider logProvider = getInstance();
        CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(config.get(raft_log_pruning_strategy), logProvider).newInstance();
        SegmentedRaftLog log = new SegmentedRaftLog(fileSystem, logDirectory, config.get(raft_log_rotation_size), new CoreReplicatedContentMarshal(), logProvider, config.get(raft_log_reader_pool_size), Clocks.systemClock(), new OnDemandJobScheduler(), pruningStrategy);
        // Not really, but we need to have a way to pass in the commit index
        long totalCommittedEntries = log.appendIndex();
        for (int i = 0; i <= totalCommittedEntries; i++) {
            ReplicatedContent content = readLogEntry(log, i).content();
            if (content instanceof ReplicatedTransaction) {
                ReplicatedTransaction tx = (ReplicatedTransaction) content;
                ReplicatedTransactionFactory.extractTransactionRepresentation(tx, new byte[0]).accept(element -> {
                    System.out.println(element);
                    return false;
                });
            }
        }
    }
}
Also used : Args(org.neo4j.helpers.Args) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) SegmentedRaftLog(org.neo4j.causalclustering.core.consensus.log.segmented.SegmentedRaftLog) ReplicatedTransaction(org.neo4j.causalclustering.core.state.machines.tx.ReplicatedTransaction) Config(org.neo4j.kernel.configuration.Config) CoreLogPruningStrategyFactory(org.neo4j.causalclustering.core.consensus.log.segmented.CoreLogPruningStrategyFactory) CoreLogPruningStrategy(org.neo4j.causalclustering.core.consensus.log.segmented.CoreLogPruningStrategy) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) LogProvider(org.neo4j.logging.LogProvider) CoreReplicatedContentMarshal(org.neo4j.causalclustering.messaging.CoreReplicatedContentMarshal) ReplicatedContent(org.neo4j.causalclustering.core.replication.ReplicatedContent) File(java.io.File)

Example 43 with LogProvider

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

the class SegmentedRaftLogRotationTest method createRaftLog.

private SegmentedRaftLog createRaftLog(long rotateAtSize) throws IOException {
    LogProvider logProvider = getInstance();
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(raft_log_pruning_strategy.getDefaultValue(), logProvider).newInstance();
    return new SegmentedRaftLog(fileSystemRule.get(), testDirectory.directory(), rotateAtSize, new DummyRaftableContentSerializer(), logProvider, 0, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) DummyRaftableContentSerializer(org.neo4j.causalclustering.core.consensus.log.DummyRaftableContentSerializer)

Example 44 with LogProvider

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

the class SegmentedRaftLogRotationTruncationPruneTest method createRaftLog.

private RaftLog createRaftLog() throws Exception {
    File directory = new File(RAFT_LOG_DIRECTORY_NAME);
    FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
    fileSystem.mkdir(directory);
    LogProvider logProvider = getInstance();
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("1 entries", logProvider).newInstance();
    SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fileSystem, directory, 1, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
    newRaftLog.start();
    return newRaftLog;
}
Also used : LogProvider(org.neo4j.logging.LogProvider) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) File(java.io.File) DummyRaftableContentSerializer(org.neo4j.causalclustering.core.consensus.log.DummyRaftableContentSerializer)

Example 45 with LogProvider

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

the class DatabaseActions method start.

public void start() throws UnableToStartServerException {
    if (isRunning()) {
        throw new UnableToStartServerException("Already started");
    }
    Config config = model.getConfig();
    Monitors monitors = new Monitors();
    LogProvider userLogProvider = FormattedLogProvider.toOutputStream(System.out);
    GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(userLogProvider).monitors(monitors);
    server = new CommunityNeoServer(config, dependencies, userLogProvider);
    try {
        server.start();
    } catch (ServerStartupException e) {
        server = null;
        Set<Class> causes = extractCauseTypes(e);
        if (causes.contains(StoreLockException.class)) {
            throw new UnableToStartServerException("Unable to lock store. Are you running another Neo4j process against this database?");
        }
        if (causes.contains(BindException.class)) {
            throw new UnableToStartServerException("Unable to bind to port. Are you running another Neo4j process on this computer?");
        }
        throw new UnableToStartServerException(e.getMessage());
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) Set(java.util.Set) HashSet(java.util.HashSet) CommunityNeoServer(org.neo4j.server.CommunityNeoServer) Config(org.neo4j.kernel.configuration.Config) ServerStartupException(org.neo4j.server.ServerStartupException) UnableToStartServerException(org.neo4j.desktop.model.exceptions.UnableToStartServerException) Monitors(org.neo4j.kernel.monitoring.Monitors) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) StoreLockException(org.neo4j.kernel.StoreLockException) BindException(java.net.BindException)

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