From: Sage Weil Date: Sat, 8 Aug 2015 11:23:15 +0000 (-0400) Subject: ceph-dencoder: mark PGMap with nondeterministic encoding X-Git-Tag: v9.1.0~408^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aaa5b75440f20e0ac24af9b6a9b84dfd249cec07;p=ceph.git ceph-dencoder: mark PGMap with nondeterministic encoding Signed-off-by: Sage Weil --- diff --git a/src/test/encoding/ceph_dencoder.cc b/src/test/encoding/ceph_dencoder.cc index 6c5cdfc4b145..0156f9c38560 100644 --- a/src/test/encoding/ceph_dencoder.cc +++ b/src/test/encoding/ceph_dencoder.cc @@ -26,15 +26,19 @@ #define TYPE(t) #define TYPEWITHSTRAYDATA(t) +#define TYPE_NONDETERMINISTIC(t) #define TYPE_FEATUREFUL(t) #define TYPE_FEATUREFUL_STRAYDATA(t) +#define TYPE_FEATUREFUL_NONDETERMINISTIC(t) #define TYPE_NOCOPY(t) #define MESSAGE(t) #include "types.h" #undef TYPE #undef TYPEWITHSTRAYDATA +#undef TYPE_NONDETERMINISTIC #undef TYPE_FEATUREFUL #undef TYPE_FEATUREFUL_STRAYDATA +#undef TYPE_FEATUREFUL_NONDETERMINISTIC #undef TYPE_NOCOPY #undef MESSAGE @@ -79,6 +83,7 @@ struct Dencoder { virtual void generate() = 0; virtual int num_generated() = 0; virtual string select_generated(unsigned n) = 0; + virtual bool is_deterministic() = 0; //virtual void print(ostream& out) = 0; }; @@ -88,9 +93,13 @@ protected: T* m_object; list m_list; bool stray_okay; + bool nondeterministic; public: - DencoderBase(bool stray_okay) : m_object(new T), stray_okay(stray_okay) {} + DencoderBase(bool stray_okay, bool nondeterministic) + : m_object(new T), + stray_okay(stray_okay), + nondeterministic(nondeterministic) {} ~DencoderBase() { delete m_object; } @@ -134,13 +143,17 @@ public: m_object = *p; return string(); } + + bool is_deterministic() { + return !nondeterministic; + } }; template class DencoderImplNoFeatureNoCopy : public DencoderBase { public: - DencoderImplNoFeatureNoCopy(bool stray_ok) - : DencoderBase(stray_ok) {} + DencoderImplNoFeatureNoCopy(bool stray_ok, bool nondeterministic) + : DencoderBase(stray_ok, nondeterministic) {} virtual void encode(bufferlist& out, uint64_t features) { out.clear(); this->m_object->encode(out); @@ -150,8 +163,8 @@ public: template class DencoderImplNoFeature : public DencoderImplNoFeatureNoCopy { public: - DencoderImplNoFeature(bool stray_ok) - : DencoderImplNoFeatureNoCopy(stray_ok) {} + DencoderImplNoFeature(bool stray_ok, bool nondeterministic) + : DencoderImplNoFeatureNoCopy(stray_ok, nondeterministic) {} void copy() { T *n = new T; *n = *this->m_object; @@ -168,7 +181,8 @@ public: template class DencoderImplFeatureful : public DencoderBase { public: - DencoderImplFeatureful(bool stray_ok) : DencoderBase(stray_ok) {} + DencoderImplFeatureful(bool stray_ok, bool nondeterministic) + : DencoderBase(stray_ok, nondeterministic) {} virtual void encode(bufferlist& out, uint64_t features) { out.clear(); ::encode(*(this->m_object), out, features); @@ -241,6 +255,9 @@ public: m_object = *p; return string(); } + bool is_deterministic() { + return true; + } //void print(ostream& out) { //out << m_object << std::endl; @@ -256,17 +273,21 @@ int main(int argc, const char **argv) #define T_STR(x) #x #define T_STRINGIFY(x) T_STR(x) -#define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature(false); -#define TYPEWITHSTRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature(true); -#define TYPE_FEATUREFUL(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful(false); -#define TYPE_FEATUREFUL_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful(true); -#define TYPE_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeatureNoCopy(false); +#define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature(false, false); +#define TYPEWITHSTRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature(true, false); +#define TYPE_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature(false, true); +#define TYPE_FEATUREFUL(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful(false, false); +#define TYPE_FEATUREFUL_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful(true, false); +#define TYPE_FEATUREFUL_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful(false, true); +#define TYPE_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeatureNoCopy(false, false); #define MESSAGE(t) dencoders[T_STRINGIFY(t)] = new MessageDencoderImpl; #include "types.h" #undef TYPE #undef TYPEWITHSTRAYDATA +#undef TYPE_NONDETERMINISTIC #undef TYPE_FEATUREFUL #undef TYPE_FEATUREFUL_STRAYDATA +#undef TYPE_FEATUREFUL_NONDETERMINISTIC #undef T_STR #undef T_STRINGIFY diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index d67c9de9eb2c..7838ca6b079f 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -120,7 +120,7 @@ TYPE(AuthMonitor::Incremental) #include "mon/PGMap.h" TYPE(PGMap::Incremental) -TYPE(PGMap) +TYPE_NONDETERMINISTIC(PGMap) #include "mon/MonitorDBStore.h" TYPE(MonitorDBStore::Transaction)