Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project Demo- Grid Notification Presentation by: Ben Zhang.

Similar presentations


Presentation on theme: "Project Demo- Grid Notification Presentation by: Ben Zhang."— Presentation transcript:

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 approach:allow 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 1.addListener: This call subscribes the calling client to a particular SDE. 2.notifyChange: Whenever a change happens, the GridService will ask the SDE to notify its subscribers. 3.deliverNotification: The SDE notifies the subscribers that a change had happened.

7 StockQuote Grid Service – provides clients real-time stock info based on stock ticker. The info includes stock ’ s 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: –, extend from a standard portType called NotificationSource which includes notification-related operations. Other changes comparing to our MathServiceSD service: <definitions name="StockQuoteService“ targetNamespace=http://www.globus.org/namespaces/bxz01Assignments/StockQuoteService xmlns:tns=http://www.globus.org/namespaces/bxz01Assignments/StockQuoteService xmlns:data=http://www.globus.org/namespaces/bxz01Assignments/StockQuoteService/StockSDE … <import location="StockSDE.xsd“ namespace="http://www.globus.org/namespaces/bxz01Assignments/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=.csv&f=sl1d1t 1c1ohgv&s=YHOO In the link, f=sl1d1t1c1ohgv 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","3:06pm",+0.18,38.07,3 8.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 <deployment name="defaultServerConfig" xmlns=http://xml.apache.org/axis/wsdd/ xmlns:java=http://xml.apache.org/axis/wsdd/providers/java

12 Step 4- compile and deploy build the service –./build.sh bxz01Assignments/services/StockQuoteService schema/bxz01Assignments/StockQuoteService/StockQ uote.gwsdl Deploy –ant deploy - Dgar.name=/home/bxz01/GridServices/build/lib/bxz01 Assignments_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(NotificationSinkManager.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/ClientListener.java Start container globus-start-container -p 30000 Run client java -classpath./build/classes/:$CLASSPATH - Dorg.globus.ogsa.schema.root=http://localhost:30000/ bxz01Assignments.clients.StockQuoteService.ClientListener http://talon.csce.uark.edu:30000/ogsa/services/bxz01Assignments/StockQuoteServi ce 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/multiplehtml/ch06s01.html http://www-unix.globus.org/toolkit/docs/3.2/core/

20 Questions?


Download ppt "Project Demo- Grid Notification Presentation by: Ben Zhang."

Similar presentations


Ads by Google