示例#1
0
		bool SQLiteBundleSet::has(const dtn::data::BundleID &id) const throw ()
		{
			// check bloom-filter first
			if (!id.isIn(_bf)) return false;

			// Return true if the bloom-filter is not consistent with
			// the bundles set. This happen if the MemoryBundleSet gets deserialized.
			if (!_consistent) return true;

			try {
				SQLiteDatabase::Statement st( const_cast<sqlite3*>(_sqldb._database), SQLiteDatabase::_sql_queries[SQLiteDatabase::BUNDLE_SET_GET]);

				sqlite3_bind_int64(*st, 1, _set_id);
				sqlite3_bind_text(*st, 2, id.source.getString().c_str(), static_cast<int>(id.source.getString().length()), SQLITE_TRANSIENT);
				sqlite3_bind_int64(*st, 3, id.timestamp.get<uint64_t>());
				sqlite3_bind_int64(*st, 4, id.sequencenumber.get<uint64_t>());

				if (id.isFragment()) {
					sqlite3_bind_int64(*st, 5, id.fragmentoffset.get<uint64_t>());
					sqlite3_bind_int64(*st, 6, id.getPayloadLength());
				} else {
					sqlite3_bind_int64(*st, 5, -1);
					sqlite3_bind_int64(*st, 6, -1);
				}

				if (st.step() == SQLITE_ROW)
					return true;
			} catch (const SQLiteDatabase::SQLiteQueryException&) {
				// error
			}

			return false;
		}
示例#2
0
		void NeighborDatabase::NeighborEntry::releaseTransfer(const dtn::data::BundleID &id)
		{
			ibrcommon::MutexLock l(_transit_lock);
			_transit_bundles.erase(id);

			IBRCOMMON_LOGGER_DEBUG_TAG("NeighborDatabase", 20) << "release transfer of " << id.toString() << " (" << _transit_bundles.size() << " bundles in transit)" << IBRCOMMON_LOGGER_ENDL;
		}
示例#3
0
		void SQLiteBundleSet::get_bundleid(SQLiteDatabase::Statement &st, dtn::data::BundleID &id, int offset) const throw (SQLiteDatabase::SQLiteQueryException)
		{
			id.source = dtn::data::EID((const char*)sqlite3_column_text(*st, offset + 0));
			id.timestamp = sqlite3_column_int64(*st, offset + 1);
			id.sequencenumber = sqlite3_column_int64(*st, offset + 2);
			dtn::data::Number fragmentoffset = 0;
			id.setFragment(sqlite3_column_int64(*st, offset + 2) >= 0);

			if (id.isFragment()) {
				id.fragmentoffset = sqlite3_column_int64(*st, offset + 3);
				id.setPayloadLength(sqlite3_column_int64(*st, offset + 4));
			} else {
				id.fragmentoffset = 0;
				id.setPayloadLength(0);
			}
		}
示例#4
0
		void NativeSession::delivered(const dtn::data::BundleID &id) const throw (BundleNotFoundException)
		{
			try {
				// announce this bundle as delivered
				const dtn::data::MetaBundle meta = dtn::core::BundleCore::getInstance().getStorage().info(id);
				_registration.delivered(meta);

				IBRCOMMON_LOGGER_DEBUG_TAG(NativeSession::TAG, 20) << "Bundle " << id.toString() << " marked as delivered" << IBRCOMMON_LOGGER_ENDL;
			} catch (const ibrcommon::Exception&) {
				throw BundleNotFoundException();
			}
		}
示例#5
0
		void NativeSession::next(RegisterIndex ri) throw (BundleNotFoundException)
		{
			try {
				const dtn::data::BundleID id = _bundle_queue.getnpop();

				IBRCOMMON_LOGGER_DEBUG_TAG(NativeSession::TAG, 20) << "Next bundle in queue is " << id.toString() << IBRCOMMON_LOGGER_ENDL;

				load(ri, id);
			} catch (const ibrcommon::QueueUnblockedException &ex) {
				IBRCOMMON_LOGGER_DEBUG_TAG(NativeSession::TAG, 15) << "No next bundle available" << IBRCOMMON_LOGGER_ENDL;
				throw BundleNotFoundException();
			}
		}
示例#6
0
		bool NeighborDatabase::NeighborEntry::has(const dtn::data::BundleID &id, const bool require_bloomfilter) const
		{
			if (_filter_state == FILTER_AVAILABLE)
			{
				if (_filter.contains(id.toString()))
					return true;
			}
			else if (require_bloomfilter)
			{
				throw BloomfilterNotAvailableException(eid);
			}

			return _summary.has(id);
		}
示例#7
0
		bool MemoryBundleSet::has(const dtn::data::BundleID &bundle) const throw ()
		{
			// check bloom-filter first
			if (bundle.isIn(_bf)) {
				// Return true if the bloom-filter is not consistent with
				// the bundles set. This happen if the MemoryBundleSet gets deserialized.
				if (!_consistent) return true;

				bundle_set::iterator iter = _bundles.find(dtn::data::MetaBundle::create(bundle));
				return (iter != _bundles.end());
			}

			return false;
		}
示例#8
0
		void NativeSession::load(RegisterIndex ri, const dtn::data::BundleID &id) throw (BundleNotFoundException)
		{
			// load the bundle
			try {
				_bundle[ri] = dtn::core::BundleCore::getInstance().getStorage().get(id);

				// process the bundle block (security, compression, ...)
				dtn::core::BundleCore::processBlocks(_bundle[ri]);

				IBRCOMMON_LOGGER_DEBUG_TAG(NativeSession::TAG, 20) << "Bundle " << id.toString() << " loaded" << IBRCOMMON_LOGGER_ENDL;
			} catch (const ibrcommon::Exception &ex) {
				IBRCOMMON_LOGGER_DEBUG_TAG(NativeSession::TAG, 15) << "Failed to load bundle " << id.toString() << ", Exception: " << ex.what() << IBRCOMMON_LOGGER_ENDL;
				throw BundleNotFoundException();
			}
		}
示例#9
0
		void NeighborDatabase::NeighborEntry::acquireTransfer(const dtn::data::BundleID &id) throw (NoMoreTransfersAvailable, AlreadyInTransitException)
		{
			ibrcommon::MutexLock l(_transit_lock);

			// check if enough resources available to transfer the bundle
			if (_transit_bundles.size() >= dtn::core::BundleCore::max_bundles_in_transit) throw NoMoreTransfersAvailable();

			// check if the bundle is already in transit
			if (_transit_bundles.find(id) != _transit_bundles.end()) throw AlreadyInTransitException();

			// insert the bundle into the transit list
			_transit_bundles.insert(id);

			IBRCOMMON_LOGGER_DEBUG_TAG("NeighborDatabase", 20) << "acquire transfer of " << id.toString() << " (" << _transit_bundles.size() << " bundles in transit)" << IBRCOMMON_LOGGER_ENDL;
		}