LogCabin
Server/RaftService.h
Go to the documentation of this file.
00001 /* Copyright (c) 2012 Stanford University
00002  *
00003  * Permission to use, copy, modify, and distribute this software for any
00004  * purpose with or without fee is hereby granted, provided that the above
00005  * copyright notice and this permission notice appear in all copies.
00006  *
00007  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
00008  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00009  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR
00010  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00011  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00012  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00013  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00014  */
00015 
00016 #include "RPC/Service.h"
00017 
00018 #ifndef LOGCABIN_SERVER_RAFTSERVICE_H
00019 #define LOGCABIN_SERVER_RAFTSERVICE_H
00020 
00021 namespace LogCabin {
00022 namespace Server {
00023 
00024 // forward declaration
00025 class Globals;
00026 
00027 // TODO(ongaro): doc
00028 class RaftService : public RPC::Service {
00029   public:
00030     /// Constructor.
00031     explicit RaftService(Globals& globals);
00032 
00033     /// Destructor.
00034     ~RaftService();
00035 
00036     void handleRPC(RPC::ServerRPC rpc);
00037     std::string getName() const;
00038 
00039   private:
00040 
00041     ////////// RPC handlers //////////
00042 
00043     void requestVote(RPC::ServerRPC rpc);
00044     void appendEntries(RPC::ServerRPC rpc);
00045     void installSnapshot(RPC::ServerRPC rpc);
00046 
00047     /**
00048      * The LogCabin daemon's top-level objects.
00049      */
00050     Globals& globals;
00051 
00052   public:
00053 
00054     // RaftService is non-copyable.
00055     RaftService(const RaftService&) = delete;
00056     RaftService& operator=(const RaftService&) = delete;
00057 }; // class RaftService
00058 
00059 } // namespace LogCabin::Server
00060 } // namespace LogCabin
00061 
00062 #endif /* LOGCABIN_SERVER_RAFTSERVICE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines