예제 #1
0
    def __init__(self, key):
        # Setting the key of the GSet Instance
        self.key = key

        # Getting/Setting the client list and type of the GSet instance
        self.client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)
        hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = G_SET
예제 #2
0
    def __init__(self, key):
        # Setting the key of the LWWERegister Instance
        self.key = key

        # Getting/Setting the client list and type of the LWWERegister instance
        self.client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)
        hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = LWW_REGISTER
예제 #3
0
    def __init__(self, key):
        # Setting the key of the GSet Instance
        self.key = key

        # Getting/Setting the client list and type of the GSet instance
        self.client_list = hot_redis.Set(key=get_client_list_key(key),
                                         client=connection)
        hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = G_SET
예제 #4
0
    def __init__(self, key):
        # Setting the key of the PN Counter Instance
        self.key = key
        self.pcounter = GCounter(get_pcounter_key(key))
        self.ncounter = GCounter(get_ncounter_key(key))

        # Getting/Setting the client list and type of the GCounter instance
        self.client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)
        hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = PN_COUNTER
예제 #5
0
    def __init__(self, key):
        # Setting the key of the PN Counter Instance
        self.key = key
        self.add_set = GSet(get_add_set_key(key))
        self.delete_set = GSet(get_delete_set_key(key))

        # Getting/Setting the client list and type of the GCounter instance
        self.client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)
        hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = TWO_P_SET
예제 #6
0
    def __init__(self, key):
        # Setting the key of the TwoPTwoPGraph Instance
        self.key = key
        self.nodes = TwoPSet(get_nodes_set_key(key))
        self.edges = TwoPSet(get_edges_set_key(key))

        # Getting/Setting the client list and type of the TwoPTwoPGraph instance
        self.client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)
        hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = TWO_P_TWO_P_GRAPH
예제 #7
0
def check_input_fault(key, client_id, value1, value2, data_type):
    result_dict = dict()

    # Checking for valid key
    if key is None or len(key) == 0:
        result_dict['status'] = status_codes['missing_key_or_state']
        return result_dict

    # Checking for valid client ID
    if client_id is None or len(client_id) == 0:
        result_dict['status'] = status_codes['client_id_not_found']
        return result_dict

    # Checking for valid value1
    if (value1 is None or len(value1) == 0) and value1 != "default":
        result_dict['status'] = status_codes['value_not_found']
        return result_dict

    # Checking for valid value2
    if (value2 is None or len(value2) == 0) and value2 != "default":
        result_dict['status'] = status_codes['value_not_found']
        return result_dict

    data_types = hot_redis.Dict(key=DATA_TYPES, client=connection)
    all_clients = hot_redis.Set(key=ALL_CLIENTS, client=connection)
    client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)

    # Checking if client ID is valid
    if client_id not in all_clients:
        result_dict['status'] = status_codes['client_id_not_found']
        return result_dict

    # Checking if key is present
    if key not in data_types.keys():
        result_dict['status'] = status_codes['missing_key_or_state']
        return result_dict

    # Checking if the key is the right type
    if data_types[key] != data_type:
        result_dict['status'] = status_codes['data_type_mismatch']
        return result_dict

    # Checking if client is in the GCounter's client list
    if get_client_key(key=key, client_id=client_id) not in client_list:
        result_dict['status'] = status_codes['client_id_not_in_crdt']
        return result_dict

    return False
예제 #8
0
def check_input_fault(key, client_id, timestamp, data_type):
    result_dict = dict()

    # Checking for valid key
    if key is None or len(key) == 0:
        result_dict['status'] = status_codes['missing_key_or_state']
        return result_dict

    # Checking for valid client ID
    if client_id is None or len(client_id) == 0:
        result_dict['status'] = status_codes['client_id_not_found']
        return result_dict

    # Checking validity of timestamp
    if timestamp != -1.0:
        try:
            timestamp = float(timestamp)
        except ValueError:
            result_dict['status'] = status_codes['timestamp_not_valid']
            return result_dict

    data_types = hot_redis.Dict(key=DATA_TYPES, client=connection)
    all_clients = hot_redis.Set(key=ALL_CLIENTS, client=connection)
    client_list = hot_redis.Set(key=get_client_list_key(key),
                                client=connection)

    # Checking if client ID is valid
    if client_id not in all_clients:
        result_dict['status'] = status_codes['client_id_not_found']
        return result_dict

    # Checking if key is present
    if key not in data_types.keys():
        result_dict['status'] = status_codes['missing_key_or_state']
        return result_dict

    # Checking if the key is the right type
    if data_types[key] != data_type:
        result_dict['status'] = status_codes['data_type_mismatch']
        return result_dict

    # Checking if client is in the GCounter's client list
    if get_client_key(key=key, client_id=client_id) not in client_list:
        result_dict['status'] = status_codes['client_id_not_in_crdt']
        return result_dict

    return False
예제 #9
0
def check_input_fault(key, client_id, timestamp, data_type):
    result_dict = dict()

    # Checking for valid key
    if key is None or len(key) == 0:
        result_dict['status'] = status_codes['missing_key_or_state']
        return result_dict

    # Checking for valid client ID
    if client_id is None or len(client_id) == 0:
        result_dict['status'] = status_codes['client_id_not_found']
        return result_dict

    # Checking validity of timestamp
    if timestamp != -1.0:
        try:
            timestamp = float(timestamp)
        except ValueError:
            result_dict['status'] = status_codes['timestamp_not_valid']
            return result_dict

    data_types = hot_redis.Dict(key=DATA_TYPES, client=connection)
    all_clients = hot_redis.Set(key=ALL_CLIENTS, client=connection)
    client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)

    # Checking if client ID is valid
    if client_id not in all_clients:
        result_dict['status'] = status_codes['client_id_not_found']
        return result_dict

    # Checking if key is present
    if key not in data_types.keys():
        result_dict['status'] = status_codes['missing_key_or_state']
        return result_dict

    # Checking if the key is the right type
    if data_types[key] != data_type:
        result_dict['status'] = status_codes['data_type_mismatch']
        return result_dict

    # Checking if client is in the GCounter's client list
    if get_client_key(key=key, client_id=client_id) not in client_list:
        result_dict['status'] = status_codes['client_id_not_in_crdt']
        return result_dict

    return False
예제 #10
0
 def __init__(self, key):
     self.key = key
     self.client_list = hot_redis.Set(key=get_client_list_key(key), client=connection)
     hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = PN_SET
     self.pnset = hot_redis.Set(key=get_pnset_key, client=connection)
예제 #11
0
 def __init__(self, key):
     self.key = key
     self.client_list = hot_redis.Set(key=get_client_list_key(key),
                                      client=connection)
     hot_redis.Dict(key=DATA_TYPES, client=connection)[key] = PN_SET
     self.pnset = hot_redis.Set(key=get_pnset_key, client=connection)