cfuse_CXXFLAGS = ${AM_CXXFLAGS}
bin_PROGRAMS += cfuse
-#if WITH_DEBUG
-#fakefuse_SOURCES = fakefuse.cc msg/FakeMessenger.cc client/fuse.cc client/fuse_ll.cc
-#fakefuse_LDADD = -lfuse libmon.a libmds.a libosd.a libos.a \
-# libclient.a libosdc.a libcrush.a
-#bin_PROGRAMS += fakefuse
-#endif
-
endif
# tcmalloc?
test_trans_LDADD = libos.a libcommon.a -lpthread -lm $(CRYPTOPP_LIBS)
bin_PROGRAMS += test_trans
-
-#fakesyn_SOURCES = fakesyn.cc msg/FakeMessenger.cc
-#fakesyn_LDADD = libmon.a libmds.a libosd.a libos.a \
-# libclient.a libosdc.a libcrush.a libcommon.a
-#bin_PROGRAMS += fakesyn
-
endif
mount/canonicalize.c\
mount/mtab.c\
msg/Dispatcher.h\
- msg/FakeMessenger.h\
msg/Message.h\
msg/Messenger.h\
msg/SimpleMessenger.h\
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * 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.
- *
- */
-
-
-
-#include <sys/stat.h>
-#include <iostream>
-#include <string>
-using namespace std;
-
-#include "config.h"
-
-#include "mon/Monitor.h"
-#include "mon/MonitorStore.h"
-#include "mds/MDS.h"
-#include "osd/OSD.h"
-#include "client/Client.h"
-#include "client/fuse.h"
-#include "client/fuse_ll.h"
-
-#include "common/Timer.h"
-#include "common/common_init.h"
-
-#include "msg/FakeMessenger.h"
-#include "messages/MMonCommand.h"
-
-
-
-
-#define NUMMDS g_conf.num_mds
-#define NUMOSD g_conf.num_osd
-#define NUMCLIENT g_conf.num_client
-
-
-class C_Test : public Context {
-public:
- void finish(int r) {
- cout << "C_Test->finish(" << r << ")" << std::endl;
- }
-};
-class C_Test2 : public Context {
-public:
- void finish(int r) {
- cout << "C_Test2->finish(" << r << ")" << std::endl;
- //g_timer.add_event_after(2, new C_Test);
- }
-};
-
-
-
-int main(int argc, const char **argv) {
- cerr << "fakefuse starting" << std::endl;
-
- // stop on our own (by default)
- g_conf.mon_stop_on_last_unmount = true;
- g_conf.mon_stop_with_last_mds = true;
-
- vector<const char*> args;
- argv_to_vec(argc, argv, args);
- env_to_vec(args);
-
- common_set_defaults(false);
- common_init(args, "fakefuse", false);
- set_foreground_logging();
-
- // start messenger thread
- fakemessenger_startthread();
-
- //g_timer.add_event_after(5.0, new C_Test2);
- //g_timer.add_event_after(10.0, new C_Test);
-
- vector<const char*> nargs;
- for (unsigned i=0; i<args.size(); i++) {
- nargs.push_back(args[i]);
- }
- args = nargs;
- vec_to_argv(args, argc, argv);
-
- // FUSE will chdir("/"); be ready.
- g_conf.use_abspaths = true;
-
- MonMap *monmap = new MonMap(g_conf.num_mon);
- entity_addr_t a;
- a.nonce = getpid();
- for (int i=0; i<g_conf.num_mon; i++) {
- a.erank = i;
- monmap->mon_inst[i] = entity_inst_t(entity_name_t::MON(i), a); // hack ; see FakeMessenger.cc
- }
-
- Monitor *mon[g_conf.num_mon];
- for (int i=0; i<g_conf.num_mon; i++) {
- char fn[100];
- snprintf(fn, sizeof(fn), "mondata/mon%d", i);
- MonitorStore *store = new MonitorStore(fn);
- mon[i] = new Monitor(i, store, new FakeMessenger(entity_name_t::MON(i)), monmap);
- mon[i]->mkfs();
- }
-
- // create osd
- OSD *osd[NUMOSD];
- for (int i=0; i<NUMOSD; i++) {
- osd[i] = new OSD(i, new FakeMessenger(entity_name_t::OSD(i)), monmap);
- }
-
- // create mds
- MDS *mds[NUMMDS];
- for (int i=0; i<NUMMDS; i++) {
- mds[i] = new MDS(i, new FakeMessenger(entity_name_t::MDS(i)), monmap);
- }
-
- // init
- for (int i=0; i<g_conf.num_mon; i++)
- mon[i]->init();
-
- // build initial osd map
- {
- OSDMap map;
- map.build_simple(0, monmap->fsid, g_conf.num_osd, 0, g_conf.osd_pg_bits, g_conf.osd_lpg_bits, 0);
- bufferlist bl;
- map.encode(bl);
- Messenger *messenger = new FakeMessenger(entity_name_t::ADMIN(-1));
- MMonCommand *m = new MMonCommand(monmap->fsid);
- m->set_data(bl);
- m->cmd.push_back("osd");
- m->cmd.push_back("setmap");
- messenger->send_message(m, monmap->get_inst(0));
- messenger->shutdown();
- }
-
- for (int i=0; i<NUMOSD; i++)
- osd[i]->init();
- for (int i=0; i<NUMMDS; i++)
- mds[i]->init();
-
- // create client
- Client *client[NUMCLIENT];
- for (int i=0; i<NUMCLIENT; i++) {
- client[i] = new Client(new FakeMessenger(entity_name_t::CLIENT(0)), monmap);
- client[i]->init();
-
-
- // start up fuse
- // use my argc, argv (make sure you pass a mount point!)
- client[i]->mount();
-
- char oldcwd[200];
- getcwd(oldcwd, 200);
- cout << "starting fuse on pid " << getpid() << std::endl;
- if (g_conf.fuse_ll)
- ceph_fuse_ll_main(client[i], argc, argv);
- else
- ceph_fuse_main(client[i], argc, argv);
- cout << "fuse finished on pid " << getpid() << std::endl;
- ::chdir(oldcwd); // return to previous wd
-
- client[i]->unmount();
- client[i]->shutdown();
- }
-
-
-
- // wait for it to finish
- cout << "DONE -----" << std::endl;
- fakemessenger_wait(); // blocks until messenger stops
-
-
- // cleanup
- for (int i=0; i<NUMMDS; i++) {
- delete mds[i];
- }
- for (int i=0; i<NUMOSD; i++) {
- delete osd[i];
- }
- for (int i=0; i<NUMCLIENT; i++) {
- delete client[i];
- }
-
- return 0;
-}
-
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * 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.
- *
- */
-
-
-
-#include <sys/stat.h>
-#include <iostream>
-#include <string>
-using namespace std;
-
-#include "config.h"
-
-#include "mds/MDS.h"
-#include "osd/OSD.h"
-#include "mon/Monitor.h"
-#include "mon/MonitorStore.h"
-#include "client/Client.h"
-
-#include "client/SyntheticClient.h"
-
-#include "msg/FakeMessenger.h"
-#include "messages/MMonCommand.h"
-
-#include "common/Timer.h"
-#include "common/common_init.h"
-
-
-class C_Test : public Context {
-public:
- void finish(int r) {
- cout << "C_Test->finish(" << r << ")" << std::endl;
- }
-};
-
-class C_Die : public Context {
-public:
- void finish(int) {
- cerr << "die" << std::endl;
- exit(1);
- }
-};
-
-
-int main(int argc, const char **argv)
-{
- cerr << "fakesyn start" << std::endl;
-
- //cerr << "inode_t " << sizeof(inode_t) << std::endl;
-
- vector<const char*> args;
- argv_to_vec(argc, argv, args);
- env_to_vec(args);
-
- // stop on our own (by default)
- g_conf.mon_stop_on_last_unmount = true;
- g_conf.mon_stop_with_last_mds = true;
-
- common_set_defaults(false);
- common_init(args, "fakesyn");
- set_foreground_logging();
-
- int start = 0;
-
- parse_syn_options(args);
-
- vector<const char*> nargs;
-
- for (unsigned i=0; i<args.size(); i++) {
- // unknown arg, pass it on.
- cerr << " stray arg " << args[i] << std::endl;
- nargs.push_back(args[i]);
- }
- assert(nargs.empty());
-
-
- //if (g_conf.kill_after)
- //g_timer.add_event_after(g_conf.kill_after, new C_Die);
-
-
- MonMap *monmap = new MonMap(g_conf.num_mon);
- entity_addr_t a;
- a.nonce = getpid();
- for (int i=0; i<g_conf.num_mon; i++) {
- a.erank = i;
- monmap->mon_inst[i] = entity_inst_t(entity_name_t::MON(i), a); // hack ; see FakeMessenger.cc
- }
-
- char hostname[100];
- gethostname(hostname,100);
- //int pid = getpid();
-
- // create mon
- Monitor *mon[g_conf.num_mon];
- for (int i=0; i<g_conf.num_mon; i++) {
- char fn[100];
- snprintf(fn, sizeof(fn), "mondata/mon%d", i);
- MonitorStore *store = new MonitorStore(fn);
- mon[i] = new Monitor(i, store, new FakeMessenger(entity_name_t::MON(i)), monmap);
- mon[i]->mkfs();
- }
-
- // create mds
- MDS *mds[g_conf.num_mds];
- OSD *mdsosd[g_conf.num_mds];
- for (int i=0; i<g_conf.num_mds; i++) {
- //cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << std::endl;
- mds[i] = new MDS(-1, new FakeMessenger(entity_name_t::MDS(i)), monmap);
- if (g_conf.mds_local_osd)
- mdsosd[i] = new OSD(i+g_conf.num_osd, new FakeMessenger(entity_name_t::OSD(i+g_conf.num_osd)), monmap);
- start++;
- }
-
- // build initial osd map
- {
- OSDMap map;
- map.build_simple(0, monmap->fsid, g_conf.num_osd, 0,
- g_conf.osd_pg_bits, g_conf.osd_lpg_bits, 0);
- bufferlist bl;
- map.encode(bl);
- Messenger *messenger = new FakeMessenger(entity_name_t::ADMIN(-1));
- MMonCommand *m = new MMonCommand(monmap->fsid);
- m->set_data(bl);
- m->cmd.push_back("osd");
- m->cmd.push_back("setmap");
- messenger->send_message(m, monmap->get_inst(0));
- messenger->shutdown();
- }
-
- // create osd
- OSD *osd[g_conf.num_osd];
- for (int i=0; i<g_conf.num_osd; i++) {
- //cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << std::endl;
- osd[i] = new OSD(i, new FakeMessenger(entity_name_t::OSD(i)), monmap);
- start++;
- }
-
-
- // start message loop
- fakemessenger_startthread();
-
- // init
- for (int i=0; i<g_conf.num_mon; i++) {
- mon[i]->init();
- }
- for (int i=0; i<g_conf.num_osd; i++) {
- osd[i]->init();
- }
- for (int i=0; i<g_conf.num_mds; i++) {
- mds[i]->init();
- if (g_conf.mds_local_osd)
- mdsosd[i]->init();
- }
-
-
- // create client(s)
- Client *client[g_conf.num_client];
- SyntheticClient *syn[g_conf.num_client];
- for (int i=0; i<g_conf.num_client; i++) {
- //cout << "starting synthetic client " << std::endl;
- client[i] = new Client(new FakeMessenger(entity_name_t::CLIENT(i)), monmap);
- syn[i] = new SyntheticClient(client[i]);
- syn[i]->start_thread();
- start++;
- }
-
-
- for (int i=0; i<g_conf.num_client; i++) {
- cout << "waiting for synthetic client " << i << " to finish" << std::endl;
- syn[i]->join_thread();
- delete syn[i];
- }
-
-
- // wait for it to finish
- fakemessenger_wait();
-
- // cleanup
- for (int i=0; i<g_conf.num_mon; i++) {
- delete mon[i];
- }
- for (int i=0; i<g_conf.num_mds; i++) {
- delete mds[i];
- }
- for (int i=0; i<g_conf.num_osd; i++) {
- delete osd[i];
- }
- for (int i=0; i<g_conf.num_client; i++) {
- delete client[i];
- }
-
- cout << "fakesyn done" << std::endl;
- return 0;
-}
-
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * 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.
- *
- */
-
-
-
-#include "Message.h"
-#include "FakeMessenger.h"
-#include "mds/MDS.h"
-
-#include "common/Timer.h"
-
-#include "common/LogType.h"
-#include "common/Logger.h"
-
-#include "config.h"
-
-#define DOUT_SUBSYS ms
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <map>
-#include <iostream>
-
-using namespace std;
-
-#include <ext/hash_map>
-using namespace __gnu_cxx;
-
-
-#include "common/Cond.h"
-#include "common/Mutex.h"
-#include <pthread.h>
-
-
-// global queue.
-
-int num_entity;
-vector<FakeMessenger*> directory;
-
-hash_map<int, Logger*> loggers;
-LogType fakemsg_logtype;
-
-set<entity_addr_t> shutdown_set;
-
-Mutex lock("FakeMessenger.cc lock");
-Cond cond;
-
-bool awake = false;
-bool fm_shutdown = false;
-pthread_t thread_id;
-
-// fake osd failures: osd -> time
-static std::map<entity_name_t,float> g_fake_kill_after;
-
-utime_t start_time;
-map<utime_t,entity_name_t> fail_queue;
-list<Message*> sent_to_failed_queue;
-
-void *fakemessenger_thread(void *ptr)
-{
- start_time = g_clock.now();
-
- lock.Lock();
- while (1) {
- if (fm_shutdown) break;
- fakemessenger_do_loop_2();
-
- if (num_entity == 0 && directory.size() > 0) break;
-
- dout(20) << "thread waiting" << dendl;
- if (fm_shutdown) break;
- awake = false;
- cond.Wait(lock);
- awake = true;
- dout(20) << "thread woke up" << dendl;
- }
- lock.Unlock();
-
- dout(1) << "thread finish (i woke up but no messages, bye)" << dendl;
- return 0;
-}
-
-
-void fakemessenger_startthread() {
- pthread_create(&thread_id, NULL, fakemessenger_thread, 0);
-}
-
-void fakemessenger_stopthread() {
- dout(0) << "fakemessenger_stopthread setting stop flag" << dendl;
- lock.Lock();
- fm_shutdown = true;
- lock.Unlock();
- cond.Signal();
-
- fakemessenger_wait();
-}
-
-void fakemessenger_wait()
-{
- dout(0) << "fakemessenger_wait waiting" << dendl;
- void *ptr;
- pthread_join(thread_id, &ptr);
-}
-
-
-// fake failure
-
-
-
-// lame main looper
-
-int fakemessenger_do_loop()
-{
- lock.Lock();
- fakemessenger_do_loop_2();
- lock.Unlock();
-
- return 0;
-}
-
-
-int fakemessenger_do_loop_2()
-{
- //lock.Lock();
- dout(18) << "do_loop begin." << dendl;
-
- while (1) {
- bool didone = false;
-
- dout(18) << "do_loop top" << dendl;
-
- // fail_queue
- while (!fail_queue.empty() &&
- fail_queue.begin()->first < g_clock.now()) {
- entity_name_t nm = fail_queue.begin()->second;
- fail_queue.erase(fail_queue.begin());
-
- dout(0) << "MUST FAKE KILL " << nm << dendl;
-
- for (unsigned i=0; i<directory.size(); i++) {
- if (directory[i] && directory[i]->get_myname() == nm) {
- dout(0) << "FAKING FAILURE of " << nm << " at " << directory[i]->get_myaddr() << dendl;
- directory[i]->failed = true;
- directory[i] = 0;
- num_entity--;
- break;
- }
- }
- }
-
- list<Message*> ls;
- ls.swap(sent_to_failed_queue);
- for (list<Message*>::iterator p = ls.begin();
- p != ls.end();
- ++p) {
- Message *m = *p;
- FakeMessenger *mgr = 0;
- Dispatcher *dis = 0;
-
- unsigned drank = m->get_source_addr().erank;
- if (drank < directory.size() && directory[drank]) {
- mgr = directory[drank];
- if (mgr)
- dis = mgr->get_dispatcher();
- }
- if (dis) {
- dout(1) << "fail on " << *m
- << " to " << m->get_dest() << " from " << m->get_source()
- << ", passing back to sender." << dendl;
- dis->ms_handle_failure(m, m->get_dest_inst());
- } else {
- dout(1) << "fail on " << *m
- << " to " << m->get_dest() << " from " << m->get_source()
- << ", sender gone, dropping." << dendl;
- delete m;
- }
- }
-
- // messages
- for (unsigned i=0; i<directory.size(); i++) {
- FakeMessenger *mgr = directory[i];
- if (!mgr) continue;
-
- dout(18) << "messenger " << mgr << " at " << mgr->get_myname() << " has " << mgr->num_incoming() << " queued" << dendl;
-
- if (!mgr->is_ready()) {
- dout(18) << "messenger " << mgr << " at " << mgr->get_myname() << " has no dispatcher, skipping" << dendl;
- continue;
- }
-
- Message *m = mgr->get_message();
-
- if (m) {
- //dout(18) << "got " << m << dendl;
- dout(1) << "==== " << m->get_dest()
- << " <- " << m->get_source()
- << " ==== " << *m
- << " ---- " << m
- << dendl;
-
- if (g_conf.fakemessenger_serialize) {
- // encode
- if (m->empty_payload())
- m->encode_payload();
- ceph_msg_header head = m->get_header();
- ceph_msg_footer foot = m->get_footer();
- bufferlist front;
- front.claim( m->get_payload() );
- bufferlist data;
- data.claim( m->get_data() );
- //bl.c_str(); // condense into 1 buffer
-
- delete m;
-
- // decode
- m = decode_message(head, foot, front, data);
- assert(m);
- }
-
- m->set_recv_stamp(g_clock.now());
-
- didone = true;
-
- lock.Unlock();
- mgr->dispatch(m);
- lock.Lock();
- }
- }
-
- // deal with shutdowns.. delayed to avoid concurrent directory modification
- if (!shutdown_set.empty()) {
- for (set<entity_addr_t>::iterator it = shutdown_set.begin();
- it != shutdown_set.end();
- it++) {
- dout(7) << "fakemessenger: removing " << *it << " from directory" << dendl;
- int r = it->erank;
- assert(directory[r]);
- directory[r] = 0;
- num_entity--;
- if (num_entity == 0) {
- dout(1) << "fakemessenger: last shutdown" << dendl;
- ::fm_shutdown = true;
- }
- }
- shutdown_set.clear();
- }
-
- if (!didone)
- break;
- }
-
-
- dout(18) << "do_loop end (no more messages)." << dendl;
- //lock.Unlock();
- return 0;
-}
-
-
-FakeMessenger::FakeMessenger(entity_name_t me) : Messenger(me)
-{
- failed = false;
-
- lock.Lock();
- {
- // assign rank
- unsigned r = directory.size();
- _myinst.name = me;
- _myinst.addr.set_port(0);
- _myinst.addr.erank = r;
- _myinst.addr.nonce = getpid();
-
- // add to directory
- directory.push_back(this);
- assert(directory.size() == r+1);
-
- num_entity++;
-
- // put myself in the fail queue?
- if (g_fake_kill_after.count(me)) {
- utime_t w = start_time;
- w += g_fake_kill_after[me];
- dout(0) << "will fake failure of " << me << " at " << w << dendl;
- fail_queue[w] = me;
- }
- }
- lock.Unlock();
-
-
- dout(0) << "fakemessenger " << get_myname() << " messenger is " << this
- << " at " << get_myaddr() << dendl;
-
- qlen = 0;
-
- /*
- string name;
- name = "m.";
- name += MSG_ADDR_TYPE(myaddr);
- int w = MSG_ADDR_NUM(myaddr);
- if (w >= 1000) name += ('0' + ((w/1000)%10));
- if (w >= 100) name += ('0' + ((w/100)%10));
- if (w >= 10) name += ('0' + ((w/10)%10));
- name += ('0' + ((w/1)%10));
-
- loggers[ myaddr ] = new Logger(name, (LogType*)&fakemsg_logtype);
- */
-}
-
-FakeMessenger::~FakeMessenger()
-{
- // hose any undelivered messages
- for (list<Message*>::iterator p = incoming.begin();
- p != incoming.end();
- ++p)
- delete *p;
-}
-
-
-int FakeMessenger::shutdown()
-{
- dout(2) << "shutdown on messenger " << this << " has " << num_incoming() << " queued" << dendl;
- lock.Lock();
- assert(directory[_myinst.addr.erank] == this);
- shutdown_set.insert(_myinst.addr);
-
- /*
- if (loggers[myaddr]) {
- delete loggers[myaddr];
- loggers.erase(myaddr);
- }
- */
-
- lock.Unlock();
- return 0;
-}
-
-
-void FakeMessenger::reset_myname(entity_name_t m)
-{
- dout(1) << "reset_myname from " << get_myname() << " to " << m << dendl;
- _myinst.name = m;
-
- // put myself in the fail queue?
- if (g_fake_kill_after.count(m)) {
- utime_t w = start_time;
- w += g_fake_kill_after[m];
- dout(0) << "will fake failure of " << m << " at " << w << dendl;
- fail_queue[w] = m;
- }
-
-}
-
-
-int FakeMessenger::send_message(Message *m, entity_inst_t inst)
-{
- m->set_source_inst(_myinst);
- m->set_orig_source_inst(_myinst);
- m->set_dest_inst(inst);
- return submit_message(m, inst);
-}
-
-int FakeMessenger::forward_message(Message *m, entity_inst_t inst)
-{
- m->set_source_inst(_myinst);
- m->set_dest_inst(inst);
- return submit_message(m, inst);
-}
-
-int FakeMessenger::submit_message(Message *m, entity_inst_t inst)
-{
- entity_name_t dest = inst.name;
-
- lock.Lock();
-
-#ifdef LOG_MESSAGES
- // stats
- loggers[get_myaddr()]->inc("+send",1);
- loggers[dest]->inc("-recv",1);
-
- char s[20];
- snprintf(s, sizeof(s), "+%s", m->get_type_name());
- loggers[get_myaddr()]->inc(s);
- snprintf(s, sizeof(s), ,"-%s", m->get_type_name());
- loggers[dest]->inc(s);
-#endif
-
- // queue
- unsigned drank = inst.addr.erank;
- if (drank < directory.size() && directory[drank] &&
- shutdown_set.count(inst.addr) == 0) {
- dout(1) << "--> " << get_myname() << " -> " << inst.name << " --- " << *m << " -- " << m
- << dendl;
- directory[drank]->queue_incoming(m);
- } else {
- dout(0) << "--> " << get_myname() << " -> " << inst.name << " " << *m << " -- " << m
- << " *** destination " << inst.addr << " DNE ***"
- << dendl;
-
- // do the failure callback
- sent_to_failed_queue.push_back(m);
- }
-
- // wake up loop?
- if (!awake) {
- dout(10) << "waking up fakemessenger thread" << dendl;
- cond.Signal();
- lock.Unlock();
- } else
- lock.Unlock();
-
- return 0;
-}
-
-
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * 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 CEPH_FAKEMESSENGER_H
-#define CEPH_FAKEMESSENGER_H
-
-#include "Messenger.h"
-#include "Dispatcher.h"
-
-#include <list>
-#include <map>
-
-class Timer;
-
-class FakeMessenger : public Messenger {
- protected:
- class Logger *logger;
-
- int qlen;
- list<Message*> incoming; // incoming queue
-
- public:
- bool failed;
-
- FakeMessenger(entity_name_t me);
- ~FakeMessenger();
-
- virtual int shutdown();
-
- void reset_myname(entity_name_t m);
-
- // msg interface
- int send_message(Message *m, entity_inst_t dest);
- int forward_message(Message *m, entity_inst_t dest);
- int submit_message(Message *m, entity_inst_t dest);
-
- int get_dispatch_queue_len() { return qlen; }
-
- // -- incoming queue --
- // (that nothing uses)
- Message *get_message() {
- if (!incoming.empty()) {
- Message *m = incoming.front();
- incoming.pop_front();
- qlen--;
- return m;
- }
- return NULL;
- }
- bool queue_incoming(Message *m) {
- incoming.push_back(m);
- qlen++;
- return true;
- }
- int num_incoming() {
- //return incoming.size();
- return qlen;
- }
-
- void suicide() {
- if (!failed) {
- failed = true;
- }
- shutdown();
- }
-
-};
-
-int fakemessenger_do_loop();
-int fakemessenger_do_loop_2();
-void fakemessenger_startthread();
-void fakemessenger_stopthread();
-void fakemessenger_wait();
-
-#endif