Exemple #1
0
        internal static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            var parameters     = new ResponseParameters();
            var partitionsSize = clientMessage.GetInt();
            var partitions     = new List <KeyValuePair <Address, IList <int> > >(partitionsSize);

            for (var partitionsIndex = 0; partitionsIndex < partitionsSize; partitionsIndex++)
            {
                var partitionsItemKey     = AddressCodec.Decode(clientMessage);
                var partitionsItemValSize = clientMessage.GetInt();
                var partitionsItemVal     = new List <int>(partitionsItemValSize);
                for (var partitionsItemValIndex = 0; partitionsItemValIndex < partitionsItemValSize; partitionsItemValIndex++)
                {
                    var partitionsItemValItem = clientMessage.GetInt();
                    partitionsItemVal.Add(partitionsItemValItem);
                }
                var partitionsItem = new KeyValuePair <Address, IList <int> >(partitionsItemKey, partitionsItemVal);
                partitions.Add(partitionsItem);
            }
            parameters.partitions = partitions;
            if (clientMessage.IsComplete())
            {
                return(parameters);
            }
            var partitionStateVersion = clientMessage.GetInt();

            parameters.partitionStateVersion      = partitionStateVersion;
            parameters.partitionStateVersionExist = true;
            return(parameters);
        }
Exemple #2
0
        internal static ClientMessage EncodeRequest(string name, long delta, bool getBeforeUpdate, IList <KeyValuePair <string, long> > replicaTimestamps, Address targetReplica)
        {
            var requiredDataSize = CalculateRequestDataSize(name, delta, getBeforeUpdate, replicaTimestamps, targetReplica);
            var clientMessage    = ClientMessage.CreateForEncode(requiredDataSize);

            clientMessage.SetMessageType((int)PNCounterMessageType.PNCounterAdd);
            clientMessage.SetRetryable(false);
            clientMessage.Set(name);
            clientMessage.Set(delta);
            clientMessage.Set(getBeforeUpdate);
            clientMessage.Set(replicaTimestamps.Count);

            foreach (var replicaTimestampsItem in replicaTimestamps)
            {
                var replicaTimestampsItemKey = replicaTimestampsItem.Key;
                var replicaTimestampsItemVal = replicaTimestampsItem.Value;

                clientMessage.Set(replicaTimestampsItemKey);
                clientMessage.Set(replicaTimestampsItemVal);
            }

            AddressCodec.Encode(targetReplica, clientMessage);
            clientMessage.UpdateFrameLength();

            return(clientMessage);
        }
        public static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            ResponseParameters parameters = new ResponseParameters();
            IDictionary <Address, ISet <int> > partitions = null;
            int partitions_size = clientMessage.GetInt();

            partitions = new Dictionary <Address, ISet <int> >(partitions_size);
            for (int partitions_index = 0; partitions_index < partitions_size; partitions_index++)
            {
                Address    partitions_key;
                ISet <int> partitions_val;
                partitions_key = AddressCodec.Decode(clientMessage);
                int partitions_val_size = clientMessage.GetInt();
                partitions_val = new HashSet <int>();
                for (int partitions_val_index = 0; partitions_val_index < partitions_val_size; partitions_val_index++)
                {
                    int partitions_val_item;
                    partitions_val_item = clientMessage.GetInt();
                    partitions_val.Add(partitions_val_item);
                }
                partitions.Add(partitions_key, partitions_val);
            }
            parameters.partitions = partitions;
            return(parameters);
        }
            public static int CalculateDataSize(string name, string serviceName, Address target)
            {
                int dataSize = ClientMessage.HeaderSize;

                dataSize += ParameterUtil.CalculateDataSize(name);
                dataSize += ParameterUtil.CalculateDataSize(serviceName);
                dataSize += AddressCodec.CalculateDataSize(target);
                return(dataSize);
            }
        public static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            var parameters = new ResponseParameters();
            var status     = clientMessage.GetByte();

            parameters.status = status;
            var addressIsNull = clientMessage.GetBoolean();

            if (!addressIsNull)
            {
                var address = AddressCodec.Decode(clientMessage);
                parameters.address = address;
            }
            var uuidIsNull = clientMessage.GetBoolean();

            if (!uuidIsNull)
            {
                var uuid = clientMessage.GetStringUtf8();
                parameters.uuid = uuid;
            }
            var ownerUuidIsNull = clientMessage.GetBoolean();

            if (!ownerUuidIsNull)
            {
                var ownerUuid = clientMessage.GetStringUtf8();
                parameters.ownerUuid = ownerUuid;
            }
            var serializationVersion = clientMessage.GetByte();

            parameters.serializationVersion = serializationVersion;
            if (clientMessage.IsComplete())
            {
                return(parameters);
            }
            var serverHazelcastVersion = clientMessage.GetStringUtf8();

            parameters.serverHazelcastVersion      = serverHazelcastVersion;
            parameters.serverHazelcastVersionExist = true;
            var clientUnregisteredMembersIsNull = clientMessage.GetBoolean();

            if (!clientUnregisteredMembersIsNull)
            {
                var clientUnregisteredMembers     = new List <Core.IMember>();
                var clientUnregisteredMembersSize = clientMessage.GetInt();
                for (var clientUnregisteredMembersIndex = 0;
                     clientUnregisteredMembersIndex < clientUnregisteredMembersSize;
                     clientUnregisteredMembersIndex++)
                {
                    var clientUnregisteredMembersItem = MemberCodec.Decode(clientMessage);
                    clientUnregisteredMembers.Add(clientUnregisteredMembersItem);
                }
                parameters.clientUnregisteredMembers = clientUnregisteredMembers;
            }
            parameters.clientUnregisteredMembersExist = true;
            return(parameters);
        }
        private static int CalculateRequestDataSize(IList <string> names, Address address)
        {
            var dataSize = ClientMessage.HeaderSize;

            dataSize += Bits.IntSizeInBytes;
            foreach (var namesItem in names)
            {
                dataSize += ParameterUtil.CalculateDataSize(namesItem);
            }
            dataSize += AddressCodec.CalculateDataSize(address);
            return(dataSize);
        }
        public static ClientMessage EncodeRequest(string name, string serviceName, Address target)
        {
            int           requiredDataSize = RequestParameters.CalculateDataSize(name, serviceName, target);
            ClientMessage clientMessage    = ClientMessage.CreateForEncode(requiredDataSize);

            clientMessage.SetMessageType((int)RequestType);
            clientMessage.SetRetryable(Retryable);
            clientMessage.Set(name);
            clientMessage.Set(serviceName);
            AddressCodec.Encode(target, clientMessage);
            clientMessage.UpdateFrameLength();
            return(clientMessage);
        }
        internal static ClientMessage EncodeRequest(string name, string serviceName, Address target)
        {
            var requiredDataSize = CalculateRequestDataSize(name, serviceName, target);
            var clientMessage    = ClientMessage.CreateForEncode(requiredDataSize);

            clientMessage.SetMessageType((int)ClientMessageType.ClientCreateProxy);
            clientMessage.SetRetryable(false);
            clientMessage.Set(name);
            clientMessage.Set(serviceName);
            AddressCodec.Encode(target, clientMessage);
            clientMessage.UpdateFrameLength();
            return(clientMessage);
        }
        internal static ClientMessage EncodeRequest(IList <string> names, Address address)
        {
            var requiredDataSize = CalculateRequestDataSize(names, address);
            var clientMessage    = ClientMessage.CreateForEncode(requiredDataSize);

            clientMessage.SetMessageType((int)MapMessageType.MapFetchNearCacheInvalidationMetadata);
            clientMessage.SetRetryable(false);
            clientMessage.Set(names.Count);
            foreach (var namesItem in names)
            {
                clientMessage.Set(namesItem);
            }
            AddressCodec.Encode(address, clientMessage);
            clientMessage.UpdateFrameLength();
            return(clientMessage);
        }
