Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void settingLastLearnedInstanceToNegativeOneShouldAlwaysWin()
        public virtual void SettingLastLearnedInstanceToNegativeOneShouldAlwaysWin()
        {
            // Given
            Config config = mock(typeof(Config));

            when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10);

            MultiPaxosContext mpCtx = new MultiPaxosContext(null, Iterables.empty(), mock(typeof(ClusterConfiguration)), null, NullLogProvider.Instance, null, null, null, null, null, config);
            LearnerContext    state = mpCtx.LearnerContext;

            // When
            state.SetLastKnownLearnedInstanceInCluster(1, new InstanceId(2));
            state.SetLastKnownLearnedInstanceInCluster(-1, null);

            // Then
            assertThat(state.LastKnownLearnedInstanceInCluster, equalTo(-1L));
            assertThat(state.LastKnownAliveUpToDateInstance, equalTo(new InstanceId(2)));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOnlyAllowHigherLastLearnedInstanceId()
        public virtual void ShouldOnlyAllowHigherLastLearnedInstanceId()
        {
            // Given

            Config config = mock(typeof(Config));

            when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10);

            MultiPaxosContext mpCtx = new MultiPaxosContext(null, Iterables.empty(), mock(typeof(ClusterConfiguration)), null, NullLogProvider.Instance, null, null, null, null, null, config);
            LearnerContext    state = mpCtx.LearnerContext;

            // When
            state.SetLastKnownLearnedInstanceInCluster(1, new InstanceId(2));
            state.SetLastKnownLearnedInstanceInCluster(0, new InstanceId(3));

            // Then
            assertThat(state.LastKnownLearnedInstanceInCluster, equalTo(1L));
        }
Example #3
0
        private RecordStorageEngine Get(FileSystemAbstraction fs, PageCache pageCache, IndexProvider indexProvider, DatabaseHealth databaseHealth, DatabaseLayout databaseLayout, System.Func <BatchTransactionApplierFacade, BatchTransactionApplierFacade> transactionApplierTransformer, Monitors monitors, LockService lockService)
        {
            IdGeneratorFactory    idGeneratorFactory          = new EphemeralIdGenerator.Factory();
            ExplicitIndexProvider explicitIndexProviderLookup = mock(typeof(ExplicitIndexProvider));

            when(explicitIndexProviderLookup.AllIndexProviders()).thenReturn(Iterables.empty());
            IndexConfigStore indexConfigStore = new IndexConfigStore(databaseLayout, fs);
            JobScheduler     scheduler        = _life.add(createScheduler());
            Config           config           = Config.defaults(GraphDatabaseSettings.default_schema_provider, indexProvider.ProviderDescriptor.name());

            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(indexProvider);

            BufferingIdGeneratorFactory bufferingIdGeneratorFactory = new BufferingIdGeneratorFactory(idGeneratorFactory, Org.Neo4j.Kernel.impl.store.id.IdReuseEligibility_Fields.Always, new CommunityIdTypeConfigurationProvider());
            DefaultIndexProviderMap     indexProviderMap            = new DefaultIndexProviderMap(dependencies, config);
            NullLogProvider             nullLogProvider             = NullLogProvider.Instance;

            _life.add(indexProviderMap);
            return(_life.add(new ExtendedRecordStorageEngine(databaseLayout, config, pageCache, fs, nullLogProvider, nullLogProvider, mockedTokenHolders(), mock(typeof(SchemaState)), new StandardConstraintSemantics(), scheduler, mock(typeof(TokenNameLookup)), lockService, indexProviderMap, IndexingService.NO_MONITOR, databaseHealth, explicitIndexProviderLookup, indexConfigStore, new SynchronizedArrayIdOrderingQueue(), idGeneratorFactory, new BufferedIdController(bufferingIdGeneratorFactory, scheduler), transactionApplierTransformer, monitors, RecoveryCleanupWorkCollector.immediate(), OperationalMode.single)));
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowIfAlreadyShutdown()
        public virtual void ShouldThrowIfAlreadyShutdown()
        {
            // Given
            CopiedStoreRecovery copiedStoreRecovery = new CopiedStoreRecovery(Config.defaults(), Iterables.empty(), mock(typeof(PageCache)));

            copiedStoreRecovery.Shutdown();

            try
            {
                // when
                copiedStoreRecovery.RecoverCopiedStore(DatabaseLayout.of(new File("nowhere")));
                fail("should have thrown");
            }
            catch (DatabaseShutdownException ex)
            {
                // then
                assertEquals("Abort store-copied store recovery due to database shutdown", ex.Message);
            }
        }