Download presentation
Presentation is loading. Please wait.
Published byClara Owen Modified over 9 years ago
1
Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology) Joint Laboratory 2008/03/31
2
2 2 Copyright © 2007 InSTech Joint Laboratory All rights reserved. outline Overwiew Subscriptions ’ persistence Events ’ persistence The other consideration
3
3 3 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Consideration on persistence It is very important for a reliable system management application to provide persistence mechanism in WiseMan. There are subscription persistence & events persistence.
4
4 4 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Consideration on persistence – cont. J.F. Denise wrote: I like the idea to persist (I think that we already logged an RFE to have more freedom for context handling). It needs to be designed carefully (allow for pluggable backend,...). Having the event serializable is a good idea but we can't mandate all events to be Serializable. It needs to be designed first.
5
5 5 Copyright © 2007 InSTech Joint Laboratory All rights reserved. outline Overview Subscriptions ’ persistence Events ’ persistence The other consideration
6
6 6 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Consideration on subscriptions ’ persistence Client (system management software) subscribe Subscription Mgr File DataBase WiseMan Server > unsubscribe restart contextMap : Map Please project this slide. Three operations: 1. store when subscribing 2. delete when unsubscribing 3. load when server restart
7
7 7 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Subscription persistence in current WiseMan WiseMan has provided one interface by implementing which application developers are able to customize “ store ” and “ delete ” operations. No mechanism to support “ load ” operation.
8
8 8 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Current WiseMan ’ s support to store & delete operations (1) BaseContext EnumerationContextEventingContext EventingContextWithAck EventingContextBatched > ContextListener + contextBound(requestContext:HandlerContext, context:UUID) + contextUnbound(requestContext:HandlerContext, context:UUID) + getListener():ContextListener + … WiseMan has provided an interface name ContextListener in current version.
9
9 9 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Current WiseMan ’ s support to store & delete operations (2) WSEventingSupport request getSubscribe() subscribe:Subscribe getDelivery() ctx:BaseContext > initContext(handlerContext, ctx) BaseSupport uuid:UUID > contextMap:Map put(uuid,ctx) ctx :BaseContext getListener() :ContextListener contextBound(handlerContext,uuid) Sequence diagram of initContext(handlerContext, ctx) Sequence diagram of subscribe(…) in contextBound(…), we can store the subscription into file or database schedule(uuid,handlerContext,ctx) In current function subscribe(…), the contextBound(…) has been called so that we can implement the contextBound(…) where we customize the store operation.
10
10 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Current WiseMan ’ s support to store & delete operations (3) WSEventingSupport request UUID getIdentifier() removeContext(handlerCtx, uuid) BaseSupportcontextMap:Map get(context) ctx :BaseContext getListener() :ContextListener contextUnbound(handlerCtx,uuid) Sequence diagram of removeContext(handlerCtx, uuid) Sequence diagram of unsubscribe(…) remove(uuid) in contextUnbound(…), we can delete the subscription from file or database fromString(identifier) In current function unsubscribe(…), the contextUnbound(…) has been called so that we can implement the contextUnbound(…) where we customize the delete operation.
11
11 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of subscriptions persistence (1) public class BaseSupport { public static final Map contextMap = new ConcurrentHashMap (); static{ … } … } // TODO : Load subscriptions to contextMap here, we think. When to “load” subscriptions? We think the load operation should be executed in the static block of class BaseSupport.
12
12 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of subscriptions persistence (2) Define one set of abstract operations which can support store/delete/load operation. interface ISubscriptionPersistence { boolean store(UUID, BaseContext); boolean delete(UUID); boolean load(final Map ); } > ISubscriptionPersistence PersistenceFilePersistenceDB
13
13 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of subscriptions persistence (3) WiseMan ’ s users (i.e. application developers) can implement ISubscriptionPersistence to concrete class such as PersistenceFile and PersistenceDB. WiseMan ’ s developers can complete the code of PersistenceFile in WiseMan by serializing BaseContext object. WiseMan ’ s developers can NOT complete the code of PersistenceDB because we have no idea the database schema.
14
14 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of subscriptions persistence (4) public class BaseSupport { public static final Map contextMap = new ConcurrentHashMap (); static{ … } … } // get the name of concrete class such as wiseman.persistence.PersistenceDB // also including some other information by reading a special configuration file, // then create an instance of ISubscriptionPersistence by reflection mechanism // and assign the instance to the variable persistence. if(persistence!=null) persistence.load(contextMap); public static ISubscriptionPersistence persistence = null; If the ISubscriptionPersistence is added, we can add some code to class BaseSupport where we initialize ISubscriptionPersistence before executing the “load” operation as necessary.
15
15 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Persist to files VS. persist to database When subscriptions are stored to files Enable BaseContext serializable In order to facilitate the operation of delete, we store each subscription as one file whose filename is the UUID of the subscription. When subscriptions are stored to database, the concrete operation including store, delete and load should be implemented by WiseMan users(i.e. application developers).
16
16 Copyright © 2007 InSTech Joint Laboratory All rights reserved. outline Overview Subscriptions ’ persistence Events ’ persistence The other consideration
17
17 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Consideration on events ’ persistence Client (system management software) Subscription Mgr File DataBase WiseMan Server > events > events Please project this slide. Three operations: 1. save when receiving events from resources 2. retrieve before sending it to client 3. erase after sending successfully
18
18 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Shortage of file persistence There are too many events. In order to facilitate the retrieving operation, it is more possible to use database in realistic. As J.F. Denise said, we can't mandate all events to be serializable. Taking into account all these factors, we only consider the database persistence of events.
19
19 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Sequence diagram of sendEvent(UUID, Object, boolean) in current WiseMan WSEventingSupport bctx := retrieveContext(id) filtered := filterEvent(bctx,event,null) :EventingContextPull:EventingContextWithAck :EventingContextBatched:EventingContext HttpClient [bctx instanceof] sendRequest(…)
20
20 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of events persistence (1) Define one set of abstract operations which can support save/retrieve/erase operation. interface IEventPersistence { boolean save(UUID, Object); Object[] retrieve(); boolean erase(Object); } > IEventPersistence EventPersistenceDB This class is implemented by application developer.
21
21 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of events persistence (2) Add a static variable typed IEventPersistence to WSEventingSupport class public static IEventPersistence eventPersistence = null; Add a public static method to WSEventingSupport class. This method has to be called in advance when persistence is necessary. public static void setEventPersistence(IEventPersistence iepersist) { eventPersistence = iepersist ; } Add a public static method to WSEventingSupport class which is called when WiseMan received an event from resource. public static void receiveEvent( … ) { … } //detail in next slide Change the function sendEvent( … ) from public to protected. protected static void sendEvent( … )
22
22 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Design of events persistence (3) public static IEventPersistence eventPersistence = null; … public static boolean receiveEvent(final UUID id, final Object event, final boolean filter) { if (eventPersistence!=null) { eventPersistence.save(id,event); Object[] events = eventPersistence.retrieve( ); for(int i=0;i<events.size();i++){ if (sendEvent(id,event,filter)) eventPersistence.erase(events[i]); return true; } else return sendEvent(id,event,filter); } The detail operations of function receiveEvent(…).
23
23 Copyright © 2007 InSTech Joint Laboratory All rights reserved. outline Overview Subscriptions ’ persistence Events ’ persistence The other consideration
24
24 Copyright © 2007 InSTech Joint Laboratory All rights reserved. How about persistence on client side ? Client (system management software) subscribe Subscription Mgr File DataBase WiseMan Server > unsubscribe restart contextMap : Map If so, we should consider to extend the client API of WiseMan.
25
25 Copyright © 2007 InSTech Joint Laboratory All rights reserved. How about persistence on client side ? – cont. Client (system management software) Subscription Mgr File DataBase events WiseMan Server save retrieve erase events If so, we should consider to extend the client API of WiseMan.
26
26 Copyright © 2007 InSTech Joint Laboratory All rights reserved. Thank you. Any Comments are welcome!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.