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);
}
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 []");
}
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);
}
}
}
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;
}
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;
}
Aggregations