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

P_CacheTest.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 __P_CACHE_TEST_H__
00025 #define __P_CACHE_TEST_H__
00026 
00027 #include "P_Cache.h"
00028 #include "RegressionSM.h"
00029 
00030 #define MAX_HOSTS_POSSIBLE 256
00031 #define PINNED_DOC_TABLE_SIZE 16
00032 #define PINNED_DOC_TABLES 246
00033 
00034 struct PinnedDocEntry
00035 {
00036   CacheKey key;
00037   ink_time_t time;
00038   LINK(PinnedDocEntry, link);
00039 };
00040 
00041 struct PinnedDocTable: public Continuation
00042 {
00043   Queue<PinnedDocEntry> bucket[PINNED_DOC_TABLE_SIZE];
00044 
00045   void insert(CacheKey * key, ink_time_t time, int update);
00046   int probe(CacheKey * key);
00047   int remove(CacheKey * key);
00048   int cleanup(int event, Event * e);
00049 
00050   PinnedDocTable():Continuation(new_ProxyMutex()) {
00051     memset(bucket, 0, sizeof(Queue<PinnedDocEntry>) * PINNED_DOC_TABLE_SIZE);
00052   }
00053 };
00054 
00055 struct CacheTestHost {
00056   char *name;
00057   volatile unsigned int xlast_cachable_id;
00058   double xprev_host_prob;
00059   double xnext_host_prob;
00060 
00061   CacheTestHost():name(NULL), xlast_cachable_id(0),
00062                   xprev_host_prob(0), xnext_host_prob(0) {}
00063 };
00064 
00065 struct CacheTestHeader {
00066   uint64_t serial;
00067 };
00068 
00069 struct CacheTestSM : public RegressionSM {
00070   int start_memcpy_on_clone; // place all variables to be copied between these markers
00071   Action *timeout;
00072   Action *cache_action;
00073   ink_hrtime start_time;
00074   CacheVConnection *cache_vc;
00075   VIO *cvio;
00076   MIOBuffer *buffer;
00077   IOBufferReader *buffer_reader;
00078 #ifdef HTTP_CACHE
00079   CacheLookupHttpConfig params;
00080   CacheHTTPInfo info;
00081   char urlstr[1024];
00082 #endif
00083   int64_t total_size;
00084   int64_t nbytes;
00085   CacheKey key;
00086   int repeat_count;
00087   int expect_event;
00088   int expect_initial_event;
00089   int initial_event;
00090   uint64_t content_salt;
00091   CacheTestHeader header;
00092   int end_memcpy_on_clone; // place all variables to be copied between these markers
00093 
00094   void fill_buffer();
00095   int check_buffer();
00096   int check_result(int event);
00097   int complete(int event);
00098   int event_handler(int event, void *edata);
00099   void make_request() {
00100     start_time = ink_get_hrtime();
00101     make_request_internal();
00102   }
00103   virtual void make_request_internal() = 0;
00104   virtual int open_read_callout();
00105   virtual int open_write_callout();
00106 
00107   void cancel_timeout() {
00108     if (timeout) timeout->cancel();
00109     timeout = 0;
00110   }
00111 
00112   // RegressionSM API
00113   void run() { MUTEX_LOCK(lock, mutex, this_ethread()); timeout = eventProcessor.schedule_imm(this); }
00114   virtual RegressionSM *clone() = 0;
00115 
00116   CacheTestSM(RegressionTest *t);
00117   CacheTestSM(const CacheTestSM &ao);
00118   ~CacheTestSM();
00119 };
00120 
00121 // It is 2010 and C++ STILL doesn't have closures, a technology of the 1950s, unbelievable
00122 #define CACHE_SM(_t, _sm, _f)                \
00123   struct CacheTestSM__##_sm : public CacheTestSM { \
00124     void make_request_internal() _f \
00125     CacheTestSM__##_sm(RegressionTest *t) : CacheTestSM(t) {} \
00126     CacheTestSM__##_sm(const CacheTestSM__##_sm &xsm) : CacheTestSM(xsm) {} \
00127     RegressionSM *clone() { return new CacheTestSM__##_sm(*this); } \
00128 } _sm(_t);
00129 
00130 void force_link_CacheTest();
00131 
00132 #endif /* __P_CACHE_TEST_H__ */

Generated by  doxygen 1.7.1