Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController Class Reference
Inheritance diagram for de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController:
de.fu_berlin.inf.dpp.whiteboard.sxe.AbstractSXEMessageHandler de.fu_berlin.inf.dpp.whiteboard.sxe.ISXEMessageHandler

List of all members.

Classes

class  MappedList< T >

Public Types

enum  State { DISCONNECTED, INIT, CONNECTING, CONNECTED }

Public Member Functions

 SXEController (ISXERecordFactory factory)
DocumentRecord getDocumentRecord ()
void setDisconnected ()
void clear ()
void initNetwork (ISXETransmitter transmitter)
void startSession ()
void startSession (SXEMessage message)
void executeRemoteRecords (SXEMessage message)
final void executeAndCommit (List< IRecord > records)
void commitRecords (List< IRecord > recordsToSend)
boolean isConnected ()
ISXETransmitter getTransmitter ()
String prefix ()
ISXERecordFactory getRecordFactory ()
SXESession getSession ()
boolean switchToConnectingState (SXESession session)
State getState ()
void dispose ()

Protected Member Functions

void initDocument ()
boolean apply (RecordDataObject rdo)
void applyNullRecord (SetRecord toConflict)
void applyLocallyAndsentConflictingSetRecord (SetRecord toConflict)
boolean handleVersionDiff (SetRecord r, boolean startSync)
void applyQueuedRecords (IRecord cause)
boolean apply (IRecord record)

Protected Attributes

DocumentRecord document
ISXERecordFactory recordFactory
SXESession session = null
State connectionState
ISXETransmitter transmitter
List< SXEMessagequeuedMessagesWhileSynchronizing = new LinkedList<SXEMessage>()
MappedList< RecordDataObjectunappliedMissingTargetRecords = new MappedList<RecordDataObject>()
MappedList< SetRecordunappliedBigVersionSetRecords = new MappedList<SetRecord>()

Detailed Description

Central part of an SXE session that maintains the document.

To its functionalities belongs:

  • maintain state of the controller during session negotiation
  • applying a local list of records
  • applying a remote SXE message
  • queue incoming messages while synchronizing and apply them on finish
  • queue out-of-order (non-causal-ready) records to apply them when possible
Author:
jurke

Member Enumeration Documentation

Enumerator:
DISCONNECTED 
INIT 
CONNECTING 
CONNECTED 

Constructor & Destructor Documentation

de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.SXEController ( ISXERecordFactory  factory)

Member Function Documentation

boolean de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.apply ( RecordDataObject  rdo) [protected]

This method attempts to convert a RecordDataObject to the corresponding record that will be applied then.

If a RecordDataObject is not casual ready (parent, target or predecessor SetRecord is missing), it will be queued. The only exception are SetRecords during start synchronization where missing records (==version) are expected due to possible previous conflicts.

Parameters:
rdo
Returns:
whether the RecordDataObject could be applied
boolean de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.apply ( IRecord  record) [protected]

Attempts to apply the passed record. If successful it will apply all queued records that became casual ready now.

Parameters:
record
Returns:
whether the passed record could be applied
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.applyLocallyAndsentConflictingSetRecord ( SetRecord  toConflict) [protected]

This method sends a SetRecord to all peers that conflicts with the provided one so that this will be reverted to a previous version. This may be necessary, if due to concurrent SetRecords the XML document would not be well-formed anymore due to a circular relationship.

Parameters:
toConflict
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.applyNullRecord ( SetRecord  toConflict) [protected]
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.applyQueuedRecords ( IRecord  cause) [protected]

Checks whether the provided record makes any queue record casual ready.

Parameters:
cause
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.clear ( )
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.commitRecords ( List< IRecord recordsToSend)

Pack the records in a message and send it to all peers in the session

Parameters:
recordsToSend
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.dispose ( )
final void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.executeAndCommit ( List< IRecord records)

This method is to be used by commands to apply locally created records.

It will apply them, notify local listeners and if applying was successful transmit them to the peers.

Parameters:
records
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.executeRemoteRecords ( SXEMessage  message)

Attempts to apply the records of a remote message

Parameters:
messagemessage containing records to apply
DocumentRecord de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.getDocumentRecord ( )
ISXERecordFactory de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.getRecordFactory ( )
SXESession de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.getSession ( )
State de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.getState ( )
ISXETransmitter de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.getTransmitter ( )
boolean de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.handleVersionDiff ( SetRecord  r,
boolean  startSync 
) [protected]

Method to take actions if a remote SetRecord has wrong version.

This may be expected behavior:

During start synchronization SetRecords may be missing (received version is too big) because they were discarded remotely due to previous conflicts.

In a session, there may arise conflicts (received version is too small).

Everything else is an error, while no action has to be taken during start synchronization but remote records must be queued to wait for the SetRecord with the missing version to arrive.

Parameters:
r
startSync
Returns:
whether the difference is handled and the record should not be applied
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.initDocument ( ) [protected]
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.initNetwork ( ISXETransmitter  transmitter)
boolean de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.isConnected ( )
String de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.prefix ( )
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.setDisconnected ( )
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.startSession ( SXEMessage  message)

Accepts a remote state and applies it to this controller, discarding the previous content.

Queues messages will be applied afterwards and the lists is cleared.

Parameters:
messagethe state message
void de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.startSession ( )

Initializes the session as host and starts to receive records from NOW.

boolean de.fu_berlin.inf.dpp.whiteboard.sxe.SXEController.switchToConnectingState ( SXESession  session)

Attempts to change the state to State#CONNECTING. If successful, this will initialize to receive remote records from NOW.

Parameters:
session
Returns:
whether the state change was successful

Member Data Documentation

a factory to create custom record instances

A predecessor of these SetRecords is missing

A target of a record is missing and it is supposed to be "on the way"

 All Classes Namespaces Files Functions Variables Enumerations