27.03.2014 Views

Programming Model and Protocols for Reconfigurable Distributed ...

Programming Model and Protocols for Reconfigurable Distributed ...

Programming Model and Protocols for Reconfigurable Distributed ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

30 CHAPTER 2. COMPONENT MODEL<br />

When a Request event is triggered by a client, as the event passes<br />

through different channels <strong>and</strong> ports in the architecture, it saves them on<br />

an internal stack. When the server component generates a Response event,<br />

it initializes it with the Request’s stack. As the Response event is passed<br />

through the architecture, the run-time system pops its stack one element at<br />

a time to see where to deliver it next. This mechanism, ensures that only<br />

the client which initiated a Request will receive the corresponding Response.<br />

2.6 Component Initialization <strong>and</strong> Life Cycle<br />

Every component provides a special Control port used <strong>for</strong> initialization,<br />

life cycle, <strong>and</strong> fault management. Figure 2.11 illustrates the Control port<br />

type <strong>and</strong> a component that declares an Init, a Start, <strong>and</strong> a Stop h<strong>and</strong>ler.<br />

Typically, <strong>for</strong> each component definition that requires state initialization,<br />

we define a specific initialization event, as a subtype of Init, which contains<br />

component-specific configuration parameters.<br />

startH<br />

Start<br />

+<br />

<br />

Control<br />

stopH<br />

Stop<br />

MyComponent<br />

initH<br />

MyInit<br />

+<br />

<br />

Control<br />

MyInit <br />

Init<br />

+<br />

<br />

Fault<br />

Started<br />

Stopped<br />

Start<br />

Stop<br />

Init<br />

Figure 2.11. Every Kompics component provides a Control port by default. To this<br />

Control port, the component can subscribe Start, Stop, <strong>and</strong> Init h<strong>and</strong>lers. In general,<br />

we do not illustrate the control port in component diagrams.<br />

An Init event is guaranteed to be the first event h<strong>and</strong>led by a component.<br />

When a component subscribes an Init event h<strong>and</strong>ler to its Control port in<br />

its constructor, the run-time system will only schedule the component <strong>for</strong><br />

execution upon receiving an Init event.<br />

Start <strong>and</strong> Stop events allow a component which h<strong>and</strong>les them to take<br />

some actions when the component is activated or passivated. A component<br />

is created passive. In the passive state, a component can receive events but it<br />

will not execute them. (Received events are stored in a port queue.) When<br />

activated, a component will enter the active state executing any enqueued<br />

events. H<strong>and</strong>ling life cycle events (illustrated in Code 2.10) is optional.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!