]> git.proxmox.com Git - mirror_ovs.git/blob - ovsdb/trigger.h
Eliminate "whitelist" and "blacklist" terms.
[mirror_ovs.git] / ovsdb / trigger.h
1 /* Copyright (c) 2009, 2011, 2012 Nicira, Inc.
2 *
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 #ifndef OVSDB_TRIGGER_H
17 #define OVSDB_TRIGGER_H 1
18
19 #include "openvswitch/list.h"
20
21 struct ovsdb;
22
23 /* Triggers have the following states:
24 *
25 * - Initialized (reply == NULL, progress == NULL): Executing the trigger
26 * can keep it in the initialized state, if it has a "wait" condition that
27 * isn't met. Executing the trigger can also yield an error, in which
28 * case it transitions to "complete". Otherwise, execution yields a
29 * transaction, which the database attempts to commit. If the transaction
30 * completes immediately and synchronously, then the trigger transitions
31 * to the "complete" state. If the transaction requires some time to
32 * complete, it transitions to the "committing" state.
33 *
34 * - Committing (reply != NULL, progress != NULL): The transaction is
35 * committing. If it succeeds, or if it fails permanently, then the
36 * trigger transitions to "complete". If it fails temporarily
37 * (e.g. because someone else committed to cluster-based storage before we
38 * did), then we transition back to "initialized" to try again.
39 *
40 * - Complete (reply != NULL, progress == NULL): The transaction is done
41 * and either succeeded or failed.
42 */
43 struct ovsdb_trigger {
44 /* In "initialized" or "committing" state, in db->triggers.
45 * In "complete", in session->completions. */
46 struct ovs_list node;
47 struct ovsdb_session *session; /* Session that owns this trigger. */
48 struct ovsdb *db; /* Database on which trigger acts. */
49 struct jsonrpc_msg *request; /* Database request. */
50 struct jsonrpc_msg *reply; /* Result (null if none yet). */
51 struct ovsdb_txn_progress *progress;
52 long long int created; /* Time created. */
53 long long int timeout_msec; /* Max wait duration. */
54 bool read_only; /* Database is in read only mode. */
55 char *role; /* Role, for role-based access controls. */
56 char *id; /* ID, for role-based access controls. */
57 };
58
59 bool ovsdb_trigger_init(struct ovsdb_session *, struct ovsdb *,
60 struct ovsdb_trigger *,
61 struct jsonrpc_msg *request, long long int now,
62 bool read_only, const char *role, const char *id);
63 void ovsdb_trigger_destroy(struct ovsdb_trigger *);
64
65 bool ovsdb_trigger_is_complete(const struct ovsdb_trigger *);
66 struct jsonrpc_msg *ovsdb_trigger_steal_reply(struct ovsdb_trigger *);
67 void ovsdb_trigger_cancel(struct ovsdb_trigger *, const char *reason);
68
69 void ovsdb_trigger_prereplace_db(struct ovsdb_trigger *);
70
71 bool ovsdb_trigger_run(struct ovsdb *, long long int now);
72 void ovsdb_trigger_wait(struct ovsdb *, long long int now);
73
74 #endif /* ovsdb/trigger.h */