Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Validation

Álvaro Carrera edited this page Jun 18, 2013 · 1 revision

#summary Chapter seven - Valdiation of the simulation. #labels Phase-Support,Phase-Implementation,Phase-Deploy

= 7. Validation =

...

== 7.1. Notifications == In order to extract information from the simulation SHANKS provides the {{{Notification.java}}} interface. A notification is a piece of information that describes a significant change in the status of an element at a specific point of the simulation. Notifications that target the same element are a trace that describes the changes of said element throughout the simulation.

The notification contains information related by the following scheme:

||[Identificator] Source => Target||

A notification is identified by a unique ID generated at runtime. Notification's source is a reference to the element that generated it, this is the active element that performs a change in the simulation. Notification's targets reference elements that have been change. Note that notification's source and target may be the same element, that situation brought about when an item is charged to notify internal changes.

Notification interface can be used by end users to implement the behavior of their own notifications. However SHANKS has implemented two types of notifications that are considered sufficient enough.

Notifications are stored in the {{{NotificationManager.java}}} steppable, that is responsible for providing mechanisms to record, store and query notifications any time during the simulation.

=== 7.1.1. Interaction Notifications === A interaction notification adds a new reference to the way it relates the information it contains, according to the following scheme:

||[Identificator] Source => Interaction => Target||

Identificator, source and target remain the meaning of the interface. Interaction may be a reference to the described implementation, in case that this is the result of an event, or a description of the interaction itself, in case that the interaction is contained within an element that contains several descriptions of interactions, such as an agent.

All events are reported automatically when executed, so the user does not have to worry about notifying the interactions that have been implemented using events.

We have previously described that in SHANKS is intended that all changes in the elements of the simulation are carried out through events. If the user follows our advice then it is only required interaction notifications to access all the information generated by the simulation.

=== 7.1.2. Value Notifications === Value Notifications are intended to carry a trace of the values ​​that a environment's variable has obtained throughout the simulation. A value notification changes the way that relates the information it contains, according to the following scheme:

||[Identificator] Source => Target => Value||

Identificator and source retain the meaning of the interface. Target field becomes a reference to the variable that has undergone changes, as an identifier. Note that variables can not be considered elements of the simulation. A new field is added to reference the variable's value.

The purpose of these notifications is to give the user a more direct way to notify changes in network element's variables. Citing the simulation example that has been developed throughout this manual value notifications conduct a follow-up data such as how many times the cat agent bit cables or the number of devices repaired by the child agent.

=== 7.1.3. Notifables === In conjunction with value notifications SHANKS provides the {{{Notifable.java}}} interface for keeping track of variables within the simulation. The interface is designed to be implemented by classes that extend clases that represents basic types such as Integer or String. Implementing the notifable interface and extending from basic types this variables will be both basic fields like those found in the attributes of a device and should have a notification behavior.

When you create a new instance of an object that is notificable it automatically enrolled in {{{NotificationManager.java}}}. This steppable notify the values ​​of all notifables elements whenever its step runs in the simulation.

=== 7.1.4. Queries === Data stored in {{{NotificationManager.java}}} can be query at any time throughout the simulation. In the textbox 8.1. you can see the interface of the class, then we will proceed to explain it.

==== Textbox 8.1. NotificationManager.java ==== {{{ package es.upm.dit.gsi.shanks.notification; import […] public class NotificationManager implements Steppable {

private static List notifications; private static List notifables; private static ShanksSimulation sim;

/** Constructor with predefined parameters. / public NotificationManager(List lNotifications, List lNotifables, ShanksSimulation simulation) {…} /* Default constructor. */ public NotificationManager(ShanksSimulation simulation) {…}

public static void addNotification(Event e) {…} public static void addNotification(Notifable n) {…} public static void addNotifable(Notifable notifable) {…}

public Notification getByID(String id) {…} public List getByStep(int step) {…} public List getBySource(Object source) {…} public List getByInteraction(String interaction) {…} public List getByTarget(Object target) {…} public List getByElementID(String elementID) {…} public ArrayList getByType(Class<?> type) {…}

public void step(SimState arg0) { for(Notifable n: NotificationManager.notifables){ NotificationManager.addNotification(n); } } } }}}

There are three ways to add notifications in {{{NotificationManager.java}}}.

  • {{{addNotification (Event e)}}}: Adds a interaction notification. Use the event parameter to extract the information needed to create it.
  • {{{addNotification (Notifable n)}}}: Adds a value notification. Use the parameter notifable to extract the information needed to create it.
  • {{{addNotifable (Notifable n)}}}: Adds a notifiable to the notifable's list. When you run {{{NotificationManager.java}}} all objects in the list will be notified.

There are seven ways to query the notifications stored in {{{NotificationManager.java}}}.

  • {{{getByID (String id)}}}: Query by ID notification. Since the IDs are unique this method will only return a single notification.
  • {{{getByStep (int step)}}}: This method returns the list of all notifications generated in step indicated as a parameter.
  • {{{getBySource (Object source)}}}: This method returns a list of all notifications that have as source the object specified as a parameter.
  • {{{getByInteraction (String interaction)}}}: This method returns a list of all notifications whose description in the interaction field is identical to that indicated as a parameter. Note that these notifications will be only the interaction type.
  • {{{getByTarget (Object target)}}}: This method returns a list of all notifications that has as target the object specified as a parameter.
  • {{{getByElementID (String elementID)}}}: This method returns a list of all notifications generated for the item ID specified as a parameter. Note that these notifications will be only of the value type.
  • {{{getByType (Class <?> Type)}}}: This method returns a list of all notifications of the type indicated as a parameter.
Clone this wiki locally