use of org.neo4j.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.
the class StoreMigratorTest method shouldGenerateTransactionInformationWhenLogsAreEmpty.
@Test
public void shouldGenerateTransactionInformationWhenLogsAreEmpty() throws Exception {
// given
long txId = 1;
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
File storeDir = directory.graphDbDir();
File neoStore = new File(storeDir, DEFAULT_NAME);
neoStore.createNewFile();
Config config = mock(Config.class);
LogService logService = new SimpleLogService(NullLogProvider.getInstance(), NullLogProvider.getInstance());
LegacyLogs legacyLogs = mock(LegacyLogs.class);
// when
// ... transaction info not in neo store
assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_ID));
assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_CHECKSUM));
assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP));
// ... and transaction not in log
when(legacyLogs.getTransactionInformation(storeDir, txId)).thenReturn(Optional.empty());
// ... and with migrator
StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, schemaIndexProvider);
TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
// then
assertEquals(txId, actual.transactionId());
assertEquals(TransactionIdStore.BASE_TX_CHECKSUM, actual.checksum());
assertEquals(TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP, actual.commitTimestamp());
}
use of org.neo4j.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.
the class StoreMigratorTest method shouldGenerateTransactionInformationWhenLogsNotPresent.
@Test
public void shouldGenerateTransactionInformationWhenLogsNotPresent() throws Exception {
// given
long txId = 42;
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
File storeDir = directory.graphDbDir();
File neoStore = new File(storeDir, DEFAULT_NAME);
neoStore.createNewFile();
Config config = mock(Config.class);
LogService logService = new SimpleLogService(NullLogProvider.getInstance(), NullLogProvider.getInstance());
LegacyLogs legacyLogs = mock(LegacyLogs.class);
// when
// ... transaction info not in neo store
assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_ID));
assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_CHECKSUM));
assertEquals(FIELD_NOT_PRESENT, getRecord(pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP));
// ... and transaction not in log
when(legacyLogs.getTransactionInformation(storeDir, txId)).thenReturn(Optional.empty());
// ... and with migrator
StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, schemaIndexProvider);
TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
// then
assertEquals(txId, actual.transactionId());
assertEquals(TransactionIdStore.UNKNOWN_TX_CHECKSUM, actual.checksum());
assertEquals(TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP, actual.commitTimestamp());
}
use of org.neo4j.kernel.impl.logging.SimpleLogService 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.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.
the class HighAvailabilityModeSwitcherTest method shouldTakeNoActionIfSwitchingToSlaveForItselfAsMaster.
@Test
public void shouldTakeNoActionIfSwitchingToSlaveForItselfAsMaster() throws Throwable {
// Given
// A HAMS
SwitchToSlaveCopyThenBranch switchToSlave = mock(SwitchToSlaveCopyThenBranch.class);
AssertableLogProvider logProvider = new AssertableLogProvider();
SimpleLogService logService = new SimpleLogService(NullLogProvider.getInstance(), logProvider);
HighAvailabilityModeSwitcher toTest = new HighAvailabilityModeSwitcher(switchToSlave, mock(SwitchToMaster.class), mock(Election.class), mock(ClusterMemberAvailability.class), mock(ClusterClient.class), storeSupplierMock(), new InstanceId(2), new ComponentSwitcherContainer(), neoStoreDataSourceSupplierMock(), logService);
// That is properly started
toTest.init();
toTest.start();
/*
* This is the URI at which we are registered as server - includes our own id, but we don't necessarily listen
* there
*/
URI serverHaUri = URI.create("ha://server2?serverId=2");
toTest.listeningAt(serverHaUri);
// When
// The HAMS tries to switch to slave for a master that is itself
toTest.masterIsAvailable(new HighAvailabilityMemberChangeEvent(PENDING, TO_SLAVE, new InstanceId(2), serverHaUri));
// Then
// No switching to slave must happen
verifyZeroInteractions(switchToSlave);
// And an error must be logged
logProvider.assertAtLeastOnce(inLog(HighAvailabilityModeSwitcher.class).error("I (ha://server2?serverId=2) tried to switch to " + "slave for myself as master (ha://server2?serverId=2)"));
}
use of org.neo4j.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.
the class ClusterTopologyChangesIT method newClusterClient.
private ClusterClientModule newClusterClient(LifeSupport life, InstanceId id) {
Config config = Config.embeddedDefaults(MapUtil.stringMap(ClusterSettings.initial_hosts.name(), cluster.getInitialHostsConfigString(), ClusterSettings.server_id.name(), String.valueOf(id.toIntegerIndex()), ClusterSettings.cluster_server.name(), "0.0.0.0:8888"));
FormattedLogProvider logProvider = FormattedLogProvider.toOutputStream(System.out);
SimpleLogService logService = new SimpleLogService(logProvider, logProvider);
return new ClusterClientModule(life, new Dependencies(), new Monitors(), config, logService, new NotElectableElectionCredentialsProvider());
}
Aggregations