1 /**
2 * collectd - bindings/java/org/collectd/api/Collectd.java
3 * Copyright (C) 2009 Florian octo Forster
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Florian octo Forster <octo at collectd.org>
25 */
27 package org.collectd.api;
29 /**
30 * Java API to internal functions of collectd.
31 *
32 * All functions in this class are {@code static}. You don't need to create an
33 * object of this class (in fact, you can't). Just call these functions
34 * directly.
35 *
36 * @author Florian Forster <octo at collectd.org>
37 */
38 public class Collectd
39 {
41 /**
42 * Constant for severity (log level) "error".
43 *
44 * @see CollectdLogInterface
45 */
46 public static final int LOG_ERR = 3;
48 /**
49 * Constant for severity (log level) "warning".
50 *
51 * @see CollectdLogInterface
52 */
53 public static final int LOG_WARNING = 4;
55 /**
56 * Constant for severity (log level) "notice".
57 *
58 * @see CollectdLogInterface
59 */
60 public static final int LOG_NOTICE = 5;
62 /**
63 * Constant for severity (log level) "info".
64 *
65 * @see CollectdLogInterface
66 */
67 public static final int LOG_INFO = 6;
69 /**
70 * Constant for severity (log level) "debug".
71 *
72 * @see CollectdLogInterface
73 */
74 public static final int LOG_DEBUG = 7;
76 /**
77 * Return value of match methods: No match.
78 *
79 * This is one of two valid return values from match callbacks, indicating
80 * that the passed {@link DataSet} and {@link ValueList} did not match.
81 *
82 * Do not use the numeric value directly, it is subject to change without
83 * notice!
84 *
85 * @see CollectdMatchInterface
86 */
87 public static final int FC_MATCH_NO_MATCH = 0;
89 /**
90 * Return value of match methods: Match.
91 *
92 * This is one of two valid return values from match callbacks, indicating
93 * that the passed {@link DataSet} and {@link ValueList} did match.
94 *
95 * Do not use the numeric value directly, it is subject to change without
96 * notice!
97 *
98 * @see CollectdMatchInterface
99 */
100 public static final int FC_MATCH_MATCHES = 1;
102 /**
103 * Return value of target methods: Continue.
104 *
105 * This is one of three valid return values from target callbacks, indicating
106 * that processing of the {@link ValueList} should continue.
107 *
108 * Do not use the numeric value directly, it is subject to change without
109 * notice!
110 *
111 * @see CollectdTargetInterface
112 */
113 public static final int FC_TARGET_CONTINUE = 0;
115 /**
116 * Return value of target methods: Stop.
117 *
118 * This is one of three valid return values from target callbacks, indicating
119 * that processing of the {@link ValueList} should stop immediately.
120 *
121 * Do not use the numeric value directly, it is subject to change without
122 * notice!
123 *
124 * @see CollectdTargetInterface
125 */
126 public static final int FC_TARGET_STOP = 1;
128 /**
129 * Return value of target methods: Return.
130 *
131 * This is one of three valid return values from target callbacks, indicating
132 * that processing of the current chain should be stopped and processing of
133 * the {@link ValueList} should continue in the calling chain.
134 *
135 * Do not use the numeric value directly, it is subject to change without
136 * notice!
137 *
138 * @see CollectdTargetInterface
139 */
140 public static final int FC_TARGET_RETURN = 2;
142 /**
143 * Java representation of collectd/src/plugin.h:plugin_register_config
144 *
145 * @return Zero when successful, non-zero otherwise.
146 * @see CollectdConfigInterface
147 */
148 native public static int registerConfig (String name,
149 CollectdConfigInterface object);
151 /**
152 * Java representation of collectd/src/plugin.h:plugin_register_init
153 *
154 * @return Zero when successful, non-zero otherwise.
155 * @see CollectdInitInterface
156 */
157 native public static int registerInit (String name,
158 CollectdInitInterface object);
160 /**
161 * Java representation of collectd/src/plugin.h:plugin_register_read
162 *
163 * @return Zero when successful, non-zero otherwise.
164 * @see CollectdReadInterface
165 */
166 native public static int registerRead (String name,
167 CollectdReadInterface object);
169 /**
170 * Java representation of collectd/src/plugin.h:plugin_register_write
171 *
172 * @return Zero when successful, non-zero otherwise.
173 * @see CollectdWriteInterface
174 */
175 native public static int registerWrite (String name,
176 CollectdWriteInterface object);
178 /**
179 * Java representation of collectd/src/plugin.h:plugin_register_flush
180 *
181 * @return Zero when successful, non-zero otherwise.
182 * @see CollectdFlushInterface
183 */
184 native public static int registerFlush (String name,
185 CollectdFlushInterface object);
187 /**
188 * Java representation of collectd/src/plugin.h:plugin_register_shutdown
189 *
190 * @return Zero when successful, non-zero otherwise.
191 * @see CollectdShutdownInterface
192 */
193 native public static int registerShutdown (String name,
194 CollectdShutdownInterface object);
196 /**
197 * Java representation of collectd/src/plugin.h:plugin_register_log
198 *
199 * @return Zero when successful, non-zero otherwise.
200 * @see CollectdLogInterface
201 */
202 native public static int registerLog (String name,
203 CollectdLogInterface object);
205 /**
206 * Java representation of collectd/src/plugin.h:plugin_register_notification
207 *
208 * @return Zero when successful, non-zero otherwise.
209 * @see CollectdNotificationInterface
210 */
211 native public static int registerNotification (String name,
212 CollectdNotificationInterface object);
214 /**
215 * Java representation of collectd/src/filter_chain.h:fc_register_match
216 *
217 * @return Zero when successful, non-zero otherwise.
218 * @see CollectdMatchFactoryInterface
219 */
220 native public static int registerMatch (String name,
221 CollectdMatchFactoryInterface object);
223 /**
224 * Java representation of collectd/src/filter_chain.h:fc_register_target
225 *
226 * @return Zero when successful, non-zero otherwise.
227 * @see CollectdTargetFactoryInterface
228 */
229 native public static int registerTarget (String name,
230 CollectdTargetFactoryInterface object);
232 /**
233 * Java representation of collectd/src/plugin.h:plugin_dispatch_values
234 *
235 * @return Zero when successful, non-zero otherwise.
236 */
237 native public static int dispatchValues (ValueList vl);
239 /**
240 * Java representation of collectd/src/plugin.h:plugin_dispatch_notification
241 *
242 * @return Zero when successful, non-zero otherwise.
243 */
244 native public static int dispatchNotification (Notification n);
246 /**
247 * Java representation of collectd/src/plugin.h:plugin_get_ds
248 *
249 * @return The appropriate {@link DataSet} object or {@code null} if no such
250 * type is registered.
251 */
252 native public static DataSet getDS (String type);
254 /**
255 * Java representation of collectd/src/plugin.h:plugin_log
256 */
257 native private static void log (int severity, String message);
259 /**
260 * Yield contents of collectd/src/collectd.h:hostname_g
261 *
262 * @return The hostname as set in the collectd configuration.
263 */
264 native public static java.lang.String getHostname ();
266 /**
267 * Prints an error message.
268 */
269 public static void logError (String message)
270 {
271 log (LOG_ERR, message);
272 } /* void logError */
274 /**
275 * Prints a warning message.
276 */
277 public static void logWarning (String message)
278 {
279 log (LOG_WARNING, message);
280 } /* void logWarning */
282 /**
283 * Prints a notice.
284 */
285 public static void logNotice (String message)
286 {
287 log (LOG_NOTICE, message);
288 } /* void logNotice */
290 /**
291 * Prints an info message.
292 */
293 public static void logInfo (String message)
294 {
295 log (LOG_INFO, message);
296 } /* void logInfo */
298 /**
299 * Prints a debug message.
300 */
301 public static void logDebug (String message)
302 {
303 log (LOG_DEBUG, message);
304 } /* void logDebug */
305 } /* class Collectd */
307 /* vim: set sw=2 sts=2 et fdm=marker : */