Patch to add new api to logsys to get priority names from subsystem names.
[openais.git] / include / rmd.h
blobd1cab381c4ec0173704374f06c1c03d6906bda17
1 /*
2 * Copyright (c) 2005 MontaVista Software, Inc.
4 * All rights reserved.
6 * Author: Steven Dake (sdake@mvista.com)
8 * This software licensed under BSD license, the text of which follows:
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither the name of the MontaVista Software, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef OPENAIS_RMD_H_DEFINED
35 #define OPENAIS_RMD_H_DEFINED
37 #include <netinet/in.h>
39 typedef unsigned int rmd_handle_t;
41 typedef enum {
42 RMD_DISPATCH_ONE,
43 RMD_DISPATCH_ALL,
44 RMD_DISPATCH_BLOCKING
45 } rmd_dispatch_t;
47 typedef enum {
48 RMD_OK = 1,
49 RMD_ERR_LIBRARY = 2,
50 RMD_ERR_TIMEOUT = 5,
51 RMD_ERR_TRY_AGAIN = 6,
52 RMD_ERR_INVALID_PARAM = 7,
53 RMD_ERR_NO_MEMORY = 8,
54 RMD_ERR_BAD_HANDLE = 9,
55 RMD_ERR_ACCESS = 11,
56 RMD_ERR_NOT_EXIST = 12,
57 RMD_ERR_EXIST = 14,
58 RMD_ERR_TOOBIG = 31
59 } rmd_error_t;
62 * This callback occurs when a synchronized read is executed
64 typedef void (*rmd_read_synchronized_t) (
65 rmd_invocation_t invocation,
66 void *key, void key_len,
67 void *data_conents, int data_len, int data_start);
70 * This callback occurs when a commit is completed after
71 * an rmd_commit_async call
73 typedef void (*rmd_commit_async_t) (
74 rmd_invocation_t invocation,
75 rmd_error_t error);
77 typedef struct {
78 rmd_read_synchronized_t rmd_read_synchronized;
79 rmd_commit_async_t rmd_commit_async;
80 } rmd_callbacks_t;
83 * Create a new replicated memory database connection
85 rmd_error_t rmd_initialize (
86 rmd_handle_t *handle,
87 rmd_callbacks_t *callbacks);
90 * Close a replicated memory database connection
92 rmd_error_t rmd_finalize (
93 rmd_handle_t *handle);
96 * Get a file descriptor on which to poll. rmd_handle_t is NOT a
97 * file descriptor and may not be used directly.
99 rmd_error_t rmd_fd_get (
100 rmd_handle_t *handle,
101 int *fd);
104 * Dispatch synchronized reads and async commitments
106 rmd_error_t rmd_dispatch (
107 rmd_handle_t *handle,
108 rmd_dispatch_t dispatch_types);
111 * Abort all updates in the currently outstanding transaction
113 rmd_error_t rmd_abort (
114 rmd_handle_t *handle);
117 * Commit all updates for the transaction to the cluster. Commit
118 * blocks until committed data is replicated to all processors.
120 rmd_error_t rmd_commit (
121 rmd_handle_t *handle);
124 * Commit all updates for the transaction to the cluster. Call returns
125 * immediately and response of commitment complete (or error) comes in
126 * callback
128 rmd_error_t rmd_commit_async (
129 rmd_handle_t *handle,
130 rmd_handle_t *invocation);
133 * Read the value for a key without synchronizing within the
134 * transaction. This offers optimal performance. If rmd_commit has not
135 * been called for write operations, rmd_read will only return committed
136 * data.
138 rmd_error_t rmd_read (
139 rmd_handle_t *handle,
140 void *key_name, int key_len,
141 void *data_contents, int data_contents_size, int data_start,
142 int *data_len);
145 * Write a key/value pair to the cluster, but only when the trasaction
146 * is commited with rmd_commit. If key/value * doesn't exist create it.
148 rmd_error_t rmd_write (
149 rmd_handle_t *handle,
150 void *key_name, int key_len,
151 void *data_contents, int data_len, int data_start);
154 * Read the value for a key and synchronize the read within the
155 * transaction. The read data is deliver by callback. Callbacks
156 * are uniquely identified by invocation which is set by the API.
158 rmd_error_t rmd_read_synchronized (
159 rmd_handle_t *handle,
160 rmd_invocation_t *invocation,
161 void *key_name, int key_len,
162 void *data_contents, int data_contents_size, int data_start,
163 int *data_len);
166 * Delete a key and value pair. Operation occurs immediately.
168 rmd_error_t rmd_delete (
169 rmd_handle_t *handle,
170 void *key_name, int key_len);
172 #endif /* OPENAIS_RMD_H_DEFINED */