Project Demo Grid Notification - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Project Demo Grid Notification

Description:

provides clients real-time stock info based on stock ticker. ... Get real-time stock info from yahoo base on stock ticker(symbol) ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 21
Provided by: itU6
Category:

less

Transcript and Presenter's Notes

Title: Project Demo Grid Notification


1
Project Demo-Grid Notification
  • Presentation by
  • Ben Zhang

2
Overview
  • Project summary
  • Notification Concept
  • Go through steps of implementing a notification
    grid service
  • Demo

3
Project Objective
  • Show how Grid Notification works
  • Idea
  • Implement a Grid Service with a notification SDE.
    This Grid Service provides clients with stock
    quote and has a notification SDE storing the
    recent queried stock info. If there is a change,
    its subscribed clients should get the
    notification.

4
Background
  • What are notification
  • When there are some changes of service, the
    observable notifies all its subscribed observers
    of the changes.
  • Notification approach
  • Push approachallow data to travel along with the
    notification
  • Pull approach data not travel along with the
    notification.

5
Notification in GT3
  • Notification in GT3 is closely related to service
    data. The clients don't subscribe to a whole
    service, but to a particular Service Data Element
    (SDE) in that service.
  • Whenever a change happens the service will ask
    the SDE to notify its subscribers.
  • GT3 only supports push notification. But a pull
    notification can be implemented by subscribing to
    a 'dummy SDE' with no data.

6
Notification in GT3
  • addListener This call subscribes the calling
    client to a particular SDE.
  • notifyChange Whenever a change happens, the
    GridService will ask the SDE to notify its
    subscribers.
  • deliverNotification The SDE notifies the
    subscribers that a change had happened.

7
StockQuote Grid Service
  • StockQuote Grid Service
  • provides clients real-time stock info based on
    stock ticker. The info includes stocks last
    price, date, time, change, open price,daily
    high,daily low, volume, etc.
  • Notification SDE
  • stores the last stock info queried by clients
  • has the follows fields
  • Stock symbol
  • Last price
  • Date
  • time

8
Step1-define interface
  • Define the service interface
  • extends"ogsiGridService ogsiNotificationSource"
    , extend from a standard portType called
    NotificationSource which includes
    notification-related operations.
  • Other changes comparing to our MathServiceSD
    service
  • targetNamespacehttp//www.globus.org/namespa
    ces/bxz01Assignments/StockQuoteService
  • xmlnstnshttp//www.globus.org/namespaces/bx
    z01Assignments/StockQuoteService
  • xmlnsdatahttp//www.globus.org/namespaces/b
    xz01Assignments/StockQuoteService/StockSDE
  • namespace"http//www.globus.org/namespaces/b
    xz01Assignments/StockQuoteService/StockSDE"/

9
Step 2-service implementation
  • Get real-time stock info from yahoo base on stock
    ticker(symbol).
  • http//finance.yahoo.com/d/quotes.csv?e.csvfsl1
    d1t1c1ohgvsYHOO
  • In the link, fsl1d1t1c1ohgv defines the format
    of querying result. (S-symbol, l-lastprice,
    d-date, t-time, c-change, o-openprice,
    h-dailyhigh, g-dailylow,v-volume)
  • For example
  • "YHOO",37.99,"11/29/2004","306pm",0.18,38.07,38.
    24,37.50,10358000

10
Step2- (continue)
  • When there is a change of StockDataSDE,
    StockDataSDE notify all its subscribers through
    notifyChange() method.
  • public void setSymbol(String symbol) throws
    RemoteException
  • this.symbol symbol.toUpperCase()
  • getQuote() StockDataValue.setSymbol(symbol)
  • StockDataValue.setLastPrice(Double.parseDouble
    (lastPrice)) StockDataValue.setDate(date1)
    StockDataValue.setTime(time1)
  • StockDataSDE.notifyChange()

