Esempio n. 1
0
def handle(msg,
           handle_i_map_invalidation_event=None,
           handle_i_map_batch_invalidation_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_I_MAP_INVALIDATION_MESSAGE_TYPE and handle_i_map_invalidation_event is not None:
        initial_frame = msg.next_frame()
        source_uuid = FixSizedTypesCodec.decode_uuid(
            initial_frame.buf, _EVENT_I_MAP_INVALIDATION_SOURCE_UUID_OFFSET)
        partition_uuid = FixSizedTypesCodec.decode_uuid(
            initial_frame.buf, _EVENT_I_MAP_INVALIDATION_PARTITION_UUID_OFFSET)
        sequence = FixSizedTypesCodec.decode_long(
            initial_frame.buf, _EVENT_I_MAP_INVALIDATION_SEQUENCE_OFFSET)
        key = CodecUtil.decode_nullable(msg, DataCodec.decode)
        handle_i_map_invalidation_event(key, source_uuid, partition_uuid,
                                        sequence)
        return
    if message_type == _EVENT_I_MAP_BATCH_INVALIDATION_MESSAGE_TYPE and handle_i_map_batch_invalidation_event is not None:
        msg.next_frame()
        keys = ListMultiFrameCodec.decode(msg, DataCodec.decode)
        source_uuids = ListUUIDCodec.decode(msg)
        partition_uuids = ListUUIDCodec.decode(msg)
        sequences = ListLongCodec.decode(msg)
        handle_i_map_batch_invalidation_event(keys, source_uuids,
                                              partition_uuids, sequences)
        return
def handle(msg, handle_item_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_ITEM_MESSAGE_TYPE and handle_item_event is not None:
        initial_frame = msg.next_frame()
        uuid = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _EVENT_ITEM_UUID_OFFSET)
        event_type = FixSizedTypesCodec.decode_int(initial_frame.buf, _EVENT_ITEM_EVENT_TYPE_OFFSET)
        item = CodecUtil.decode_nullable(msg, DataCodec.decode)
        handle_item_event(item, uuid, event_type)
        return
Esempio n. 3
0
def decode_response(msg):
    initial_frame = msg.next_frame()
    response = dict()
    response["status"] = FixSizedTypesCodec.decode_byte(
        initial_frame.buf, _RESPONSE_STATUS_OFFSET)
    response["member_uuid"] = FixSizedTypesCodec.decode_uuid(
        initial_frame.buf, _RESPONSE_MEMBER_UUID_OFFSET)
    response["serialization_version"] = FixSizedTypesCodec.decode_byte(
        initial_frame.buf, _RESPONSE_SERIALIZATION_VERSION_OFFSET)
    response["partition_count"] = FixSizedTypesCodec.decode_int(
        initial_frame.buf, _RESPONSE_PARTITION_COUNT_OFFSET)
    response["cluster_id"] = FixSizedTypesCodec.decode_uuid(
        initial_frame.buf, _RESPONSE_CLUSTER_ID_OFFSET)
    response["failover_supported"] = FixSizedTypesCodec.decode_boolean(
        initial_frame.buf, _RESPONSE_FAILOVER_SUPPORTED_OFFSET)
    response["address"] = CodecUtil.decode_nullable(msg, AddressCodec.decode)
    response["server_hazelcast_version"] = StringCodec.decode(msg)
    return response
Esempio n. 4
0
def handle(msg, handle_map_partition_lost_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_MAP_PARTITION_LOST_MESSAGE_TYPE and handle_map_partition_lost_event is not None:
        initial_frame = msg.next_frame()
        partition_id = FixSizedTypesCodec.decode_int(
            initial_frame.buf, _EVENT_MAP_PARTITION_LOST_PARTITION_ID_OFFSET)
        uuid = FixSizedTypesCodec.decode_uuid(
            initial_frame.buf, _EVENT_MAP_PARTITION_LOST_UUID_OFFSET)
        handle_map_partition_lost_event(partition_id, uuid)
        return
def handle(msg, handle_distributed_object_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_DISTRIBUTED_OBJECT_MESSAGE_TYPE and handle_distributed_object_event is not None:
        initial_frame = msg.next_frame()
        source = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _EVENT_DISTRIBUTED_OBJECT_SOURCE_OFFSET)
        name = StringCodec.decode(msg)
        service_name = StringCodec.decode(msg)
        event_type = StringCodec.decode(msg)
        handle_distributed_object_event(name, service_name, event_type, source)
        return
Esempio n. 6
0
def handle(msg, handle_topic_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_TOPIC_MESSAGE_TYPE and handle_topic_event is not None:
        initial_frame = msg.next_frame()
        publish_time = FixSizedTypesCodec.decode_long(
            initial_frame.buf, _EVENT_TOPIC_PUBLISH_TIME_OFFSET)
        uuid = FixSizedTypesCodec.decode_uuid(initial_frame.buf,
                                              _EVENT_TOPIC_UUID_OFFSET)
        item = DataCodec.decode(msg)
        handle_topic_event(item, publish_time, uuid)
        return
Esempio n. 7
0
def handle(msg, handle_partition_lost_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_PARTITION_LOST_MESSAGE_TYPE and handle_partition_lost_event is not None:
        initial_frame = msg.next_frame()
        partition_id = FixSizedTypesCodec.decode_int(
            initial_frame.buf, _EVENT_PARTITION_LOST_PARTITION_ID_OFFSET)
        lost_backup_count = FixSizedTypesCodec.decode_int(
            initial_frame.buf, _EVENT_PARTITION_LOST_LOST_BACKUP_COUNT_OFFSET)
        source = FixSizedTypesCodec.decode_uuid(
            initial_frame.buf, _EVENT_PARTITION_LOST_SOURCE_OFFSET)
        handle_partition_lost_event(partition_id, lost_backup_count, source)
        return
Esempio n. 8
0
 def decode(msg):
     msg.next_frame()
     initial_frame = msg.next_frame()
     code = FixSizedTypesCodec.decode_int(initial_frame.buf, _CODE_DECODE_OFFSET)
     originating_member_id = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _ORIGINATING_MEMBER_ID_DECODE_OFFSET)
     message = CodecUtil.decode_nullable(msg, StringCodec.decode)
     is_suggestion_exists = False
     suggestion = None
     if not msg.peek_next_frame().is_end_frame():
         suggestion = CodecUtil.decode_nullable(msg, StringCodec.decode)
         is_suggestion_exists = True
     CodecUtil.fast_forward_to_end_frame(msg)
     return _SqlError(code, message, originating_member_id, is_suggestion_exists, suggestion)
def handle(msg, handle_entry_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_ENTRY_MESSAGE_TYPE and handle_entry_event is not None:
        initial_frame = msg.next_frame()
        event_type = FixSizedTypesCodec.decode_int(initial_frame.buf, _EVENT_ENTRY_EVENT_TYPE_OFFSET)
        uuid = FixSizedTypesCodec.decode_uuid(initial_frame.buf, _EVENT_ENTRY_UUID_OFFSET)
        number_of_affected_entries = FixSizedTypesCodec.decode_int(initial_frame.buf, _EVENT_ENTRY_NUMBER_OF_AFFECTED_ENTRIES_OFFSET)
        key = CodecUtil.decode_nullable(msg, DataCodec.decode)
        value = CodecUtil.decode_nullable(msg, DataCodec.decode)
        old_value = CodecUtil.decode_nullable(msg, DataCodec.decode)
        merging_value = CodecUtil.decode_nullable(msg, DataCodec.decode)
        handle_entry_event(key, value, old_value, merging_value, event_type, uuid, number_of_affected_entries)
        return
 def decode(msg):
     msg.next_frame()
     initial_frame = msg.next_frame()
     uuid = FixSizedTypesCodec.decode_uuid(initial_frame.buf,
                                           _UUID_DECODE_OFFSET)
     lite_member = FixSizedTypesCodec.decode_boolean(
         initial_frame.buf, _LITE_MEMBER_DECODE_OFFSET)
     address = AddressCodec.decode(msg)
     attributes = MapCodec.decode(msg, StringCodec.decode,
                                  StringCodec.decode)
     version = MemberVersionCodec.decode(msg)
     is_address_map_exists = False
     address_map = None
     if not msg.peek_next_frame().is_end_frame():
         address_map = MapCodec.decode(msg, EndpointQualifierCodec.decode,
                                       AddressCodec.decode)
         is_address_map_exists = True
     CodecUtil.fast_forward_to_end_frame(msg)
     return MemberInfo(address, uuid, attributes, lite_member, version,
                       is_address_map_exists, address_map)
def decode_response(msg):
    initial_frame = msg.next_frame()
    return FixSizedTypesCodec.decode_uuid(initial_frame.buf,
                                          _RESPONSE_RESPONSE_OFFSET)
 def test_uuid(self):
     random_uuid = uuid.uuid4()
     FixSizedTypesCodec.encode_uuid(self.buf, 16, random_uuid)
     message = self.write_and_decode()
     buf = message.next_frame().buf
     self.assertEqual(random_uuid, FixSizedTypesCodec.decode_uuid(buf, 10))
 def test_none_uuid(self):
     FixSizedTypesCodec.encode_uuid(self.buf, 16, None)
     message = self.write_and_decode()
     buf = message.next_frame().buf
     self.assertIsNone(FixSizedTypesCodec.decode_uuid(buf, 10))