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-2020, 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 
24 #include "PSync/producer-base.hpp"
25 
26 #include <map>
27 
28 #include <ndn-cxx/face.hpp>
29 #include <ndn-cxx/security/key-chain.hpp>
30 #include <ndn-cxx/util/scheduler.hpp>
31 #include <ndn-cxx/util/time.hpp>
32 
33 namespace psync {
34 
35 const ndn::time::milliseconds HELLO_REPLY_FRESHNESS = 1_s;
36 
46 {
47 public:
62  PartialProducer(size_t expectedNumEntries,
63  ndn::Face& face,
64  const ndn::Name& syncPrefix,
65  const ndn::Name& userPrefix,
66  ndn::time::milliseconds helloReplyFreshness = HELLO_REPLY_FRESHNESS,
67  ndn::time::milliseconds syncReplyFreshness = SYNC_REPLY_FRESHNESS,
68  CompressionScheme ibltCompression = CompressionScheme::NONE);
69 
81  void
82  publishName(const ndn::Name& prefix, ndn::optional<uint64_t> seq = ndn::nullopt);
83 
84 private:
90  void
91  satisfyPendingSyncInterests(const ndn::Name& prefix);
92 
102  void
103  onHelloInterest(const ndn::Name& prefix, const ndn::Interest& interest);
104 
114  void
115  onSyncInterest(const ndn::Name& prefix, const ndn::Interest& interest);
116 
118  struct PendingEntryInfo
119  {
121  detail::IBLT iblt;
122  ndn::scheduler::ScopedEventId expirationEvent;
123  };
124 
125  std::map<ndn::Name, PendingEntryInfo> m_pendingEntries;
126  ndn::ScopedRegisteredPrefixHandle m_registeredPrefix;
127  ndn::time::milliseconds m_helloReplyFreshness;
128 };
129 
130 } // namespace psync
131 
132 #endif // PSYNC_PARTIAL_PRODUCER_HPP
Invertible Bloom Lookup Table (Invertible Bloom Filter)
Definition: iblt.hpp:81
Definition: common.hpp:33
const ndn::time::milliseconds HELLO_REPLY_FRESHNESS
const ndn::time::milliseconds SYNC_REPLY_FRESHNESS
Partial sync logic to publish data names.
void publishName(const ndn::Name &prefix, ndn::optional< uint64_t > seq=ndn::nullopt)
Publish name to let subscribed consumers know.
CompressionScheme
Definition: common.hpp:35
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
PartialProducer(size_t expectedNumEntries, ndn::Face &face, 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
Base class for PartialProducer and FullProducer.