def encode_request(name, index, value_list):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    FixSizedTypesCodec.encode_int(buf, _REQUEST_INDEX_OFFSET, index)
    StringCodec.encode(buf, name)
    ListMultiFrameCodec.encode(buf, value_list, DataCodec.encode, True)
    return OutboundMessage(buf, False)
Ejemplo n.º 2
0
 def test_errors(self):
     self.mark_initial_frame_as_non_final()
     holder = ErrorHolder(-12345, "class", "message", [])
     ListMultiFrameCodec.encode(self.buf, [holder], ErrorHolderCodec.encode,
                                True)
     message = self.write_and_decode()
     self.assertEqual([holder], _ErrorsCodec.decode(message))
def encode_request(name, value_list, overflow_policy):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    FixSizedTypesCodec.encode_int(buf, _REQUEST_OVERFLOW_POLICY_OFFSET,
                                  overflow_policy)
    StringCodec.encode(buf, name)
    ListMultiFrameCodec.encode(buf, value_list, DataCodec.encode, True)
    return OutboundMessage(buf, False)
Ejemplo n.º 4
0
 def encode(buf, schema, is_final=False):
     buf.extend(BEGIN_FRAME_BUF)
     StringCodec.encode(buf, schema.type_name)
     ListMultiFrameCodec.encode(buf, schema.fields_list,
                                FieldDescriptorCodec.encode)
     if is_final:
         buf.extend(END_FINAL_FRAME_BUF)
     else:
         buf.extend(END_FRAME_BUF)
def encode_request(name, keys, replace_existing_values):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    FixSizedTypesCodec.encode_boolean(buf,
                                      _REQUEST_REPLACE_EXISTING_VALUES_OFFSET,
                                      replace_existing_values)
    StringCodec.encode(buf, name)
    ListMultiFrameCodec.encode(buf, keys, DataCodec.encode, True)
    return OutboundMessage(buf, False)
Ejemplo n.º 6
0
 def encode(buf, error_holder, is_final=False):
     initial_frame_buf = create_initial_buffer_custom(_INITIAL_FRAME_SIZE)
     FixSizedTypesCodec.encode_int(initial_frame_buf, _ERROR_CODE_ENCODE_OFFSET, error_holder.error_code)
     buf.extend(initial_frame_buf)
     StringCodec.encode(buf, error_holder.class_name)
     CodecUtil.encode_nullable(buf, error_holder.message, StringCodec.encode)
     ListMultiFrameCodec.encode(buf, error_holder.stack_trace_elements, StackTraceElementCodec.encode)
     if is_final:
         buf.extend(END_FINAL_FRAME_BUF)
     else:
         buf.extend(END_FRAME_BUF)
 def encode(buf, index_config, is_final=False):
     initial_frame_buf = create_initial_buffer_custom(_INITIAL_FRAME_SIZE)
     FixSizedTypesCodec.encode_int(initial_frame_buf, _TYPE_ENCODE_OFFSET,
                                   index_config.type)
     buf.extend(initial_frame_buf)
     CodecUtil.encode_nullable(buf, index_config.name, StringCodec.encode)
     ListMultiFrameCodec.encode(buf, index_config.attributes,
                                StringCodec.encode)
     CodecUtil.encode_nullable(buf, index_config.bitmap_index_options,
                               BitmapIndexOptionsCodec.encode)
     if is_final:
         buf.extend(END_FINAL_FRAME_BUF)
     else:
         buf.extend(END_FRAME_BUF)
Ejemplo n.º 8
0
def encode_request(cluster_name, credentials, uuid, client_type,
                   serialization_version, client_hazelcast_version,
                   client_name, labels):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    FixSizedTypesCodec.encode_uuid(buf, _REQUEST_UUID_OFFSET, uuid)
    FixSizedTypesCodec.encode_byte(buf, _REQUEST_SERIALIZATION_VERSION_OFFSET,
                                   serialization_version)
    StringCodec.encode(buf, cluster_name)
    ByteArrayCodec.encode(buf, credentials)
    StringCodec.encode(buf, client_type)
    StringCodec.encode(buf, client_hazelcast_version)
    StringCodec.encode(buf, client_name)
    ListMultiFrameCodec.encode(buf, labels, StringCodec.encode, True)
    return OutboundMessage(buf, True)
