servlib/bundling/BPQCache.h
changeset 64 1296a0283271
parent 56 76420d9f6e62
child 66 e1101c5d54a1
equal deleted inserted replaced
63:9a8be24c5037 64:1296a0283271
     1 /*
     1 /*
     2  *    Copyright 2004-2006 Intel Corporation
     2  *    Copyright 2010-2011 Trinity College Dublin
     3  *
     3  *
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
     5  *    you may not use this file except in compliance with the License.
     5  *    you may not use this file except in compliance with the License.
     6  *    You may obtain a copy of the License at
     6  *    You may obtain a copy of the License at
     7  *
     7  *
    22 #endif
    22 #endif
    23 
    23 
    24 #include "Bundle.h"
    24 #include "Bundle.h"
    25 #include <oasys/debug/Log.h>
    25 #include <oasys/debug/Log.h>
    26 #include <oasys/util/StringUtils.h>
    26 #include <oasys/util/StringUtils.h>
    27 
    27 #include "../reg/Registration.h"
       
    28 #include "../reg/RegistrationTable.h"
    28 namespace dtn {
    29 namespace dtn {
    29 
    30 
    30 class BPQBlock;
    31 class BPQBlock;
    31 class BPQCacheEntry;
    32 class BPQCacheEntry;
    32 class EndpointID;
    33 class EndpointID;
    33 class BPQResponse;
    34 class BPQResponse;
       
    35 class RegistrationList;
       
    36 class RegistrationTable;
    34 
    37 
    35 class BPQCache : public oasys::Logger {
    38 class BPQCache : public oasys::Logger {
    36 public:
    39 public:
    37 	BPQCache() :
    40 	BPQCache() :
    38         Logger("BPQCache", "/dtn/bundle/bpq") {}
    41         Logger("BPQCache", "/dtn/bundle/bpq") {}
    56 
    59 
    57     static const size_t MAX_KEY_SIZE = 4096;
    60     static const size_t MAX_KEY_SIZE = 4096;
    58 
    61 
    59 protected:
    62 protected:
    60 
    63 
    61     void create_cache_entry(Bundle* bundle, std::string key);
    64     /**
    62     void replace_cache_entry(Bundle* bundle, std::string key);
    65      * Build a new BPQCcacheEntry from this bundle.
       
    66      * Copy the bundle into the fragment list
       
    67      */
       
    68     void create_cache_entry(Bundle* bundle, BPQBlock* block, std::string key);
       
    69     void replace_cache_entry(Bundle* bundle, BPQBlock* block, std::string key);
    63     void append_cache_entry(Bundle* bundle, std::string key);
    70     void append_cache_entry(Bundle* bundle, std::string key);
    64     int  update_bpq_block(Bundle* bundle, BPQBlock* block);
    71     int  update_bpq_block(Bundle* bundle, BPQBlock* block);
       
    72     bool try_to_deliver(BPQCacheEntry* entry);
    65 
    73 
    66     /**
    74     /**
    67      * Calculate a hash table key from a bundle
    75      * Calculate a hash table key from a bundle
    68      * This is a concatenation of the Matching Rule and the Query
    76      * This is a  SHA256 hash of the concatenation of:
    69      *
    77      * 		Matching Rule and Query Value
    70      * If the query is too long, use a hash of the query
       
    71      */
    78      */
    72     void get_hash_key(Bundle* bundle, std::string* key);
    79     void get_hash_key(Bundle* bundle, std::string* key);
    73     void get_hash_key(BPQBlock* block, std::string* key);
    80     void get_hash_key(BPQBlock* block, std::string* key);
    74 
    81 
    75 
    82