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-2022, 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:
54  PartialProducer(ndn::Face& face,
55  ndn::KeyChain& keyChain,
56  size_t expectedNumEntries,
57  const ndn::Name& syncPrefix,
58  const ndn::Name& userPrefix,
59  ndn::time::milliseconds helloReplyFreshness = HELLO_REPLY_FRESHNESS,
60  ndn::time::milliseconds syncReplyFreshness = SYNC_REPLY_FRESHNESS,
61  CompressionScheme ibltCompression = CompressionScheme::NONE);
62 
74  void
75  publishName(const ndn::Name& prefix, std::optional<uint64_t> seq = std::nullopt);
76 
77 private:
83  void
84  satisfyPendingSyncInterests(const ndn::Name& prefix);
85 
95  void
96  onHelloInterest(const ndn::Name& prefix, const ndn::Interest& interest);
97 
107  void
108  onSyncInterest(const ndn::Name& prefix, const ndn::Interest& interest);
109 
111  struct PendingEntryInfo
112  {
114  detail::IBLT iblt;
115  ndn::scheduler::ScopedEventId expirationEvent;
116  };
117 
118  std::map<ndn::Name, PendingEntryInfo> m_pendingEntries;
119  ndn::ScopedRegisteredPrefixHandle m_registeredPrefix;
120  ndn::time::milliseconds m_helloReplyFreshness;
121 };
122 
123 } // namespace psync
124 
125 #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, size_t expectedNumEntries, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds helloReplyFreshness=HELLO_REPLY_FRESHNESS, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS, CompressionScheme ibltCompression=CompressionScheme::NONE)
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:81
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