Ejemplo n.º 9
0
 def decode(msg):
     msg.next_frame()
     type_name = StringCodec.decode(msg)
     fields_list = ListMultiFrameCodec.decode(msg,
                                              FieldDescriptorCodec.decode)
     CodecUtil.fast_forward_to_end_frame(msg)
     return Schema(type_name, fields_list)
def encode_request(sql, parameters, timeout_millis, cursor_buffer_size, schema,
                   expected_result_type, query_id):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    FixSizedTypesCodec.encode_long(buf, _REQUEST_TIMEOUT_MILLIS_OFFSET,
                                   timeout_millis)
    FixSizedTypesCodec.encode_int(buf, _REQUEST_CURSOR_BUFFER_SIZE_OFFSET,
                                  cursor_buffer_size)
    FixSizedTypesCodec.encode_byte(buf, _REQUEST_EXPECTED_RESULT_TYPE_OFFSET,
                                   expected_result_type)
    StringCodec.encode(buf, sql)
    ListMultiFrameCodec.encode_contains_nullable(buf, parameters,
                                                 DataCodec.encode)
    CodecUtil.encode_nullable(buf, schema, StringCodec.encode)
    SqlQueryIdCodec.encode(buf, query_id, True)
    return OutboundMessage(buf, False)
Ejemplo n.º 11
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
Ejemplo n.º 12
0
 def decode(msg):
     msg.next_frame()
     initial_frame = msg.next_frame()
     error_code = FixSizedTypesCodec.decode_int(initial_frame.buf, _ERROR_CODE_DECODE_OFFSET)
     class_name = StringCodec.decode(msg)
     message = CodecUtil.decode_nullable(msg, StringCodec.decode)
     stack_trace_elements = ListMultiFrameCodec.decode(msg, StackTraceElementCodec.decode)
     CodecUtil.fast_forward_to_end_frame(msg)
     return ErrorHolder(error_code, class_name, message, stack_trace_elements)
def decode_response(msg):
    initial_frame = msg.next_frame()
    response = dict()
    response["update_count"] = FixSizedTypesCodec.decode_long(
        initial_frame.buf, _RESPONSE_UPDATE_COUNT_OFFSET)
    response["row_metadata"] = ListMultiFrameCodec.decode_nullable(
        msg, SqlColumnMetadataCodec.decode)
    response["row_page"] = CodecUtil.decode_nullable(msg, SqlPageCodec.decode)
    response["error"] = CodecUtil.decode_nullable(msg, SqlErrorCodec.decode)
    return response
 def decode(msg):
     msg.next_frame()
     initial_frame = msg.next_frame()
     type = FixSizedTypesCodec.decode_int(initial_frame.buf,
                                          _TYPE_DECODE_OFFSET)
     name = CodecUtil.decode_nullable(msg, StringCodec.decode)
     attributes = ListMultiFrameCodec.decode(msg, StringCodec.decode)
     bitmap_index_options = CodecUtil.decode_nullable(
         msg, BitmapIndexOptionsCodec.decode)
     CodecUtil.fast_forward_to_end_frame(msg)
     return IndexConfig(name, type, attributes, bitmap_index_options)
def decode_response(msg):
    initial_frame = msg.next_frame()
    response = dict()
    response["read_count"] = FixSizedTypesCodec.decode_int(
        initial_frame.buf, _RESPONSE_READ_COUNT_OFFSET)
    response["next_seq"] = FixSizedTypesCodec.decode_long(
        initial_frame.buf, _RESPONSE_NEXT_SEQ_OFFSET)
    response["items"] = ListMultiFrameCodec.decode(msg, DataCodec.decode)
    response["item_seqs"] = CodecUtil.decode_nullable(msg,
                                                      LongArrayCodec.decode)
    return response
