def encode_request(name, job_id, predicate, mapper, combiner_factory, reducer_factory, key_value_source, chunk_size, keys, topology_changed_strategy):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, job_id, predicate, mapper, combiner_factory, reducer_factory, key_value_source, chunk_size, keys, topology_changed_strategy))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_str(job_id)
    client_message.append_bool(predicate is None)
    if predicate is not None:
        client_message.append_data(predicate)
    client_message.append_data(mapper)
    client_message.append_bool(combiner_factory is None)
    if combiner_factory is not None:
        client_message.append_data(combiner_factory)
    client_message.append_bool(reducer_factory is None)
    if reducer_factory is not None:
        client_message.append_data(reducer_factory)
    client_message.append_data(key_value_source)
    client_message.append_int(chunk_size)
    client_message.append_bool(keys is None)
    if keys is not None:
        client_message.append_int(len(keys))
        for keys_item in keys:
            client_message.append_data(keys_item)
    client_message.append_bool(topology_changed_strategy is None)
    if topology_changed_strategy is not None:
        client_message.append_str(topology_changed_strategy)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 2
0
def encode_request(name, index):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, index))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(index)
    client_message.update_frame_length()
    return client_message
def encode_request(name, index):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, index))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(index)
    client_message.update_frame_length()
    return client_message
def encode_request(name, listener_flags, local_only):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, listener_flags, local_only))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(listener_flags)
    client_message.append_bool(local_only)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 5
0
def encode_request(uuid, partition_id, interrupt):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(uuid, partition_id, interrupt))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(uuid)
    client_message.append_int(partition_id)
    client_message.append_bool(interrupt)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 6
0
def encode_request(name, overflow_policy, value):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, overflow_policy, value))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(overflow_policy)
    client_message.append_data(value)
    client_message.update_frame_length()
    return client_message
def encode_request(uuid, partition_id, interrupt):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(uuid, partition_id, interrupt))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(uuid)
    client_message.append_int(partition_id)
    client_message.append_bool(interrupt)
    client_message.update_frame_length()
    return client_message
def encode_request(name, uuid, callable, partition_id):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, uuid, callable, partition_id))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_str(uuid)
    client_message.append_data(callable)
    client_message.append_int(partition_id)
    client_message.update_frame_length()
    return client_message
def encode_request(timeout, durability, transaction_type, thread_id):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(timeout, durability, transaction_type, thread_id))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_long(timeout)
    client_message.append_int(durability)
    client_message.append_int(transaction_type)
    client_message.append_long(thread_id)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 10
0
def encode_request(name, overflow_policy, value):
    """ Encode request into client_message"""
    client_message = ClientMessage(
        payload_size=calculate_size(name, overflow_policy, value))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(overflow_policy)
    client_message.append_data(value)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 11
0
def encode_request(name, listener_flags, local_only):
    """ Encode request into client_message"""
    client_message = ClientMessage(
        payload_size=calculate_size(name, listener_flags, local_only))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(listener_flags)
    client_message.append_bool(local_only)
    client_message.update_frame_length()
    return client_message
def encode_request(name, values):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, values))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(values))
    for values_item in values:
        client_message.append_data(values_item)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 13
0
def encode_request(name, values):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, values))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(values))
    for values_item in values:
        client_message.append_data(values_item)
    client_message.update_frame_length()
    return client_message
def encode_request(timeout, durability, transaction_type, thread_id):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(
        timeout, durability, transaction_type, thread_id))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_long(timeout)
    client_message.append_int(durability)
    client_message.append_int(transaction_type)
    client_message.append_long(thread_id)
    client_message.update_frame_length()
    return client_message
def encode_request(name, entries):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, entries))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(entries))
    for key, value in entries.iteritems():
        client_message.append_data(key)
        client_message.append_data(val)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 16
0
def encode_request(name, keys, replace_existing_values):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, keys, replace_existing_values))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(keys))
    for keys_item in keys:
        client_message.append_data(keys_item)
    client_message.append_bool(replace_existing_values)
    client_message.update_frame_length()
    return client_message
def encode_request(name, uuid, callable, partition_id):
    """ Encode request into client_message"""
    client_message = ClientMessage(
        payload_size=calculate_size(name, uuid, callable, partition_id))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_str(uuid)
    client_message.append_data(callable)
    client_message.append_int(partition_id)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 18
0
def encode_request(name, start_sequence, min_count, max_count, filter):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, start_sequence, min_count, max_count, filter))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_long(start_sequence)
    client_message.append_int(min_count)
    client_message.append_int(max_count)
    client_message.append_bool(filter is None)
    if filter is not None:
        client_message.append_data(filter)
    client_message.update_frame_length()
    return client_message
def encode_request(name, start_sequence, min_count, max_count, filter):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, start_sequence, min_count, max_count, filter))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_long(start_sequence)
    client_message.append_int(min_count)
    client_message.append_int(max_count)
    client_message.append_bool(filter is None)
    if filter is not None:
        client_message.append_data(filter)
    client_message.update_frame_length()
    return client_message
def encode_request(map_name, cache_name, predicate, batch_size, buffer_size, delay_seconds, populate, coalesce):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(map_name, cache_name, predicate, batch_size, buffer_size, delay_seconds, populate, coalesce))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(map_name)
    client_message.append_str(cache_name)
    client_message.append_data(predicate)
    client_message.append_int(batch_size)
    client_message.append_int(buffer_size)
    client_message.append_long(delay_seconds)
    client_message.append_bool(populate)
    client_message.append_bool(coalesce)
    client_message.update_frame_length()
    return client_message
def encode_request(name, replica_timestamps, target_replica):
    """ Encode request into client_message"""
    client_message = ClientMessage(
        payload_size=calculate_size(name, replica_timestamps, target_replica))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(replica_timestamps))
    for replica_timestamps_item in replica_timestamps:
        key = replica_timestamps_item[0]
        val = replica_timestamps_item[1]
        client_message.append_str(key)
        client_message.append_long(val)

    AddressCodec.encode(client_message, target_replica)
    client_message.update_frame_length()
    return client_message
Exemplo n.º 22
0
def calculate_size(name, from, to):
    """ Calculates the request payload size"""
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += INT_SIZE_IN_BYTES
    data_size += INT_SIZE_IN_BYTES
    return data_size


def encode_request(name, from, to):
    """ Encode request into client_message"""
    client_message = ClientMessage(payload_size=calculate_size(name, from, to))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(from)
    client_message.append_int(to)
    client_message.update_frame_length()
    return client_message


def decode_response(client_message):
    """ Decode response from client message"""
    parameters = dict(response=None)
    response_size = client_message.read_int()
    response = []
    for response_index in xrange(0, response_size):
        response_item = client_message.read_data()
        response.append(response_item)
    parameters['response'] = response
    return parameters