public static void Main()
        {
            // See app.config: <atomicConfiguration atomicSequenceReserveSize="10" />
            // Each node reserves 10 numbers to itself, so that 10 increments can be done locally,
            // without communicating to other nodes. After that, another 10 elements are reserved.

            using (var ignite = Ignition.StartFromApplicationConfiguration())
            {
                Console.WriteLine();
                Console.WriteLine(">>> Atomic sequence example started.");

                IAtomicSequence atomicSequence =
                    ignite.GetAtomicSequence(AtomicSequenceIncrementAction.AtomicSequenceName, 0, true);

                Console.WriteLine(">>> Atomic sequence initial value: " + atomicSequence.Read());

                // Broadcast an action that increments AtomicSequence a number of times.
                ignite.GetCompute().Broadcast(new AtomicSequenceIncrementAction());

                // Actual value will depend on number of participating nodes.
                Console.WriteLine("\n>>> Atomic sequence current value: " + atomicSequence.Read());
            }

            Console.WriteLine("\n>>> Check output on all nodes.");
            Console.WriteLine("\n>>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
        /// <summary>
        /// Invokes action.
        /// </summary>
        public void Invoke()
        {
            IAtomicSequence atomicSequence = _ignite.GetAtomicSequence(AtomicSequenceName, 0, true);

            for (int i = 0; i < 20; i++)
            {
                Console.WriteLine(">>> AtomicSequence value has been incremented: " + atomicSequence.Increment());
            }
        }
Пример #3
0
        static void Main()
        {
            using (var ignite = Ignition.Start())
            {
                Console.WriteLine("Atomic sequence example");
                IAtomicSequence atomicSequence = ignite.GetAtomicSequence(AtomicSequenceIncrementAction.AtomicSequenceName, 0, true);
                Console.WriteLine(">>Atomic Sequence Initial value:" + atomicSequence.Read());
                // Broadcast an action that increments AtomicSequence a number of times.
                ignite.GetCompute().Broadcast(new AtomicSequenceIncrementAction());

                // Actual value will depend on number of participating nodes.
                Console.WriteLine("\n>>> Atomic sequence current value: " + atomicSequence.Read());
            }
            Console.WriteLine("\n>>> Check output on all nodes.");
            Console.WriteLine("\n>>> press any key to exit ...");
            Console.ReadKey();
        }
Пример #4
0
        public static void Main()
        {
            var atomicCfg = new AtomicConfiguration
            {
                // Each node reserves 10 numbers to itself, so that 10 increments can be done locally,
                // without communicating to other nodes. After that, another 10 elements are reserved.
                AtomicSequenceReserveSize = 10
            };

            var cfg = new IgniteConfiguration
            {
                DiscoverySpi = new TcpDiscoverySpi
                {
                    IpFinder = new TcpDiscoveryMulticastIpFinder
                    {
                        Endpoints = new[] { "127.0.0.1:47500" }
                    }
                },
                AtomicConfiguration = atomicCfg
            };

            using (var ignite = Ignition.Start(cfg))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Atomic sequence example started.");

                IAtomicSequence atomicSequence =
                    ignite.GetAtomicSequence(AtomicSequenceIncrementAction.AtomicSequenceName, 0, true);

                Console.WriteLine(">>> Atomic sequence initial value: " + atomicSequence.Read());

                // Broadcast an action that increments AtomicSequence a number of times.
                ignite.GetCompute().Broadcast(new AtomicSequenceIncrementAction());

                // Actual value will depend on number of participating nodes.
                Console.WriteLine("\n>>> Atomic sequence current value: " + atomicSequence.Read());
            }

            Console.WriteLine("\n>>> Check output on all nodes.");
            Console.WriteLine("\n>>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
Пример #5
0
        public static void Main()
        {
            using (IIgnite ignite = Ignition.Start(Utils.GetServerNodeConfiguration()))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Atomic sequence example started.");

                IAtomicSequence atomicSequence =
                    ignite.GetAtomicSequence(AtomicSequenceIncrementAction.AtomicSequenceName, 0, true);

                Console.WriteLine(">>> Atomic sequence initial value: " + atomicSequence.Read());

                // Broadcast an action that increments AtomicSequence a number of times.
                ignite.GetCompute().Broadcast(new AtomicSequenceIncrementAction());

                // Actual value will depend on number of participating nodes.
                Console.WriteLine("\n>>> Atomic sequence current value: " + atomicSequence.Read());
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
Пример #6
0
        public static void Main()
        {
            using (var ignite = Ignition.StartFromApplicationConfiguration())
            {
                Console.WriteLine();
                Console.WriteLine(">>> Atomic sequence example started.");

                IAtomicSequence atomicSequence =
                    ignite.GetAtomicSequence(AtomicSequenceIncrementAction.AtomicSequenceName, 0, true);

                Console.WriteLine(">>> Atomic sequence initial value: " + atomicSequence.Read());


                ignite.GetCompute().Broadcast(new AtomicSequenceIncrementAction());


                Console.WriteLine("\n>>> Atomic sequence current value: " + atomicSequence.Read());
            }

            Console.WriteLine("\n>>> Check output on all nodes.");
            Console.WriteLine("\n>>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }