~ubuntu-branches/ubuntu/trusty/ocamlnet/trusty

« back to all changes in this revision

Viewing changes to src/netplex/netplex_ctrl.x

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-09-02 14:12:33 UTC
  • mfrom: (18.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110902141233-zbj0ygxb92u6gy4z
Tags: 3.4-1
* New upstream release
  - add a new NetcgiRequire directive to ease dependency management
    (Closes: #637147)
  - remove patches that were applied upstream:
    + Added-missing-shebang-lines-in-example-shell-scripts
    + Try-also-ocamlc-for-POSIX-threads

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: netplex_ctrl.x 976 2006-08-26 16:04:13Z gerd $ -*- c -*- */
 
1
/* $Id: netplex_ctrl.x 1652 2011-08-03 21:50:30Z gerd $ -*- c -*- */
2
2
 
3
3
typedef string longstring<>;
4
4
 
 
5
typedef longstring *longstring_opt;
 
6
 
5
7
typedef longstring *internal_port;
6
8
/* The path of a Unix domain socket if the service is found and enabled */
7
9
 
 
10
typedef longstring internal_ports<>;
 
11
 
8
12
struct message {
9
13
    longstring msg_name;
10
14
    longstring msg_arguments<>;
26
30
    EVENT_NOACCEPT = 2,
27
31
    EVENT_RECEIVED_MESSAGE = 3,
28
32
    EVENT_RECEIVED_ADMIN_MESSAGE = 4,
29
 
    EVENT_SHUTDOWN = 5
 
33
    EVENT_SHUTDOWN = 5,
 
34
    EVENT_SYSTEM_SHUTDOWN = 6
30
35
};
31
36
 
32
37
 
44
49
     message msg;
45
50
 case EVENT_SHUTDOWN:
46
51
     void;
 
52
 case EVENT_SYSTEM_SHUTDOWN:
 
53
     void;
47
54
};
48
55
 
49
56
 
67
74
 
68
75
        void ping(void) = 0;
69
76
 
70
 
        event poll(int               /* Number of active connections */
 
77
        event poll(int,              /* Number of active connections */
 
78
                   bool              /* whether currently busy anyway (not accepting) */
71
79
                   ) = 1;
72
80
        /* Polls for the next controller event */
73
81
 
109
117
         */
110
118
 
111
119
        void log(level,                /* log level */
 
120
                 longstring,           /* subchannel or "" */
112
121
                 longstring            /* log message */
113
122
                 ) = 3;
114
123
        /* This is a special procedure: The controller does not send a
115
124
         * response for performance reasons.
116
125
         */
117
126
 
 
127
        longstring call_plugin(_int64 hyper,         /* plugin ID */
 
128
                               longstring,    /* proc name */
 
129
                               longstring     /* proc argument */
 
130
                               ) = 4;
 
131
        /* Proc argument and return value are XDR-encoded according to the
 
132
           plugin program spec.
 
133
        */
 
134
 
 
135
        void register_container_socket(longstring,  /* service name */
 
136
                                       longstring,  /* proto name */
 
137
                                       longstring   /* socket path */
 
138
                                       ) = 5;
 
139
        /* Registers this socket under the passed service and protocol names.
 
140
           It is automatically unregistered when the container finishes.
 
141
        */
 
142
 
 
143
        internal_ports lookup_container_sockets(longstring,
 
144
                                                longstring) = 6;
 
145
        /* Returns all container sockets for these service and protocol
 
146
           names. The list may be empty if there is no such socket.
 
147
        */
 
148
 
 
149
        longstring activate_lever(int, longstring) = 7;
 
150
        /* Activates the already registered lever. The int is the ID.
 
151
           The string argument is the marshalled argument exception.
 
152
           The return value is the marshalled result exception.
 
153
        */
 
154
 
118
155
    } = 1;
119
156
 
120
157
} = 2;
180
217
};
181
218
 
182
219
 
