LogCabin
Server/ClientService.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 
00019 #include "build/Protocol/Client.pb.h"
00020 #include "build/Protocol/Raft.pb.h"
00021 #include "Core/Debug.h"
00022 #include "Core/ProtoBuf.h"
00023 #include "RPC/ClientRPC.h"
00024 #include "Protocol/Common.h"
00025 #include "RPC/ClientSession.h"
00026 
00027 #ifndef LOGCABIN_SERVER_CLIENTSERVICE_H
00028 #define LOGCABIN_SERVER_CLIENTSERVICE_H
00029 
00030 namespace LogCabin {
00031 namespace Server {
00032 
00033 // forward declaration
00034 class Globals;
00035 class Replication;
00036 
00037 /**
00038  * This is LogCabin's application-facing RPC service. As some of these RPCs may
00039  * be long-running, this is intended to run under a RPC::ThreadDispatchService.
00040  */
00041 class ClientService : public RPC::Service {
00042   public:
00043     /// Constructor.
00044     explicit ClientService(Globals& globals);
00045 
00046     /// Destructor.
00047     ~ClientService();
00048 
00049     void handleRPC(RPC::ServerRPC rpc);
00050     std::string getName() const;
00051 
00052   private:
00053     ////////// RPC handlers //////////
00054 
00055     void getServerInfo(RPC::ServerRPC rpc);
00056     void getConfiguration(RPC::ServerRPC rpc);
00057     void setConfiguration(RPC::ServerRPC rpc);
00058     void stateMachineCommand(RPC::ServerRPC rpc);
00059     void stateMachineQuery(RPC::ServerRPC rpc);
00060     void verifyRecipient(RPC::ServerRPC rpc);
00061 
00062     /**
00063      * The LogCabin daemon's top-level objects.
00064      */
00065     Globals& globals;
00066 
00067     // ClientService is non-copyable.
00068     ClientService(const ClientService&) = delete;
00069     ClientService& operator=(const ClientService&) = delete;
00070 }; // class ClientService
00071 
00072 } // namespace LogCabin::Server
00073 } // namespace LogCabin
00074 
00075 #endif /* LOGCABIN_SERVER_CLIENTSERVICE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines