partial-producer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2023, The University of Memphis
4  *
5  * This file is part of PSync.
6  * See AUTHORS.md for complete list of PSync authors and contributors.
7  *
8  * PSync is free software: you can redistribute it and/or modify it under the terms
9  * of the GNU Lesser General Public License as published by the Free Software Foundation,
10  * either version 3 of the License, or (at your option) any later version.
11  *
12  * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  * PURPOSE. See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License along with
17  * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18  **/
19 
20 #ifndef PSYNC_PARTIAL_PRODUCER_HPP
21 #define PSYNC_PARTIAL_PRODUCER_HPP
22 
23 #include "PSync/producer-base.hpp"
25 
26 namespace psync {
27 
37 {
38 public:
42  struct Options
43  {
45  uint32_t ibfCount = 40;
49  ndn::time::milliseconds helloDataFreshness = HELLO_REPLY_FRESHNESS;
51  ndn::time::milliseconds syncDataFreshness = SYNC_REPLY_FRESHNESS;
52  };
53 
62  PartialProducer(ndn::Face& face,
63  ndn::KeyChain& keyChain,
64  const ndn::Name& syncPrefix,
65  const Options& opts);
66 
67  [[deprecated]]
68  PartialProducer(ndn::Face& face,
69  ndn::KeyChain& keyChain,
70  size_t expectedNumEntries,
71  const ndn::Name& syncPrefix,
72  const ndn::Name& userPrefix,
73  ndn::time::milliseconds helloReplyFreshness = HELLO_REPLY_FRESHNESS,
74  ndn::time::milliseconds syncReplyFreshness = SYNC_REPLY_FRESHNESS,
75  CompressionScheme ibltCompression = CompressionScheme::NONE);
76 
88  void
89  publishName(const ndn::Name& prefix, std::optional<uint64_t> seq = std::nullopt);
90 
91 private:
97  void
98  satisfyPendingSyncInterests(const ndn::Name& prefix);
99 
109  void
110  onHelloInterest(const ndn::Name& prefix, const ndn::Interest& interest);
111 
121  void
122  onSyncInterest(const ndn::Name& prefix, const ndn::Interest& interest);
123 
125  struct PendingEntryInfo
126  {
128  detail::IBLT iblt;
129  ndn::scheduler::ScopedEventId expirationEvent;
130  };
131 
132  std::map<ndn::Name, PendingEntryInfo> m_pendingEntries;
133  ndn::ScopedRegisteredPrefixHandle m_registeredPrefix;
134  ndn::time::milliseconds m_helloReplyFreshness;
135 };
136 
137 } // namespace psync
138 
139 #endif // PSYNC_PARTIAL_PRODUCER_HPP
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Partial sync logic to publish data names.
PartialProducer(ndn::Face &face, ndn::KeyChain &keyChain, const ndn::Name &syncPrefix, const Options &opts)
Constructor.
void publishName(const ndn::Name &prefix, std::optional< uint64_t > seq=std::nullopt)
Publish name to let subscribed consumers know.
Base class for PartialProducer and FullProducer.
Invertible Bloom Lookup Table (Invertible Bloom Filter)
Definition: iblt.hpp:95
Definition: common.hpp:34
constexpr ndn::time::milliseconds HELLO_REPLY_FRESHNESS
Definition: common.hpp:39
CompressionScheme
Definition: common.hpp:43
constexpr ndn::time::milliseconds SYNC_REPLY_FRESHNESS
Definition: common.hpp:41
uint32_t ibfCount
Expected number of entries in IBF.
ndn::time::milliseconds helloDataFreshness
FreshnessPeriod of hello Data.
ndn::time::milliseconds syncDataFreshness
FreshnessPeriod of sync Data.
CompressionScheme ibfCompression
Compression scheme to use for IBF.