Replace remaining uses of BOOST_THROW_EXCEPTION with NDN_THROW

Minor formatting improvements in examples/README.md

Change-Id: Ib8f605074b9ee07c8dea2e9ea2bf04892251d945
This commit is contained in:
Davide Pesavento
2020-12-18 00:02:25 -05:00
parent f91d1dfe15
commit b60398c5fc
9 changed files with 50 additions and 43 deletions
+3 -2
View File
@@ -46,6 +46,7 @@
#include "PSync/detail/bloom-filter.hpp"
#include "PSync/detail/util.hpp"
#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <algorithm>
@@ -162,12 +163,12 @@ BloomFilter::BloomFilter(unsigned int projected_element_count,
BloomFilter::BloomFilter(unsigned int projected_element_count,
double false_positive_probability,
const ndn::name::Component& bfName)
: BloomFilter(projected_element_count, false_positive_probability)
: BloomFilter(projected_element_count, false_positive_probability)
{
std::vector<BloomFilter::cell_type> table(bfName.value_begin(), bfName.value_end());
if (table.size() != raw_table_size_) {
BOOST_THROW_EXCEPTION(Error("Received BloomFilter cannot be decoded!"));
NDN_THROW(Error("Received BloomFilter cannot be decoded!"));
}
bit_table_ = table;
}
+3 -3
View File
@@ -43,8 +43,8 @@
* SOFTWARE.
*/
#ifndef PSYNC_BLOOM_FILTER_HPP
#define PSYNC_BLOOM_FILTER_HPP
#ifndef PSYNC_DETAIL_BLOOM_FILTER_HPP
#define PSYNC_DETAIL_BLOOM_FILTER_HPP
#include <ndn-cxx/name.hpp>
@@ -177,4 +177,4 @@ operator<<(std::ostream& out, const BloomFilter& bf);
} // namespace psync
#endif // PSYNC_BLOOM_FILTER_HPP
#endif // PSYNC_DETAIL_BLOOM_FILTER_HPP
+2
View File
@@ -45,6 +45,8 @@
#include "PSync/detail/iblt.hpp"
#include <ndn-cxx/util/exception.hpp>
namespace psync {
namespace be = boost::endian;
+4 -4
View File
@@ -43,8 +43,8 @@
* SOFTWARE.
*/
#ifndef PSYNC_IBLT_HPP
#define PSYNC_IBLT_HPP
#ifndef PSYNC_DETAIL_IBLT_HPP
#define PSYNC_DETAIL_IBLT_HPP
#include "PSync/detail/util.hpp"
@@ -52,8 +52,8 @@
#include <inttypes.h>
#include <set>
#include <vector>
#include <string>
#include <vector>
namespace psync {
@@ -179,4 +179,4 @@ operator<<(std::ostream& out, const IBLT& iblt);
} // namespace psync
#endif // PSYNC_IBLT_HPP
#endif // PSYNC_DETAIL_IBLT_HPP
+6 -6
View File
@@ -19,6 +19,7 @@
#include "PSync/detail/state.hpp"
#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/ostream-joiner.hpp>
namespace psync {
@@ -73,10 +74,9 @@ NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(State);
void
State::wireDecode(const ndn::Block& wire)
{
auto blockType = wire.type();
if (blockType != tlv::PSyncContent) {
BOOST_THROW_EXCEPTION(ndn::tlv::Error("Expected PSyncContent Block, but Block is of type: #" +
ndn::to_string(blockType)));
if (wire.type() != tlv::PSyncContent) {
NDN_THROW(ndn::tlv::Error("Expected PSyncContent element, but TLV has type " +
ndn::to_string(wire.type())));
}
m_content.clear();
@@ -89,8 +89,8 @@ State::wireDecode(const ndn::Block& wire)
m_content.emplace_back(*it);
}
else {
BOOST_THROW_EXCEPTION(ndn::tlv::Error("Expected Name Block, but Block is of type: #" +
ndn::to_string(it->type())));
NDN_THROW(ndn::tlv::Error("Expected Name element, but TLV has type " +
ndn::to_string(it->type())));
}
}
}
+3 -3
View File
@@ -17,8 +17,8 @@
* PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PSYNC_STATE_HPP
#define PSYNC_STATE_HPP
#ifndef PSYNC_DETAIL_STATE_HPP
#define PSYNC_DETAIL_STATE_HPP
#include <ndn-cxx/name.hpp>
@@ -82,4 +82,4 @@ operator<<(std::ostream& os, const State& State);
} // namespace psync
#endif // PSYNC_STATE_HPP
#endif // PSYNC_DETAIL_STATE_HPP
+3 -3
View File
@@ -21,8 +21,8 @@
* https://github.com/aappleby/smhasher/blob/master/src/murmurHash3.cpp
*/
#ifndef PSYNC_UTIL_HPP
#define PSYNC_UTIL_HPP
#ifndef PSYNC_DETAIL_UTIL_HPP
#define PSYNC_DETAIL_UTIL_HPP
#include "PSync/detail/config.hpp"
@@ -84,4 +84,4 @@ public:
} // namespace psync
#endif // PSYNC_UTIL_HPP
#endif // PSYNC_DETAIL_UTIL_HPP
+7 -5
View File
@@ -19,12 +19,14 @@
#include "PSync/producer-base.hpp"
#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <boost/algorithm/string.hpp>
#include <cstring>
#include <limits>
#include <functional>
#include <limits>
namespace psync {
@@ -39,7 +41,7 @@ ProducerBase::ProducerBase(size_t expectedNumEntries,
CompressionScheme contentCompression)
: m_iblt(expectedNumEntries, ibltCompression)
, m_expectedNumEntries(expectedNumEntries)
, m_threshold(expectedNumEntries/2)
, m_threshold(expectedNumEntries / 2)
, m_face(face)
, m_scheduler(m_face.getIoService())
, m_syncPrefix(syncPrefix)
@@ -140,8 +142,8 @@ ProducerBase::sendApplicationNack(const ndn::Name& name)
void
ProducerBase::onRegisterFailed(const ndn::Name& prefix, const std::string& msg) const
{
NDN_LOG_ERROR("ProduerBase::onRegisterFailed " << prefix << " " << msg);
BOOST_THROW_EXCEPTION(Error(msg));
NDN_LOG_ERROR("ProducerBase::onRegisterFailed(" << prefix << "): " << msg);
NDN_THROW(Error(msg));
}
} // namespace psync
} // namespace psync
+19 -17
View File
@@ -1,24 +1,25 @@
PSync examples
==============
# PSync examples
By default, examples in `examples/` folder are not built. To enable them, use
By default, the examples in this folder are not built. To enable them, use the
`--with-examples` configure option. For example:
./waf configure --with-examples
./waf
```bash
./waf configure --with-examples
./waf
```
Example binary can be found under `build/examples`:
The example binaries can be found in `build/examples`:
- Full sync : `psync-full-sync`
- Partial sync : `psync-producer` and `psync-consumer`
- Full sync: `psync-full-sync`
- Partial sync: `psync-producer` and `psync-consumer`
If the library is installed to the system using `./waf install` then the examples
are also installed and can be executed directly.
## Partial Sync Example
## Partial Sync example
Partial sync example of PSync has two parts: producer and consumer.
These can be run on a machine after starting NFD:
These can be run on a machine after starting NFD.
### Producer
@@ -28,7 +29,8 @@ These can be run on a machine after starting NFD:
export NDN_LOG=examples.PartialSyncProducerApp=INFO
```
- Start the producer that will listen on /sync and publish 1 update for /a-0 ... /a-9 each.
- Start the producer that will listen on `/sync` and publish 1 update for
`/a-0` ... `/a-9` each.
```bash
psync-producer /sync /a 10 1
@@ -57,7 +59,7 @@ psync-producer /sync /a 10 1
export NDN_LOG=examples.PartialSyncConsumerApp=INFO
```
- Run the consumer to subscribe to 5 random prefixes from the publisher on /sync
- Run the consumer to subscribe to 5 random prefixes from the publisher on `/sync`
```bash
psync-consumer /sync 5
@@ -79,9 +81,9 @@ for the subscribed prefixes:
1546280489.349793 INFO: [examples.PartialSyncConsumerApp] Update: /a-9/1
```
## Full Sync Example
## Full Sync example
To demonstrate full sync mode of PSync, ``psync-full-sync``
To demonstrate full sync mode of PSync, `psync-full-sync`
can be run on a machine after starting NFD:
- Enable the logs for full sync:
@@ -90,8 +92,8 @@ can be run on a machine after starting NFD:
export NDN_LOG=examples.FullSyncApp=INFO
```
- Run the full sync example with sync prefix /sync, user prefix /a,
and publish three updates for each user prefix: /a-0 and /a-1. This will simulate node a.
- Run the full sync example with sync prefix `/sync`, user prefix `/a`,
and publish three updates for each user prefix: `/a-0` and `/a-1`. This will simulate node a.
```bash
psync-full-sync /sync /a 2 3
@@ -138,4 +140,4 @@ from node b successfully:
1546282804.033214 INFO: [examples.FullSyncApp] Publish: /b-1/3
1546282845.274680 INFO: [examples.FullSyncApp] Update /a-1/3
1546282855.101780 INFO: [examples.FullSyncApp] Publish: /b-0/3
```
```