no.ntnu.item.router
Class ServiceSessionBank

java.lang.Object
  extended by no.ntnu.item.router.ServiceSessionBank

public class ServiceSessionBank
extends java.lang.Object

This is a registry for all service sessions known to the router.
It contains functionality for handling the ServiceSession objects and sorting incoming SilverlightMeasurement objects.

Author:
Kristian Haugene

Field Summary
private  ActionPlaneSessions actionPlaneSessions
          The ActionPlaneSessions that will keep track of AP sessions
private  GuiXmlWriter guiXmlWriter
          The GuiXmlWriter that is to be called when changes occur
private  Parser parser
          Holds the Parser
private  java.util.List<ServiceSession> serviceSessions
          List of ongoing service sessions known to the Router
 
Constructor Summary
ServiceSessionBank(Parser parser, GuiXmlWriter guiXmlWriter, ActionPlaneSessions actionPlaneSessions)
          Constructor
 
Method Summary
private  void addMeasurement(SilverlightMeasurement sm)
          Method for adding a SilverlightMeasurement to the bank
private  void addMeasurementToExistingServiceSession(SilverlightMeasurement sm)
          Given that the measurement is not from a new ServiceSession, adds the SilverlightMeasurement to the correct ServiceSession
private  void createNewServiceSessionAndAddMeasurement(SilverlightMeasurement sm)
          Creates a new ServiceSession and adds the SilverlightMeasurement to it.
 java.util.List<ServiceSession> getServiceSessions()
          Returns the current list of ServiceSession objects.
private  boolean measurementAndServiceSessionHaveSameId(ServiceSession session, SilverlightMeasurement measurement)
          Checks if the given ServiceSession and SilverlightMeasurement have the same Id
 java.lang.String registerMeasurement(java.lang.String measurement)
          Register a new SilverlightMeasurement
 void registerUserPreferences(java.lang.String userPreferences)
          Update user preferences
private  boolean serviceSessionWithSameIdExistsInBank(SilverlightMeasurement measurement)
          Simple method for checking if a SilverlightMeasurement has an Id that is equal to a already registered ServiceSession
private  void setTargetBitRateToSessionGivenById(java.lang.String clientId, java.lang.Integer targetBitRate)
          Takes cliendId and targetBitRate as parameter.
Will set the targetBitRate to the ServiceSession identified by clientId
 void updateGuiXmlAndApSessions()
          Method that calls the GuiXmlWriter to write the current state.
Should be called when changes occur in the lists.
Also notifies the ActionPlaneSessions that a change has occured
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceSessions

private java.util.List<ServiceSession> serviceSessions
List of ongoing service sessions known to the Router


parser

private Parser parser
Holds the Parser


guiXmlWriter

private GuiXmlWriter guiXmlWriter
The GuiXmlWriter that is to be called when changes occur


actionPlaneSessions

private ActionPlaneSessions actionPlaneSessions
The ActionPlaneSessions that will keep track of AP sessions

Constructor Detail

ServiceSessionBank

public ServiceSessionBank(Parser parser,
                          GuiXmlWriter guiXmlWriter,
                          ActionPlaneSessions actionPlaneSessions)
Constructor

Parameters:
parser -
Method Detail

registerMeasurement

public java.lang.String registerMeasurement(java.lang.String measurement)
Register a new SilverlightMeasurement

Parameters:
measurement - string representing a SilverlightMeasurement
Returns:
the clientId this measurement relates to

registerUserPreferences

public void registerUserPreferences(java.lang.String userPreferences)
Update user preferences

Parameters:
userPreferences - string representation

updateGuiXmlAndApSessions

public void updateGuiXmlAndApSessions()
Method that calls the GuiXmlWriter to write the current state.
Should be called when changes occur in the lists.
Also notifies the ActionPlaneSessions that a change has occured


getServiceSessions

public java.util.List<ServiceSession> getServiceSessions()
Returns the current list of ServiceSession objects.

Returns:
current list of ServiceSession objects

addMeasurement

private void addMeasurement(SilverlightMeasurement sm)
Method for adding a SilverlightMeasurement to the bank

Parameters:
sm - SilverlightMeasurement to add

addMeasurementToExistingServiceSession

private void addMeasurementToExistingServiceSession(SilverlightMeasurement sm)
Given that the measurement is not from a new ServiceSession, adds the SilverlightMeasurement to the correct ServiceSession

Parameters:
sm - SilverlightMeasurement to add to existing ServiceSession

createNewServiceSessionAndAddMeasurement

private void createNewServiceSessionAndAddMeasurement(SilverlightMeasurement sm)
Creates a new ServiceSession and adds the SilverlightMeasurement to it. Also adds the session to the ServiceSessionBank list of sessions.

Parameters:
sm - SilverlightMeasurement from a new session

serviceSessionWithSameIdExistsInBank

private boolean serviceSessionWithSameIdExistsInBank(SilverlightMeasurement measurement)
Simple method for checking if a SilverlightMeasurement has an Id that is equal to a already registered ServiceSession

Parameters:
measurement - SilverlightMeasurement to check for
Returns:
true if serviceSession list contains a session with this Id. False otherwise.

measurementAndServiceSessionHaveSameId

private boolean measurementAndServiceSessionHaveSameId(ServiceSession session,
                                                       SilverlightMeasurement measurement)
Checks if the given ServiceSession and SilverlightMeasurement have the same Id

Parameters:
session -
measurement -
Returns:
true if equal, false otherwise

setTargetBitRateToSessionGivenById

private void setTargetBitRateToSessionGivenById(java.lang.String clientId,
                                                java.lang.Integer targetBitRate)
Takes cliendId and targetBitRate as parameter.
Will set the targetBitRate to the ServiceSession identified by clientId

Parameters:
clientId - the session id
targetBitRate - wanted bit rate