예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScheduledCommand"/> class.
        /// </summary>
        /// <param name="isPrimary">the function indicating if the backend object is primary</param>
        /// <param name="rm">Ring master object</param>
        /// <param name="marshaller">the marshaller to use when serializing/deserializing commands</param>
        internal ScheduledCommand(Func <bool> isPrimary, AbstractRingMaster rm, IByteArrayMarshaller marshaller)
        {
            if (isPrimary == null)
            {
                throw new ArgumentNullException("isPrimary");
            }

            if (marshaller == null)
            {
                throw new ArgumentNullException("marshaller");
            }

            this.marshaller = marshaller;
            this.isPrimary  = isPrimary;
            this.self       = rm;
        }
예제 #2
0
        /// <summary>
        /// returns the bytes corresponding to the request given
        /// </summary>
        /// <param name="req">request to serialize</param>
        /// <param name="marshaller">marshaller to use</param>
        /// <returns>serialization bytes</returns>
        public static byte[] GetBytes(IRingMasterBackendRequest req, IByteArrayMarshaller marshaller)
        {
            if (req == null)
            {
                throw new ArgumentNullException("req");
            }

            if (marshaller == null)
            {
                throw new ArgumentNullException("marshaller");
            }

            RequestCall call = new RequestCall()
            {
                CallId  = 0,
                Request = req,
            };

            return(marshaller.SerializeRequestAsBytes(call));
        }