Skip to content

Commit

Permalink
In the middle of getting rid of last vestiges of boost archive, but t…
Browse files Browse the repository at this point in the history
…oo tired to do it now. Does not compile.
  • Loading branch information
srh committed Apr 9, 2012
1 parent 0eca984 commit d09a82f
Show file tree
Hide file tree
Showing 29 changed files with 187 additions and 800 deletions.
4 changes: 0 additions & 4 deletions scripts/generate_join_macros.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def generate_make_equality_comparable_macro(nfields):
print "Please modify '%s' instead of modifying this file.*/" % sys.argv[0]
print

print "#include \"errors.hpp\""
print "#include <boost/serialization/access.hpp>"
print

print """
/* The purpose of these macros is to make it easier to define semilattice joins
for types that consist of a fixed set of fields which it is a simple product of.
Expand Down
23 changes: 12 additions & 11 deletions scripts/generate_rpc_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,22 @@ def cpre(template):
else:
print " template<" + csep("class a#_t") + ">"
print " friend void send(mailbox_manager_t*, typename mailbox_t< void(" + csep("a#_t") + ") >::address_t" + cpre("const a#_t&") + ");"
print " static void write(std::ostream &stream" + cpre("const arg#_t &arg#") + ") {"
print " boost::archive::binary_oarchive archive(stream);"
print " static void write(write_stream_t *stream" + cpre("const arg#_t &arg#") + ") {"
print " write_message_t msg;"
for i in xrange(nargs):
print " archive << arg%d;" % i
print " msg << arg%d;" % i
print " int res = send_write_message(stream, &msg);"
print " if (res) { throw fake_archive_exc_t(); }"
print " }"
print " static void on_message(std::istream &stream, const boost::function<void()> &done, const boost::function< void(" + csep("arg#_t") + ") > &fun) {"
print " static void on_message(read_stream_t *stream, const boost::function<void()> &done, const boost::function< void(" + csep("arg#_t") + ") > &fun) {"
for i in xrange(nargs):
print " arg%d_t arg%d;" % (i, i)
print " {"
print " int res;"

print " boost::archive::binary_iarchive archive(stream);"
for i in xrange(nargs):
print " archive >> arg%d;" % i
print " }"
print " res = deserialize(stream, &arg%d);" % i
print " if (res) { throw fake_archive_exc_t(); }"
print " done();"
print " fun(" + csep("arg#") + ");"
print " }"
Expand Down Expand Up @@ -102,9 +105,7 @@ def cpre(template):
print "Please modify '%s' instead of modifying this file.*/" % sys.argv[0]
print

print "#include \"errors.hpp\""
print "#include <boost/archive/binary_iarchive.hpp>"
print "#include <boost/archive/binary_oarchive.hpp>"
print "#include \"containers/archive/archive.hpp\""
print "#include \"rpc/serialize_macros.hpp\""
print "#include \"rpc/mailbox/mailbox.hpp\""
print
Expand All @@ -116,7 +117,7 @@ def cpre(template):
print "};"
print
print "template<class invalid_proto_t> class mailbox_addr_t {"
print " // If someoen tries to instantiate mailbox_addr_t incorrectly,"
print " // If someone tries to instantiate mailbox_addr_t incorrectly,"
print " // this should cause an error."
print " typename invalid_proto_t::you_are_using_mailbox_addr_t_incorrectly foo;"
print "};"
Expand Down
14 changes: 0 additions & 14 deletions scripts/generate_serialize_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
def generate_make_serializable_macro(nfields):
print "#define RDB_MAKE_SERIALIZABLE_%d(type_t%s) \\" % \
(nfields, "".join(", field%d" % (i+1) for i in xrange(nfields)))
print " namespace boost {\\"
print " namespace serialization {\\"
zeroarg = ("UNUSED " if nfields == 0 else "")
print " template<class Archive> void serialize(%sArchive &__archive, %stype_t &__thing, UNUSED const unsigned int /* version */) { \\" % (zeroarg, zeroarg)
for i in xrange(nfields):
print " __archive & __thing.field%d; \\" % (i + 1)
print " }}} \\"
print " inline write_message_t &operator<<(%swrite_message_t &msg, %sconst type_t &thing) { \\" % (zeroarg, zeroarg)
for i in xrange(nfields):
print " msg << thing.field%d; \\" % (i + 1)
Expand All @@ -42,11 +36,6 @@ def generate_make_serializable_macro(nfields):
def generate_make_me_serializable_macro(nfields):
print "#define RDB_MAKE_ME_SERIALIZABLE_%d(%s) \\" % \
(nfields, ", ".join("field%d" % (i+1) for i in xrange(nfields)))
print " friend class boost::serialization::access; \\"
print " template<typename Archive> void serialize(%sArchive &__archive, UNUSED const unsigned int /* version */) { \\" % ("UNUSED " if nfields == 0 else "")
for i in xrange(nfields):
print " __archive & field%d; \\" % (i + 1)
print " } \\"
zeroarg = ("UNUSED " if nfields == 0 else "")
print " friend class write_message_t; \\"
print " void rdb_serialize(%swrite_message_t &msg) const { \\" % zeroarg
Expand All @@ -72,9 +61,6 @@ def generate_make_me_serializable_macro(nfields):
print "Please modify '%s' instead of modifying this file.*/" % sys.argv[0]
print

print "#include \"errors.hpp\""
print "#include <boost/serialization/access.hpp>"
print
print "#include \"containers/archive/archive.hpp\""
print "#include \"containers/archive/stl_types.hpp\""
print "#include \"containers/archive/boost_types.hpp\""
Expand Down
13 changes: 3 additions & 10 deletions src/arch/address.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef ARCH_ADDRESS_HPP_
#define ARCH_ADDRESS_HPP_

#include "utils.hpp" // (for UNUSED macro)
#include <boost/serialization/access.hpp>
#include <boost/serialization/binary_object.hpp>
#include <netinet/in.h>

#include <string>

#include "containers/archive/archive.hpp"
#include "errors.hpp"

/* ip_address_t represents an IPv4 address. */
struct ip_address_t {
Expand All @@ -25,13 +25,6 @@ struct ip_address_t {
struct in_addr addr;

private:
friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, UNUSED const unsigned int version) {
// Not really platform independent...
boost::serialization::binary_object bin_addr(&addr, sizeof(in_addr));
ar & bin_addr;
}

friend class write_message_t;
void rdb_serialize(write_message_t &msg) const {
msg.append(&addr, sizeof(addr));
Expand Down
9 changes: 0 additions & 9 deletions src/btree/keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include <string>
#include <vector>

#include "errors.hpp"
#include <boost/serialization/binary_object.hpp>

#include "config/args.hpp"
#include "protocol_api.hpp" // FIXME: ugh!
#include "utils.hpp"
Expand Down Expand Up @@ -88,12 +85,6 @@ struct store_key_t {
return sized_strcmp(contents, size, k.contents, k.size);
}

friend class boost::serialization::access;
template<typename Archive> void serialize(Archive &ar, UNUSED const unsigned int version) {
ar & size;
ar & boost::serialization::make_binary_object(contents, size);
}

void rdb_serialize(write_message_t &msg) const {
uint8_t sz = size;
msg << sz;
Expand Down
5 changes: 0 additions & 5 deletions src/btree/slice.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#include "errors.hpp"
#include <boost/archive/binary_oarchive.hpp>
#include "containers/vector_stream.hpp"

#include "btree/slice.hpp"
#include "btree/node.hpp"
#include "buffer_cache/buffer_cache.hpp"
#include "concurrency/cond_var.hpp"

namespace arc = boost::archive;

// Run backfilling at a reduced priority
#define BACKFILL_CACHE_PRIORITY 10

Expand Down
17 changes: 0 additions & 17 deletions src/buffer_cache/mirrored/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

#include "config/args.hpp"
#include "utils.hpp"

#include <boost/serialization/serialization.hpp>
#include <boost/serialization/access.hpp>

#include "containers/archive/archive.hpp"

#define NEVER_FLUSH -1
Expand Down Expand Up @@ -63,19 +59,6 @@ struct mirrored_cache_config_t {
int io_priority_reads;
int io_priority_writes;

friend class boost::serialization::access;
template<class Archive> void serialize(Archive &ar, UNUSED const unsigned int version) {
ar & max_size;
ar & wait_for_flush;
ar & flush_timer_ms;
ar & max_dirty_size;
ar & flush_dirty_size;
ar & flush_waiting_threshold;
ar & max_concurrent_flushes;
ar & io_priority_reads;
ar & io_priority_writes;
}

void rdb_serialize(write_message_t &msg) const {
msg << max_size;
msg << wait_for_flush;
Expand Down
2 changes: 0 additions & 2 deletions src/clustering/administration/metadata.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef CLUSTERING_ADMINISTRATION_METADATA_HPP_
#define CLUSTERING_ADMINISTRATION_METADATA_HPP_

#include "errors.hpp"
#include <boost/serialization/list.hpp>
#include <sstream>

#include "clustering/administration/datacenter_metadata.hpp"
Expand Down
60 changes: 28 additions & 32 deletions src/clustering/administration/persist.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#include <fstream>

#include "errors.hpp"
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/export.hpp>

#include "clustering/administration/persist.hpp"
#include "containers/archive/file_stream.hpp"

namespace metadata_persistence {

Expand Down Expand Up @@ -37,40 +31,46 @@ void create(const std::string& file_path, machine_id_t machine_id, const cluster
throw file_exc_t("Could not create directory: " + errno_to_string(errno));
}

std::ofstream file(metadata_file(file_path).c_str(), std::ios_base::trunc | std::ios_base::out);
if (file.fail()) {
throw file_exc_t("Could not write to file.");
blocking_write_file_stream_t file;
if (!file.init(metadata_file(file_path).c_str())) {
throw file_exc_t("Could not create file.");
}

boost::archive::text_oarchive archive(file);
archive << machine_id;
archive << semilattice;
write_message_t msg;
msg << machine_id;
msg << semilattice;

int res = send_write_message(&file, &msg);
if (res) {
throw file_exc_t("Could not write to file.");
}
}

void update(const std::string& file_path, machine_id_t machine_id, const cluster_semilattice_metadata_t &semilattice) THROWS_ONLY(file_exc_t) {
std::ofstream file(metadata_file(file_path).c_str(), std::ios_base::trunc | std::ios_base::out);
if (file.fail()) {
blocking_write_file_stream_t file;
if (!file.init(metadata_file(file_path).c_str())) {
throw file_exc_t("Could not create file.");
}
write_message_t msg;
msg << machine_id;
msg << semilattice;
int res = send_write_message(&file, &msg);
if (res) {
throw file_exc_t("Could not write to file.");
}

boost::archive::text_oarchive archive(file);
archive << machine_id;
archive << semilattice;
}

void read(const std::string& file_path, machine_id_t *machine_id_out, cluster_semilattice_metadata_t *semilattice_out) THROWS_ONLY(file_exc_t) {

std::ifstream file(metadata_file(file_path).c_str(), std::ios_base::in);
if (file.fail()) {
throw file_exc_t("Could not read from file.");
blocking_read_file_stream_t file;
if (!file.init(metadata_file(file_path).c_str())) {
throw file_exc_t("Could not open file for read.");
}

try {
boost::archive::text_iarchive archive(file);
archive >> *machine_id_out;
archive >> *semilattice_out;
} catch (boost::archive::archive_exception e) {
throw file_exc_t(std::string("File contents invalid: ") + e.what());
int res = deserialize(&file, machine_id_out);
if (!res) { deserialize(&file, semilattice_out); }
if (res) {
throw file_exc_t("File contents invalid.");
}
}

Expand Down Expand Up @@ -102,7 +102,3 @@ void semilattice_watching_persister_t::dump() {

} // namespace metadata_persistence

/* Necessary so that we can serialize `persistence_issue_t` in the form of a
`clone_ptr_t<local_issue_t>` */
BOOST_CLASS_EXPORT(metadata_persistence::persistence_issue_t)

3 changes: 0 additions & 3 deletions src/clustering/immediate_consistency/branch/metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include <map>

#include "errors.hpp"
#include <boost/serialization/map.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/variant.hpp>

Expand Down
1 change: 0 additions & 1 deletion src/clustering/reactor/directory_echo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "utils.hpp"
#include <boost/optional.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/serialization/optional.hpp>

#include "rpc/directory/view.hpp"
#include "rpc/mailbox/typed.hpp"
Expand Down
18 changes: 2 additions & 16 deletions src/concurrency/fifo_checker.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#ifndef CONCURRENCY_FIFO_CHECKER_HPP_
#define CONCURRENCY_FIFO_CHECKER_HPP_

#include "utils.hpp"
#include <boost/serialization/split_member.hpp>

#ifndef NDEBUG
#include <map>
#endif

#include "utils.hpp"


struct order_bucket_t {
order_bucket_t(int thread, int number) :
Expand Down Expand Up @@ -67,19 +66,6 @@ class order_token_t {
friend class order_sink_t;
friend class backfill_receiver_order_source_t;
friend class plain_sink_t;

/* Serialization. Since we don't have sane facilities for choosing bucket
identifiers in a cluster-safe way, we don't even try. */
friend class ::boost::serialization::access;
BOOST_SERIALIZATION_SPLIT_MEMBER();
template<class Archive>
void save(UNUSED Archive & a, UNUSED const int version) const {
// Do nothing
}
template<class Archive>
void load(UNUSED Archive & a, UNUSED const int version) {
*this = ignore;
}
};


Expand Down
6 changes: 6 additions & 0 deletions src/containers/archive/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include "errors.hpp"
#include "containers/intrusive_list.hpp"

struct fake_archive_exc_t {
const char *what() const throw() {
return "Writing to a tcp stream failed.";
}
};

class read_stream_t {
public:
read_stream_t() { }
Expand Down
Loading

0 comments on commit d09a82f

Please sign in to comment.