Thank you for that advice, it helped me get past the catch and the stream error in the code I posted previously. Unfortunately, when I try this, the stream is still not reading anything from the bundle in disk based storage, while it works fine in memory based. I have a line that outputs the gcount() output after a read from the ios and in memory based storage I'm getting out
Hello Carson.
I think there is a mistake in the usage of the iostream element of the
BLOB. The iostream is used to lock the BLOB and open/close the
corresponding file descriptor. You need to create an iostream object for
the whole time you are working with the stream. In your code you create
and destroy the stream in the same operation.
This code is not tested, but something like that should work:
ibrcommon::BLOB::iostream ios = ref.iostream();
ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create();
dtn::data::DefaultSerializer serializer(*ios);
if (!ios->good()) throw ibrcommon::IOException("stream went bad");
try {
// activate exceptions for this method
serializer << (bundle);(*ios) << std::flush;
// flush the stream
Kind regards,
} catch (const ibrcommon::Exception &ex) {
IBRCOMMON_LOGGER_DEBUG(10) << ex.what() << IBRCOMMON_LOGGER_ENDL;
throw;
}
Johannes
Am 27.08.2012 22:00, schrieb Carson Dunbar:
--> u_int32_t
> NCRoutingExtension::generate_and_enqueue_encodings(dtn::data::Bundle
> bundle, u_int32_t max_chunk_size)
> {
> // start with just the standard basis, i.e. fragmentation
>
> // need to figure out the number of chunks that will be created
> // still requiring the number of chunks to be a multiple of 8?
> // let's try to not require it
> //
> dtn::core::BundleStorage &storage = (**this).getStorage();
> u_int32_t num_chunks, chunk_size;
>
> size_t orig_bundle_len = 0;
> size_t block_len;
> ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create();
> dtn::data::DefaultSerializer serializer(*ref.iostream());
> try {
> // activate exceptions for this method
> if (!ref.iostream()->good()) throw ibrcommon::IOException("stream went
> bad");
> serializer << (bundle);
> // flush the stream
> (*ref.iostream()) << std::flush;
>
> } catch (const ibrcommon::Exception &ex) {
> IBRCOMMON_LOGGER_DEBUG(10) << ex.what() << IBRCOMMON_LOGGER_ENDL;
> throw;
> }
Johannes Morgenroth Institut fuer Betriebssysteme und Rechnerverbund
Tel.: +49-531-391-3249 Muehlenpfordtstrasse 23
Fax.: +49-531-391-5936 TU Braunschweig D-38106 Braunschweig