2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
19 #ifndef _THRIFT_TEST_EVENTLOG_H_
20 #define _THRIFT_TEST_EVENTLOG_H_ 1
22 #include <thrift/concurrency/Monitor.h>
28 // Initially I made EventType an enum, but using char* results
29 // in much more readable error messages when there is a mismatch.
30 // It also lets users of EventLog easily define their own new types.
31 // Comparing the literal pointer values should be safe, barring any strange
32 // linking setup that results in duplicate symbols.
33 typedef const char* EventType
;
36 Event(EventType type
, uint32_t connectionId
, uint32_t callId
, const std::string
& message
)
37 : type(type
), connectionId(connectionId
), callId(callId
), message(message
) {}
40 uint32_t connectionId
;
47 static EventType ET_LOG_END
;
48 static EventType ET_CONN_CREATED
;
49 static EventType ET_CONN_DESTROYED
;
50 static EventType ET_CALL_STARTED
;
51 static EventType ET_CALL_FINISHED
;
52 static EventType ET_PROCESS
;
53 static EventType ET_PRE_READ
;
54 static EventType ET_POST_READ
;
55 static EventType ET_PRE_WRITE
;
56 static EventType ET_POST_WRITE
;
57 static EventType ET_ASYNC_COMPLETE
;
58 static EventType ET_HANDLER_ERROR
;
60 static EventType ET_CALL_INCREMENT_GENERATION
;
61 static EventType ET_CALL_GET_GENERATION
;
62 static EventType ET_CALL_ADD_STRING
;
63 static EventType ET_CALL_GET_STRINGS
;
64 static EventType ET_CALL_GET_DATA_WAIT
;
65 static EventType ET_CALL_ONEWAY_WAIT
;
66 static EventType ET_CALL_UNEXPECTED_EXCEPTION_WAIT
;
67 static EventType ET_CALL_EXCEPTION_WAIT
;
68 static EventType ET_WAIT_RETURN
;
69 static EventType ET_CALL_SET_VALUE
;
70 static EventType ET_CALL_GET_VALUE
;
74 void append(EventType type
,
75 uint32_t connectionId
,
77 const std::string
& message
= "");
79 Event
waitForEvent(int64_t timeout
= 500);
80 Event
waitForConnEvent(uint32_t connId
, int64_t timeout
= 500);
83 typedef std::list
<Event
> EventList
;
85 concurrency::Monitor monitor_
;
89 static uint32_t nextId_
;
93 } // apache::thrift::test
95 #endif // _THRIFT_TEST_EVENTLOG_H_