コード例 #1
0
        public void TestCustomConfigurationPropagatesToServer()
        {
            var cfg1 = new AtomicClientConfiguration
            {
                AtomicSequenceReserveSize = 32,
                Backups   = 2,
                CacheMode = CacheMode.Partitioned,
                GroupName = "atomics-partitioned"
            };

            var cfg2 = new AtomicClientConfiguration
            {
                AtomicSequenceReserveSize = 33,
                Backups   = 3,
                CacheMode = CacheMode.Replicated,
                GroupName = "atomics-replicated"
            };

            var name = TestUtils.TestName;

            var atomicLong1 = Client.GetAtomicLong(name, cfg1, 1, true);
            var atomicLong2 = Client.GetAtomicLong(name, cfg2, 2, true);
            var atomicLong3 = Client.GetAtomicLong(name, 3, true);

            var cacheConfigBytes = GetIgnite().GetCompute().ExecuteJavaTask <byte[]>(
                "org.apache.ignite.platform.PlatformGetInternalCachesTask", null);

            Assert.IsNotNull(cacheConfigBytes);

            var stream = new BinaryHeapStream(cacheConfigBytes);
            var reader = new BinaryReader(BinaryUtils.Marshaller, stream, BinaryMode.Deserialize, null);

            var caches = Enumerable.Range(0, reader.ReadInt())
                         .Select(_ => new CacheConfiguration(reader))
                         .ToDictionary(c => c.Name);

            Assert.AreEqual(2, caches["ignite-sys-atomic-cache@atomics-partitioned"].Backups);
            Assert.AreEqual(int.MaxValue, caches["ignite-sys-atomic-cache@atomics-replicated"].Backups);
            Assert.AreEqual(1, caches["ignite-sys-atomic-cache@default-ds-group"].Backups);

            Assert.AreEqual(1, atomicLong1.Read());
            Assert.AreEqual(2, atomicLong2.Read());
            Assert.AreEqual(3, atomicLong3.Read());
        }
コード例 #2
0
ファイル: IgniteClient.cs プロジェクト: wwjiang007/ignite
        /** <inheritDoc /> */
        public IAtomicLongClient GetAtomicLong(
            string name,
            AtomicClientConfiguration configuration,
            long initialValue,
            bool create)
        {
            IgniteArgumentCheck.NotNullOrEmpty(name, "name");

            if (create)
            {
                _socket.DoOutInOp <object>(ClientOp.AtomicLongCreate, ctx =>
                {
                    var w = ctx.Writer;

                    w.WriteString(name);
                    w.WriteLong(initialValue);

                    if (configuration != null)
                    {
                        w.WriteBoolean(true);
                        w.WriteInt(configuration.AtomicSequenceReserveSize);
                        w.WriteByte((byte)configuration.CacheMode);
                        w.WriteInt(configuration.Backups);
                        w.WriteString(configuration.GroupName);
                    }
                    else
                    {
                        w.WriteBoolean(false);
                    }
                }, null);
            }

            var res = new AtomicLongClient(_socket, name, configuration?.GroupName);

            if (!create && res.IsClosed())
            {
                // Return null when specified atomic long does not exist to match thick API behavior.
                return(null);
            }

            return(res);
        }
コード例 #3
0
        public void AtomicLong_RequestIsRoutedToPrimaryNode(
            string name, string groupName, CacheMode cacheMode, int gridIdx)
        {
            var cfg = new AtomicClientConfiguration
            {
                GroupName = groupName,
                CacheMode = cacheMode
            };

            var atomicLong = Client.GetAtomicLong(name, cfg, 1, true);

            // Warm up.
            atomicLong.Read();
            ClearLoggers();

            // Test.
            atomicLong.Read();

            Assert.AreEqual(gridIdx, GetClientRequestGridIndex("ValueGet", "datastructures.ClientAtomicLong"));
        }