Difference between revisions of "Synchronize Blocks"

From PresenceWiki
Jump to: navigation, search
Line 34: Line 34:
  
 
Synchronization Blocks are managed by the [[Database Server]]. A TCP/IP socket service listens for lock requests (from the Start Synch Block node) and returns the lock immediately, if no other threads hold the lock, or waits until the lock is free and then returns it. It also listens for cancel lock requests which are generated by the End Synch Block node.
 
Synchronization Blocks are managed by the [[Database Server]]. A TCP/IP socket service listens for lock requests (from the Start Synch Block node) and returns the lock immediately, if no other threads hold the lock, or waits until the lock is free and then returns it. It also listens for cancel lock requests which are generated by the End Synch Block node.
 +
 +
 +
{{FlowControl}}

Revision as of 16:47, 7 March 2012

Synchronize blocks (available in version 3.7 and onwards) are useful for situations where parts of different Tasks must not run simultaneously. A Synchronize Block consists of a Start Synch Block node and an End Synch Block node. Both nodes have a lock key, which is guaranteed to only be held by one Synchronize Block at a time. This is illustrated below:

http://www.international-presence.com/wikidocs/images/synch_illustration.png


Synchronize Blocks are managed by a service that runs as part of the Presence database server. When a Start Synch Block node is encountered, it sends a message to the service requesting an exclusive lock based on the key provided (this can be dynamic and based on your data). If no other Tasks have managed to obtain this lock, it will be returned immediately. If another Task (or Thread within the same Task) currently has that lock, it will wait until that lock is released before continuing. When the End Synch Block node executes it will release the lock so that any waiting Tasks can continue.


Managing Synchronize Locks

To view a list of currently held locks, in the Presence Task Administrator select Server > Manage Synchronize Locks from the top menu:

http://www.international-presence.com/wikidocs/images/manage_synch_locks.png

The following columns are displayed in the table. Click on a column header to sort the locks by that criteria.

Server Name

This is the hostname of the Presence server that owns the lock.

Task

This is the name of the Task that owns the lock.

Identifier

This is the parsed text key associated with this lock.

Time obtained

Displays the time and date at which the lock was obtained in the format "HH:mm:ss.SSS dd MMM yyyy".

Note that this operation is only available for users that have "Administrator" rights in Presence.

The "Clear All" and "Clear Selected" buttons allow you to prematurely clear the lock(s), freeing any Tasks which are waiting for them. This is useful if a Task is stuck during its normal operation, for example if it is waiting for a remote service to return.

Server Mechanics

Synchronization Blocks are managed by the Database Server. A TCP/IP socket service listens for lock requests (from the Start Synch Block node) and returns the lock immediately, if no other threads hold the lock, or waits until the lock is free and then returns it. It also listens for cancel lock requests which are generated by the End Synch Block node.


Task Elements > Flow Control Task Elements > Synchronize Blocks

Schedule Nodes | Decision Point Nodes | Start of Task | End of Task | Error Handler
Throw Exception | Passive Node | Log Entry | Sleep For n Seconds | While Node | Loop Node | Exit Loop Node | |Switch Node
Fork Execution | Join Forked Threads | Start Synch Block | End Synch Block | Event Notification Nodes



Task Elements | Resources