Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Gemstone Notifications



Gemstone Notifications. Implementation of an abstract Gemstone notification mechanism. Alfred Wullschleger

Gemstone Notifications. Implementation of an abstract Gemstone notification mechanism. Alfred Wullschleger
ESUG 2006, Prague



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds


Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Gemstone Notifications Gemstone Notifications Presentation Transcript

    • abcdefg Gemstone Notifications Implementation of an abstract Gemstone notification mechanism presented by Alfred Wullschleger Swiss National Bank
    • abcdefg The Author ● Smalltalker since 1992 ● Project OVID at Fides Informatik (1992-1999) – OVID currently in production more than 11 years ● Project OASE at Swiss National Bank (since 1999 in production) – Financial Statistics from Swiss Banks and Companies – based on Gemstone/S and VisualWorks – ongoing development under full production awu060710 2
    • abcdefg Gemstone Notification Basics ● a GS session declares interest in change notification for anObject by: – System addToNotifySet: anObject ● whenever anObject changes and is commited (typically by another session), execution of – System signaledObjects ● returns an array including anObject and the signaledObjects are cleared by this operation ● by this you can poll for changed objects if you like awu060710 3
    • abcdefg Gemstone Notification Handler ● using – System enableSignaledObjectsError ● allows for the following Gemstone exception: – Exception installStaticException: [:theException :cat :num :args | „... do here whatever is interesting... „ System enableSignaledObjectsError] category: GemStoneError number: (ErrorSymbols at: #rtErrSignalCommit). awu060710 4
    • abcdefg Goal: Abstract Notification ● We want to have a highly standardized way of notification – do not use the objects, that are just there from application perspective ● it has to be fully conflict free – any session can commit independently – there can be as many notifiers as you like awu060710 5
    • abcdefg Mechanisms „Event Side“: „Event Handler Side“: Objects that are committed a Session, that wants to and want to inform know, when certain Objects other Objects are changed and commited about this uses a TpzNotificationReceiver use tpzNotify as an „Event“ as „Event handler“ mediated by a TpzNotification to execute the necessary actions complete separation of Generation and Handling awu060710 6
    • abcdefg Event Side: 2 Classes ● TpzNotification – notifierSymbol: defines a notification by a symbol – sessionValues: ● an array of size System maxSessionId. ● containing a TpzNotificationElement for each possible session ● TpzNotificationElement – has a value (anInteger) and a sessionId. The sessionId is used for quick lookup in the sessionValues awu060710 7
    • abcdefg Event Side: Notification ● TpzNotification>>tpzNotify – (sessionValues at: System session) tpzNotify ● TpzNotificationElement>>tpzNotify – value := value + 1 ● could also use value := value not ● since all parallel GS sessions have different sessionIds, there cannot occur any collision ● since index lookup in the array is fast, no problem even for 1000 sessions awu060710 8
    • abcdefg Handler Side: 2 Classes ● Where do we put TpzNotificationReceivers (the handlers for the notifications)? – into session state – can use index 20 (user slot in session state) ● define a holder for all notificationReceivers: TpzNotificationReceiverCollection – collects all notification receivers – implements the notification exception – dispatches notifications to the corresponding receivers awu060710 9
    • abcdefg TpzNotificationReceiver ● Defines a process loop, which is activated by its corresponding TpzNotification – registerForNotification: aSymbol ● gets the corresponding TpzNotification ● inits the process loop ● inserts itself into the TpzNotificationReceiverCollection ● executes the first update awu060710 10
    • abcdefg TpzNotificationReceiverCollection ● main Methods: – addNotificationReceiver: aNotificationReceiver receivers at: aNotificationReceiver class put: aNotificationReceiver – notifierSignaled | notelems | notelems := System signaledObjects. receivers do: [:each | each notifierSignaled: notelems]. ● called from the exception awu060710 11
    • abcdefg Dispatch of signaledObjects ● in TpzNotificationReceiver: ● notifierSignaled: signaledObjects (tpzNotification hasSignaledObjects: signaledObjects) ifFalse: [signalingInformation := nil. ^self]. signalingInformation := signaledObjects. processSemaphore signal ● in TpzNotification: ● hasSignaledObjects: signaledObjects signaledObjects detect: [ :elem | (sessionValues at: elem sessionId ) == elem ] ifNone: [ ^false ]. ^true ● is quick, since typically few signaledObjects awu060710 12
    • abcdefg Receivers for specific Notifications ● each specific receiver is a subclass of TpzNotificationReceiver – must implement 2 methods: ● class side: notifierSymbol – to declare, which Notification is accepted by this receiver ● instance side: executeUpdateFromNotification – the activation of the code for which the notification is all about awu060710 13
    • abcdefg Demo ● We have two Handlers for the same notifierSymbol #SimpleNotification: – SimpleNotificationHandler ● waits 15 seconds, then returns a string – SecondSimpleNotificationHandler ● waits 5 seconds, then returns some other string – during the waiting, the results of the handlers are nil awu060710 14
    • abcdefg Thank you for listening Questions? awu060710 15