84e659265850dceafd0650c4a9bb7297e728b11f
[collectd.git] / bindings / java / org / collectd / api / Collectd.java
1 /*
2  * collectd/java - org/collectd/api/Collectd.java
3  * Copyright (C) 2009  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  */
21
22 package org.collectd.api;
23
24 /**
25  * Java API to internal functions of collectd.
26  *
27  * All functions in this class are {@code static}. You don't need to create an
28  * object of this class (in fact, you can't). Just call these functions
29  * directly.
30  *
31  * @author Florian Forster &lt;octo at verplant.org&gt;
32  */
33 public class Collectd
34 {
35
36   /**
37    * Constant for severity (log level) "error".
38    *
39    * @see CollectdLogInterface
40    */
41   public static final int LOG_ERR     = 3;
42
43   /**
44    * Constant for severity (log level) "warning".
45    *
46    * @see CollectdLogInterface
47    */
48   public static final int LOG_WARNING = 4;
49
50   /**
51    * Constant for severity (log level) "notice".
52    *
53    * @see CollectdLogInterface
54    */
55   public static final int LOG_NOTICE  = 5;
56
57   /**
58    * Constant for severity (log level) "info".
59    *
60    * @see CollectdLogInterface
61    */
62   public static final int LOG_INFO    = 6;
63
64   /**
65    * Constant for severity (log level) "debug".
66    *
67    * @see CollectdLogInterface
68    */
69   public static final int LOG_DEBUG   = 7;
70
71   /**
72    * Return value of match methods: No match.
73    *
74    * This is one of two valid return values from match callbacks, indicating
75    * that the passed {@link DataSet} and {@link ValueList} did not match.
76    *
77    * Do not use the numeric value directly, it is subject to change without
78    * notice!
79    *
80    * @see CollectdMatchInterface
81    */
82   public static final int FC_MATCH_NO_MATCH  = 0;
83
84   /**
85    * Return value of match methods: Match.
86    *
87    * This is one of two valid return values from match callbacks, indicating
88    * that the passed {@link DataSet} and {@link ValueList} did match.
89    *
90    * Do not use the numeric value directly, it is subject to change without
91    * notice!
92    *
93    * @see CollectdMatchInterface
94    */
95   public static final int FC_MATCH_MATCHES   = 1;
96
97   /**
98    * Return value of target methods: Continue.
99    *
100    * This is one of three valid return values from target callbacks, indicating
101    * that processing of the {@link ValueList} should continue.
102    *
103    * Do not use the numeric value directly, it is subject to change without
104    * notice!
105    *
106    * @see CollectdTargetInterface
107    */
108   public static final int FC_TARGET_CONTINUE = 0;
109
110   /**
111    * Return value of target methods: Stop.
112    *
113    * This is one of three valid return values from target callbacks, indicating
114    * that processing of the {@link ValueList} should stop immediately.
115    *
116    * Do not use the numeric value directly, it is subject to change without
117    * notice!
118    *
119    * @see CollectdTargetInterface
120    */
121   public static final int FC_TARGET_STOP     = 1;
122
123   /**
124    * Return value of target methods: Return.
125    *
126    * This is one of three valid return values from target callbacks, indicating
127    * that processing of the current chain should be stopped and processing of
128    * the {@link ValueList} should continue in the calling chain.
129    *
130    * Do not use the numeric value directly, it is subject to change without
131    * notice!
132    *
133    * @see CollectdTargetInterface
134    */
135   public static final int FC_TARGET_RETURN   = 2;
136
137   /**
138    * Java representation of collectd/src/plugin.h:plugin_register_config
139    *
140    * @return Zero when successful, non-zero otherwise.
141    * @see CollectdConfigInterface
142    */
143   native public static int registerConfig (String name,
144       CollectdConfigInterface object);
145
146   /**
147    * Java representation of collectd/src/plugin.h:plugin_register_init
148    *
149    * @return Zero when successful, non-zero otherwise.
150    * @see CollectdInitInterface
151    */
152   native public static int registerInit (String name,
153       CollectdInitInterface object);
154
155   /**
156    * Java representation of collectd/src/plugin.h:plugin_register_read
157    *
158    * @return Zero when successful, non-zero otherwise.
159    * @see CollectdReadInterface
160    */
161   native public static int registerRead (String name,
162       CollectdReadInterface object);
163
164   /**
165    * Java representation of collectd/src/plugin.h:plugin_register_write
166    *
167    * @return Zero when successful, non-zero otherwise.
168    * @see CollectdWriteInterface
169    */
170   native public static int registerWrite (String name,
171       CollectdWriteInterface object);
172
173   /**
174    * Java representation of collectd/src/plugin.h:plugin_register_flush
175    *
176    * @return Zero when successful, non-zero otherwise.
177    * @see CollectdFlushInterface
178    */
179   native public static int registerFlush (String name,
180       CollectdFlushInterface object);
181
182   /**
183    * Java representation of collectd/src/plugin.h:plugin_register_shutdown
184    *
185    * @return Zero when successful, non-zero otherwise.
186    * @see CollectdShutdownInterface
187    */
188   native public static int registerShutdown (String name,
189       CollectdShutdownInterface object);
190
191   /**
192    * Java representation of collectd/src/plugin.h:plugin_register_log
193    *
194    * @return Zero when successful, non-zero otherwise.
195    * @see CollectdLogInterface
196    */
197   native public static int registerLog (String name,
198       CollectdLogInterface object);
199
200   /**
201    * Java representation of collectd/src/plugin.h:plugin_register_notification
202    *
203    * @return Zero when successful, non-zero otherwise.
204    * @see CollectdNotificationInterface
205    */
206   native public static int registerNotification (String name,
207       CollectdNotificationInterface object);
208
209   /**
210    * Java representation of collectd/src/filter_chain.h:fc_register_match
211    *
212    * @return Zero when successful, non-zero otherwise.
213    * @see CollectdMatchFactoryInterface
214    */
215   native public static int registerMatch (String name,
216       CollectdMatchFactoryInterface object);
217
218   /**
219    * Java representation of collectd/src/filter_chain.h:fc_register_target
220    *
221    * @return Zero when successful, non-zero otherwise.
222    * @see CollectdTargetFactoryInterface
223    */
224   native public static int registerTarget (String name,
225       CollectdTargetFactoryInterface object);
226
227   /**
228    * Java representation of collectd/src/plugin.h:plugin_dispatch_values
229    *
230    * @return Zero when successful, non-zero otherwise.
231    */
232   native public static int dispatchValues (ValueList vl);
233
234   /**
235    * Java representation of collectd/src/plugin.h:plugin_dispatch_notification
236    *
237    * @return Zero when successful, non-zero otherwise.
238    */
239   native public static int dispatchNotification (Notification n);
240
241   /**
242    * Java representation of collectd/src/plugin.h:plugin_get_ds
243    *
244    * @return The appropriate {@link DataSet} object or {@code null} if no such
245    * type is registered.
246    */
247   native public static DataSet getDS (String type);
248
249   /**
250    * Java representation of collectd/src/plugin.h:plugin_log
251    */
252   native private static void log (int severity, String message);
253
254   /**
255    * Prints an error message.
256    */
257   public static void logError (String message)
258   {
259     log (LOG_ERR, message);
260   } /* void logError */
261
262   /**
263    * Prints a warning message.
264    */
265   public static void logWarning (String message)
266   {
267     log (LOG_WARNING, message);
268   } /* void logWarning */
269
270   /**
271    * Prints a notice.
272    */
273   public static void logNotice (String message)
274   {
275     log (LOG_NOTICE, message);
276   } /* void logNotice */
277
278   /**
279    * Prints an info message.
280    */
281   public static void logInfo (String message)
282   {
283     log (LOG_INFO, message);
284   } /* void logInfo */
285
286   /**
287    * Prints a debug message.
288    */
289   public static void logDebug (String message)
290   {
291     log (LOG_DEBUG, message);
292   } /* void logDebug */
293 } /* class Collectd */
294
295 /* vim: set sw=2 sts=2 et fdm=marker : */