Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rpc-trace.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef IMPALA_RPC_RPC_TRACE_H
16 #define IMPALA_RPC_RPC_TRACE_H
17 
19 #include "rpc/thrift-server.h"
20 #include "util/internal-queue.h"
21 
22 #include <thrift/TProcessor.h>
23 #include <boost/thread/thread.hpp>
24 #include <boost/unordered_map.hpp>
25 
26 #include <rapidjson/document.h>
27 
28 namespace impala {
29 
30 class Webserver;
31 class MetricGroup;
32 
37  public:
38  RpcEventHandler(const std::string& server_name, MetricGroup* metrics);
39 
43  virtual void* getContext(const char* fn_name, void* server_context);
44 
48  virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes);
49 
67  void ToJson(rapidjson::Value* server, rapidjson::Document* document);
68 
70  void Reset(const std::string& method_name);
71 
73  void ResetAll();
74 
75  std::string server_name() const { return server_name_; }
76 
77  private:
81  std::string name;
82 
85 
88  };
89 
91  typedef boost::unordered_map<std::string, MethodDescriptor*> MethodMap;
92 
96  const int64_t start_time_ms;
97 
102 
105 
107  MethodDescriptor* descriptor)
108  : start_time_ms(start_time), cnxn_ctx(cnxn_ctx), method_descriptor(descriptor) { }
109  };
110 
112  boost::mutex method_map_lock_;
113 
116 
118  std::string server_name_;
119 
122 
123 };
124 
126 void InitRpcEventTracing(Webserver* webserver);
127 
128 }
129 
130 #endif
InvocationContext(int64_t start_time, const ThriftServer::ConnectionContext *cnxn_ctx, MethodDescriptor *descriptor)
Definition: rpc-trace.h:106
boost::mutex method_map_lock_
Protects method_map_ and rpc_counter_.
Definition: rpc-trace.h:112
MetricGroup * metrics_
Metrics subsystem access.
Definition: rpc-trace.h:121
MetricGroups may be organised hierarchically as a tree.
Definition: metrics.h:200
const ThriftServer::ConnectionContext * cnxn_ctx
Definition: rpc-trace.h:101
void ResetAll()
Resets the statistics for all methods.
Definition: rpc-trace.cc:125
void Reset(const std::string &method_name)
Resets the statistics for a single method.
Definition: rpc-trace.cc:117
std::string server_name_
Name of the server that we listen for events from.
Definition: rpc-trace.h:118
Created per-Rpc invocation.
Definition: rpc-trace.h:94
Per-connection information.
Definition: thrift-server.h:45
void InitRpcEventTracing(Webserver *webserver)
Initialises rpc event tracing, must be called before any RpcEventHandlers are created.
Definition: rpc-trace.cc:67
std::string name
Name of the method.
Definition: rpc-trace.h:81
virtual void * getContext(const char *fn_name, void *server_context)
Definition: rpc-trace.cc:158
StatsMetric< double > * time_stats
Summary statistics for the time taken to respond to this method.
Definition: rpc-trace.h:84
void ToJson(rapidjson::Value *server, rapidjson::Document *document)
Definition: rpc-trace.cc:138
const int64_t start_time_ms
Monotonic milliseconds (typically boot time) when the call started.
Definition: rpc-trace.h:96
virtual void postWrite(void *ctx, const char *fn_name, uint32_t bytes)
Definition: rpc-trace.cc:184
MethodMap method_map_
Map of all methods, populated lazily as they are invoked for the first time.
Definition: rpc-trace.h:115
boost::unordered_map< std::string, MethodDescriptor * > MethodMap
Map from method name to descriptor.
Definition: rpc-trace.h:91
std::string server_name() const
Definition: rpc-trace.h:75
MethodDescriptor * method_descriptor
Pointer to parent MethodDescriptor, to save a lookup on deletion.
Definition: rpc-trace.h:104
AtomicInt< uint32_t > num_in_flight
Number of invocations in flight.
Definition: rpc-trace.h:87
RpcEventHandler(const std::string &server_name, MetricGroup *metrics)
Definition: rpc-trace.cc:133