183
 
struct service {
 
220
enum cnt_state_enum {
 
221
    CSTATE_ACCEPTING = 0,
 
222
    CSTATE_SELECTED = 1,
 
223
    CSTATE_BUSY = 2,
 
224
    CSTATE_STARTING = 3,
 
225
    CSTATE_SHUTDOWN = 4
 
226
};
 
227
 
 
228
union cnt_state switch(cnt_state_enum d) {
 
229
 case CSTATE_ACCEPTING: void;
 
230
 default: void;
 
231
};
 
232
 
 
233
 
 
234
struct container_info {
 
235
    _int64 hyper cnt_id;     /* Object ID of the container in the controller */
 
236
    longstring   cnt_sys_id; /* System ID (thread/process ID) */
 
237
    cnt_state    cnt_state;
 
238
};
 
239
 
 
240
 
 
241
struct service_info {
184
242
    longstring srv_name;
185
243
    prot_list  srv_protocols;
186
244
    int        srv_nr_containers;
 
245
    container_info srv_containers<>;
187
246
    srv_state  srv_state;
188
247
};
189
248
 
190
249
 
191
 
typedef service service_list<>;
 
250
typedef service_info service_info_list<>;
192
251
 
193
252
 
194
253
program Admin {
195
254
    /* User API, accessible from the outside */
196
255
 
197
 
    version V1 {
 
256
    version V2 {
198
257
 
199
258
        void ping(void) = 0;
200
259
 
201
 
        service_list list(void) = 1;
 
260
        service_info_list list(void) = 1;
202
261
        /* list of services: name, protocols, ports, state */
203
262
 
204
263
        unit_result enable(longstring          /* service name */
211
270
                            ) = 4;
212
271
        unit_result restart_all(void) = 5;
213
272
 
214
 
        unit_result shutdown(void) = 6;
 
273
        unit_result system_shutdown(void) = 6;
215
274
 
216
275
        unit_result reopen_logfiles(void) = 7;
217
276
        /* reopen logfiles */
224
283
         */
225
284
 
226
285
 
227
 
    } = 1;
 
286
    } = 2;
228
287
 
229
288
} = 3;
 
289
 
 
290
 
 
291
/* Plugins: */
 
292
 
 
293
program Semaphore {
 
294
    version V1 {
 
295
        void ping (void) = 0;
 
296
        
 
297
        _int64 hyper increment(longstring) = 1;     /* semaphore name */
 
298
        /* Increments the semaphore by 1, and returns the new semaphore
 
299
           value. If the semaphore does not exist, it is created with an
 
300
           initial value of 0, and 1 is returned.
 
301
        */
 
302
 
 
303
        _int64 hyper decrement(longstring, bool) = 3;
 
304
        /* Decrements the semaphore by 1, and returns the new value.
 
305
           A semaphore value cannot become negative. If the value is already
 
306
           0, the semaphore is not decremented, but -1 is returned. 
 
307
           If the semaphore does not exist,
 
308
           it is created with an initial value of 0, and -1 is returned.
 
309
 
 
310
           If the bool arg is true, and the semaphore is already 0, it is
 
311
           first waited until it is incremented again.
 
312
        */
 
313
 
 
314
        _int64 hyper get(longstring) = 4;
 
315
        /* Returns the value of the semaphore. If the semaphore does not
 
316
           exist a value of 0 is returned instead.
 
317
        */
 
318
 
 
319
        bool create(longstring, _int64 hyper, bool) = 5;
 
320
        /* Create the semaphore if it does not exist. The second arg is the
 
321
           initial value. Returns whether the semaphore has been created
 
322
           (true), or the semaphore already existed (false).
 
323
 
 
324
           The bool arg says whether the semaphore is protected.
 
325
           When the container finishes (or even crashes), the protected 
 
326
           semaphore is decremented by the number pi-d, where pi is
 
327
           the number of increments the container has requested,
 
328
           and d the number of decrements the container has requested.
 
329
 
 
330
           It is not possible to change the style of semaphores from 
 
331
           non-protected to protected or back after creation. 
 
332
           Implicitly created semaphores are always protected.
 
333
        */
 
334
 
 
335
        void destroy(longstring) = 6;
 
336
        /* Destroys this semaphore. Any waiting [decrement] operation gets
 
337
           immediately (-1) as return value.
 
338
        */
 
339
        
 
340
 
 
341
    } = 1;
 
342
} = 4;
 
343
 
 
344
 
 
345
enum shvar_enum {
 
346
    SHVAR_OK = 0,         /* success */
 
347
    SHVAR_BADTYPE = 1,    /* bad type */
 
348
    SHVAR_NOTFOUND = 2,   /* variable does not exist */
 
349
    SHVAR_EXISTS = 3,     /* variable exists */
 
350
    SHVAR_NOPERM = 4      /* no permission */
 
351
};
 
352
 
 
353
union shvar_code switch(shvar_enum d) {
 
354
 case SHVAR_OK: void;
 
355
 default: void;
 
356
};
 
357
 
 
358
union shvar_get switch(shvar_enum d) {
 
359
 case SHVAR_OK: 
 
360
     longstring value;
 
361
 default: 
 
362
     void;
 
363
};
 
364
 
 
365
 
 
366
 
 
367
 
 
368
program Sharedvar {
 
369
    version V1 {
 
370
        void ping(void) = 0;
 
371
 
 
372
        shvar_code create_var(longstring, bool, bool, longstring) = 1;
 
373
        /* create_var(var_name, own_flag, ro_flag, ty): Creates the variable 
 
374
           with
 
375
           an empty string
 
376
           as value. It is an error if the variable has already been created.
 
377
           Returns whether the function is successful (i.e. the variable
 
378
           did not exist before).
 
379
 
 
380
           own_flag: if true, the created variable is owned by the calling
 
381
           socket service.
 
382
           Only the caller can delete it, and when the last component of
 
383
           the socket service terminates, the variable is automatically 
 
384
           deleted.
 
385
 
 
386
           ro_flag: if true, only the owner can set the value
 
387
 
 
388
           ty: the type identifier ("string", or "exn")
 
389
        */
 
390
 
 
391
        shvar_code set_value(longstring, longstring, longstring) = 2;
 
392
        /* set_value(var_name, var_value, ty): Sets the variable var_name to
 
393
           var_value. This is only possible when the variable exists,
 
394
           and has the right type.
 
395
           Returns whether the function is successful (i.e. the variable
 
396
           exists).
 
397
        */
 
398
 
 
399
        shvar_get get_value(longstring, longstring) = 3;
 
400
        /* get_value(var_name, ty): Returns the value of the existing variable,
 
401
           or an error if the variable does not exist.
 
402
        */
 
403
 
 
404
        shvar_code delete_var(longstring) = 4;
 
405
        /* delete_var(var_name): Deletes the variable. This is only possible
 
406
           when the variable exists. Returns whether the function is 
 
407
           successful (i.e. the variable existed).
 
408
        */
 
409
 
 
410
        shvar_get wait_for_value(longstring, longstring) = 5;
 
411
        /* wait_for_value(var_name,ty): If the variable exists and
 
412
           set_value has already been called, the current value is
 
413
           simply returned. If the variable exists, but set_value has
 
414
           not yet been called, the function waits until set_value is
 
415
           called, and returns the value set then. If the variable
 
416
           does not exist, the function immediately returns NULL.
 
417
        */
 
418
 
 
419
        void dump(longstring, longstring) = 6;
 
420
        /* dump(var_name, log_level): Dump the access counter of this
 
421
           variable (or all variables if var_name="*"). log_level is
 
422
           the stringified log level
 
423
        */
 
424
 
 
425
    } = 1;
 
426
} = 5;
 
427