X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fcommon%2FCommandTable.h;fp=src%2Fceph%2Fsrc%2Fcommon%2FCommandTable.h;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=e952ebe2f27895ebef745056b44a1056e4d89f9f;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/common/CommandTable.h b/src/ceph/src/common/CommandTable.h deleted file mode 100644 index e952ebe..0000000 --- a/src/ceph/src/common/CommandTable.h +++ /dev/null @@ -1,103 +0,0 @@ -// -*- 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) 2016 Red Hat Inc - * - * 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 COMMAND_TABLE_H_ -#define COMMAND_TABLE_H_ - -#include "messages/MCommand.h" - -class CommandOp -{ - public: - ConnectionRef con; - ceph_tid_t tid; - - std::vector cmd; - bufferlist inbl; - Context *on_finish; - bufferlist *outbl; - std::string *outs; - - MCommand *get_message(const uuid_d &fsid) const - { - MCommand *m = new MCommand(fsid); - m->cmd = cmd; - m->set_data(inbl); - m->set_tid(tid); - - return m; - } - - CommandOp(const ceph_tid_t t) : tid(t), on_finish(nullptr), - outbl(nullptr), outs(nullptr) {} - CommandOp() : tid(0), on_finish(nullptr), outbl(nullptr), outs(nullptr) {} -}; - -/** - * Hold client-side state for a collection of in-flight commands - * to a remote service. - */ -template -class CommandTable -{ -protected: - ceph_tid_t last_tid; - std::map commands; - -public: - - CommandTable() - : last_tid(0) - {} - - ~CommandTable() - { - assert(commands.empty()); - } - - T& start_command() - { - ceph_tid_t tid = last_tid++; - commands.insert(std::make_pair(tid, T(tid)) ); - - return commands.at(tid); - } - - const std::map &get_commands() const - { - return commands; - } - - bool exists(ceph_tid_t tid) const - { - return commands.count(tid) > 0; - } - - T& get_command(ceph_tid_t tid) - { - return commands.at(tid); - } - - void erase(ceph_tid_t tid) - { - commands.erase(tid); - } - - void clear() { - commands.clear(); - } -}; - -#endif -