internal static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            var parameters = new ResponseParameters();
            var namePartitionSequenceListSize = clientMessage.GetInt();
            var namePartitionSequenceList     =
                new List <KeyValuePair <string, IList <KeyValuePair <int, long> > > >(namePartitionSequenceListSize);

            for (var namePartitionSequenceListIndex = 0;
                 namePartitionSequenceListIndex < namePartitionSequenceListSize;
                 namePartitionSequenceListIndex++)
            {
                var namePartitionSequenceListItemKey     = clientMessage.GetStringUtf8();
                var namePartitionSequenceListItemValSize = clientMessage.GetInt();
                var namePartitionSequenceListItemVal     = new List <KeyValuePair <int, long> >(namePartitionSequenceListItemValSize);
                for (var namePartitionSequenceListItemValIndex = 0;
                     namePartitionSequenceListItemValIndex < namePartitionSequenceListItemValSize;
                     namePartitionSequenceListItemValIndex++)
                {
                    var namePartitionSequenceListItemValItemKey = clientMessage.GetInt();
                    var namePartitionSequenceListItemValItemVal = clientMessage.GetLong();
                    var namePartitionSequenceListItemValItem    =
                        new KeyValuePair <int, long>(namePartitionSequenceListItemValItemKey,
                                                     namePartitionSequenceListItemValItemVal);
                    namePartitionSequenceListItemVal.Add(namePartitionSequenceListItemValItem);
                }
                var namePartitionSequenceListItem =
                    new KeyValuePair <string, IList <KeyValuePair <int, long> > >(namePartitionSequenceListItemKey,
                                                                                  namePartitionSequenceListItemVal);
                namePartitionSequenceList.Add(namePartitionSequenceListItem);
            }
            parameters.namePartitionSequenceList = namePartitionSequenceList;
            var partitionUuidListSize = clientMessage.GetInt();
            var partitionUuidList     = new List <KeyValuePair <int, Guid> >(partitionUuidListSize);

            for (var partitionUuidListIndex = 0; partitionUuidListIndex < partitionUuidListSize; partitionUuidListIndex++)
            {
                var partitionUuidListItemKey = clientMessage.GetInt();
                var partitionUuidListItemVal = GuidCodec.Decode(clientMessage);
                var partitionUuidListItem    = new KeyValuePair <int, Guid>(partitionUuidListItemKey, partitionUuidListItemVal);
                partitionUuidList.Add(partitionUuidListItem);
            }
            parameters.partitionUuidList = partitionUuidList;
            return(parameters);
        }
예제 #2
0
            internal static void HandleEvent(IClientMessage clientMessage,
                                             HandleIMapInvalidationEventV10 handleIMapInvalidationEventV10,
                                             HandleIMapInvalidationEventV14 handleIMapInvalidationEventV14,
                                             HandleIMapBatchInvalidationEventV10 handleIMapBatchInvalidationEventV10,
                                             HandleIMapBatchInvalidationEventV14 handleIMapBatchInvalidationEventV14)
            {
                var messageType = clientMessage.GetMessageType();

                if (messageType == EventMessageConst.EventIMapInvalidation)
                {
                    IData key       = null;
                    var   keyIsNull = clientMessage.GetBoolean();
                    if (!keyIsNull)
                    {
                        key = clientMessage.GetData();
                    }
                    if (clientMessage.IsComplete())
                    {
                        handleIMapInvalidationEventV10(key);
                        return;
                    }
                    var sourceUuid    = clientMessage.GetStringUtf8();
                    var partitionUuid = GuidCodec.Decode(clientMessage);
                    var sequence      = clientMessage.GetLong();
                    handleIMapInvalidationEventV14(key, sourceUuid, partitionUuid, sequence);
                    return;
                }
                if (messageType == EventMessageConst.EventIMapBatchInvalidation)
                {
                    var keysSize = clientMessage.GetInt();
                    var keys     = new List <IData>(keysSize);
                    for (var keysIndex = 0; keysIndex < keysSize; keysIndex++)
                    {
                        var keysItem = clientMessage.GetData();
                        keys.Add(keysItem);
                    }
                    if (clientMessage.IsComplete())
                    {
                        handleIMapBatchInvalidationEventV10(keys);
                        return;
                    }
                    var sourceUuidsSize = clientMessage.GetInt();
                    var sourceUuids     = new List <string>(sourceUuidsSize);
                    for (var sourceUuidsIndex = 0; sourceUuidsIndex < sourceUuidsSize; sourceUuidsIndex++)
                    {
                        var sourceUuidsItem = clientMessage.GetStringUtf8();
                        sourceUuids.Add(sourceUuidsItem);
                    }
                    var partitionUuidsSize = clientMessage.GetInt();
                    var partitionUuids     = new List <Guid>(partitionUuidsSize);
                    for (var partitionUuidsIndex = 0; partitionUuidsIndex < partitionUuidsSize; partitionUuidsIndex++)
                    {
                        var partitionUuidsItem = GuidCodec.Decode(clientMessage);
                        partitionUuids.Add(partitionUuidsItem);
                    }
                    var sequencesSize = clientMessage.GetInt();
                    var sequences     = new List <long>(sequencesSize);
                    for (var sequencesIndex = 0; sequencesIndex < sequencesSize; sequencesIndex++)
                    {
                        var sequencesItem = clientMessage.GetLong();
                        sequences.Add(sequencesItem);
                    }
                    handleIMapBatchInvalidationEventV14(keys, sourceUuids, partitionUuids, sequences);
                    return;
                }
                Logger.GetLogger(typeof(EventHandler)).Warning("Unknown message type received on event handler :" + messageType);
            }