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 
36 {
39  ndn::scheduler::ScopedEventId expirationEvent;
40 };
41 
42 const ndn::time::milliseconds HELLO_REPLY_FRESHNESS = 1_s;
43 
53 {
54 public:
69  PartialProducer(size_t expectedNumEntries,
70  ndn::Face& face,
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, ndn::optional<uint64_t> seq = ndn::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  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
const ndn::time::milliseconds HELLO_REPLY_FRESHNESS
const ndn::time::milliseconds SYNC_REPLY_FRESHNESS
Partial sync logic to publish data names.
Invertible Bloom Lookup Table (Invertible Bloom Filter)
Definition: iblt.hpp:82
ndn::scheduler::ScopedEventId expirationEvent
CompressionScheme
Definition: util.hpp:51
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Base class for PartialProducer and FullProducer.