11
Step3- Deployment Descriptor
  • xmlnshttp//xml.apache.org/axis/wsdd/
  • xmlnsjavahttp//xml.apache.org/axis/wsdd/provide
    rs/java
  • e" provider"Handler" style"wrapped"
  • (with notification)"/
  • value"bxz01Assignments.services.StockQuoteService
    .impl.StockQuoteImpl"/
  • nts.stubs.StockQuoteService.StockPortType"/
  • Assignments/StockQuoteService/StockQuote_service.w
    sdl"/
  • value"org.globus.ogsa.impl.ogsi.NotificationSourc
    eProvider"/
  • value"org.globus.ogsa.handlers.RPCURIProvider"/

12
Step 4- compile and deploy
  • build the service
  • ./build.sh bxz01Assignments/services/StockQuoteSer
    vice schema/bxz01Assignments/StockQuoteService/Sto
    ckQuote.gwsdl
  • Deploy
  • ant deploy -Dgar.name/home/bxz01/GridServices/bui
    ld/lib/bxz01Assignments_services_StockQuoteService
    .gar

13
Step 5- Client Listener
  • Class declaration
  • public class ClientListener extends
    ServicePropertiesImpl implements
    NotificationSinkCallback
  • extends ServicePropertiesImpl
  • This class is the base class of GridServiceImpl
    which is intended for the server-side of our
    application. Atually, our "client" is both a
    client and a server, because it is going to make
    calls to StockQuoteService (to subscribe to the
    StockDataSDE), but also receive them
    (deliverNotification). So, our client needs a
    server infrastructure, which the
    ServicePropertiesImpl class provides.
  • implements NotificationSinkCallback
  • This interface must be implemented by classes
    that wish to subscribe to notifications. A
    deliverNotification method which is called by the
    Grid Service when a change is produced

14
Step 5- (continue)
  • Subscribe to a SDE.
  • Can be done by NotificationSinkManager. Two
    simple steps startListening and addListener
  • NotificationSinkManager
    notifManager NotificationSinkManager.getManager(
    )
  • notifManager.startListening(Notifi
    cationSinkManager.MAIN_THREAD)
  • String sink
    notifManager.addListener("StockData", null, GSH,
    this)
  • addListener method specifies which service and
    SDE the client should subscribe. The parameters
    are follows
  • The Service Data Element we want to subscribe to.
  • A timeout (null--if we don't want to stop
    listening)
  • The GSH of the Grid Service that has the Service
    Data Element we want to subscribe to
  • The class which will take care of receiving the
    notifications

15
Step 5- (continue )
  • Implement deliverNotification method
  • public void deliverNotification(ExtensibilityType
    any) throws RemoteException
  • try
  • // Service Data has changed. Show new
    data.
  • ServiceDataValuesType serviceData
    AnyHelper.getAsServiceDataValues(any)
  • StockDataType StockData (StockDataType)
    AnyHelper.getAsSingleObject(serviceData,
    StockDataType.class)
  • // Write service data
  • System.out.println("Current stock info
    ")
  • System.out.println("symbol "
    StockData.getSymbol())
  • System.out.println("lastPrice "
    StockData.getLastPrice())
  • System.out.println("Date "
    StockData.getDate())
  • System.out.println("Time "
    StockData.getTime())
  • catch(Exception exc)
  • System.out.println("ERROR!")
  • exc.printStackTrace()

16
Step 5- (continue )
  • Unsubscribe client
  • // Stop listening
  • notifManager.removeListener(sink)
  • notifManager.stopListening()

17
Step 6 run command
  • Compile client
  • javac -classpath ./build/classes/CLASSPATH
    bxz01Assignments/clients/StockQuoteService/ClientL
    istener.java
  • Start container
  • globus-start-container -p 30000
  • Run client
  • java -classpath ./build/classes/CLASSPATH
    -Dorg.globus.ogsa.schema.roothttp//localhost300
    00/ bxz01Assignments.clients.StockQuoteService.Cli
    entListener http//talon.csce.uark.edu30000/ogsa/
    services/bxz01Assignments/StockQuoteService
  • Notice we have to define a property called
    org.globus.ogsa.schema.root.

18
StockQuote Demo
19
References
  • http//www.casa-sotomayor.net/gt3-tutorial/multipl
    ehtml/ch06s01.html
  • http//www-unix.globus.org/toolkit/docs/3.2/core/

20
Questions?
Write a Comment
User Comments (0)
About PowerShow.com