⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tpccstruct.h

📁 oracle数据库tpcc(在线事务处理能力)测试的源码
💻 H
字号:
/***************************
tpccstruct.h
***************************/
#ifndef TPCCSTRUCT_H
#define TPCCSTRUCT_H
#include "apr_thread_mutex.h"
/******************************************************************
**********
****************************** tpccstruct.h
********************************
*******************************************************************
**********/
/*
** tpccstruct.h: This header file declares data structures for use in
** application and server
*/
/* Copyright 1996 Digital Equipment Corporation */
/*
** Author: Bill Carr
** (Majority of content from previous work by Ruth Morgenstein)
**
*
* Modification history:
*
*
* 08/01/2002 Andrew Bond, HP
* - Conversion to run under Linux and Apache
*
*/
#include <time.h>
/*
#include <sys/types.h>
*/
#define BOOLEAN int
#define BOOL int
#define VMS 0
#define LINEMAX 256
#define FALSE 0
#ifndef TRUE
#define TRUE 1
#endif
#define MAX_OL 15
#ifdef FFE_DEBUG
# define CALLING_LH 0x0001
# define IN_LH 0x0002
# define IN_RH 0x0004
# define IN_DB 0x0008
# define LEAVING_DB 0x0010
# define LEAVING_RH 0x0020
# define LEAVING_LH 0x0040
# define CALLING_RESP 0x0080
# define UNRESERVING 0x0100
# define ALL_STAGES 0x01ff
/* users * scale * hours * min * txn/no
*/
# define HISTORY_SIZE ((int)( 5000 * 1.2 * 2 * 60 * 2.22222))
# define TRANSACTION_DEBUG_INFO\
int iStage;\
int dwThreadId;\
int dwXPThreadId;\
int iSynchronous;\
int iType;\
int iReserveHistoryId;\
int iUnreserveHistoryId;\
# define INIT_TRANSACTION(type,pData)\
gpTransactionPool->iHistoryId++;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iFailure = 0;\
_ASSERT( gpTransactionPool->iNextFree <= gpTransactionPool->iMaxIndex );\
memset( pData, 0x01, gpTransactionPool->iTransactionSize );\
pData->iStage = 0;\
pData->dwThreadId = GetCurrentThreadId();\
pData->dwXPThreadId = 0;\
pData->iType = type;\
pData->iReserveHistoryId = gpTransactionPool->iHistoryId;\
pData->iUnreserveHistoryId = 0;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iOpCode = 1;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iReserveHistoryId = gpTransactionPool->iHistoryId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iUnreserveHistoryId = 0;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iType = type;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].dwThreadId = pData->dwThreadId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].dwXPThreadId = pData->dwXPThreadId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].pTrans = pData;
# define CHECK_TRANSACTION(type,pData)\
gpTransactionPool->iHistoryId++;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iFailure++;\
_ASSERT( gpTransactionPool->iNextFree > 0 );\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iFailure++;\
_ASSERT(((pData->iStage) | ALL_STAGES) == ALL_STAGES);\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iFailure++;\
if( pData->iSynchronous == 1 )\
_ASSERT((pData->dwThreadId == GetCurrentThreadId( )));\
else if( pData->iSynchronous == 0 )\
_ASSERT((pData->dwXPThreadId == GetCurrentThreadId( )));\
else\
_ASSERT(FALSE);\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iFailure++;\
_ASSERT((pData->iType==type));\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iFailure++;\
_ASSERT((gpTransactionPool->History[pData->iReserveHistoryId].pTrans) == pData);\
pData->iUnreserveHistoryId = gpTransactionPool->iHistoryId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iOpCode = 2;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iReserveHistoryId = pData->iReserveHistoryId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iUnreserveHistoryId = gpTransactionPool->iHistoryId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].iType =type;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].dwThreadId = pData->dwThreadId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].dwXPThreadId = pData->dwXPThreadId;\
gpTransactionPool->History[gpTransactionPool->iHistoryId].pTrans = pData;
#else /* FFE_DEBUG */
# define TRANSACTION_DEBUG_INFO
# define INIT_TRANSACTION(type,pData)
# define CHECK_TRANSACTION(type,pData)
#endif /* FFE_DEBUG */
# define NUMBER_POOL_TRANS_TYPES 5
# define DELIVERY_TRANS 0
# define NEW_ORDER_TRANS 1
# define ORDER_STATUS_TRANS 2
# define PAYMENT_TRANS 3
# define STOCK_LEVEL_TRANS 4
#define RESERVE_TRANSACTION_STRUCT(type,pData)\
   apr_thread_mutex_lock( gpTransactionPool->critSec );\
   pData = gpTransactionPool->index[gpTransactionPool->iNextFree];\
   INIT_TRANSACTION(type,pData);\
   gpTransactionPool->iNextFree++;\
   apr_thread_mutex_unlock( gpTransactionPool->critSec );
#define UNRESERVE_TRANSACTION_STRUCT(type,pData)\
   apr_thread_mutex_lock( gpTransactionPool->critSec );\
   CHECK_TRANSACTION(type,pData);\
   gpTransactionPool->index[--gpTransactionPool->iNextFree] = pData;\
   apr_thread_mutex_unlock( gpTransactionPool->critSec );
