• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

LogHost.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 #ifndef LOG_HOST_H
00024 #define LOG_HOST_H
00025 
00026 class LogSock;
00027 class LogBuffer;
00028 class LogCollationClientSM;
00029 
00030 #include "LogBufferSink.h"
00031 
00032 /*-------------------------------------------------------------------------
00033   LogHost
00034   This object corresponds to a named log collation host.
00035   -------------------------------------------------------------------------*/
00036 class LogHost
00037 {
00038 
00039   friend class LogCollationClientSM;
00040 
00041 public:
00042   LogHost(const char *object_filename, uint64_t object_signature);
00043   LogHost(const LogHost &);
00044   ~LogHost();
00045 
00046   int set_name_or_ipstr(char *name_or_ipstr);
00047   int set_ipstr_port(char *ipstr, unsigned int port);
00048   int set_name_port(char *hostname, unsigned int port);
00049 
00050   bool connected(bool ping);
00051   bool connect();
00052   void disconnect();
00053   //
00054   // preprocess the given buffer data before sent to target host
00055   // and try to delete it when its reference become zero.
00056   //
00057   int preproc_and_try_delete(LogBuffer * lb);
00058 
00059   //
00060   // write the given buffer data to orhpan file and
00061   // try to delete it when its reference become zero.
00062   //
00063   void orphan_write_and_try_delete(LogBuffer * lb);
00064 
00065   char const* name() const { return m_name ? m_name : "UNKNOWN"; }
00066   IpAddr const& ip_addr() const { return m_ip; }
00067   in_port_t port() const { return m_port; }
00068   char const* ipstr() const { return m_ipstr; }
00069 
00070   void display(FILE * fd = stdout);
00071 
00072   LogFile *get_orphan_logfile() const { return m_orphan_file; }
00073   // check if we will be able to write orphan file
00074   int do_filesystem_checks() { return m_orphan_file->do_filesystem_checks(); }
00075 
00076 private:
00077   void clear();
00078   bool authenticated();
00079   void create_orphan_LogFile_object();
00080 
00081 private:
00082   char *m_object_filename;
00083   uint64_t m_object_signature;
00084   IpAddr m_ip; // IP address, network order.
00085   in_port_t m_port; // IP port, host order.
00086   ip_text_buffer m_ipstr;
00087   char *m_name;
00088   LogSock *m_sock;
00089   int m_sock_fd;
00090   bool m_connected;
00091   Ptr<LogFile> m_orphan_file;
00092   LogCollationClientSM *m_log_collation_client_sm;
00093 
00094 public:
00095   LINK(LogHost, link);
00096   SLINK(LogHost, failover_link);
00097 
00098 private:
00099   // -- member functions not allowed --
00100   LogHost();
00101   LogHost & operator=(const LogHost &);
00102 };
00103 
00104 /*-------------------------------------------------------------------------
00105   LogHostList
00106   -------------------------------------------------------------------------*/
00107 class LogHostList:public LogBufferSink
00108 {
00109 public:
00110   LogHostList();
00111   ~LogHostList();
00112 
00113   void add(LogHost * host, bool copy = true);
00114   unsigned count();
00115   void clear();
00116   int preproc_and_try_delete(LogBuffer * lb);
00117 
00118   LogHost *first() { return m_host_list.head; }
00119   LogHost *next(LogHost * here) { return (here->link).next; }
00120 
00121   void display(FILE * fd = stdout);
00122   bool operator==(LogHostList & rhs);
00123   int do_filesystem_checks();
00124 
00125 private:
00126   Queue<LogHost> m_host_list;
00127 
00128   // -- member functions not allowed --
00129   LogHostList(const LogHostList &);
00130   LogHostList & operator=(const LogHostList &);
00131 };
00132 
00133 #endif

Generated by  doxygen 1.7.1