GraphLab: Distributed Graph-Parallel API
2.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
metrics_server.hpp
1
/*
2
* Copyright (c) 2009 Carnegie Mellon University.
3
* All rights reserved.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing,
12
* software distributed under the License is distributed on an "AS
13
* IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
* express or implied. See the License for the specific language
15
* governing permissions and limitations under the License.
16
*
17
* For more about this software visit:
18
*
19
* http://www.graphlab.ml.cmu.edu
20
*
21
*/
22
23
#ifndef GRAPHLAB_METRICS_SERVER_HPP
24
#define GRAPHLAB_METRICS_SERVER_HPP
25
#include <string>
26
#include <map>
27
#include <utility>
28
#include <boost/function.hpp>
29
30
31
namespace
graphlab {
32
33
34
35
/**
36
\ingroup httpserver
37
The callback type used for add_metric_server_callback()
38
See add_metric_server_callback() for details.
39
*/
40
typedef
boost::function<std::pair<std::string, std::string>
41
(std::map<std::string, std::string>&)>
42
http_redirect_callback_type
;
43
44
45
46
47
/**
48
49
\ingroup httpserver
50
\brief This is used to map a URL on the mtrics server
51
to a processing function.
52
53
The processing function must have the prototype
54
\code
55
std::pair<std::string, std::string> callback(std::map<std::string, std::string>&)
56
\endcode
57
58
The processing function takes a map of GET variables to their corresponding
59
values, and returns a pair of strings. (content_type, content)
60
\li \c content type is the http content_type header. For instance text/plain
61
or text/html.
62
\li \c content is the actual body
63
64
For instance: The builtin 404 handler looks like this:
65
66
\code
67
std::pair<std::string, std::string>
68
four_oh_four(std::map<std::string, std::string>& varmap) {
69
return std::make_pair(std::string("text/html"),
70
std::string("Page Not Found"));
71
}
72
\endcode
73
74
\note The callbacks are only processed on machine 0 since only machine 0
75
launches the server.
76
77
\param page The page to map. For instance <code>page = "a.html"</code>
78
will be shown on http://[server]/a.html
79
\param callback The callback function to use to process the page
80
*/
81
void
add_metric_server_callback
(std::string page,
82
http_redirect_callback_type
callback);
83
84
85
/**
86
\ingroup httpserver
87
\brief Starts the metrics reporting server.
88
89
The function may be called by all machines simultaneously since it only
90
does useful work on machine 0. Only machine 0 will launch the web server.
91
*/
92
void
launch_metric_server
();
93
94
95
96
/**
97
\ingroup httpserver
98
\brief Stops the metrics reporting server if one is started.
99
100
The function may be called by all machines simultaneously since it only
101
does useful work on machine 0.
102
*/
103
void
stop_metric_server
();
104
105
/**
106
\ingroup httpserver
107
\brief Waits for a ctrl-D on machine 0, and
108
stops the metrics reporting server if one is started.
109
110
The function may be called by all machines simultaneously since it only
111
does useful work on machine 0. It waits for the stdin stream to close
112
(when the user hit ctrl-d), then shuts down the server.
113
*/
114
void
stop_metric_server_on_eof
();
115
116
}
// graphlab
117
#endif // GRAPHLAB_METRICS_SERVER_HPP
graphlab
ui
metrics_server.hpp
Generated on Mon Jun 3 2013 05:00:04 for GraphLab: Distributed Graph-Parallel API by
1.8.1.1