📄 provisionserver.hxx
字号:
/// Handle request to register an item for notification void handleItemRegisterRequest(const string &group, const string &item, const string &hostPortPair); /// Handle request to register a group for notification void handleGroupRegisterRequest(const string &group, const string &hostPortPair); /// Handle request to unregister an item for notification void handleItemUnregisterRequest(const string &group, const string &item, const string &hostPortPair); /// Handle request to unregister a group for notification void handleGroupUnregisterRequest(const string &group, const string &hostPortPair); /// Handles request to return timestamped directory listing for sync void handleSyncStartRequest(LockedConnection& conn); /// Processes the SYNCPUT request (put with timestamp) void handleSyncPutRequest(LockedConnection& conn, const string& group, const string &name); /// Processes the SYNCGET request (get with timestamp) void handleSyncGetRequest(LockedConnection& conn, const string& group, const string &name); /** * Process a SYNCSTAT request (can call this from GUI or * other outside location to see if we are synched) */ void handleSyncStatRequest(LockedConnection &conn); /// Handle a SYNCGOOD from other redundant server void handleSyncGoodRequest(LockedConnection& conn); /// Handle a REMOVE request void handleRemoveRequest(LockedConnection &conn, const string &arg); /// Handle a SYNCGLIST request void handleSyncGetRListRequest(LockedConnection &conn); /// Handle a SYNCPLIST request void handleSyncPutRListRequest(LockedConnection &conn); /// Handle request to register a host for notification void handleSyncRegisterItemRequest(const string &group, const string &name, const string &host); /// Handle an incoming request to add a register from another server void handleSyncRegisterGroupRequest(const string &group, const string &host); /// Handle request to unregister a host for notification void handleSyncUnregisterItemRequest(const string &group, const string &name, const string &host); /// Handle an incoming request to remove a register from another server void handleSyncUnregisterGroupRequest(const string &group, const string &host); /// Process a delete from the other server void handleSyncDelRequest(LockedConnection &conn, const string &name, const string &group); /** * Creates a VPP header, that is set out with response * based on the success or failure of the request * conLength is the length of data following the * header. */ /// Make a 200 or 400 header and return it string makeVPPHeader(int success, int contLength, TimeStamp timestamp = 0); /// Make a 400 and send on the provided connection void sendVPPFail(LockedConnection &conn); /// Make a 200 and send on the provided connection void sendVPPOk(LockedConnection &conn); /// generate a map of items/timestamps of local items for sync int getLocalMap(map < string, TimeStamp > &local); // the word "file" appears in these as a backward compatability thing... /// Reads the content of item from the data store string readFile(const string& fileName, TimeStamp *timestamp = 0) throw (VIoException&); /// Writes the contents of item on the data store, returns timestamp void writeFile(const string& fileName, const string& contents, TimeStamp *timestamp) throw (VIoException&); /// If a new server register for update, update the client list void updateClientList(); /** * Initialises the list of hosts, to which, * notification has to be sent.Gets called when * object is first created or a HUP signal is received. */ void initializeClientList() throw (VIoException&); /// void initializeFeatureServerList() throw (VIoException&); /// Create the heartbeat and other threads void startHeartbeatThreads (const string &hostname, int port, const string &mcasthost, int mcastport); /** * These two timers are used for syncing. The sync timer is * set when we see another server -- at expiry, we try to sync. * Once syncing starts, the SyncFail timer is set, and if it * expires and the sync is still going on, the sync is aborted * (timeout) */ /// Set timer, on expire, tries to sync void setSyncTimer(); /// Set timer, if expires and still synching, took too long -- abort void setSyncFailTimer(); /// Called if we start sync. Manages the entire sync process. void initiateSync(); /// Cleanup func if a sync fails (for example if one dies during sync) void failTimerHandler(); /// Parse and incoming Map item int parseMapItem(const string &input, string &group, string &name); /* Various locks */ // _clientListLock and _featureListLock not used // static pthread_mutex_t _clientListLock; // static pthread_mutex_t _featureListLock; // Use VMutex instead of pthread_mutex directly static VMutex _MutexconnectionMapLock; static VMutex _MutextimerLock; typedef map < int, LockedConnection > ConnectionMap; /// Map of int to LockedConnection, tracks the active connections ConnectionMap _connectionMap; /// pointer to the singleton instance static ProvisionServer* _instance; /// Socket to listen on TcpServerSocket _serverSocket; /// Holds the PorvisionServer port int _pServerPort; /// Pool of worker threads Sptr < VThreadPool > _threadPool; /// File system root (location of the data) string _root; /// The redundant server manages all contact with the other server RedundancyManager _copy; /// Timer to track if we are waiting for a sync timer to expire bool timerPending; /// Timer to track if we have a timeout set for sync bool failTimerPending; /// Smart pointer to the DataStore where the files reside Sptr < DataStore > _dataStore; /// Register manager to track client registrations RegisterManager _registerManager; /// Number of bins in the DataStore int _nbins; /// Number of threads in thread pool int _nthreads; /// true if TLS must be used. bool myRequireTls; /// true if TLS should be used on outgoing connections. bool myUseTls; /** location of the TLS certificate file e.g. * /usr/local/vocal/etc/cert.pem */ string myCertPath; /** location of TLS key file e.g. /usr/local/vocal/etc/key.pem */ string myKeyPath; /// password server PasswdFile myPasswdFile; /// ACL file AclFile myAclFile; /// bool myFileOkTls;};/* Local Variables: *//* c-file-style: "stroustrup" *//* indent-tabs-mode: nil *//* c-file-offsets: ((access-label . -) (inclass . ++)) *//* c-basic-offset: 4 *//* End: */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -