public static void HandleEvent(ClientMessage clientMessage, HandleIMapInvalidationEvent handleIMapInvalidationEvent, HandleIMapBatchInvalidationEvent handleIMapBatchInvalidationEvent) { var messageType = clientMessage.MessageType; var iterator = clientMessage.GetIterator(); if (messageType == EventIMapInvalidationMessageType) { var initialFrame = iterator.Next(); Guid sourceUuid = DecodeGuid(initialFrame.Content, EventIMapInvalidationSourceUuidFieldOffset); Guid partitionUuid = DecodeGuid(initialFrame.Content, EventIMapInvalidationPartitionUuidFieldOffset); long sequence = DecodeLong(initialFrame.Content, EventIMapInvalidationSequenceFieldOffset); IData key = CodecUtil.DecodeNullable(iterator, DataCodec.Decode); handleIMapInvalidationEvent(key, sourceUuid, partitionUuid, sequence); return; } if (messageType == EventIMapBatchInvalidationMessageType) { //empty initial frame iterator.Next(); IList <IData> keys = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); IList <Guid> sourceUuids = ListUUIDCodec.Decode(iterator); IList <Guid> partitionUuids = ListUUIDCodec.Decode(iterator); IList <long> sequences = ListLongCodec.Decode(iterator); handleIMapBatchInvalidationEvent(keys, sourceUuids, partitionUuids, sequences); return; } Logger.GetLogger(typeof(EventHandler)).Finest("Unknown message type received on event handler :" + messageType); }
public static ValueTask HandleEventAsync(ClientMessage clientMessage, Func <IData, Guid, Guid, long, object, ValueTask> handleIMapInvalidationEventAsync, Func <IList <IData>, IList <Guid>, IList <Guid>, IList <long>, object, ValueTask> handleIMapBatchInvalidationEventAsync, object state, ILoggerFactory loggerFactory) { using var iterator = clientMessage.GetEnumerator(); var messageType = clientMessage.MessageType; if (messageType == EventIMapInvalidationMessageType) { var initialFrame = iterator.Take(); var sourceUuid = initialFrame.Bytes.ReadGuidL(EventIMapInvalidationSourceUuidFieldOffset); var partitionUuid = initialFrame.Bytes.ReadGuidL(EventIMapInvalidationPartitionUuidFieldOffset); var sequence = initialFrame.Bytes.ReadLongL(EventIMapInvalidationSequenceFieldOffset); var key = CodecUtil.DecodeNullable(iterator, DataCodec.Decode); return(handleIMapInvalidationEventAsync(key, sourceUuid, partitionUuid, sequence, state)); } if (messageType == EventIMapBatchInvalidationMessageType) { iterator.Take(); // empty initial frame var keys = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); var sourceUuids = ListUUIDCodec.Decode(iterator); var partitionUuids = ListUUIDCodec.Decode(iterator); var sequences = ListLongCodec.Decode(iterator); return(handleIMapBatchInvalidationEventAsync(keys, sourceUuids, partitionUuids, sequences, state)); } loggerFactory.CreateLogger(typeof(EventHandler)).LogDebug("Unknown message type received on event handler :" + messageType); return(default);
public static List <ErrorHolder> Decode(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); //initial frame iterator.Take(); return(ListMultiFrameCodec.Decode(iterator, ErrorHolderCodec.Decode)); }
public static RequestParameters DecodeRequest(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var request = new RequestParameters(); iterator.Take(); // empty initial frame request.Name = StringCodec.Decode(iterator); request.Values = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); return request; }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var response = new ResponseParameters(); iterator.Take(); // empty initial frame response.Response = ListMultiFrameCodec.DecodeContainsNullable(iterator, DataCodec.Decode); return(response); }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var response = new ResponseParameters(); iterator.Take(); // empty initial frame response.Response = ListMultiFrameCodec.Decode(iterator, DistributedObjectInfoCodec.Decode); return(response); }
public static RequestParameters DecodeRequest(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var request = new RequestParameters(); var initialFrame = iterator.Take(); request.Uuid = initialFrame.Bytes.ReadGuidL(RequestUuidFieldOffset); request.Names = ListMultiFrameCodec.Decode(iterator, StringCodec.Decode); return(request); }
public static ClientMessage EncodeResponse(ICollection <Hazelcast.Models.DistributedObjectInfo> response) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[ResponseInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, ResponseMessageType); clientMessage.Append(initialFrame); ListMultiFrameCodec.Encode(clientMessage, response, DistributedObjectInfoCodec.Encode); return(clientMessage); }
public static ClientMessage EncodeResponse(ICollection <IData> response) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[ResponseInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, ResponseMessageType); clientMessage.Append(initialFrame); ListMultiFrameCodec.EncodeContainsNullable(clientMessage, response, DataCodec.Encode); return(clientMessage); }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { var iterator = clientMessage.GetIterator(); var response = new ResponseParameters(); //empty initial frame iterator.Next(); response.Response = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); return(response); }
// or should this be available for all codecs, EncodeResponse, in the testing project? public static ClientMessage EncodeResponse(IEnumerable <ErrorHolder> errorHolders) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[InitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); clientMessage.Append(initialFrame); clientMessage.MessageType = ExceptionMessageType; ListMultiFrameCodec.Encode(clientMessage, errorHolders, ErrorHolderCodec.Encode); return(clientMessage); }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var response = new ResponseParameters(); iterator.Take(); // empty initial frame response.IterationPointers = EntryListIntegerIntegerCodec.Decode(iterator); response.Keys = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); return(response); }
public static ClientMessage EncodeResponse(ICollection <KeyValuePair <int, int> > iterationPointers, ICollection <IData> keys) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[ResponseInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, ResponseMessageType); clientMessage.Append(initialFrame); EntryListIntegerIntegerCodec.Encode(clientMessage, iterationPointers); ListMultiFrameCodec.Encode(clientMessage, keys, DataCodec.Encode); return(clientMessage); }
public static RequestParameters DecodeRequest(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var request = new RequestParameters(); var initialFrame = iterator.Take(); request.ReplaceExistingValues = initialFrame.Bytes.ReadBoolL(RequestReplaceExistingValuesFieldOffset); request.Name = StringCodec.Decode(iterator); request.Keys = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); return(request); }
public static RequestParameters DecodeRequest(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var request = new RequestParameters(); var initialFrame = iterator.Take(); request.OverflowPolicy = initialFrame.Bytes.ReadIntL(RequestOverflowPolicyFieldOffset); request.Name = StringCodec.Decode(iterator); request.ValueList = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); return(request); }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { var iterator = clientMessage.GetIterator(); var response = new ResponseParameters(); //empty initial frame iterator.Next(); response.Results = ListMultiFrameCodec.DecodeContainsNullable(iterator, DataCodec.Decode); response.IterationPointers = EntryListIntegerIntegerCodec.Decode(iterator); return(response); }
public static ClientMessage EncodeResponse(ICollection <IData> response, Hazelcast.Protocol.Models.AnchorDataListHolder anchorDataList) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[ResponseInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, ResponseMessageType); clientMessage.Append(initialFrame); ListMultiFrameCodec.Encode(clientMessage, response, DataCodec.Encode); AnchorDataListHolderCodec.Encode(clientMessage, anchorDataList); return(clientMessage); }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { var iterator = clientMessage.GetIterator(); var response = new ResponseParameters(); var initialFrame = iterator.Next(); response.ReadCount = DecodeInt(initialFrame.Content, ResponseReadCountFieldOffset); response.NextSeq = DecodeLong(initialFrame.Content, ResponseNextSeqFieldOffset); response.Items = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); response.ItemSeqs = CodecUtil.DecodeNullable(iterator, LongArrayCodec.Decode); return(response); }
public static ResponseParameters DecodeResponse(ClientMessage clientMessage) { using var iterator = clientMessage.GetEnumerator(); var response = new ResponseParameters(); var initialFrame = iterator.Take(); response.ReadCount = initialFrame.Bytes.ReadIntL(ResponseReadCountFieldOffset); response.NextSeq = initialFrame.Bytes.ReadLongL(ResponseNextSeqFieldOffset); response.Items = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode); response.ItemSeqs = CodecUtil.DecodeNullable(iterator, LongArrayCodec.Decode); return(response); }
public static ClientMessage EncodeMembersViewEvent(int version, ICollection <Hazelcast.Models.MemberInfo> memberInfos) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[EventMembersViewInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, EventMembersViewMessageType); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.PartitionId, -1); initialFrame.Bytes.WriteIntL(EventMembersViewVersionFieldOffset, version); clientMessage.Append(initialFrame); clientMessage.Flags |= ClientMessageFlags.Event; ListMultiFrameCodec.Encode(clientMessage, memberInfos, MemberInfoCodec.Encode); return(clientMessage); }
public static ClientMessage EncodeResponse(int readCount, ICollection <IData> items, long[] itemSeqs, long nextSeq) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[ResponseInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, ResponseMessageType); initialFrame.Bytes.WriteIntL(ResponseReadCountFieldOffset, readCount); initialFrame.Bytes.WriteLongL(ResponseNextSeqFieldOffset, nextSeq); clientMessage.Append(initialFrame); ListMultiFrameCodec.Encode(clientMessage, items, DataCodec.Encode); CodecUtil.EncodeNullable(clientMessage, itemSeqs, LongArrayCodec.Encode); return(clientMessage); }
public static Hazelcast.Models.IndexOptions Decode(IEnumerator <Frame> iterator) { // begin frame iterator.Take(); var initialFrame = iterator.Take(); var type = initialFrame.Bytes.ReadIntL(TypeFieldOffset); var name = CodecUtil.DecodeNullable(iterator, StringCodec.Decode); var attributes = ListMultiFrameCodec.Decode(iterator, StringCodec.Decode); var bitmapIndexOptions = CodecUtil.DecodeNullable(iterator, BitmapIndexOptionsCodec.Decode); iterator.SkipToStructEnd(); return(CustomTypeFactory.CreateIndexConfig(name, type, attributes, bitmapIndexOptions)); }
public static ClientMessage EncodeRequest(string name, ICollection <IData> values) { var clientMessage = CreateForEncode(); clientMessage.IsRetryable = true; clientMessage.OperationName = "List.ContainsAll"; var initialFrame = new Frame(new byte[RequestInitialFrameSize], UnfragmentedMessage); EncodeInt(initialFrame.Content, TypeFieldOffset, RequestMessageType); EncodeInt(initialFrame.Content, PartitionIdFieldOffset, -1); clientMessage.Add(initialFrame); StringCodec.Encode(clientMessage, name); ListMultiFrameCodec.Encode(clientMessage, values, DataCodec.Encode); return(clientMessage); }
public static ClientMessage EncodeRequest(string name, ICollection<IData> values) { var clientMessage = new ClientMessage { IsRetryable = true, OperationName = "List.ContainsAll" }; var initialFrame = new Frame(new byte[RequestInitialFrameSize], (FrameFlags) ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, RequestMessageType); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.PartitionId, -1); clientMessage.Append(initialFrame); StringCodec.Encode(clientMessage, name); ListMultiFrameCodec.Encode(clientMessage, values, DataCodec.Encode); return clientMessage; }
public static void Encode(ClientMessage clientMessage, Hazelcast.Models.IndexOptions indexConfig) { clientMessage.Append(Frame.CreateBeginStruct()); var initialFrame = new Frame(new byte[InitialFrameSize]); initialFrame.Bytes.WriteIntL(TypeFieldOffset, indexConfig.Type); clientMessage.Append(initialFrame); CodecUtil.EncodeNullable(clientMessage, indexConfig.Name, StringCodec.Encode); ListMultiFrameCodec.Encode(clientMessage, indexConfig.Attributes, StringCodec.Encode); CodecUtil.EncodeNullable(clientMessage, indexConfig.BitmapIndexOptions, BitmapIndexOptionsCodec.Encode); clientMessage.Append(Frame.CreateEndStruct()); }
public static ClientMessage EncodeRequest(ICollection <string> names, Guid uuid) { var clientMessage = CreateForEncode(); clientMessage.IsRetryable = false; clientMessage.OperationName = "Map.FetchNearCacheInvalidationMetadata"; var initialFrame = new Frame(new byte[RequestInitialFrameSize], UnfragmentedMessage); EncodeInt(initialFrame.Content, TypeFieldOffset, RequestMessageType); EncodeInt(initialFrame.Content, PartitionIdFieldOffset, -1); EncodeGuid(initialFrame.Content, RequestUuidFieldOffset, uuid); clientMessage.Add(initialFrame); ListMultiFrameCodec.Encode(clientMessage, names, StringCodec.Encode); return(clientMessage); }
public static Hazelcast.Protocol.Models.ErrorHolder Decode(IEnumerator <Frame> iterator) { // begin frame iterator.Take(); var initialFrame = iterator.Take(); var errorCode = initialFrame.Bytes.ReadIntL(ErrorCodeFieldOffset); var className = StringCodec.Decode(iterator); var message = CodecUtil.DecodeNullable(iterator, StringCodec.Decode); var stackTraceElements = ListMultiFrameCodec.Decode(iterator, StackTraceElementCodec.Decode); iterator.SkipToStructEnd(); return(new Hazelcast.Protocol.Models.ErrorHolder(errorCode, className, message, stackTraceElements)); }
public static ClientMessage EncodeIMapBatchInvalidationEvent(ICollection <IData> keys, ICollection <Guid> sourceUuids, ICollection <Guid> partitionUuids, ICollection <long> sequences) { var clientMessage = new ClientMessage(); var initialFrame = new Frame(new byte[EventIMapBatchInvalidationInitialFrameSize], (FrameFlags)ClientMessageFlags.Unfragmented); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.MessageType, EventIMapBatchInvalidationMessageType); initialFrame.Bytes.WriteIntL(Messaging.FrameFields.Offset.PartitionId, -1); clientMessage.Append(initialFrame); clientMessage.Flags |= ClientMessageFlags.Event; ListMultiFrameCodec.Encode(clientMessage, keys, DataCodec.Encode); ListUUIDCodec.Encode(clientMessage, sourceUuids); ListUUIDCodec.Encode(clientMessage, partitionUuids); ListLongCodec.Encode(clientMessage, sequences); return(clientMessage); }
public static void Encode(ClientMessage clientMessage, Hazelcast.Protocol.Models.ErrorHolder errorHolder) { clientMessage.Append(Frame.CreateBeginStruct()); var initialFrame = new Frame(new byte[InitialFrameSize]); initialFrame.Bytes.WriteIntL(ErrorCodeFieldOffset, errorHolder.ErrorCode); clientMessage.Append(initialFrame); StringCodec.Encode(clientMessage, errorHolder.ClassName); CodecUtil.EncodeNullable(clientMessage, errorHolder.Message, StringCodec.Encode); ListMultiFrameCodec.Encode(clientMessage, errorHolder.StackTraceElements, StackTraceElementCodec.Encode); clientMessage.Append(Frame.CreateEndStruct()); }
public static void Encode(ClientMessage clientMessage, Hazelcast.Client.Protocol.ErrorHolder errorHolder) { clientMessage.Add(BeginFrame.Copy()); var initialFrame = new Frame(new byte[InitialFrameSize]); EncodeInt(initialFrame.Content, ErrorCodeFieldOffset, errorHolder.ErrorCode); clientMessage.Add(initialFrame); StringCodec.Encode(clientMessage, errorHolder.ClassName); CodecUtil.EncodeNullable(clientMessage, errorHolder.Message, StringCodec.Encode); ListMultiFrameCodec.Encode(clientMessage, errorHolder.StackTraceElements, StackTraceElementCodec.Encode); clientMessage.Add(EndFrame.Copy()); }