]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@907 29311d96-e01e-0410-9327-a35deaab8ce9
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 3 Oct 2006 22:48:30 +0000 (22:48 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 3 Oct 2006 22:48:30 +0000 (22:48 +0000)
ceph/mds/MDSMap.h [new file with mode: 0644]

diff --git a/ceph/mds/MDSMap.h b/ceph/mds/MDSMap.h
new file mode 100644 (file)
index 0000000..b08a5d6
--- /dev/null
@@ -0,0 +1,90 @@
+// -*- mode:C++; tab-width:4; c-basic-offset:2; indent-tabs-mode:t -*- 
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+
+#ifndef __MDSMAP_H
+#define __MDSMAP_H
+
+#include "include/types.h"
+
+#include <string>
+#include <vector>
+using namespace std;
+
+class MDSMap {
+ protected:
+  epoch_t epoch;
+  utime_t ctime;
+
+  set<int> all_mds;
+  set<int> down_mds;
+  map<int,entity_inst_t> mds_inst;
+
+ public:
+  MDSMap() : epoch(0) {}
+
+  epoch_t get_epoch() const { return epoch; }
+  void inc_epoch() { epoch++; }
+
+  const utime_t& get_ctime() const { return ctime; }
+
+  int get_num_mds() const { 
+       return up_mds.size() + down_mds.size();
+  }
+  int get_num_up_mds() const {
+       return up_mds.size();
+  }
+
+  const set<int>& get_mds() const { return all_mds; }
+  const set<int>& get_down_mds() const { return down_mds; }
+
+  bool is_down(int m) const { return down_mds.count(m); }
+  bool is_up(int m) const { return !is_mds(m); }
+
+  bool lookup(int m, entity_inst_t& inst) { 
+       if (mds_inst.count(m)) {
+         inst = mds_inst[m];
+         return true;
+       } 
+       return false;
+  }
+
+  // serialize, unserialize
+  void encode(bufferlist& blist) {
+       blist.append((char*)&epoch, sizeof(epoch));
+       blist.append((char*)&ctime, sizeof(ctime));
+       
+       _encode(all_mds, blist);
+       _encode(down_mds, blist);
+       _encode(mds_inst, blist);
+  }
+  
+  void decode(bufferlist& blist) {
+       int off = 0;
+       blist.copy(off, sizeof(epoch), (char*)&epoch);
+       off += sizeof(epoch);
+       blist.copy(off, sizeof(ctime), (char*)&ctime);
+       off += sizeof(ctime);
+       
+       _decode(all_mds, blist, off);
+       _decode(down_mds, blist, off);
+       _decode(mds_inst, blist, off);
+  }
+
+
+  /*** mapping functions ***/
+
+  int hash_dentry( inodeno_t dirino, const string& dn );  
+};
+
+#endif