Search in sources :

Example 36 with LogProvider

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

the class DefaultWinnerStrategyTest method theWinnerShouldHaveTheBestVoteCredentials.

@Test
public void theWinnerShouldHaveTheBestVoteCredentials() throws Exception {
    // given
    InstanceId instanceOne = new InstanceId(1);
    InstanceId instanceTwo = new InstanceId(2);
    ClusterContext clusterContext = mock(ClusterContext.class);
    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;
        }
    };
    when(clusterContext.getLog(DefaultWinnerStrategy.class)).thenReturn(logProvider.getLog(DefaultWinnerStrategy.class));
    // when
    Collection<Vote> votes = Arrays.asList(new Vote(instanceOne, new IntegerElectionCredentials(1)), new Vote(instanceTwo, new IntegerElectionCredentials(2)));
    DefaultWinnerStrategy strategy = new DefaultWinnerStrategy(clusterContext);
    org.neo4j.cluster.InstanceId winner = strategy.pickWinner(votes);
    // then
    assertEquals(instanceTwo, winner);
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) InstanceId(org.neo4j.cluster.InstanceId) Log(org.neo4j.logging.Log) ClusterContext(org.neo4j.cluster.protocol.cluster.ClusterContext) IntegerElectionCredentials(org.neo4j.cluster.protocol.election.IntegerElectionCredentials) LogProvider(org.neo4j.logging.LogProvider) Test(org.junit.Test)

Example 37 with LogProvider

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

the class DefaultWinnerStrategyTest method shouldLogElectionProcess.

@Test
public void shouldLogElectionProcess() {
    // given
    ClusterContext clusterContext = mock(ClusterContext.class);
    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;
        }
    };
    when(clusterContext.getLog(DefaultWinnerStrategy.class)).thenReturn(logProvider.getLog(DefaultWinnerStrategy.class));
    // when
    Collection<Vote> votes = Collections.emptyList();
    DefaultWinnerStrategy strategy = new DefaultWinnerStrategy(clusterContext);
    strategy.pickWinner(votes);
    // then
    verify(log).debug("Election: received votes [], eligible votes []");
}
Also used : LogProvider(org.neo4j.logging.LogProvider) Log(org.neo4j.logging.Log) ClusterContext(org.neo4j.cluster.protocol.cluster.ClusterContext) Test(org.junit.Test)

Example 38 with LogProvider

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

the class DumpStore method main.

public static void main(String... args) throws Exception {
    if (args == null || args.length == 0) {
        System.err.println("SYNTAX: [file[:id[,id]*]]+");
        return;
    }
    try (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction();
        PageCache pageCache = createPageCache(fs)) {
        final DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
        Function<File, StoreFactory> createStoreFactory = file -> new StoreFactory(file.getParentFile(), Config.defaults(), idGeneratorFactory, pageCache, fs, logProvider());
        for (String arg : args) {
            dumpFile(createStoreFactory, arg);
        }
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) StandalonePageCacheFactory.createPageCache(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache) Token(org.neo4j.storageengine.api.Token) NullLogProvider(org.neo4j.logging.NullLogProvider) Function(java.util.function.Function) ByteBuffer(java.nio.ByteBuffer) NeoStores(org.neo4j.kernel.impl.store.NeoStores) AbstractBaseRecord(org.neo4j.kernel.impl.store.record.AbstractBaseRecord) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) CommonAbstractStore(org.neo4j.kernel.impl.store.CommonAbstractStore) TokenRecord(org.neo4j.kernel.impl.store.record.TokenRecord) PrintStream(java.io.PrintStream) PageCache(org.neo4j.io.pagecache.PageCache) Config(org.neo4j.kernel.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) FORCE(org.neo4j.kernel.impl.store.record.RecordLoad.FORCE) SchemaStorage(org.neo4j.kernel.impl.store.SchemaStorage) SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) TokenStore(org.neo4j.kernel.impl.store.TokenStore) PrintStreamLogger(org.neo4j.logging.PrintStreamLogger) File(java.io.File) DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RecordStore(org.neo4j.kernel.impl.store.RecordStore) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) HexPrinter(org.neo4j.kernel.impl.util.HexPrinter) StoreType(org.neo4j.kernel.impl.store.StoreType) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) File(java.io.File) StandalonePageCacheFactory.createPageCache(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache) PageCache(org.neo4j.io.pagecache.PageCache)

Example 39 with LogProvider

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

the class SegmentedConcurrentStressIT method createRaftLog.

@Override
public SegmentedRaftLog createRaftLog(FileSystemAbstraction fsa, File dir) throws Throwable {
    long rotateAtSize = 8 * 1024 * 1024;
    LogProvider logProvider = getInstance();
    int readerPoolSize = 8;
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(raft_log_pruning_strategy.getDefaultValue(), logProvider).newInstance();
    SegmentedRaftLog raftLog = new SegmentedRaftLog(fsa, dir, rotateAtSize, new DummyRaftableContentSerializer(), logProvider, readerPoolSize, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
    raftLog.start();
    return raftLog;
}
Also used : LogProvider(org.neo4j.logging.LogProvider) OnDemandJobScheduler(org.neo4j.test.OnDemandJobScheduler) DummyRaftableContentSerializer(org.neo4j.causalclustering.core.consensus.log.DummyRaftableContentSerializer)

Example 40 with LogProvider

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

the class SegmentedRaftLogCursorIT method createRaftLog.

private SegmentedRaftLog createRaftLog(long rotateAtSize, String pruneStrategy) {
    if (fileSystem == null) {
        fileSystem = new EphemeralFileSystemAbstraction();
    }
    File directory = new File(RAFT_LOG_DIRECTORY_NAME);
    fileSystem.mkdir(directory);
    LogProvider logProvider = getInstance();
    CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(pruneStrategy, logProvider).newInstance();
    SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fileSystem, directory, rotateAtSize, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.systemClock(), new OnDemandJobScheduler(), pruningStrategy);
    life.add(newRaftLog);
    life.init();
    life.start();
    return newRaftLog;
}
Also used : LogProvider(org.neo4j.logging.LogProvider) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) 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