1
0
Fork 0

added ConnectionStatisticsHandler

This commit is contained in:
Frank Celler 2012-07-05 18:02:43 +02:00
parent 4403da5568
commit 56bdef98b8
5 changed files with 377 additions and 0 deletions

View File

@ -637,6 +637,7 @@ am__bin_arangod_SOURCES_DIST = arangod/Actions/actions.cpp \
arangod/PriorityQueue/pqueueindex.c \
arangod/PriorityQueue/priorityqueue.c \
arangod/RestHandler/StatisticsBaseHandler.cpp \
arangod/RestHandler/ConnectionStatisticsHandler.cpp \
arangod/RestHandler/RequestStatisticsHandler.cpp \
arangod/RestHandler/RestBatchHandler.cpp \
arangod/RestHandler/RestDocumentHandler.cpp \
@ -699,6 +700,7 @@ am_bin_arangod_OBJECTS = \
arangod/PriorityQueue/bin_arangod-pqueueindex.$(OBJEXT) \
arangod/PriorityQueue/bin_arangod-priorityqueue.$(OBJEXT) \
arangod/RestHandler/bin_arangod-StatisticsBaseHandler.$(OBJEXT) \
arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.$(OBJEXT) \
arangod/RestHandler/bin_arangod-RequestStatisticsHandler.$(OBJEXT) \
arangod/RestHandler/bin_arangod-RestBatchHandler.$(OBJEXT) \
arangod/RestHandler/bin_arangod-RestDocumentHandler.$(OBJEXT) \
@ -1438,6 +1440,7 @@ bin_arangod_SOURCES = arangod/Actions/actions.cpp \
arangod/PriorityQueue/pqueueindex.c \
arangod/PriorityQueue/priorityqueue.c \
arangod/RestHandler/StatisticsBaseHandler.cpp \
arangod/RestHandler/ConnectionStatisticsHandler.cpp \
arangod/RestHandler/RequestStatisticsHandler.cpp \
arangod/RestHandler/RestBatchHandler.cpp \
arangod/RestHandler/RestDocumentHandler.cpp \
@ -2566,6 +2569,9 @@ arangod/RestHandler/$(DEPDIR)/$(am__dirstamp):
arangod/RestHandler/bin_arangod-StatisticsBaseHandler.$(OBJEXT): \
arangod/RestHandler/$(am__dirstamp) \
arangod/RestHandler/$(DEPDIR)/$(am__dirstamp)
arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.$(OBJEXT): \
arangod/RestHandler/$(am__dirstamp) \
arangod/RestHandler/$(DEPDIR)/$(am__dirstamp)
arangod/RestHandler/bin_arangod-RequestStatisticsHandler.$(OBJEXT): \
arangod/RestHandler/$(am__dirstamp) \
arangod/RestHandler/$(DEPDIR)/$(am__dirstamp)
@ -2819,6 +2825,7 @@ mostlyclean-compile:
-rm -f arangod/MRServer/bin_arangod-mr-actions.$(OBJEXT)
-rm -f arangod/PriorityQueue/bin_arangod-pqueueindex.$(OBJEXT)
-rm -f arangod/PriorityQueue/bin_arangod-priorityqueue.$(OBJEXT)
-rm -f arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.$(OBJEXT)
-rm -f arangod/RestHandler/bin_arangod-RequestStatisticsHandler.$(OBJEXT)
-rm -f arangod/RestHandler/bin_arangod-RestBatchHandler.$(OBJEXT)
-rm -f arangod/RestHandler/bin_arangod-RestDocumentHandler.$(OBJEXT)
@ -3080,6 +3087,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@arangod/MRServer/$(DEPDIR)/bin_arangod-mr-actions.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangod/PriorityQueue/$(DEPDIR)/bin_arangod-pqueueindex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangod/PriorityQueue/$(DEPDIR)/bin_arangod-priorityqueue.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangod/RestHandler/$(DEPDIR)/bin_arangod-RequestStatisticsHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangod/RestHandler/$(DEPDIR)/bin_arangod-RestBatchHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@arangod/RestHandler/$(DEPDIR)/bin_arangod-RestDocumentHandler.Po@am__quote@
@ -4200,6 +4208,22 @@ arangod/RestHandler/bin_arangod-StatisticsBaseHandler.obj: arangod/RestHandler/S
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangod_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arangod/RestHandler/bin_arangod-StatisticsBaseHandler.obj `if test -f 'arangod/RestHandler/StatisticsBaseHandler.cpp'; then $(CYGPATH_W) 'arangod/RestHandler/StatisticsBaseHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/arangod/RestHandler/StatisticsBaseHandler.cpp'; fi`
arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.o: arangod/RestHandler/ConnectionStatisticsHandler.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangod_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.o -MD -MP -MF arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Tpo -c -o arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.o `test -f 'arangod/RestHandler/ConnectionStatisticsHandler.cpp' || echo '$(srcdir)/'`arangod/RestHandler/ConnectionStatisticsHandler.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Tpo arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='arangod/RestHandler/ConnectionStatisticsHandler.cpp' object='arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangod_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.o `test -f 'arangod/RestHandler/ConnectionStatisticsHandler.cpp' || echo '$(srcdir)/'`arangod/RestHandler/ConnectionStatisticsHandler.cpp
arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.obj: arangod/RestHandler/ConnectionStatisticsHandler.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangod_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.obj -MD -MP -MF arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Tpo -c -o arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.obj `if test -f 'arangod/RestHandler/ConnectionStatisticsHandler.cpp'; then $(CYGPATH_W) 'arangod/RestHandler/ConnectionStatisticsHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/arangod/RestHandler/ConnectionStatisticsHandler.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Tpo arangod/RestHandler/$(DEPDIR)/bin_arangod-ConnectionStatisticsHandler.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='arangod/RestHandler/ConnectionStatisticsHandler.cpp' object='arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangod_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o arangod/RestHandler/bin_arangod-ConnectionStatisticsHandler.obj `if test -f 'arangod/RestHandler/ConnectionStatisticsHandler.cpp'; then $(CYGPATH_W) 'arangod/RestHandler/ConnectionStatisticsHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/arangod/RestHandler/ConnectionStatisticsHandler.cpp'; fi`
arangod/RestHandler/bin_arangod-RequestStatisticsHandler.o: arangod/RestHandler/RequestStatisticsHandler.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bin_arangod_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT arangod/RestHandler/bin_arangod-RequestStatisticsHandler.o -MD -MP -MF arangod/RestHandler/$(DEPDIR)/bin_arangod-RequestStatisticsHandler.Tpo -c -o arangod/RestHandler/bin_arangod-RequestStatisticsHandler.o `test -f 'arangod/RestHandler/RequestStatisticsHandler.cpp' || echo '$(srcdir)/'`arangod/RestHandler/RequestStatisticsHandler.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) arangod/RestHandler/$(DEPDIR)/bin_arangod-RequestStatisticsHandler.Tpo arangod/RestHandler/$(DEPDIR)/bin_arangod-RequestStatisticsHandler.Po

View File

@ -56,6 +56,7 @@ bin_arangod_SOURCES = \
arangod/PriorityQueue/pqueueindex.c \
arangod/PriorityQueue/priorityqueue.c \
arangod/RestHandler/StatisticsBaseHandler.cpp \
arangod/RestHandler/ConnectionStatisticsHandler.cpp \
arangod/RestHandler/RequestStatisticsHandler.cpp \
arangod/RestHandler/RestBatchHandler.cpp \
arangod/RestHandler/RestDocumentHandler.cpp \

View File

@ -0,0 +1,157 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief statistics handler
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "ConnectionStatisticsHandler.h"
#include "Basics/StringUtils.h"
#include "Rest/HttpRequest.h"
#include "Variant/VariantArray.h"
using namespace triagens::arango;
using namespace triagens::basics;
using namespace triagens::rest;
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs a new handler
////////////////////////////////////////////////////////////////////////////////
ConnectionStatisticsHandler::ConnectionStatisticsHandler (triagens::rest::HttpRequest* request)
: StatisticsBaseHandler(request) {
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- Handler methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
void ConnectionStatisticsHandler::compute (TRI_statistics_granularity_e granularity, size_t length) {
bool showTotalTime = false;
bool showQueueTime = false;
bool showRequestTime = false;
bool showBytesSent = false;
bool showBytesReceived = false;
// .............................................................................
// extract the figures to show
// .............................................................................
bool found;
string figures = StringUtils::tolower(_request->value("figures", found));
if (found) {
if (figures == "*" || figures == "all") {
showTotalTime = true;
showQueueTime = true;
showRequestTime = true;
showBytesSent = true;
showBytesReceived = true;
}
else {
vector<string> f = StringUtils::split(figures);
for (vector<string>::iterator i = f.begin(); i != f.end(); ++i) {
string const& fn = *i;
if (fn == "totaltime") {
showTotalTime = true;
}
else if (fn == "queuetime") {
showQueueTime = true;
}
else if (fn == "requesttime") {
showRequestTime = true;
}
else if (fn == "bytessent") {
showBytesSent = true;
}
else if (fn == "bytesreceived") {
showBytesReceived = true;
}
else {
generateError(HttpResponse::BAD, TRI_ERROR_HTTP_BAD_PARAMETER, "unknown figure '" + fn + "'");
return;
}
}
}
}
else {
showTotalTime = true;
showBytesSent = true;
showBytesReceived = true;
}
// .............................................................................
// compute
// .............................................................................
VariantArray* result = TRI_StatisticsInfo(granularity,
length,
showTotalTime,
showQueueTime,
showRequestTime,
showBytesSent,
showBytesReceived);
generateResult(result);
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -0,0 +1,190 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief statistics handler
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_REST_HANDLER_CONNECTION_STATISTICS_HANDLER_H
#define TRIAGENS_REST_HANDLER_CONNECTION_STATISTICS_HANDLER_H 1
#include "RestHandler/StatisticsBaseHandler.h"
// -----------------------------------------------------------------------------
// --SECTION-- class RestDocumentHandler
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
namespace triagens {
namespace arango {
////////////////////////////////////////////////////////////////////////////////
/// @brief statistics handler
////////////////////////////////////////////////////////////////////////////////
class ConnectionStatisticsHandler : public StatisticsBaseHandler {
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs a new handler
////////////////////////////////////////////////////////////////////////////////
ConnectionStatisticsHandler (triagens::rest::HttpRequest*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- StatisticsBaseHandler methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
///
/// @RESTHEADER{GET /_admin/request-statistics,reads the request statistics}
///
/// @REST{GET /_admin/request-statistics?granalurity=@FA{granularity}&figures=@FA{figures}&length=@FA{length}}
///
/// The call returns statistics about the current and past requests. The
/// following parameter control which information is returned.
///
/// - @FA{granularity}: use @LIT{minutes} for a granularity of minutes,
/// @LIT{hours} for hours, and @LIT{days} for days. The default is
/// @LIT{minutes}.
///
/// - @FA{figures}: a list of figures, comma-separated. Possible figures are
/// @LIT{totalTime}, @LIT{queueTime}, @LIT{requestTime}, @LIT{bytesSent}, and
/// @LIT{bytesReceived}. You can use @LIT{all} to get all figures. The default
/// is @LIT{totalTime}, @LIT{bytesSent}, and @LIT{bytesReceived}.
///
/// - @FA{length}: If you want a time series, the maximal length of the series
/// as integer. You can use @LIT{all} to get all available information. You can
/// use @LIT{current} to get the latest interval.
///
/// The returned statistics objects contains information of the request figures.
///
/// - @LIT{resolution}: the resolution in seconds aka granularity. The length of
/// the time intervals.
///
/// - @LIT{start}: a list of time stamps in seconds since 1970-01-01. Each entry
/// marks the start of an interval for which the figures were computed. The length
/// of the interval is given by @LIT{resolution}.
///
/// - @LIT{length}: the number of returned intervals.
///
/// - @LIT{totalLength}: the number of available intervals.
///
/// - @LIT{totalTime}: the distribution of the total time.
///
/// - @LIT{queueTime}: the distribution of the queue time.
///
/// - @LIT{requestTime}: the distribution of the request time.
///
/// - @LIT{bytesSent}: the distribution of the number of bytes sent.
///
/// - @LIT{bytesReceived}: the distribution of the number of bytes received.
///
/// A distribution contains the following fields:
///
/// - @LIT{count}: a list describing the number of requests per time
/// interval. This corresponds to the field @LIT{start}.
///
/// - @LIT{mean}: a list describing the mean of the values per time
/// interval. This corresponds to the field @LIT{start}.
///
/// - @LIT{min}: a list describing the minimum of the values per time
/// interval. This corresponds to the field @LIT{start}.
///
/// - @LIT{max}: a list describing the maximum of the values per time
/// interval. This corresponds to the field @LIT{start}.
///
/// - @LIT{deviation}: a list describing the deviation of the values per time
/// interval. This corresponds to the field @LIT{start}.
///
/// - @LIT{cuts}: a list [N1, N2, ... Nx] of numbers defining the intervals for
/// the figure. The first interval is [0 .. N1), the last interval is [Nx
/// .. INF).
///
/// - @LIT{distribution}: a list describing the distribution of the values per
/// time interval. This corresponds to the field @LIT{start}. Each entry of the
/// list is again a list. This list describes the number of requests per cut and
/// corresponds to the field @{cuts}.
///
/// If @FA{length} is @LIT{current} the figures for the current interval are returned.
///
/// @EXAMPLES
///
/// A time-series:
///
/// @EXAMPLE{request-statistics,request statistics as time series}
///
/// The current figures:
///
/// @EXAMPLE{request-statistics-current,current request statistics}
////////////////////////////////////////////////////////////////////////////////
void compute (TRI_statistics_granularity_e, size_t length);
};
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -56,6 +56,7 @@
#include "HttpServer/RedirectHandler.h"
#include "Logger/Logger.h"
#include "Rest/Initialise.h"
#include "RestHandler/ConnectionStatisticsHandler.h"
#include "RestHandler/RequestStatisticsHandler.h"
#include "RestHandler/RestBatchHandler.h"
#include "RestHandler/RestDocumentHandler.h"
@ -155,6 +156,10 @@ static void DefineAdminHandlers (HttpHandlerFactory* factory,
user->addHandlers(factory, "/_admin");
// add statistics
factory->addHandler("/_admin/connection-statistics",
RestHandlerCreator<ConnectionStatisticsHandler>::createNoData,
0);
factory->addHandler("/_admin/request-statistics",
RestHandlerCreator<RequestStatisticsHandler>::createNoData,
0);