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

CongestionDB.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 /*****************************************************************************
00025  *
00026  *  CongestionDB.h - Implementation of Congestion Control
00027  *
00028  *
00029  ****************************************************************************/
00030 
00031 /*
00032  * CongestionDB is implemented in a Multithread-Safe hash table
00033  * the Data will be wrote to a disk file for recovery purpose.
00034  */
00035 #ifndef CongestionDB_H_
00036 #define CongestionDB_H_
00037 
00038 #include "P_EventSystem.h"
00039 #include "MT_hashtable.h"
00040 #include "ControlMatcher.h"
00041 
00042 
00043 class CongestionControlRecord;
00044 struct CongestionEntry;
00045 
00046 typedef MTHashTable<uint64_t, CongestionEntry *>CongestionTable;
00047 typedef HashTableIteratorState<uint64_t, CongestionEntry *>Iter;
00048 
00049 /* API to the outside world */
00050 // check whether key was congested, store the found entry into pEntry
00051 Action *get_congest_entry(Continuation * cont, HttpRequestData * data, CongestionEntry ** ppEntry);
00052 Action *get_congest_list(Continuation * cont, MIOBuffer * buffer, int format = 0);
00053 void remove_all_congested_entry(void);
00054 void remove_congested_entry(uint64_t key);
00055 void remove_congested_entry(char *buf, MIOBuffer * out_buffer);
00056 void revalidateCongestionDB();
00057 void initCongestionDB();
00058 
00059 /*
00060  * CongestRequestParam is the data structure passed to the request
00061  * to update the congestion db with the appropriate info
00062  * It is used when the TS missed a try_lock, the request info will be
00063  * stored in the CongestRequestParam and insert in the to-do list of the
00064  * approperiate DB partition.
00065  * The first operation after the TS get the lock for a partition is
00066  * to run the to do list
00067  */
00068 
00069 struct CongestRequestParam
00070 {
00071   enum Op_t
00072   {
00073     ADD_RECORD,
00074     REMOVE_RECORD,
00075     REMOVE_ALL_RECORDS,
00076     REVALIDATE_BUCKET
00077   };
00078 
00079     CongestRequestParam():m_key(0), m_op(REVALIDATE_BUCKET), m_pEntry(NULL)
00080   {
00081   }
00082 
00083    ~CongestRequestParam()
00084   {
00085   }
00086 
00087   uint64_t m_key;
00088   Op_t m_op;
00089   CongestionEntry *m_pEntry;
00090 
00091   LINK(CongestRequestParam, link);
00092 };
00093 
00094 /* struct declaration and definitions */
00095 class CongestionDB:public CongestionTable
00096 {
00097 public:
00098   CongestionDB(int tablesize);
00099    ~CongestionDB();
00100   bool congested(uint64_t key);
00101 
00102 // add an entry to the db
00103   void addRecord(uint64_t key, CongestionEntry * pEntry);
00104 // remove an entry from the db
00105   void removeRecord(uint64_t key);
00106   void removeAllRecords(void);
00107   InkAtomicList *todo_lists;
00108   void RunTodoList(int buckId);
00109   void process(int buckId, CongestRequestParam * param);
00110   void revalidateBucket(int buckId);
00111 };
00112 
00113 extern CongestionDB *theCongestionDB;
00114 
00115 #endif /* CongestionDB_H_ */

Generated by  doxygen 1.7.1