Top | ![]() |
![]() |
![]() |
![]() |
InfAdoptedSessionInfAdoptedSession — Session handling concurrency control via the adOPTed algorithm. |
InfIo * | inf_adopted_session_get_io () |
InfAdoptedAlgorithm * | inf_adopted_session_get_algorithm () |
void | inf_adopted_session_broadcast_request () |
void | inf_adopted_session_undo () |
void | inf_adopted_session_redo () |
gboolean | inf_adopted_session_read_request_info () |
void | inf_adopted_session_write_request_info () |
InfAdoptedAlgorithm * | algorithm | Read |
InfIo * | io | Read / Write / Construct Only |
guint | max-total-log-size | Read / Write / Construct Only |
InfAdoptedSession handles concurrency control with an InfAdoptedAlgorithm on top of a InfSession. It takes care of sending all necessary information to joining users, receives requests from the network (passing them to InfAdoptedAlgorithm) and transfers local requests to the other users. It also makes sure to periodically send the state the local host is in to other uses even if the local users are idle (which is required for others to cleanup their request logs and request caches).
InfIo *
inf_adopted_session_get_io (InfAdoptedSession *session
);
Returns the InfIo object of session
.
InfAdoptedAlgorithm *
inf_adopted_session_get_algorithm (InfAdoptedSession *session
);
Returns the InfAdoptedAlgorithm object of session
. Returns NULL
if
session
has status INF_SESSION_PRESYNC
or INF_SESSION_SYNCHRONIZING
because there the algorithm object is not yet created before successful
synchronization.
void inf_adopted_session_broadcast_request (InfAdoptedSession *session
,InfAdoptedRequest *request
);
Sends a request to all subscribed connections. The request should originate
from a call to inf_adopted_algorithm_generate_request()
, with
session
's InfAdoptedAlgorithm.
void inf_adopted_session_undo (InfAdoptedSession *session
,InfAdoptedUser *user
,guint n
);
This is a shortcut for creating n
undo requests and broadcasting them.
If n
> 1 then this is also more efficient.
void inf_adopted_session_redo (InfAdoptedSession *session
,InfAdoptedUser *user
,guint n
);
This is a shortcut for creating n
redo requests and broadcasting them.
If n
> 1 then this is also more efficient.
gboolean inf_adopted_session_read_request_info (InfAdoptedSession *session
,xmlNodePtr xml
,InfAdoptedStateVector *diff_vec
,InfAdoptedUser **user
,InfAdoptedStateVector **time
,xmlNodePtr *operation
,GError **error
);
This function reads common information such as the state vector the request was made and the user that made the request from XML. It is most likely to be used by implementations of the xml_to_request virtual function.
session |
||
xml |
The XML to read the data from. |
|
diff_vec |
The reference vector of the time vector of the request, or |
|
user |
Location to store the user of
the request, or |
[out][transfer none][allow-none] |
time |
Location to store the state the
request was made, or |
[out][transfer full][allow-none] |
operation |
Location to store the
operation of the request, or |
[out][transfer none][allow-none] |
error |
Location to place an error, if any. |
void inf_adopted_session_write_request_info (InfAdoptedSession *session
,InfAdoptedRequest *request
,InfAdoptedStateVector *diff_vec
,xmlNodePtr xml
,xmlNodePtr operation
);
This function writes common data from request
, such as the user that
issued the request and the state in which the request was made into xml
.
If diff_vec
is given, then the state is written as a diff to this vector,
see inf_adopted_state_vector_to_string_diff()
. Deserializing this data
again (via inf_adopted_session_read_request_info()
) requires the same
diff_vec
then.
This function is most likely to be used by implementations of the request_to_xml virtual function.
session |
||
diff_vec |
A reference state vector, or |
|
request |
The InfAdoptedRequest whose info to write. |
|
xml |
The XML node to write the data into. |
|
operation |
An XML node representing the operation of the request, or
|
Error codes for InfAdoptedSession. These only occur when invalid requests are received from the network.
The "user" field in a request message does not contain a valid user ID. |
||
A request message does not contain an operation. |
||
A request in a synchronized request log is invalid. Invalid means that it is not the request that was issued after the previous request in the log, or that it is an Undo or Redo request without a request to Undo or Redo, respectively. |
||
A synchronized user does not contain that the state that user currently is in. |
||
No further specified error code. |
struct InfAdoptedSession;
InfAdoptedSession is an opaque data type. You should only access it via the public API functions.
struct InfAdoptedSessionClass { InfAdoptedRequest*(*xml_to_request)(InfAdoptedSession* session, xmlNodePtr xml, InfAdoptedStateVector* diff_vec, gboolean for_sync, GError** error); void(*request_to_xml)(InfAdoptedSession* session, xmlNodePtr xml, InfAdoptedRequest* request, InfAdoptedStateVector* diff_vec, gboolean for_sync); /* Signals */ gboolean(*check_request)(InfAdoptedSession* session, InfAdoptedRequest* request, InfAdoptedUser* user); };
Virtual functions and default signal handlers for InfAdoptedSession.
Virtual function to deserialize an InfAdoptedRequest
from XML. The implementation of this function can use
|
||
Virtual function to serialize an InfAdoptedRequest
to XML. This function should add properties and children to the given XML
node. At might use |
||
Default signal handler of the InfAdoptedSession::check-request signal. |
“algorithm”
property“algorithm” InfAdoptedAlgorithm *
The adOPTed algorithm used for translating incoming requests.
Owner: InfAdoptedSession
Flags: Read
“io”
property“io” InfIo *
The IO object used for timeouts.
Owner: InfAdoptedSession
Flags: Read / Write / Construct Only
“check-request”
signalgboolean user_function (InfAdoptedSession *session, InfAdoptedRequest *request, InfAdoptedUser *user, gpointer user_data)
This signal is emitted whenever the session received a request from a
non-local user. It is used to decide whether the request should be
processed or not. Note that generally not processing a request results is
loss of synchronization, since other hosts might process the request.
Only if the same condition can be applied on all sites a request should
be rejected. Another possibility is to reject a request at a central host
before it gets distributed to all other clients. If there is one signal
handler returning TRUE
the request is rejected, i.e. only if all signal
handlers return FALSE
it is accepted.
session |
The InfAdoptedSession which is about to process a request. |
|
request |
The request to be processed. |
|
user |
The user who issued the request. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last