Add support for query key extraction
[com/gs-lite.git] / include / lapp.h
1 /* ------------------------------------------------
2  Copyright 2014 AT&T Intellectual Property
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 /*
16  * lapp.h: low level interface for applications
17  */
18 #ifndef LAPP_H
19 #define LAPP_H
20
21 #include <fta.h>
22 #include <systat.h>
23 #include <fta_stat.h>
24
25 #define REGULAR_TUPLE 0
26 #define TEMPORAL_TUPLE 1
27 #define EOF_TUPLE 2
28
29 /* LOW LEVEL APPLICATION INTERFACE */
30 /* =============================== */
31
32 /* NOTE: A streamid is only unique in the context of a particular
33  * producer. Therefore, all the fields in the FTAID need to be compared
34  * to decided if to FTA instances are the same
35  */
36
37 #define CLEARINGHOUSE 1
38 #define APP 2
39 #define HFTA 3
40 #define LFTA 4
41
42 /* deviceid should be set to DEFAULTDEV mapcnt and map to 0 for HFTAs and apps */
43
44 gs_retval_t hostlib_init(gs_int32_t type, gs_int32_t recvbuffersz, gs_int32_t deviceid,  gs_int32_t mapcnt, gs_sp_t map[]);
45
46 void hostlib_free();
47
48 /* find an FTA message queue ID, index and schema based on an FTA key
49  * if reuse is set we return an already running instance if possible*/
50
51 gs_retval_t fta_find(FTAname name, gs_uint32_t  reuse,  FTAID * ftaid,
52                      gs_sp_t schema , gs_int32_t buffersz );
53
54 /* the following is used to send a heart beat message to the clearinghouse. Self is the FTAID of the sending
55  * fta instance*/
56
57 gs_retval_t fta_heartbeat(FTAID self, gs_uint64_t trace_id,
58                           gs_uint32_t  sz, fta_stat * trace);
59
60 /*
61  * FTA's cannot be dynamically installed (since we currently don't
62  * have a run-time linker in the card).  however, new parameterized
63  * instances of previously installed FTAs can be created.  The FTA
64  * template IDs have to defined in an include file.  the following
65  * call will result in a call to the FTA's alloc_fta function.
66  * if sucessfull the streamid is set in the ftaid.
67  */
68
69 gs_retval_t fta_alloc_instance(FTAID subscriber,
70                                FTAID * ftaid, FTAname name, gs_sp_t schema,
71                                gs_uint32_t  reusable,
72                                gs_int32_t command, gs_int32_t sz, void *  data);
73
74 /* see app.h for description of the additional parameter */
75 gs_retval_t fta_alloc_print_instance(FTAID subscriber,
76                                      FTAID * ftaid,
77                                      FTAname name, gs_sp_t schema,gs_uint32_t  reusable,
78                                      gs_int32_t command, gs_int32_t sz, void *  data,
79                                      gs_sp_t path,gs_sp_t basename,
80                                      gs_sp_t temporal_field, gs_sp_t split_field,
81                                      gs_uint32_t  delta, gs_uint32_t  split);
82
83
84 /*
85  * the next two functions result in callouts to the corresponding FTA
86  * functions (fta_free, control_fta).
87  */
88
89 gs_retval_t fta_free_instance(FTAID subscriber,FTAID ftaid, gs_uint32_t  recursive);
90
91
92 gs_retval_t fta_control(FTAID subscriber,
93                         FTAID ftaid, gs_int32_t command, gs_int32_t sz, void * value);
94
95
96 /*
97  * gscp_get_buffer: get a tuple from a read shared buffer
98  * established with any other porcess  when an FTA
99  * was established. Returns -1 on error, 0 on success and 1 on timeout and 2 for a temporal tuple.
100  * On a timeout the streamid is set to 1 and the length to 0.
101  * The timeout is in seconds. A timeout of 0 makes the call blocking
102  * a timeout of -1 returns imidiatly if no buffer is availabe.
103  */
104 gs_retval_t gscp_get_buffer(FTAID * ftaid, gs_int32_t * size, void *tbuffer,
105                             gs_int32_t tbuf_size, gs_int32_t timeout);
106
107 /* the following function send a control callback to every
108  active FTA in a particular process identified by the
109  IP and port part of the ftaid. The result is < 0 if not
110  successful if the control operation is returning a result it is ignored.
111  The main purpose of this message is to support a
112  flush of all FTAs in a proccess*/
113
114 gs_retval_t process_control(FTAID ftaid, gs_int32_t command,
115                             gs_int32_t sz, void * value);
116
117
118 /* called by an FTA if one of its producers fails. Self is the FTAID of the instance
119  * sending the notification */
120
121 gs_retval_t fta_notify_producer_failure(FTAID self, FTAID producer);
122
123 /* returns FTAID of current process */
124 FTAID  gscpipc_getftaid();
125
126 extern gs_uint64_t shared_memory_full_warning;
127
128 /* returns 1 if GSCP ringbuffers are in blocking mode */
129 gs_retval_t gscp_blocking_mode();
130
131 #endif