Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void roundRobinWithNoSlaves()
        public virtual void RoundRobinWithNoSlaves()
        {
            // Given
            SlavePriority roundRobin = SlavePriorities.RoundRobin();

            // When
            IEnumerator <Slave> slaves = roundRobin.Prioritize(slaves()).GetEnumerator();

            // Then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(slaves.hasNext());
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPrioritizeDescendingIfAsked()
        public virtual void ShouldPrioritizeDescendingIfAsked()
        {
            // GIVEN
            Configuration propagator = TransactionPropagator.From(Config.defaults(tx_push_strategy, fixed_descending.name()));
            SlavePriority strategy   = propagator.ReplicationStrategy;

            // WHEN
            IEnumerable <Slave> prioritize = strategy.Prioritize(asList(Slave(1), Slave(0), Slave(2)));

            // THEN
            assertThat(Iterables.asList(prioritize), equalTo(asList(Slave(2), Slave(1), Slave(0))));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void roundRobinWithTwoSlavesAndPushFactorOne()
        public virtual void RoundRobinWithTwoSlavesAndPushFactorOne()
        {
            // Given
            SlavePriority roundRobin = SlavePriorities.RoundRobin();

            // When
            Slave slave1 = roundRobin.Prioritize(Slaves(2, 3)).GetEnumerator().next();
            Slave slave2 = roundRobin.Prioritize(Slaves(2, 3)).GetEnumerator().next();

            // Then
            assertEquals(2, slave1.ServerId);
            assertEquals(3, slave2.ServerId);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void roundRobinWithTwoSlavesAndPushFactorTwo()
        public virtual void RoundRobinWithTwoSlavesAndPushFactorTwo()
        {
            // Given
            SlavePriority roundRobin = SlavePriorities.RoundRobin();

            // When
            IEnumerator <Slave> slaves = roundRobin.Prioritize(slaves(2, 3)).GetEnumerator();

            // Then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(2, slaves.next().ServerId);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(3, slaves.next().ServerId);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testFixedPriorityStrategy()
        public virtual void TestFixedPriorityStrategy()
        {
            int[]         serverIds = new int[] { 55, 101, 66 };
            SlavePriority @fixed    = SlavePriorities.fixedDescending();
            List <Slave>  slaves    = new List <Slave>(3);

            slaves.Add(new FakeSlave(false, serverIds[0]));
            slaves.Add(new FakeSlave(false, serverIds[1]));
            slaves.Add(new FakeSlave(false, serverIds[2]));
            IEnumerator <Slave> sortedSlaves = @fixed.Prioritize(slaves).GetEnumerator();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(serverIds[1], sortedSlaves.next().ServerId);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(serverIds[2], sortedSlaves.next().ServerId);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(serverIds[0], sortedSlaves.next().ServerId);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertTrue(!sortedSlaves.hasNext());
        }
Exemplo n.º 6
0
        private TransactionPropagator NewPropagator(int slaveCount, int replication, SlavePriority slavePriority, params bool[] failingSlaves)
        {
            _slaves = InstantiateSlaves(slaveCount, failingSlaves);

            Config                config    = Config.defaults(MapUtil.stringMap(HaSettings.TxPushFactor.name(), "" + replication, ClusterSettings.server_id.name(), "" + MASTER_SERVER_ID));
            JobScheduler          scheduler = Cleanup.add(createInitialisedScheduler());
            TransactionPropagator result    = new TransactionPropagator(TransactionPropagator.from(config, slavePriority), NullLog.Instance, () => _slaves, new CommitPusher(scheduler));

            // Life
            try
            {
                scheduler.Start();

                result.Init();
                result.Start();
            }
            catch (Exception e)
            {
                throw new Exception(e);
            }
            return(result);
        }
Exemplo n.º 7
0
 public override void Start()
 {
     this._slaveCommitters     = Executors.newCachedThreadPool(new NamedThreadFactory("slave-committer"));
     _desiredReplicationFactor = _config.TxPushFactor;
     _replicationStrategy      = _config.ReplicationStrategy;
 }
Exemplo n.º 8
0
 public ConfigurationAnonymousInnerClass2(Config config, SlavePriority slavePriority)
 {
     this._config        = config;
     this._slavePriority = slavePriority;
 }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static Configuration from(final org.neo4j.kernel.configuration.Config config, final org.neo4j.kernel.ha.com.master.SlavePriority slavePriority)
        public static Configuration From(Config config, SlavePriority slavePriority)
        {
            return(new ConfigurationAnonymousInnerClass2(config, slavePriority));
        }