📄 provisionserver.hxx
字号:
#ifndef PROVISIONSERVER_HXX_#define PROVISIONSERVER_HXX_/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const ProvisionServer_hxx_Version = "$Id: ProvisionServer.hxx,v 1.55.2.1 2003/01/23 02:49:39 sprajpat Exp $";#include <sys/time.h>#include <sys/types.h>#include <map>#include <string>#include "Tcp_ServerSocket.hxx"#include "LockedConnection.hxx"#include "RedundancyManager.hxx"#include "HouseKeepingThread.hxx"#include "VMutex.h"#include "VIoException.hxx"#include "PasswdFile.hxx"#include "AclFile.hxx"class VThreadPool;class HeartbeatTxThread;class HeartbeatRxThread;/** * Uses VPP to serve the client request to get and put data items * on the ProvisionServer. VPP is Vocal Provisioning Protocol, the * HTTP like protocol used to communicate with the provisioning server */ class ProvisionServer{ public: /// Interface to get reference to singelton object. static ProvisionServer& instance(); /// Interface to get reference to singelton object. // static ProvisionServer& instance(int nusers, int nthreads); /// Interface to get reference to singelton with redundancy static ProvisionServer& instance( int nusers, int nthreads, bool requireTls, bool useTls, const string& etcPath, const string& mcasthost = "", int mcastport = 0, const string& hostname = "", int port = 0); /// Return the name of the class string className() { return "ProvisionServer"; } /// Main process loop. Waits on connections and handles them void run(); /// Destructor ~ProvisionServer(); /// Get file system root string getRoot(); // Symbolic string aliases for common group names static string SYS_CONF; static string FEATURES; static string ACCOUNTS; static string CALLEDLIST; static string CALLINGLIST; /// Called when we see the heartbeat from the redundant server void gotBeat(); /// Called when we notice that the heartbeat is gone void lostBeat() { _copy.heartBeatGone(); } protected: /// Smart pointer to the heartbeat transmit thread Sptr < HeartbeatTxThread > _itsHeartbeatTxThread; /// Smart pointer to the heartbeat receiver thread Sptr < HeartbeatRxThread > _itsHeartbeatRxThread; /// Smart pointer to the heartbeat process/housekeeping thread Sptr < HouseKeepingThread > _itsHouseKeepingThread; /// void sendRegisterUpdate(); /// void getListOfItems(StringList& retList, string group, string name); private: static const int THREAD_DELAY; static const int FAIL_SLEEP_TIME; /** * Private constructor to build the class (public access using * the instance() operator since this is a singleton) */ ProvisionServer(int nusers, int nthreads, bool requireTls, bool useTls, const char* certPath, const char* keyPath, const char* passwdPath, const char* aclPath, const char* readSecretPath, const char* writeSecretPath); /** * Basically a big set of if's to decide how to handle an incoming * message. */ void processRequest(LockedConnection& conn) throw (VException&); /** * Frees the memory associated with singelton instance. * gets register to atexit() function at the time of creation. */ static void destroy(void); /// A thread from the pool is passed this with a conenction to service static void processRequestFunc(void* con); /// Timer function passed to a thread when we need to sync. Sync on expire static void timerFunc(void* arg); /// Timer function passed to a thread while synching. Abort on expire static void timerFailFunc(void* arg); /** * Signal handler for SIGHUP signal, causes the client list to * be reinitialized. */ static void sigHupHandler(int sigNo); /// Signal handler for SIGTERM static void sigTerm(int signo); /// Signal handler to cleanup the child static void sigChld(int signo); /// Processes the AUTH request void handleAuthRequest(LockedConnection& conn, const string userpass); /// Processes the GET request void handleGetRequest(LockedConnection& conn, const string &group, const string &item); /// Processes the PUT request void handlePutRequest(LockedConnection& conn, const string &group, const string &item); /// Handles request to return directory listing w/ content-length header void handleListRequest(LockedConnection& conn, const string &group, bool useHeader); /// Handles request to remove an item void handleRemoveRequest(LockedConnection& conn, const string& group, const string &item); /// Handles request to remove an item void handleDeleteUserRequest(LockedConnection& conn, const string& userName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -