Remove use of deprecated code
Change-Id: I721e9d0f9b41e7a53d75b1fde4a718c349273eeb
Refs: #3988
diff --git a/src/handles/base-handle.hpp b/src/handles/base-handle.hpp
index 95b8caa..a598883 100644
--- a/src/handles/base-handle.hpp
+++ b/src/handles/base-handle.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -31,7 +31,7 @@
class BaseHandle : noncopyable
{
public:
- class Error : std::runtime_error
+ class Error : public std::runtime_error
{
public:
explicit
diff --git a/src/handles/delete-handle.cpp b/src/handles/delete-handle.cpp
index 5cd0506..5cfbea2 100644
--- a/src/handles/delete-handle.cpp
+++ b/src/handles/delete-handle.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -40,7 +40,7 @@
void
DeleteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
- throw Error("Delete prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Delete prefix registration failed"));
}
@@ -54,7 +54,7 @@
void
DeleteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
{
- throw Error("Delete check prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Delete check prefix registration failed"));
}
@@ -194,4 +194,4 @@
}
}
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/tcp-bulk-insert-handle.cpp b/src/handles/tcp-bulk-insert-handle.cpp
index a445110..1d81b17 100644
--- a/src/handles/tcp-bulk-insert-handle.cpp
+++ b/src/handles/tcp-bulk-insert-handle.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -84,7 +84,7 @@
ip::tcp::resolver::iterator end;
if (endpoint == end)
- throw Error("Cannot listen on [" + host + ":" + port + "]");
+ BOOST_THROW_EXCEPTION(Error("Cannot listen on [" + host + ":" + port + "]"));
m_localEndpoint = *endpoint;
std::cerr << "Start listening on " << m_localEndpoint << std::endl;
@@ -179,7 +179,7 @@
else
std::cerr << "FAILED to inject " << data.getName() << std::endl;
}
- catch (std::runtime_error& error) {
+ catch (const std::runtime_error& error) {
/// \todo Catch specific error after determining what wireDecode() can throw
std::cerr << "Error decoding received Data packet" << std::endl;
}
diff --git a/src/handles/watch-handle.cpp b/src/handles/watch-handle.cpp
index 9e80212..25ce278 100644
--- a/src/handles/watch-handle.cpp
+++ b/src/handles/watch-handle.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -68,7 +68,7 @@
WatchHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << reason << std::endl;
- throw Error("watch prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("watch prefix registration failed"));
}
void
@@ -106,7 +106,7 @@
}
void
-WatchHandle::onData(const Interest& interest, ndn::Data& data, const Name& name)
+WatchHandle::onData(const Interest& interest, const ndn::Data& data, const Name& name)
{
m_validator.validate(data,
bind(&WatchHandle::onDataValidated, this, interest, _1, name),
@@ -148,10 +148,11 @@
++m_interestNum;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, name),
+ bind(&WatchHandle::onTimeout, this, _1, name), // Nack
bind(&WatchHandle::onTimeout, this, _1, name));
}
else {
- throw Error("Insert into Repo Failed");
+ BOOST_THROW_EXCEPTION(Error("Insert into Repo Failed"));
}
m_processes[name].first.setInsertNum(m_size);
}
@@ -190,6 +191,7 @@
++m_interestNum;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, name),
+ bind(&WatchHandle::onTimeout, this, _1, name), // Nack
bind(&WatchHandle::onTimeout, this, _1, name));
}
@@ -211,6 +213,7 @@
++m_interestNum;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, name),
+ bind(&WatchHandle::onTimeout, this, _1, name), // Nack
bind(&WatchHandle::onTimeout, this, _1, name));
}
@@ -310,7 +313,7 @@
WatchHandle::deferredDeleteProcess(const Name& name)
{
getScheduler().scheduleEvent(PROCESS_DELETE_TIME,
- ndn::bind(&WatchHandle::deleteProcess, this, name));
+ bind(&WatchHandle::deleteProcess, this, name));
}
void
@@ -351,6 +354,7 @@
m_interestNum++;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, parameter.getName()),
+ bind(&WatchHandle::onTimeout, this, _1, parameter.getName()), // Nack
bind(&WatchHandle::onTimeout, this, _1, parameter.getName()));
}
@@ -377,4 +381,4 @@
return true;
}
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/watch-handle.hpp b/src/handles/watch-handle.hpp
index 2fde3cf..f34b1fb 100644
--- a/src/handles/watch-handle.hpp
+++ b/src/handles/watch-handle.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -87,7 +87,7 @@
* @brief fetch data and send next interest
*/
void
- onData(const Interest& interest, Data& data, const Name& name);
+ onData(const Interest& interest, const Data& data, const Name& name);
/**
* @brief handle when fetching one data timeout
@@ -169,4 +169,4 @@
} // namespace repo
-#endif // REPO_HANDLES_Watch_HANDLE_HPP
+#endif // REPO_HANDLES_WATCH_HANDLE_HPP
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index 08e951b..16c622e 100644
--- a/src/handles/write-handle.cpp
+++ b/src/handles/write-handle.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -59,7 +59,7 @@
WriteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << reason << std::endl;
- throw Error("Insert prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Insert prefix registration failed"));
}
// onRegisterFailed for insert.
@@ -67,7 +67,7 @@
WriteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << reason << std::endl;
- throw Error("Insert check prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Insert check prefix registration failed"));
}
void
@@ -106,7 +106,7 @@
}
void
-WriteHandle::onData(const Interest& interest, Data& data, ProcessId processId)
+WriteHandle::onData(const Interest& interest, const Data& data, ProcessId processId)
{
m_validator.validate(data,
bind(&WriteHandle::onDataValidated, this, interest, _1, processId),
@@ -143,7 +143,7 @@
}
void
-WriteHandle::onSegmentData(const Interest& interest, Data& data, ProcessId processId)
+WriteHandle::onSegmentData(const Interest& interest, const Data& data, ProcessId processId)
{
m_validator.validate(data,
bind(&WriteHandle::onSegmentDataValidated, this, interest, _1, processId),
@@ -247,6 +247,7 @@
interest.setInterestLifetime(m_interestLifetime);
getFace().expressInterest(interest,
bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+ bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
process.credit--;
processRetry[segment] = 0;
@@ -341,6 +342,7 @@
fetchInterest.setInterestLifetime(m_interestLifetime);
getFace().expressInterest(fetchInterest,
bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+ bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
//When an interest is expressed, processCredit--
processCredit--;
@@ -392,6 +394,7 @@
retryInterest.setInterestLifetime(m_interestLifetime);
getFace().expressInterest(retryInterest,
bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+ bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
}
@@ -464,7 +467,7 @@
WriteHandle::deferredDeleteProcess(ProcessId processId)
{
getScheduler().scheduleEvent(PROCESS_DELETE_TIME,
- ndn::bind(&WriteHandle::deleteProcess, this, processId));
+ bind(&WriteHandle::deleteProcess, this, processId));
}
void
@@ -491,6 +494,7 @@
}
getFace().expressInterest(fetchInterest,
bind(&WriteHandle::onData, this, _1, _2, processId),
+ bind(&WriteHandle::onTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onTimeout, this, _1, processId));
}
@@ -569,4 +573,4 @@
reply(interest, response);
}
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index 1c64437..a02f675 100644
--- a/src/handles/write-handle.hpp
+++ b/src/handles/write-handle.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -125,7 +125,7 @@
* @brief fetch one data
*/
void
- onData(const Interest& interest, Data& data, ProcessId processId);
+ onData(const Interest& interest, const Data& data, ProcessId processId);
void
onDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
@@ -145,7 +145,7 @@
* @brief fetch segmented data
*/
void
- onSegmentData(const Interest& interest, Data& data, ProcessId processId);
+ onSegmentData(const Interest& interest, const Data& data, ProcessId processId);
void
onSegmentDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,