Exemple #10
0
        public static Member Decode(IClientMessage clientMessage)
        {
            var address       = AddressCodec.Decode(clientMessage);
            var uuid          = clientMessage.GetStringUtf8();
            var liteMember    = clientMessage.GetBoolean();
            var attributeSize = clientMessage.GetInt();
            IDictionary <string, string> attributes = new Dictionary <string, string>();

            for (var i = 0; i < attributeSize; i++)
            {
                var key   = clientMessage.GetStringUtf8();
                var value = clientMessage.GetStringUtf8();
                attributes[key] = value;
            }
            return(new Member(address, uuid, attributes, liteMember));
        }
Exemple #11
0
        private static int CalculateRequestDataSize(string name, IList <KeyValuePair <string, long> > replicaTimestamps, Address targetReplica)
        {
            var dataSize = ClientMessage.HeaderSize;

            dataSize += ParameterUtil.CalculateDataSize(name);
            dataSize += Bits.IntSizeInBytes;
            foreach (var replicaTimestampsItem in replicaTimestamps)
            {
                var replicaTimestampsItemKey = replicaTimestampsItem.Key;
                var replicaTimestampsItemVal = replicaTimestampsItem.Value;
                dataSize += ParameterUtil.CalculateDataSize(replicaTimestampsItemKey);
                dataSize += ParameterUtil.CalculateDataSize(replicaTimestampsItemVal);
            }
            dataSize += AddressCodec.CalculateDataSize(targetReplica);
            return(dataSize);
        }
        public static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            var  parameters = new ResponseParameters();
            byte status;

            status            = clientMessage.GetByte();
            parameters.status = status;
            Address address        = null;
            var     address_isNull = clientMessage.GetBoolean();

            if (!address_isNull)
            {
                address            = AddressCodec.Decode(clientMessage);
                parameters.address = address;
            }
            string uuid        = null;
            var    uuid_isNull = clientMessage.GetBoolean();

            if (!uuid_isNull)
            {
                uuid            = clientMessage.GetStringUtf8();
                parameters.uuid = uuid;
            }
            string ownerUuid        = null;
            var    ownerUuid_isNull = clientMessage.GetBoolean();

            if (!ownerUuid_isNull)
            {
                ownerUuid            = clientMessage.GetStringUtf8();
                parameters.ownerUuid = ownerUuid;
            }
            byte serializationVersion;

            serializationVersion            = clientMessage.GetByte();
            parameters.serializationVersion = serializationVersion;
            return(parameters);
        }
        public static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            var parameters     = new ResponseParameters();
            var partitions     = new List <KeyValuePair <Address, IList <int> > >();
            var partitionsSize = clientMessage.GetInt();

            for (var partitionsIndex = 0; partitionsIndex < partitionsSize; partitionsIndex++)
            {
                var partitionsItemKey     = AddressCodec.Decode(clientMessage);
                var partitionsItemVal     = new List <int>();
                var partitionsItemValSize = clientMessage.GetInt();
                for (var partitionsItemValIndex = 0;
                     partitionsItemValIndex < partitionsItemValSize;
                     partitionsItemValIndex++)
                {
                    var partitionsItemValItem = clientMessage.GetInt();
                    partitionsItemVal.Add(partitionsItemValItem);
                }
                var partitionsItem = new KeyValuePair <Address, IList <int> >(partitionsItemKey, partitionsItemVal);
                partitions.Add(partitionsItem);
            }
            parameters.partitions = partitions;
            return(parameters);
        }