typedef struct
{
apr_thread_mutex_t * critSec;
int iNextFree;
#ifdef FFE_DEBUG
int iMaxIndex;
int iTransactionSize;
int iHistoryId;
struct
{
int iOpCode;
int iFailure;
int iReserveHistoryId;
int iUnreserveHistoryId;
int iType;
int dwThreadId;
int dwXPThreadId;
void *pTrans;
} History[HISTORY_SIZE];
#endif
void *index[1];
char data[1];
} TransactionPoolStruct, *pTransactionPoolStruct;
/*
** Data structures descriptions for IO data for each transaction
type
**
*/
typedef void CallersContext;
typedef void *pCallersContext;
typedef void *DBContext;
#define INVALID_DB_CONTEXT NULL
typedef struct _DBDate {
int year; /* 1900 - 2100 */
int month; /* 1 - 12 */
int day; /* 1 - 31 */
int hour; /* 0 - 23 */
int minute; /* 0 - 59 */
int second; /* 0 - 59 */
} DBDateData, *pDBDateData;
/* Data common to all transactions that represents the connection
to the UI */
/* and the database are built as a macro to reduce duplication. */
#define CONN_DATA \
TRANSACTION_DEBUG_INFO ;\
int w_id;\
int ld_id;\
CallersContext *pCC;\
int status;\
int dbstatus;
typedef struct _ConnData
{
CONN_DATA
} ConnData, *pConnData;
/* DELIVERY is built as a macro so that i_delivery struct is
consistant with */
/* the io_delivery struct. Note also that the input portion of the
delivery */
/* data can be simply memcpyed from the input to the input/output
struct. */
#define I_DELIVERY \
CONN_DATA \
time_t queue_time;\
int delta_time; /* in milliseconds*/\
struct timeval tbegin;\
struct timeval tend;\
int o_carrier_id;
typedef struct _DeliveryDataInput {
I_DELIVERY
} DeliveryDataInput, *pDeliveryDataInput;
typedef struct _DeliveryData {
I_DELIVERY /* see comment above */
int o_id[10];
} DeliveryData, *pDeliveryData;
struct io_order_line {
int ol_i_id;
int ol_supply_w_id;
int ol_quantity;
char i_name[25];
int s_quantity;
char b_g[2];
double i_price;
double ol_amount;
};
typedef struct _NewOrderData {
CONN_DATA
int d_id;
int c_id;
int o_ol_cnt;
int o_all_local;
struct io_order_line o_ol[MAX_OL];
DBDateData o_entry_d;
char c_last[17];
char c_credit[3];
double c_discount;
double w_tax;
double d_tax;
int o_id;
double tax_n_discount;
double total_amount;
} NewOrderData, *pNewOrderData;
struct status_order_line {
int ol_supply_w_id;
int ol_i_id;
int ol_quantity;
double ol_amount;
DBDateData ol_delivery_d;
};
typedef struct _OrderStatusData {
CONN_DATA
BOOLEAN byname;
int d_id;
int c_id;
char c_last[17];
char c_first[17];
char c_middle[3];
double c_balance;
int o_id;
DBDateData o_entry_d;
int o_carrier_id;
int o_ol_cnt;
struct status_order_line s_ol[MAX_OL];
} OrderStatusData, *pOrderStatusData;
typedef struct _PaymentData {
CONN_DATA
BOOLEAN byname;
int d_id;
int c_id;
char c_last[17];
int c_w_id;
int c_d_id;
double h_amount;
DBDateData h_date;
char w_street_1[21];
char w_street_2[21];
char w_city[21];
char w_state[3];
char w_zip[10];
char d_street_1[21];
char d_street_2[21];
char d_city[21];
char d_state[3];
char d_zip[10];
char c_first[17];
char c_middle[3];
char c_street_1[21];
char c_street_2[21];
char c_city[21];
char c_state[3];
char c_zip[10];
char c_phone[17];
DBDateData c_since;
char c_credit[3];
double c_credit_lim;
double c_discount;
double c_balance;
char c_data[201];
} PaymentData, *pPaymentData;
typedef struct _StockLevelData {
CONN_DATA
int threshold;
int low_stock;
} StockLevelData, *pStockLevelData;
typedef struct _CheckpointData {
CONN_DATA
int how_many;
int interval;
} CheckpointData, *pCheckpointData;
/*
** Data structure for input & output data
*/
typedef struct _TransactionData {
int type;
union {
DeliveryData delivery;
NewOrderData newOrder;
OrderStatusData orderStatus;
PaymentData payment;
StockLevelData stockLevel;
CheckpointData checkpoint;
} info;
} TransactionData, *pTransactionData;
typedef struct _TransportData {
BOOLEAN asynchronous;
BOOLEAN generic;
int num_gc;
int num_dy;
int num_no;
int num_os;
int num_pt;
int num_sl;
BOOLEAN dy_use_transport;
int num_dy_servers;
int num_queued_deliveries;
int num_queued_responses;
} TransportData, *pTransportData;
/* Data structure for passing connection information */
typedef struct _LoginData {
CONN_DATA
char szServer[32];
char szDatabase[32];
char szUser[32];
char szPassword[32];
char szApplication[32];
} LoginData, *pLoginData;
#endif /* TPCCSTRUCT_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -