]> git.proxmox.com Git - mirror_ovs.git/blame - ovsdb/trigger.h
dist-docs: Include manpages generated from rST.
[mirror_ovs.git] / ovsdb / trigger.h
CommitLineData
b4e8d170 1/* Copyright (c) 2009, 2011, 2012 Nicira, Inc.
f85f8ebb
BP
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
b19bab5b 19#include "openvswitch/list.h"
f85f8ebb
BP
20
21struct ovsdb;
22
1b1d2e6d
BP
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 */
f85f8ebb 43struct ovsdb_trigger {
1b1d2e6d
BP
44 /* In "initialized" or "committing" state, in db->triggers.
45 * In "complete", in session->completions. */
46 struct ovs_list node;
e317253b 47 struct ovsdb_session *session; /* Session that owns this trigger. */
b4e8d170 48 struct ovsdb *db; /* Database on which trigger acts. */
53178986
BP
49 struct jsonrpc_msg *request; /* Database request. */
50 struct jsonrpc_msg *reply; /* Result (null if none yet). */
1b1d2e6d 51 struct ovsdb_txn_progress *progress;
f85f8ebb
BP
52 long long int created; /* Time created. */
53 long long int timeout_msec; /* Max wait duration. */
e51879e9 54 bool read_only; /* Database is in read only mode. */
d6db7b3c
LR
55 char *role; /* Role, for role-based access controls. */
56 char *id; /* ID, for role-based access controls. */
f85f8ebb
BP
57};
58
53178986 59bool ovsdb_trigger_init(struct ovsdb_session *, struct ovsdb *,
b4e8d170 60 struct ovsdb_trigger *,
53178986
BP
61 struct jsonrpc_msg *request, long long int now,
62 bool read_only, const char *role, const char *id);
f85f8ebb
BP
63void ovsdb_trigger_destroy(struct ovsdb_trigger *);
64
65bool ovsdb_trigger_is_complete(const struct ovsdb_trigger *);
53178986 66struct jsonrpc_msg *ovsdb_trigger_steal_reply(struct ovsdb_trigger *);
1b1d2e6d 67void ovsdb_trigger_cancel(struct ovsdb_trigger *, const char *reason);
f85f8ebb 68
53178986
BP
69void ovsdb_trigger_prereplace_db(struct ovsdb_trigger *);
70
71bool ovsdb_trigger_run(struct ovsdb *, long long int now);
f85f8ebb
BP
72void ovsdb_trigger_wait(struct ovsdb *, long long int now);
73
74#endif /* ovsdb/trigger.h */