Ejemplo n.º 16
0
def handle(msg,
           handle_members_view_event=None,
           handle_partitions_view_event=None):
    message_type = msg.get_message_type()
    if message_type == _EVENT_MEMBERS_VIEW_MESSAGE_TYPE and handle_members_view_event is not None:
        initial_frame = msg.next_frame()
        version = FixSizedTypesCodec.decode_int(
            initial_frame.buf, _EVENT_MEMBERS_VIEW_VERSION_OFFSET)
        member_infos = ListMultiFrameCodec.decode(msg, MemberInfoCodec.decode)
        handle_members_view_event(version, member_infos)
        return
    if message_type == _EVENT_PARTITIONS_VIEW_MESSAGE_TYPE and handle_partitions_view_event is not None:
        initial_frame = msg.next_frame()
        version = FixSizedTypesCodec.decode_int(
            initial_frame.buf, _EVENT_PARTITIONS_VIEW_VERSION_OFFSET)
        partitions = EntryListUUIDListIntegerCodec.decode(msg)
        handle_partitions_view_event(version, partitions)
        return
Ejemplo n.º 17
0
def decode_response(msg):
    msg.next_frame()
    response = dict()
    response["response"] = ListMultiFrameCodec.decode(msg, DataCodec.decode)
    response["anchor_data_list"] = AnchorDataListHolderCodec.decode(msg)
    return response
Ejemplo n.º 18
0
def decode_response(msg):
    msg.next_frame()
    return ListMultiFrameCodec.decode(msg, DataCodec.decode)
Ejemplo n.º 19
0
 def decode(msg):
     msg.next_frame()
     return ListMultiFrameCodec.decode(msg, ErrorHolderCodec.decode)
def decode_response(msg):
    msg.next_frame()
    return ListMultiFrameCodec.decode_contains_nullable(msg, DataCodec.decode)
def decode_response(msg):
    msg.next_frame()
    return ListMultiFrameCodec.decode(msg, DistributedObjectInfoCodec.decode)
Ejemplo n.º 22
0
def encode_request(schemas):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    ListMultiFrameCodec.encode(buf, schemas, SchemaCodec.encode, True)
    return OutboundMessage(buf, True)
Ejemplo n.º 23
0
def encode_request(name, values):
    buf = create_initial_buffer(_REQUEST_INITIAL_FRAME_SIZE,
                                _REQUEST_MESSAGE_TYPE)
    StringCodec.encode(buf, name)
    ListMultiFrameCodec.encode(buf, values, DataCodec.encode, True)
    return OutboundMessage(buf, False)
 def test_list(self):
     self.mark_initial_frame_as_non_final()
     l = list(map(six.u, ["a", "b", "c", "😃"]))
     ListMultiFrameCodec.encode(self.buf, l, StringCodec.encode)
     ListMultiFrameCodec.encode_nullable(self.buf, l, StringCodec.encode)
     ListMultiFrameCodec.encode_nullable(self.buf, None, StringCodec.encode)
     ListMultiFrameCodec.encode_contains_nullable(self.buf, l, StringCodec.encode)
     ListMultiFrameCodec.encode_contains_nullable(self.buf, [None], StringCodec.encode, True)
     message = self.write_and_decode()
     message.next_frame()  # initial frame
     self.assertEqual(l, ListMultiFrameCodec.decode(message, StringCodec.decode))
     self.assertEqual(l, ListMultiFrameCodec.decode_nullable(message, StringCodec.decode))
     self.assertIsNone(ListMultiFrameCodec.decode_nullable(message, StringCodec.decode))
     self.assertEqual(l, ListMultiFrameCodec.decode_contains_nullable(message, StringCodec.decode))
     self.assertEqual([None], ListMultiFrameCodec.decode_contains_nullable(message, StringCodec.decode))