test/http_performance_common.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef HTTP_TEST_COMMON_H
00018 #define HTTP_TEST_COMMON_H
00019 
00020 #include "globus_xio.h"
00021 #include "globus_xio_http.h"
00022 
00023 #define PINGPONG_MAX_SIZE   1000000
00024 #define THROUGHPUT_MAX_SIZE 1000000
00025 #define START_SIZE 1000000
00026 #define TCP_BUF_SIZE 80000
00027 
00028 typedef struct
00029 {
00030     globus_byte_t *                     buffer;                 
00031     globus_size_t                       size;
00032     int                                 iterations;
00033     int                                 temp_iterations;
00034     int                                 done;
00035     globus_xio_http_version_t           version;
00036     char *                              contact;
00037     char *                              transfer_encoding;
00038     globus_xio_driver_t                 tcp_driver;
00039     globus_xio_driver_t                 http_driver;
00040     globus_xio_stack_t                  stack;
00041 }
00042 http_test_info_t;
00043 
00044 typedef struct
00045 {
00046     globus_mutex_t                      mutex;
00047     globus_cond_t                       cond;
00048 
00049     int                                 outstanding_operation;
00050 
00051     globus_xio_server_t                 server;
00052     globus_xio_handle_t                 handle;
00053 
00054     char *                              contact;
00055     globus_bool_t                       shutdown;
00056     globus_bool_t                       shutdown_done;
00057 
00058     globus_hashtable_t                  uri_handlers;
00059     http_test_info_t *                  info;
00060     globus_xio_driver_t                 http_driver;
00061 }
00062 http_test_server_t;
00063 
00064 typedef int
00065 (*pingpong_func_t)(          
00066     http_test_info_t *       info,
00067     int                      timer);
00068 
00069 typedef int
00070 (*next_size_func_t)(
00071     int                       last_size);
00072 
00073 typedef void (*globus_xio_http_request_ready_callback_t)(
00074     void *                              user_arg,
00075     globus_result_t                     result,
00076     const char *                        method,
00077     const char *                        uri,
00078     globus_xio_http_version_t           http_version,
00079     globus_hashtable_t                  headers);
00080 
00081 typedef struct _performance_s
00082 {
00083     next_size_func_t         next_size;
00084     pingpong_func_t          pingpong;
00085     char *                   name;
00086     void *                   user_arg;
00087     int                      iterations;        
00088 } performance_t;
00089 
00090 globus_result_t
00091 http_test_server_init(
00092     http_test_server_t *                server,
00093     globus_xio_driver_t                 tcp_driver,
00094     globus_xio_driver_t                 http_driver,
00095     globus_xio_stack_t                  stack);
00096 
00097 globus_result_t
00098 http_test_server_register_handler(
00099     http_test_server_t *                server,
00100     const char *                        uri,
00101     globus_xio_http_request_ready_callback_t
00102                                         ready_callback,
00103     void *                              arg);
00104 
00105 globus_result_t
00106 http_test_server_run(
00107     http_test_server_t *                server);
00108 
00109 globus_result_t
00110 http_test_server_shutdown(
00111     http_test_server_t *                server);
00112 
00113 void
00114 http_test_server_destroy(
00115     http_test_server_t *                server);
00116 
00117 globus_result_t
00118 http_test_server_respond(
00119     http_test_server_t *                server,
00120     int                                 status_code,
00121     char *                              reason_phrase,
00122     globus_xio_http_header_t *          header_array,
00123     size_t                              header_array_len);
00124 
00125 globus_result_t
00126 http_test_server_close_handle(
00127     http_test_server_t *                test_server);
00128 
00129 globus_result_t
00130 http_test_client_request(
00131     globus_xio_handle_t *               new_handle,
00132     globus_xio_driver_t                 tcp_driver,
00133     globus_xio_driver_t                 http_driver,
00134     globus_xio_stack_t                  stack,
00135     const char *                        contact,
00136     const char *                        uri,
00137     const char *                        method,
00138     globus_xio_http_version_t           http_version,
00139     globus_xio_http_header_t *          header_array,
00140     size_t                              header_array_length);
00141 
00142 int
00143 http_test_initialize(
00144     globus_xio_driver_t *               tcp_driver,
00145     globus_xio_driver_t *               http_driver,
00146     globus_xio_stack_t *                stack);
00147 
00148 globus_bool_t
00149 http_is_eof(
00150     globus_result_t                     res);
00151 
00152 void
00153 performance_init(
00154     performance_t *          perf,
00155     pingpong_func_t          pingpong,  
00156     next_size_func_t         next_size,
00157     int                      iterations,        
00158     char *                   test_name,
00159     int                      buf_size);
00160 
00161 void
00162 performance_start_slave(
00163     performance_t *          perf,
00164     http_test_info_t *       info);
00165 
00166 int
00167 performance_start_master(
00168     performance_t *          perf,
00169     http_test_info_t *       info);
00170 
00171 int
00172 throughput_next_size(
00173     int                       last_size);
00174 
00175 int
00176 pingpong_next_size(
00177     int                       last_size);
00178 
00179 int
00180 pingpong_next_size(
00181     int                       last_size);
00182 
00183 int
00184 throughput_next_size(
00185     int                       last_size);
00186 
00187 void
00188 prep_timers(
00189     performance_t *           perf,
00190     char *                    label,
00191     int                       iterations,
00192     int                       buf_size);
00193 
00194 void
00195 write_timers(
00196     char *                    label);
00197 
00198 void
00199 performance_write_timers(
00200     performance_t *           perf);
00201 
00202 #endif

Generated on 25 Nov 2015 for globus_xio by  doxygen 1.4.7