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

LogCollationClientSM.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 
00024 #ifndef LOG_COLLATION_CLIENT_SM_H
00025 #define LOG_COLLATION_CLIENT_SM_H
00026 
00027 //-------------------------------------------------------------------------
00028 // includes
00029 //-------------------------------------------------------------------------
00030 #include "P_HostDB.h"
00031 #include "P_Net.h"
00032 #include "LogCollationBase.h"
00033 
00034 //-------------------------------------------------------------------------
00035 // pre-declarations
00036 //-------------------------------------------------------------------------
00037 
00038 class LogBuffer;
00039 class LogHost;
00040 
00041 //-------------------------------------------------------------------------
00042 // LogCollationClientSM
00043 //-------------------------------------------------------------------------
00044 
00045 class LogCollationClientSM:public LogCollationBase, public Continuation
00046 {
00047 
00048 public:
00049 
00050   LogCollationClientSM(LogHost * log_host);
00051   ~LogCollationClientSM();
00052 
00053   int client_handler(int event, void *data);
00054 
00055   // public interface (for LogFile)
00056   int send(LogBuffer * log_buffer);
00057 
00058 private:
00059 
00060   enum ClientState
00061   {
00062     LOG_COLL_CLIENT_AUTH,
00063     LOG_COLL_CLIENT_DNS,
00064     LOG_COLL_CLIENT_DONE,
00065     LOG_COLL_CLIENT_FAIL,
00066     LOG_COLL_CLIENT_IDLE,
00067     LOG_COLL_CLIENT_INIT,
00068     LOG_COLL_CLIENT_OPEN,
00069     LOG_COLL_CLIENT_SEND
00070   };
00071 
00072   enum ClientFlowControl
00073   {
00074     LOG_COLL_FLOW_ALLOW,
00075     LOG_COLL_FLOW_DENY
00076   };
00077 
00078 private:
00079 
00080   // client states
00081   int client_auth(int event, VIO * vio);
00082   int client_dns(int event, HostDBInfo * hostdb_info);
00083   int client_done(int event, void *data);
00084   int client_fail(int event, void *data);
00085   int client_idle(int event, void *data);
00086   int client_init(int event, void *data);
00087   int client_open(int event, NetVConnection * net_vc);
00088   int client_send(int event, VIO * vio);
00089   ClientState m_client_state;
00090 
00091   // support functions
00092   void flush_to_orphan();
00093 
00094   // iocore stuff (two buffers to avoid races)
00095   NetVConnection *m_host_vc;
00096   VIO *m_host_vio;
00097   MIOBuffer *m_auth_buffer;
00098   IOBufferReader *m_auth_reader;
00099   MIOBuffer *m_send_buffer;
00100   IOBufferReader *m_send_reader;
00101   Action *m_pending_action;
00102   Event *m_pending_event;
00103 
00104   // to detect server closes (there's got to be a better way to do this)
00105   VIO *m_abort_vio;
00106   MIOBuffer *m_abort_buffer;
00107   bool m_host_is_up;
00108 
00109   // send stuff
00110   LogBufferList *m_buffer_send_list;
00111   LogBuffer *m_buffer_in_iocore;
00112   ClientFlowControl m_flow;
00113 
00114   // back pointer to LogHost container
00115   LogHost *m_log_host;
00116 
00117   // debugging
00118   static int ID;
00119   int m_id;
00120 
00121 };
00122 
00123 typedef int (LogCollationClientSM::*LogCollationClientSMHandler) (int, void *);
00124 
00125 #endif // LOG_COLLATION_CLIENT_SM_H

Generated by  doxygen 1.7.1