ims: move InMemoryStorage from util/
refs #3940 Change-Id: I4468fe9b65ef6263a62800701eb6b03df28fa274
This commit is contained in:
1 parent
4ab3be28d0
commit
c542f63d03
19 files changed
+107
-164
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "in-memory-storage-entry.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
InMemoryStorageEntry::InMemoryStorageEntry()
|
||||
: m_isFresh(true)
|
||||
@@ -44,7 +43,7 @@ InMemoryStorageEntry::setData(const Data& data)
|
||||
}
|
||||
|
||||
void
|
||||
InMemoryStorageEntry::setMarkStaleEventId(unique_ptr<scheduler::ScopedEventId>&& markStaleEventId)
|
||||
InMemoryStorageEntry::setMarkStaleEventId(unique_ptr<util::scheduler::ScopedEventId> markStaleEventId)
|
||||
{
|
||||
m_markStaleEventId = std::move(markStaleEventId);
|
||||
}
|
||||
@@ -55,5 +54,4 @@ InMemoryStorageEntry::markStale()
|
||||
m_isFresh = false;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -19,23 +19,20 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_ENTRY_HPP
|
||||
#define NDN_UTIL_IN_MEMORY_STORAGE_ENTRY_HPP
|
||||
#ifndef NDN_IMS_IN_MEMORY_STORAGE_ENTRY_HPP
|
||||
#define NDN_IMS_IN_MEMORY_STORAGE_ENTRY_HPP
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../interest.hpp"
|
||||
#include "../data.hpp"
|
||||
#include "scheduler-scoped-event-id.hpp"
|
||||
#include "../interest.hpp"
|
||||
#include "../util/scheduler-scoped-event-id.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
/** @brief Represents an in-memory storage entry
|
||||
/** @brief Represents an in-memory storage entry
|
||||
*/
|
||||
class InMemoryStorageEntry : noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
/** @brief Create an entry
|
||||
*/
|
||||
InMemoryStorageEntry();
|
||||
@@ -62,7 +59,6 @@ public:
|
||||
return m_dataPacket->getFullName();
|
||||
}
|
||||
|
||||
|
||||
/** @brief Returns the Data packet stored in the in-memory storage entry
|
||||
*/
|
||||
const Data&
|
||||
@@ -71,7 +67,6 @@ public:
|
||||
return *m_dataPacket;
|
||||
}
|
||||
|
||||
|
||||
/** @brief Changes the content of in-memory storage entry
|
||||
*
|
||||
* This method also allows data to satisfy Interest with MustBeFresh
|
||||
@@ -82,7 +77,7 @@ public:
|
||||
/** @brief Set eventId for the markStale event.
|
||||
*/
|
||||
void
|
||||
setMarkStaleEventId(unique_ptr<scheduler::ScopedEventId>&& eventId);
|
||||
setMarkStaleEventId(unique_ptr<util::scheduler::ScopedEventId> eventId);
|
||||
|
||||
/** @brief Disable the data from satisfying interest with MustBeFresh
|
||||
*/
|
||||
@@ -101,10 +96,9 @@ private:
|
||||
shared_ptr<const Data> m_dataPacket;
|
||||
|
||||
bool m_isFresh;
|
||||
unique_ptr<scheduler::ScopedEventId> m_markStaleEventId;
|
||||
unique_ptr<util::scheduler::ScopedEventId> m_markStaleEventId;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NDN_UTIL_IN_MEMORY_STORAGE_ENTRY_HPP
|
||||
#endif // NDN_IMS_IN_MEMORY_STORAGE_ENTRY_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "in-memory-storage-fifo.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
InMemoryStorageFifo::InMemoryStorageFifo(size_t limit)
|
||||
: InMemoryStorage(limit)
|
||||
@@ -62,5 +61,4 @@ InMemoryStorageFifo::beforeErase(InMemoryStorageEntry* entry)
|
||||
m_cleanupIndex.get<byEntity>().erase(it);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -19,20 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_FIFO_HPP
|
||||
#define NDN_UTIL_IN_MEMORY_STORAGE_FIFO_HPP
|
||||
#ifndef NDN_IMS_IN_MEMORY_STORAGE_FIFO_HPP
|
||||
#define NDN_IMS_IN_MEMORY_STORAGE_FIFO_HPP
|
||||
|
||||
#include "in-memory-storage.hpp"
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
/** @brief Provides in-memory storage employing FIFO replacement policy, which is first in first
|
||||
* out.
|
||||
/** @brief Provides in-memory storage employing First-In-First-Out (FIFO) replacement policy.
|
||||
*/
|
||||
class InMemoryStorageFifo : public InMemoryStorage
|
||||
{
|
||||
@@ -62,7 +60,7 @@ NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
|
||||
beforeErase(InMemoryStorageEntry* entry) override;
|
||||
|
||||
private:
|
||||
//multi_index_container to implement FIFO
|
||||
// multi_index_container to implement FIFO
|
||||
class byArrival;
|
||||
class byEntity;
|
||||
|
||||
@@ -87,7 +85,6 @@ private:
|
||||
CleanupIndex m_cleanupIndex;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NDN_UTIL_IN_MEMORY_STORAGE_FIFO_HPP
|
||||
#endif // NDN_IMS_IN_MEMORY_STORAGE_FIFO_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "in-memory-storage-lfu.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
InMemoryStorageLfu::InMemoryStorageLfu(size_t limit)
|
||||
: InMemoryStorage(limit)
|
||||
@@ -72,5 +71,4 @@ InMemoryStorageLfu::afterAccess(InMemoryStorageEntry* entry)
|
||||
m_cleanupIndex.get<byEntity>().modify(it, &incrementFrequency);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -19,19 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_LFU_HPP
|
||||
#define NDN_UTIL_IN_MEMORY_STORAGE_LFU_HPP
|
||||
#ifndef NDN_IMS_IN_MEMORY_STORAGE_LFU_HPP
|
||||
#define NDN_IMS_IN_MEMORY_STORAGE_LFU_HPP
|
||||
|
||||
#include "in-memory-storage.hpp"
|
||||
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/identity.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
/** @brief Provides an in-memory storage with Least Frequently Used (LFU) replacement policy.
|
||||
* @note The frequency right now is usage count.
|
||||
@@ -88,7 +87,7 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
//multi_index_container to implement LFU
|
||||
// multi_index_container to implement LFU
|
||||
class byFrequency;
|
||||
class byEntity;
|
||||
|
||||
@@ -115,7 +114,6 @@ private:
|
||||
CleanupIndex m_cleanupIndex;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NDN_UTIL_IN_MEMORY_STORAGE_LFU_HPP
|
||||
#endif // NDN_IMS_IN_MEMORY_STORAGE_LFU_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "in-memory-storage-lru.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
InMemoryStorageLru::InMemoryStorageLru(size_t limit)
|
||||
: InMemoryStorage(limit)
|
||||
@@ -71,5 +70,4 @@ InMemoryStorageLru::afterAccess(InMemoryStorageEntry* entry)
|
||||
afterInsert(entry);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -19,22 +19,20 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
|
||||
#define NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
|
||||
#ifndef NDN_IMS_IN_MEMORY_STORAGE_LRU_HPP
|
||||
#define NDN_IMS_IN_MEMORY_STORAGE_LRU_HPP
|
||||
|
||||
#include "in-memory-storage.hpp"
|
||||
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/identity.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
/** @brief Provides in-memory storage employing LRU replacement policy, of which the least
|
||||
* recently used entry will be evict first.
|
||||
/** @brief Provides in-memory storage employing Least Recently Used (LRU) replacement policy.
|
||||
*/
|
||||
class InMemoryStorageLru : public InMemoryStorage
|
||||
{
|
||||
@@ -70,7 +68,7 @@ NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
|
||||
beforeErase(InMemoryStorageEntry* entry) override;
|
||||
|
||||
private:
|
||||
//multi_index_container to implement LRU
|
||||
// multi_index_container to implement LRU
|
||||
class byUsedTime;
|
||||
class byEntity;
|
||||
|
||||
@@ -95,7 +93,6 @@ private:
|
||||
CleanupIndex m_cleanupIndex;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NDN_UTIL_IN_MEMORY_STORAGE_LRU_HPP
|
||||
#endif // NDN_IMS_IN_MEMORY_STORAGE_LRU_HPP
|
||||
+2
-4
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "in-memory-storage-persistent.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
InMemoryStoragePersistent::InMemoryStoragePersistent()
|
||||
: InMemoryStorage()
|
||||
@@ -40,5 +39,4 @@ InMemoryStoragePersistent::evictItem()
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
+6
-8
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2013-2016 Regents of the University of California.
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -19,16 +19,15 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_PERSISTENT_HPP
|
||||
#define NDN_UTIL_IN_MEMORY_STORAGE_PERSISTENT_HPP
|
||||
#ifndef NDN_IMS_IN_MEMORY_STORAGE_PERSISTENT_HPP
|
||||
#define NDN_IMS_IN_MEMORY_STORAGE_PERSISTENT_HPP
|
||||
|
||||
#include "in-memory-storage.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
/** @brief Provides application cache with persistent storage, of which no replacement policy will
|
||||
* be employed. Entries will only be deleted by explicitly application control.
|
||||
* be employed. Entries will only be deleted by explicit application control.
|
||||
*/
|
||||
class InMemoryStoragePersistent : public InMemoryStorage
|
||||
{
|
||||
@@ -49,7 +48,6 @@ NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
|
||||
evictItem() override;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NDN_UTIL_IN_MEMORY_STORAGE_PERSISTENT_HPP
|
||||
#endif // NDN_IMS_IN_MEMORY_STORAGE_PERSISTENT_HPP
|
||||
@@ -22,10 +22,7 @@
|
||||
#include "in-memory-storage.hpp"
|
||||
#include "in-memory-storage-entry.hpp"
|
||||
|
||||
#include "../security/signature-sha256-with-rsa.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
const time::milliseconds InMemoryStorage::INFINITE_WINDOW(-1);
|
||||
const time::milliseconds InMemoryStorage::ZERO_WINDOW(0);
|
||||
@@ -189,7 +186,7 @@ InMemoryStorage::insert(const Data& data, const time::milliseconds& mustBeFreshP
|
||||
m_nPackets++;
|
||||
entry->setData(data);
|
||||
if (m_scheduler != nullptr && mustBeFreshProcessingWindow > ZERO_WINDOW) {
|
||||
auto eventId = make_unique<scheduler::ScopedEventId>(*m_scheduler);
|
||||
auto eventId = make_unique<util::scheduler::ScopedEventId>(*m_scheduler);
|
||||
*eventId = m_scheduler->scheduleEvent(mustBeFreshProcessingWindow,
|
||||
bind(&InMemoryStorageEntry::markStale, entry));
|
||||
entry->setMarkStaleEventId(std::move(eventId));
|
||||
@@ -449,5 +446,4 @@ InMemoryStorage::printCache(std::ostream& os) const
|
||||
os << (*it)->getFullName() << std::endl;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
@@ -19,34 +19,29 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#ifndef NDN_UTIL_IN_MEMORY_STORAGE_HPP
|
||||
#define NDN_UTIL_IN_MEMORY_STORAGE_HPP
|
||||
#ifndef NDN_IMS_IN_MEMORY_STORAGE_HPP
|
||||
#define NDN_IMS_IN_MEMORY_STORAGE_HPP
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../interest.hpp"
|
||||
#include "../data.hpp"
|
||||
#include "scheduler.hpp"
|
||||
#include "in-memory-storage-entry.hpp"
|
||||
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <iterator>
|
||||
#include <stack>
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
#include <boost/multi_index/identity.hpp>
|
||||
#include <boost/multi_index/mem_fun.hpp>
|
||||
|
||||
#include <stack>
|
||||
#include <iterator>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
|
||||
/** @brief Represents in-memory storage
|
||||
*/
|
||||
class InMemoryStorage : noncopyable
|
||||
{
|
||||
public:
|
||||
//multi_index_container to implement storage
|
||||
// multi_index_container to implement storage
|
||||
class byFullName;
|
||||
|
||||
typedef boost::multi_index_container<
|
||||
@@ -341,7 +336,6 @@ private:
|
||||
unique_ptr<Scheduler> m_scheduler;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NDN_UTIL_IN_MEMORY_STORAGE_HPP
|
||||
#endif // NDN_IMS_IN_MEMORY_STORAGE_HPP
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
@@ -23,9 +23,9 @@
|
||||
#define NDN_MGMT_DISPATCHER_HPP
|
||||
|
||||
#include "../face.hpp"
|
||||
#include "../security/key-chain.hpp"
|
||||
#include "../encoding/block.hpp"
|
||||
#include "../util/in-memory-storage-fifo.hpp"
|
||||
#include "../security/key-chain.hpp"
|
||||
#include "../ims/in-memory-storage-fifo.hpp"
|
||||
#include "control-response.hpp"
|
||||
#include "control-parameters.hpp"
|
||||
#include "status-dataset-context.hpp"
|
||||
@@ -473,7 +473,7 @@ private:
|
||||
std::unordered_map<Name, uint64_t> m_streams;
|
||||
|
||||
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
util::InMemoryStorageFifo m_storage;
|
||||
InMemoryStorageFifo m_storage;
|
||||
};
|
||||
|
||||
template<typename CP>
|
||||
|
||||
+6
-10
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
@@ -19,20 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#include "util/in-memory-storage-fifo.hpp"
|
||||
#include "ims/in-memory-storage-fifo.hpp"
|
||||
|
||||
#include "boost-test.hpp"
|
||||
#include "../make-interest-data.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
namespace tests {
|
||||
|
||||
using namespace ndn::tests;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Util)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorage)
|
||||
BOOST_AUTO_TEST_SUITE(Fifo)
|
||||
BOOST_AUTO_TEST_SUITE(Ims)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorageFifo)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ArrivalQueue)
|
||||
{
|
||||
@@ -75,10 +73,8 @@ BOOST_AUTO_TEST_CASE(ArrivalQueue2)
|
||||
BOOST_CHECK(found2 == nullptr);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // Fifo
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorage
|
||||
BOOST_AUTO_TEST_SUITE_END() // Util
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorageFifo
|
||||
BOOST_AUTO_TEST_SUITE_END() // Ims
|
||||
|
||||
} // namespace tests
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
+6
-10
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
@@ -19,20 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#include "util/in-memory-storage-lfu.hpp"
|
||||
#include "ims/in-memory-storage-lfu.hpp"
|
||||
|
||||
#include "boost-test.hpp"
|
||||
#include "../make-interest-data.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
namespace tests {
|
||||
|
||||
using namespace ndn::tests;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Util)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorage)
|
||||
BOOST_AUTO_TEST_SUITE(Lfu)
|
||||
BOOST_AUTO_TEST_SUITE(Ims)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorageLfu)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(FrequencyQueue)
|
||||
{
|
||||
@@ -130,10 +128,8 @@ BOOST_AUTO_TEST_CASE(FrequencyQueue2)
|
||||
BOOST_CHECK_EQUAL(found3->getName(), name3);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // Lfu
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorage
|
||||
BOOST_AUTO_TEST_SUITE_END() // Util
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorageLfu
|
||||
BOOST_AUTO_TEST_SUITE_END() // Ims
|
||||
|
||||
} // namespace tests
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
+6
-10
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
@@ -19,20 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#include "util/in-memory-storage-lru.hpp"
|
||||
#include "ims/in-memory-storage-lru.hpp"
|
||||
|
||||
#include "boost-test.hpp"
|
||||
#include "../make-interest-data.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
namespace tests {
|
||||
|
||||
using namespace ndn::tests;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Util)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorage)
|
||||
BOOST_AUTO_TEST_SUITE(Lru)
|
||||
BOOST_AUTO_TEST_SUITE(Ims)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorageLru)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UsedTimeQueue)
|
||||
{
|
||||
@@ -132,10 +130,8 @@ BOOST_AUTO_TEST_CASE(UsedTimeQueue2)
|
||||
BOOST_CHECK_EQUAL(found3->getName(), name3);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // Lru
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorage
|
||||
BOOST_AUTO_TEST_SUITE_END() // Util
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorageLru
|
||||
BOOST_AUTO_TEST_SUITE_END() // Ims
|
||||
|
||||
} // namespace tests
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
+6
-10
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
@@ -19,20 +19,18 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#include "util/in-memory-storage-persistent.hpp"
|
||||
#include "ims/in-memory-storage-persistent.hpp"
|
||||
|
||||
#include "boost-test.hpp"
|
||||
#include "../make-interest-data.hpp"
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
namespace tests {
|
||||
|
||||
using namespace ndn::tests;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Util)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorage)
|
||||
BOOST_AUTO_TEST_SUITE(Persistent)
|
||||
BOOST_AUTO_TEST_SUITE(Ims)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStoragePersistent)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetLimit)
|
||||
{
|
||||
@@ -60,10 +58,8 @@ BOOST_AUTO_TEST_CASE(InsertAndDouble)
|
||||
BOOST_CHECK_EQUAL(ims.getCapacity(), 20);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // Persistent
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorage
|
||||
BOOST_AUTO_TEST_SUITE_END() // Util
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStoragePersistent
|
||||
BOOST_AUTO_TEST_SUITE_END() // Ims
|
||||
|
||||
} // namespace tests
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
+14
-19
@@ -19,12 +19,13 @@
|
||||
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
|
||||
*/
|
||||
|
||||
#include "util/in-memory-storage-persistent.hpp"
|
||||
#include "util/in-memory-storage-fifo.hpp"
|
||||
#include "util/in-memory-storage-lfu.hpp"
|
||||
#include "util/in-memory-storage-lru.hpp"
|
||||
#include "util/digest.hpp"
|
||||
#include "ims/in-memory-storage.hpp"
|
||||
#include "ims/in-memory-storage-fifo.hpp"
|
||||
#include "ims/in-memory-storage-lfu.hpp"
|
||||
#include "ims/in-memory-storage-lru.hpp"
|
||||
#include "ims/in-memory-storage-persistent.hpp"
|
||||
#include "security/signature-sha256-with-rsa.hpp"
|
||||
#include "util/digest.hpp"
|
||||
|
||||
#include "boost-test.hpp"
|
||||
#include "../make-interest-data.hpp"
|
||||
@@ -33,14 +34,12 @@
|
||||
#include <boost/mpl/list.hpp>
|
||||
|
||||
namespace ndn {
|
||||
namespace util {
|
||||
namespace tests {
|
||||
|
||||
using namespace ndn::tests;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Util)
|
||||
BOOST_AUTO_TEST_SUITE(Ims)
|
||||
BOOST_AUTO_TEST_SUITE(TestInMemoryStorage)
|
||||
BOOST_AUTO_TEST_SUITE(Common)
|
||||
|
||||
using InMemoryStorages = boost::mpl::list<InMemoryStoragePersistent,
|
||||
InMemoryStorageFifo,
|
||||
@@ -274,7 +273,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(DigestCalculation, T, InMemoryStorages)
|
||||
{
|
||||
shared_ptr<Data> data = makeData("/digest/compute");
|
||||
|
||||
ConstBufferPtr digest1 = Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
|
||||
ConstBufferPtr digest1 = util::Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
|
||||
BOOST_CHECK_EQUAL(digest1->size(), 32);
|
||||
|
||||
InMemoryStorageEntry entry;
|
||||
@@ -372,7 +371,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(EraseCanonical, T, InMemoryStorages)
|
||||
shared_ptr<Data> data7 = makeData("/c/c/1");
|
||||
ims.insert(*data7);
|
||||
|
||||
ConstBufferPtr digest1 = Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
|
||||
ConstBufferPtr digest1 = util::Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
|
||||
|
||||
Name name("/a");
|
||||
ims.erase(name);
|
||||
@@ -393,7 +392,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ImplicitDigestSelector, T, InMemoryStorages)
|
||||
shared_ptr<Data> data3 = makeData("/z/z/z");
|
||||
ims.insert(*data3);
|
||||
|
||||
ConstBufferPtr digest1 = Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
|
||||
ConstBufferPtr digest1 = util::Sha256::computeDigest(data->wireEncode().wire(), data->wireEncode().size());
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("");
|
||||
interest->setName(Name(name).appendImplicitSha256Digest(digest1->buf(), digest1->size()));
|
||||
@@ -506,7 +505,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(PublisherKeySelector2, T, InMemoryStorages)
|
||||
|
||||
SignatureSha256WithRsa fakeSignature;
|
||||
fakeSignature.setValue(makeEmptyBlock(tlv::SignatureValue));
|
||||
|
||||
fakeSignature.setKeyLocator(locator);
|
||||
data2->setSignature(fakeSignature);
|
||||
data2->wireEncode();
|
||||
@@ -694,8 +692,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(InsertAndEvict, T, InMemoryStoragesLimited)
|
||||
BOOST_CHECK(found == nullptr);
|
||||
}
|
||||
|
||||
///as Find function is implemented at the base case, therefore testing for one derived class is
|
||||
///sufficient for all
|
||||
// Find function is implemented at the base case, so it's sufficient to test for one derived class.
|
||||
class FindFixture : public tests::UnitTestTimeFixture
|
||||
{
|
||||
protected:
|
||||
@@ -928,9 +925,9 @@ BOOST_AUTO_TEST_CASE(DigestExclude)
|
||||
Name n2 = insert(2, "ndn:/A");
|
||||
insert(3, "ndn:/A/B");
|
||||
|
||||
uint8_t digest00[Sha256::DIGEST_SIZE];
|
||||
uint8_t digest00[util::Sha256::DIGEST_SIZE];
|
||||
std::fill_n(digest00, sizeof(digest00), 0x00);
|
||||
uint8_t digestFF[Sha256::DIGEST_SIZE];
|
||||
uint8_t digestFF[util::Sha256::DIGEST_SIZE];
|
||||
std::fill_n(digestFF, sizeof(digestFF), 0xFF);
|
||||
|
||||
Exclude excludeDigest;
|
||||
@@ -1050,10 +1047,8 @@ BOOST_AUTO_TEST_CASE(MustBeFresh)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // Find
|
||||
BOOST_AUTO_TEST_SUITE_END() // Common
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestInMemoryStorage
|
||||
BOOST_AUTO_TEST_SUITE_END() // Util
|
||||
BOOST_AUTO_TEST_SUITE_END() // Ims
|
||||
|
||||
} // namespace tests
|
||||
} // namespace util
|
||||
} // namespace ndn
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2013-2017 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
public:
|
||||
util::DummyClientFace face;
|
||||
mgmt::Dispatcher dispatcher;
|
||||
util::InMemoryStorageFifo& storage;
|
||||
InMemoryStorageFifo& storage;
|
||||
};
|
||||
|
||||
class VoidParameters : public mgmt::ControlParameters
|
||||
|
||||
Reference in new issue
Block a user