Exemple #1
0
        /// <summary>
        /// Serialize <see cref="IOperationOverrides"/>.
        /// </summary>
        /// <param name="operationOverrides"><see cref="IOperationOverrides"/> to serialize</param>
        private void SerializeOperationOverrides(IOperationOverrides operationOverrides)
        {
            bool isNull = operationOverrides == null;

            this.binaryWriter.Write((bool)isNull);

            if (!isNull)
            {
                this.binaryWriter.Write((ulong)operationOverrides.TxId);
                this.binaryWriter.Write((ulong)operationOverrides.TxTime);
            }
        }
Exemple #2
0
        /// <summary>
        /// Deserialize <see cref="IRingMasterRequest"/>
        /// </summary>
        /// <param name="callid">Id of the call</param>
        /// <param name="ringMasterRequest">The ring master request.</param>
        /// <exception cref="System.ArgumentException">unknown type  + type</exception>
        private void DeserializeRingMasterRequest(ulong callid, out IRingMasterRequest ringMasterRequest)
        {
            RingMasterRequestType type = (RingMasterRequestType)this.binaryReader.ReadUInt16();

            ulong  uid  = this.binaryReader.ReadUInt64();
            string path = this.binaryReader.ReadString();

            ISessionAuth        sessionAuth        = this.DeserializeSessionAuth();
            IOperationOverrides operationOverrides = this.DeserializeOperationOverrides();
            Guid executionQueueId = Guid.Empty;
            int  executionQueueTimeoutMilliseconds = 0;

            if (this.serializationVersionUsed >= SerializationFormatVersions.Version17)
            {
                bool hasExecutionQueueData = this.binaryReader.ReadBoolean();

                if (hasExecutionQueueData)
                {
                    executionQueueId = this.binaryReader.ReadGuid();
                    executionQueueTimeoutMilliseconds = this.binaryReader.ReadInt32();
                }
            }

            ulong timeStreamId = 0;

            if (this.serializationVersionUsed >= SerializationFormatVersions.Version21)
            {
                timeStreamId = this.binaryReader.ReadUInt64();
            }

            AbstractRingMasterRequest request = null;

            switch (type)
            {
            case RingMasterRequestType.Init:
                request = this.DeserializeRequestInit(uid);
                break;

            case RingMasterRequestType.SetAuth:
                request = this.DeserializeRequestSetAuth(uid);
                break;

            case RingMasterRequestType.Create:
                request = this.DeserializeRequestCreate(uid, path);
                break;

            case RingMasterRequestType.Move:
                request = this.DeserializeRequestMove(uid, path);
                break;

            case RingMasterRequestType.Multi:
                request = this.DeserializeRequestMulti(callid, uid);
                break;

            case RingMasterRequestType.Batch:
                request = this.DeserializeRequestBatch(callid, uid);
                break;

            case RingMasterRequestType.Delete:
                request = this.DeserializeRequestDelete(uid, path);
                break;

            case RingMasterRequestType.Check:
                request = this.DeserializeRequestCheck(uid, path);
                break;

            case RingMasterRequestType.Sync:
                request = this.DeserializeRequestSync(uid, path);
                break;

            case RingMasterRequestType.Exists:
                request = this.DeserializeRequestExists(uid, path);
                break;

            case RingMasterRequestType.GetAcl:
                request = this.DeserializeRequestGetAcl(uid, path);
                break;

            case RingMasterRequestType.GetData:
                request = this.DeserializeRequestGetData(uid, path);
                break;

            case RingMasterRequestType.GetChildren:
                request = this.DeserializeRequestGetChildren(uid, path);
                break;

            case RingMasterRequestType.SetData:
                request = this.DeserializeRequestSetData(uid, path);
                break;

            case RingMasterRequestType.SetAcl:
                request = this.DeserializeRequestSetAcl(uid, path);
                break;

            case RingMasterRequestType.GetSubtree:
                request = this.DeserializeRequestGetSubtree(uid, path);
                break;

            case RingMasterRequestType.None:
            default:
                throw new ArgumentException("unknown type " + type);
            }

            if (request != null)
            {
                request.TimeStreamId = timeStreamId;
                request.Auth         = sessionAuth;
                request.Overrides    = operationOverrides;

                request.ExecutionQueueId            = executionQueueId;
                request.ExecutionQueueTimeoutMillis = executionQueueTimeoutMilliseconds;
            }

            ringMasterRequest = request;
        }