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
7 http://www.apache.org/licenses/LICENSE-2.0
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 ------------------------------------------- */
16 * fta.h: fta definition for applications
24 typedef struct FTAID {
25 gs_uint32_t ip; /* identifies the node */
26 gs_uint32_t port; /* identifies a process */
27 gs_uint32_t index; /* the index identifies a particular FTA in the process */
28 gs_p_t streamid; /* streamid if set identifies an instance */
33 typedef struct PRINTFUNC {
37 FILE * fa[MAXPRINTFILES];
43 gs_schemahandle_t schemaid;
44 gs_int32_t split_field;
45 gs_int32_t temporal_field;
49 /* the following defines define the FTA commands */
51 #define FTA_COMMAND_LOAD_PARAMS 1
52 #define FTA_COMMAND_FLUSH 2
53 #define FTA_COMMAND_GET_TEMP_STATUS 3
54 #define FTA_COMMAND_SET_SAMPLING_RATE 4
55 #define FTA_COMMAND_FILE_DONE 5
57 typedef gs_csp_t FTAname;
59 typedef gs_csp_t DEVname;
63 // Use gs_param_handle_t defined in gscpv3/include/gstypes.h instead
64 // typedef gs_uint32_t param_handle_t;
68 /* reference counts managed by the RTS */
70 gs_uint32_t runrefcnt;
72 /* the ID gets filled in by the runtime system */
75 /* indicates if the FTA instance can be reused. Set by FTA 0 indicates
76 * that it can not be reused.
80 /* ftaids the HFTA is subscribed to*/
81 FTAID stream_subscribed[64];
83 /* number of valid entries in stream_subscribe [0..stream_subscribed_cnt-1] */
84 gs_uint32_t stream_subscribed_cnt;
86 /* State needed to print directly to a file out of a HFTA */
90 /* value of prefilter only used in lftas */
91 gs_uint64_t prefilter;
93 /* allocates and initializes a paramterized instance of a FTA
95 struct FTA * (*alloc_fta) (FTAID ftaid, gs_uint32_t reusable,
96 gs_int32_t command, gs_int32_t sz, void * value );
98 /* release all resources associated with FTA (including the FTA) */
99 gs_retval_t (*free_fta) (struct FTA *, gs_uint32_t recursive);
101 /* send control data from host to an instance of an FTA, may return status */
102 gs_retval_t (*control_fta) (struct FTA *, gs_int32_t command, gs_int32_t sz, void * value);
104 /* gets called once every second. Might be delayed until the current thread execution
105 * returns into the run time system. If delayed for more then 1 second then only one
106 * call will be made at the next oportunity.
108 gs_retval_t (*clock_fta) (struct FTA *);
111 * process a packet received on the interface or a tuple received from
112 * another FTA. If ftaid is 0 then packet is of
113 * type struct packet otherwise it is a tuple as defined by the
116 gs_retval_t (*accept_packet)(struct FTA *, FTAID * f, void * packet, gs_int32_t sz);
119 /* The following definitions are used or provided in automatically generated files */
121 typedef struct FTA * (*alloc_fta) (FTAID ftaid, gs_uint32_t reusable,
122 gs_int32_t command, gs_int32_t sz, void * value ) ;
127 /* These functions are used by FTAs in addition to the LOW and HIGH
128 * level application interface functions.
131 /* start_service is called to process requests from the message queue
132 which would invoke callback functions registered by fta_register.
133 Number indicates how many seconds should be waited before the
134 function returns. If number < 0 then the function is an endless
135 loop (should be used for HFTA) if the number == 0 all currently
136 outstanding requests are processed before the function returns.
138 gs_retval_t fta_start_service(gs_int32_t number);
140 /* the dev name indicates on which device the FTA is supposed to execute.
141 * HFTA should always use DEFAULTDEV and a snaplen of -1
143 FTAID fta_register(FTAname name, gs_uint32_t reusable, DEVname device,
144 alloc_fta fta_alloc_functionptr, gs_csp_t schema,gs_int32_t snaplen,
145 gs_uint64_t prefilter);
147 gs_retval_t fta_unregister(FTAID f);
151 * get the maximum snap length of all ftas registered within the current proccess
154 gs_retval_t fta_max_snaplen();
157 * Post a tupple back to the clearing house This tuple cannot
158 * use the lfta tuple allocation functions. NOTE: post tuple will
159 * return -1 if at least one ringbuffer for that FTA which is in the atomic
160 * set has not enought space. Otherwise 0 is returned.
162 gs_retval_t hfta_post_tuple(struct FTA * self, gs_int32_t sz, void *tuple);
164 /* the following function fills in the FTAID array r with the FTAIDs of processes receiving
165 * tuplese from the FTA specified in f. The space array indicates how many tuples of tuplesz
166 * can still fit in the ringbuffer corresponding to the FTAID of the process with the same index
167 * in r. The return values indicates how many ring buffers are valid in r. szr indicates the memory
168 * length (in elements) of r and space. The function will fill at most szr elements into these array.
169 * If the return value is larger then szr it is an indication that not enough memory in r and space
170 * were provided to hold all results. A return value of -1 indicates an error.
173 gs_retval_t hfta_get_ringbuf_space(struct FTA * f, FTAID * r, gs_int32_t* space, gs_int32_t szr, gs_int32_t tuplesz);
176 /* the following function can be used to put a ringbuffer to a process identified by the FTAID
177 * process into one of the following 3 modes. ATOMIC makes the ringbuffer part of the atomic set.
178 * A post to the atomic set either succeed or fails entirely. BESTEFFORT is the besteffort set
179 * posts to BESTEFFORT ringbuffers might fail quitely. SUSPEND will prevent any tuples of being
180 * posted to that proccess from the specified FTA.
183 #define HFTA_RINGBUF_ATOMIC 1
184 #define HFTA_RINGBUF_BESTEFFORT 2
185 #define HFTA_RINGBUF_SUSPEND 3
187 gs_retval_t hfta_set_ringbuf_type(struct FTA * f, FTAID process, gs_int32_t state);