Search in sources :

Example 1 with SimpleLogService

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());
}
Also used : SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) LegacyLogs(org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) TransactionId(org.neo4j.kernel.impl.store.TransactionId) Test(org.junit.Test)

Example 2 with SimpleLogService

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());
}
Also used : SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) LegacyLogs(org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) TransactionId(org.neo4j.kernel.impl.store.TransactionId) Test(org.junit.Test)

Example 3 with SimpleLogService

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;
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) OperationalMode(org.neo4j.kernel.impl.factory.OperationalMode) NullLogProvider(org.neo4j.logging.NullLogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) LogProvider(org.neo4j.logging.LogProvider) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) IndexStoreView(org.neo4j.kernel.impl.api.index.IndexStoreView) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) Dependencies(org.neo4j.kernel.impl.util.Dependencies) PageCache(org.neo4j.io.pagecache.PageCache) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext)

Example 4 with SimpleLogService

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)"));
}
Also used : ClusterClient(org.neo4j.cluster.client.ClusterClient) SwitchToSlaveCopyThenBranch(org.neo4j.kernel.ha.cluster.SwitchToSlaveCopyThenBranch) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) InstanceId(org.neo4j.cluster.InstanceId) HighAvailabilityMemberChangeEvent(org.neo4j.kernel.ha.cluster.HighAvailabilityMemberChangeEvent) ClusterMemberAvailability(org.neo4j.cluster.member.ClusterMemberAvailability) SwitchToMaster(org.neo4j.kernel.ha.cluster.SwitchToMaster) Election(org.neo4j.cluster.protocol.election.Election) URI(java.net.URI) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 5 with SimpleLogService

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());
}
Also used : SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) NotElectableElectionCredentialsProvider(org.neo4j.cluster.protocol.election.NotElectableElectionCredentialsProvider) Monitors(org.neo4j.kernel.monitoring.Monitors) Dependencies(org.neo4j.kernel.impl.util.Dependencies) ClusterClientModule(org.neo4j.cluster.client.ClusterClientModule) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider)

Aggregations

SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)9 Test (org.junit.Test)6 Config (org.neo4j.kernel.configuration.Config)6 File (java.io.File)5 PageCache (org.neo4j.io.pagecache.PageCache)4 Dependencies (org.neo4j.kernel.impl.util.Dependencies)3 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)3 IOException (java.io.IOException)2 AccessStatistics (org.neo4j.consistency.statistics.AccessStatistics)2 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)2 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)2 VerboseStatistics (org.neo4j.consistency.statistics.VerboseStatistics)2 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)2 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)2 IndexStoreView (org.neo4j.kernel.impl.api.index.IndexStoreView)2 LogService (org.neo4j.kernel.impl.logging.LogService)2 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)2 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)2 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)2 StoreAccess (org.neo4j.kernel.impl.store.StoreAccess)2