copyright © 2007 instech joint laboratory all rights reserved. 1 consideration on persistence of...

26
Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persist Consideration on Persist ence of WiseMan ence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology) Joint L aboratory 2008/03/31

Upload: clara-owen

Post on 21-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

Copyright © 2007 InSTech Joint Laboratory All rights reserved.1

Consideration on Persistence of Consideration on Persistence of WiseManWiseMan

FuDan-Hitachi InSTech (Innovative Software Technology) Joint Laboratory

2008/03/31

Page 2: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

2

2

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

outlineoutline

OverwiewSubscriptions’ persistenceEvents’ persistenceThe other consideration

Page 3: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

3

3

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Consideration on persistenceConsideration on persistence

It is very important for a reliable system management application to provide persistence mechanism in WiseMan.

There are subscription persistence & events persistence.

Page 4: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

4

4

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Consideration on persistence Consideration on persistence ––cont.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.

Page 5: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

5

5

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

outlineoutline

OverviewSubscriptions’ persistenceEvents’ persistenceThe other consideration

Page 6: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

6

6

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Consideration on subscriptions’ Consideration on subscriptions’ persistencepersistence

Client (system management software)

subscribe

Subscription Mgr

FileDataBase

WiseMan Server

<<store>>

<<delete>>

<<load>>

unsubscribe

restartcontextMap : Map<UUID, BaseContext>

Please project this slide.

Three operations:1. store when subscribing2. delete when unsubscribing3. load when server restart

Page 7: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

7

7

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Subscription persistence in current WiseMaSubscription persistence in current WiseMann

WiseMan has provided one interface by implementing which application developers are able to customize “store” and “delete” operations.

No mechanism to support “load” operation.

Page 8: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

8

8

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Current WiseMan’s support to store & dCurrent WiseMan’s support to store & delete operations (1)elete operations (1)

BaseContext

EnumerationContext EventingContext

EventingContextWithAck

EventingContextBatched

<<interface>>ContextListener

+ contextBound(requestContext:HandlerContext, context:UUID)+ contextUnbound(requestContext:HandlerContext, context:UUID)

+ getListener():ContextListener+ …

WiseMan has provided an interface name ContextListener in current version.

Page 9: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

9

9

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Current WiseMan’s support to store & dCurrent WiseMan’s support to store & delete operations (2)elete operations (2)

WSEventingSupport request

getSubscribe()

subscribe:Subscribe

getDelivery()

ctx:BaseContext<<create>>

initContext(handlerContext, ctx)

BaseSupport

uuid:UUID<<create>>

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.

Page 10: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

10

10

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Current WiseMan’s support to store & dCurrent WiseMan’s support to store & delete operations (3)elete operations (3)

WSEventingSupport request

UUID

getIdentifier()

removeContext(handlerCtx, uuid)

BaseSupport contextMap: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.

Page 11: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

11

11

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of subscriptions persistence Design of subscriptions persistence (1)(1)

public class BaseSupport {public static final Map<UUID, BaseContext> contextMap =

new ConcurrentHashMap<UUID, BaseContext>();

static{…

}

…}

// TODO : Load subscriptions to contextMap here, we think.

When to “load” subscriptions? We think the load operation should be executedWhen to “load” subscriptions? We think the load operation should be executedin the static block of class BaseSupport.in the static block of class BaseSupport.

Page 12: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

12

12

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of subscriptions persistence Design of subscriptions persistence (2)(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<UUID, BaseContext>);

}

<<interface>>ISubscriptionPersistence

PersistenceFile PersistenceDB

Page 13: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

13

13

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of subscriptions persistence (3)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 noidea the database schema.

Page 14: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

14

14

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of subscriptions persistence Design of subscriptions persistence (4)(4)

public class BaseSupport {public static final Map<UUID, BaseContext> contextMap =

new ConcurrentHashMap<UUID, BaseContext>();

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 BaIf the ISubscriptionPersistence is added, we can add some code to class BaseSupport where we initialize ISubscriptionPersistence before executing the seSupport where we initialize ISubscriptionPersistence before executing the “load” operation as necessary.“load” operation as necessary.

Page 15: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

15

15

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Persist to files VS. persist to databasePersist to files VS. persist to database

When subscriptions are stored to filesEnable BaseContext serializableIn order to facilitate the operation of del

ete, we store each subscription as onefile 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).

Page 16: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

16

16

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

outlineoutline

OverviewSubscriptions’ persistenceEvents’ persistenceThe other consideration

Page 17: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

17

17

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Consideration on events’ Consideration on events’ persistencepersistence

Client (system management software)

Subscription Mgr

FileDataBase WiseMan Server

<<save>>

events

<<retrieve>>

<<erase>>

events

Please project this slide.Three operations:1. save when receiving events from resources2. retrieve before sending it to client3. erase after sending successfully

Page 18: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

18

18

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Shortage of file persistence 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.

Page 19: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

19

19

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Sequence diagram of Sequence diagram of sendEvent(UUID, Object, boolean) in current WiseMsendEvent(UUID, Object, boolean) in current WiseManan

WSEventingSupport

bctx := retrieveContext(id)

filtered := filterEvent(bctx,event,null)

:EventingContextPull :EventingContextWithAck

:EventingContextBatched :EventingContext

HttpClient

[bctx instanceof]

[bctx instanceof]

[bctx instanceof]

[bctx instanceof]

sendRequest(…)

Page 20: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

20

20

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of events persistence (1)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);

}

<<interface>>IEventPersistence

EventPersistenceDB

This class is implemented by application developer.

Page 21: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

21

21

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of events persistence (2)Design of events persistence (2) Add a static variable typed IEventPersistence to WS

EventingSupport 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) { event

Persistence = 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(…)

Page 22: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

22

22

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Design of events persistence (3)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(…) .The detail operations of function receiveEvent(…) .

Page 23: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

23

23

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

outlineoutline

OverviewSubscriptions’ persistenceEvents’ persistenceThe other consideration

Page 24: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

24

24

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

How about persistence on client How about persistence on client side ?side ?

Client (system management software)

subscribe

Subscription Mgr

FileDataBase

WiseMan Server

<<store>>

<<delete>>

<<load>>

unsubscribe

restartcontextMap : Map<UUID, BaseContext>

If so, we should consider to extend the client API of WiseMan.

Page 25: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

25

25

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

How about persistence on client side ? How about persistence on client side ? ––cont.cont.

Client (system management software)

Subscription Mgr

FileDataBase

events

WiseMan Server

save

retrieve

erase

events

If so, we should consider to extend the client API of WiseMan.

Page 26: Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)

26

26

Copyright © 2007 InSTech Joint Laboratory All rights reserved.

Thank you.Any Comments are

welcome!