use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class GraphStoreFixture method directStoreAccess.
public DirectStoreAccess directStoreAccess() {
if (directStoreAccess == null) {
fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = getPageCache(fileSystem);
LogProvider logProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(directory, pageCache, fileSystem, logProvider);
neoStore = storeFactory.openAllNeoStores();
StoreAccess nativeStores;
if (keepStatistics) {
AccessStatistics accessStatistics = new AccessStatistics();
statistics = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.getInstance());
nativeStores = new AccessStatsKeepingStoreAccess(neoStore, accessStatistics);
} else {
statistics = Statistics.NONE;
nativeStores = new StoreAccess(neoStore);
}
nativeStores.initialize();
Config config = Config.empty();
OperationalMode operationalMode = OperationalMode.single;
IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores());
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies(Config.defaults(), fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
KernelContext kernelContext = new SimpleKernelContext(directory, UNKNOWN, dependencies);
LabelScanStore labelScanStore = startLabelScanStore(config, dependencies, kernelContext);
directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, createIndexes(fileSystem, config, operationalMode));
}
return directStoreAccess;
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class ObservedClusterMembersTest method clusterConfiguration.
private ClusterConfiguration clusterConfiguration(URI... uris) {
LogProvider logProvider = FormattedLogProvider.toOutputStream(System.out);
ClusterConfiguration toReturn = new ClusterConfiguration("neo4j.ha", logProvider, asList(uris));
toReturn.joined(clusterId1, clusterUri1);
toReturn.joined(clusterId2, clusterUri2);
if (uris.length == 3) {
toReturn.joined(clusterId3, clusterUri3);
}
return toReturn;
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class TransactionHandleTest method shouldLogMessageIfCommitErrorOccurs.
@Test
public void shouldLogMessageIfCommitErrorOccurs() throws Exception {
// given
TransitionalPeriodTransactionMessContainer kernel = mockKernel();
TransitionalTxManagementKernelTransaction transactionContext = kernel.newTransaction(explicit, AUTH_DISABLED, -1);
doThrow(new NullPointerException()).when(transactionContext).commit();
LogProvider logProvider = mock(LogProvider.class);
Log log = mock(Log.class);
when(logProvider.getLog(TransactionHandle.class)).thenReturn(log);
TransactionRegistry registry = mock(TransactionRegistry.class);
QueryExecutionEngine engine = mock(QueryExecutionEngine.class);
Result executionResult = mock(Result.class);
TransactionalContext transactionalContext = prepareKernelWithQuerySession(kernel);
when(engine.executeQuery("query", map(), transactionalContext)).thenReturn(executionResult);
when(registry.begin(any(TransactionHandle.class))).thenReturn(1337L);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
TransactionHandle handle = new TransactionHandle(kernel, engine, queryService, registry, uriScheme, false, AUTH_DISABLED, anyLong(), logProvider);
ExecutionResultSerializer output = mock(ExecutionResultSerializer.class);
// when
Statement statement = new Statement("query", map(), false, (ResultDataContent[]) null);
handle.commit(statements(statement), output, mock(HttpServletRequest.class));
// then
verify(log).error(eq("Failed to commit transaction."), any(NullPointerException.class));
verify(registry).forget(1337L);
InOrder outputOrder = inOrder(output);
outputOrder.verify(output).statementResult(executionResult, false, (ResultDataContent[]) null);
outputOrder.verify(output).notifications(anyCollectionOf(Notification.class));
outputOrder.verify(output).errors(argThat(hasErrors(Status.Transaction.TransactionCommitFailed)));
outputOrder.verify(output).finish();
verifyNoMoreInteractions(output);
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class DumpSegmentedRaftLog method dump.
private int dump(String filenameOrDirectory, PrintStream out) throws IOException, DamagedLogStorageException, DisposedException {
LogProvider logProvider = NullLogProvider.getInstance();
final int[] logsFound = { 0 };
FileNames fileNames = new FileNames(new File(filenameOrDirectory));
ReaderPool readerPool = new ReaderPool(0, logProvider, fileNames, fileSystem, Clocks.systemClock());
RecoveryProtocol recoveryProtocol = new RecoveryProtocol(fileSystem, fileNames, readerPool, marshal, logProvider);
Segments segments = recoveryProtocol.run().segments;
segments.visit((segment) -> {
logsFound[0]++;
out.println("=== " + segment.getFilename() + " ===");
SegmentHeader header = segment.header();
out.println(header.toString());
try (IOCursor<EntryRecord> cursor = segment.getCursor(header.prevIndex() + 1)) {
while (cursor.next()) {
out.println(cursor.get().toString());
}
} catch (DisposedException e) {
e.printStackTrace();
System.exit(-1);
return true;
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
return true;
}
return false;
});
return logsFound[0];
}
use of org.neo4j.logging.LogProvider in project neo4j by neo4j.
the class FlatFileStressBase method setup.
@Before
public void setup() throws Throwable {
Config config = Config.defaults();
LogProvider logProvider = NullLogProvider.getInstance();
JobScheduler jobScheduler = new NoopJobScheduler();
userRepository = CommunitySecurityModule.getUserRepository(config, logProvider, getFileSystem());
roleRepository = EnterpriseSecurityModule.getRoleRepository(config, logProvider, getFileSystem());
flatFileRealm = new InternalFlatFileRealm(userRepository, roleRepository, new BasicPasswordPolicy(), new RateLimitedAuthenticationStrategy(Clock.systemUTC(), 3), jobScheduler, CommunitySecurityModule.getInitialUserRepository(config, logProvider, getFileSystem()), EnterpriseSecurityModule.getDefaultAdminRepository(config, logProvider, getFileSystem()));
flatFileRealm.init();
flatFileRealm.start();
}
Aggregations