Esempio n. 1
0
        /** <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);
        }
Esempio n. 2
0
        /// <summary>
        /// Does the out in op.
        /// </summary>
        private T DoOutInOp <T>(ClientOp opId, Action <BinaryWriter> writeAction,
                                Func <IBinaryStream, T> readFunc)
        {
            return(_socket.DoOutInOp(opId, stream =>
            {
                if (writeAction != null)
                {
                    var writer = _marsh.StartMarshal(stream);

                    writeAction(writer);

                    _marsh.FinishMarshal(writer);
                }
            }, readFunc));
        }
Esempio n. 3
0
 /// <summary>
 /// Does the out in op.
 /// </summary>
 private T DoOutInOp <T>(ClientOp opId, Action <ClientRequestContext> writeAction,
                         Func <ClientResponseContext, T> readFunc)
 {
     return(_socket.DoOutInOp(opId, writeAction, readFunc));
 }