use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class NonUniqueIndexTests method newEmbeddedGraphDatabaseWithSlowJobScheduler.
private GraphDatabaseService newEmbeddedGraphDatabaseWithSlowJobScheduler() {
GraphDatabaseFactoryState graphDatabaseFactoryState = new GraphDatabaseFactoryState();
graphDatabaseFactoryState.setUserLogProvider(NullLogService.getInstance().getUserLogProvider());
return new GraphDatabaseFacadeFactory(DatabaseInfo.COMMUNITY, CommunityEditionModule::new) {
@Override
protected PlatformModule createPlatform(File storeDir, Config config, Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade) {
return new PlatformModule(storeDir, config, databaseInfo, dependencies, graphDatabaseFacade) {
@Override
protected Neo4jJobScheduler createJobScheduler() {
return newSlowJobScheduler();
}
@Override
protected LogService createLogService(LogProvider userLogProvider) {
return NullLogService.getInstance();
}
};
}
}.newFacade(directory.graphDbDir(), Config.embeddedDefaults(), graphDatabaseFactoryState.databaseDependencies());
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class CommunityCypherEngineProvider method createEngine.
@Override
protected QueryExecutionEngine createEngine(Dependencies deps, GraphDatabaseAPI graphAPI) {
GraphDatabaseCypherService queryService = new GraphDatabaseCypherService(graphAPI);
deps.satisfyDependency(queryService);
DependencyResolver resolver = graphAPI.getDependencyResolver();
LogService logService = resolver.resolveDependency(LogService.class);
KernelAPI kernelAPI = resolver.resolveDependency(KernelAPI.class);
Monitors monitors = resolver.resolveDependency(Monitors.class);
LogProvider logProvider = logService.getInternalLogProvider();
CommunityCompatibilityFactory compatibilityFactory = new CommunityCompatibilityFactory(queryService, kernelAPI, monitors, logProvider);
deps.satisfyDependencies(compatibilityFactory);
return new ExecutionEngine(queryService, logProvider, compatibilityFactory);
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class NeoStoreDataSource method buildTransactionLogs.
private NeoStoreTransactionLogModule buildTransactionLogs(File storeDir, Config config, LogProvider logProvider, JobScheduler scheduler, FileSystemAbstraction fileSystemAbstraction, StorageEngine storageEngine, LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader, SynchronizedArrayIdOrderingQueue legacyIndexTransactionOrdering, TransactionIdStore transactionIdStore, LogVersionRepository logVersionRepository) {
TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache(100_000);
LogHeaderCache logHeaderCache = new LogHeaderCache(1000);
final PhysicalLogFiles logFiles = new PhysicalLogFiles(storeDir, PhysicalLogFile.DEFAULT_NAME, fileSystemAbstraction);
final PhysicalLogFile logFile = life.add(new PhysicalLogFile(fileSystemAbstraction, logFiles, config.get(GraphDatabaseSettings.logical_log_rotation_threshold), transactionIdStore::getLastCommittedTransactionId, logVersionRepository, physicalLogMonitor, logHeaderCache));
final PhysicalLogFileInformation.LogVersionToTimestamp logInformation = version -> {
LogPosition position = LogPosition.start(version);
try (ReadableLogChannel channel = logFile.getReader(position)) {
LogEntry entry;
while ((entry = logEntryReader.readLogEntry(channel)) != null) {
if (entry instanceof LogEntryStart) {
return entry.<LogEntryStart>as().getTimeWritten();
}
}
}
return -1;
};
final LogFileInformation logFileInformation = new PhysicalLogFileInformation(logFiles, logHeaderCache, transactionIdStore::getLastCommittedTransactionId, logInformation);
if (config.get(GraphDatabaseFacadeFactory.Configuration.ephemeral)) {
config = config.withDefaults(stringMap(GraphDatabaseSettings.keep_logical_logs.name(), "1 files"));
}
String pruningConf = config.get(GraphDatabaseSettings.keep_logical_logs);
LogPruneStrategy logPruneStrategy = fromConfigValue(fs, logFileInformation, logFiles, pruningConf);
final LogPruning logPruning = new LogPruningImpl(logPruneStrategy, logProvider);
final LogRotation logRotation = new LogRotationImpl(monitors.newMonitor(LogRotation.Monitor.class), logFile, databaseHealth);
final TransactionAppender appender = life.add(new BatchingTransactionAppender(logFile, logRotation, transactionMetadataCache, transactionIdStore, legacyIndexTransactionOrdering, databaseHealth));
final LogicalTransactionStore logicalTransactionStore = new PhysicalLogicalTransactionStore(logFile, transactionMetadataCache, logEntryReader);
int txThreshold = config.get(GraphDatabaseSettings.check_point_interval_tx);
final CountCommittedTransactionThreshold countCommittedTransactionThreshold = new CountCommittedTransactionThreshold(txThreshold);
long timeMillisThreshold = config.get(GraphDatabaseSettings.check_point_interval_time);
TimeCheckPointThreshold timeCheckPointThreshold = new TimeCheckPointThreshold(timeMillisThreshold, clock);
CheckPointThreshold threshold = CheckPointThresholds.or(countCommittedTransactionThreshold, timeCheckPointThreshold);
final CheckPointerImpl checkPointer = new CheckPointerImpl(transactionIdStore, threshold, storageEngine, logPruning, appender, databaseHealth, logProvider, tracers.checkPointTracer, ioLimiter, storeCopyCheckPointMutex);
long recurringPeriod = Math.min(timeMillisThreshold, TimeUnit.SECONDS.toMillis(10));
CheckPointScheduler checkPointScheduler = new CheckPointScheduler(checkPointer, scheduler, recurringPeriod, databaseHealth);
life.add(checkPointer);
life.add(checkPointScheduler);
return new NeoStoreTransactionLogModule(logicalTransactionStore, logFileInformation, logFiles, logFile, logRotation, checkPointer, appender, legacyIndexTransactionOrdering);
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class NeoStoreDataSource method selectStoreFormats.
private static RecordFormats selectStoreFormats(Config config, File storeDir, FileSystemAbstraction fs, PageCache pageCache, LogService logService) {
LogProvider logging = logService.getInternalLogProvider();
RecordFormats formats = RecordFormatSelector.selectNewestFormat(config, storeDir, fs, pageCache, logging);
new RecordFormatPropertyConfigurator(formats, config).configure();
return formats;
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class RelationshipGroupGetterTest method shouldAbortLoadingGroupChainIfComeTooFar.
@Test
public void shouldAbortLoadingGroupChainIfComeTooFar() throws Exception {
// GIVEN a node with relationship group chain 2-->4-->10-->23
File dir = new File("dir");
fs.get().mkdirs(dir);
LogProvider logProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(dir, pageCache.getPageCache(fs.get()), fs.get(), logProvider);
try (NeoStores stores = storeFactory.openNeoStores(true, StoreType.RELATIONSHIP_GROUP)) {
RecordStore<RelationshipGroupRecord> store = spy(stores.getRelationshipGroupStore());
RelationshipGroupRecord group_2 = group(0, 2);
RelationshipGroupRecord group_4 = group(1, 4);
RelationshipGroupRecord group_10 = group(2, 10);
RelationshipGroupRecord group_23 = group(3, 23);
link(group_2, group_4, group_10, group_23);
store.updateRecord(group_2);
store.updateRecord(group_4);
store.updateRecord(group_10);
store.updateRecord(group_23);
RelationshipGroupGetter groupGetter = new RelationshipGroupGetter(store);
NodeRecord node = new NodeRecord(0, true, group_2.getId(), -1);
// WHEN trying to find relationship group 7
RecordAccess<Long, RelationshipGroupRecord, Integer> access = new DirectRecordAccess<>(store, Loaders.relationshipGroupLoader(store));
RelationshipGroupPosition result = groupGetter.getRelationshipGroup(node, 7, access);
// THEN only groups 2, 4 and 10 should have been loaded
InOrder verification = inOrder(store);
verification.verify(store).getRecord(eq(group_2.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
verification.verify(store).getRecord(eq(group_4.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
verification.verify(store).getRecord(eq(group_10.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
verification.verify(store, times(0)).getRecord(eq(group_23.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
// it should also be reported as not found
assertNull(result.group());
// with group 4 as closes previous one
assertEquals(group_4, result.closestPrevious().forReadingData());
}
}
Aggregations