Prism.conn.distribution.top
Class TopBorderConnector

java.lang.Object
  |
  +--Prism.framework.Brick
        |
        +--Prism.framework.Connector
              |
              +--Prism.conn.distribution.top.TopBorderConnector
All Implemented Interfaces:
ArchitectureEventConstants, Prism.conn.distribution.top.BorderConnectorConstants, IConnector, ScaffoldConstants, Prism.conn.distribution.top.TBCConstants

public class TopBorderConnector
extends Connector
implements Prism.conn.distribution.top.BorderConnectorConstants, Prism.conn.distribution.top.TBCConstants

This connector encapsulates communication accross process boundaries. It receives notifications from the other processes, and sends requests to all connected processes. It connects to the corresponding BottomBorderConnector(s) (BBC). It is IMPORTANT to note that parameters to messages being sent using this border connector have to be serializable (i.e., they have to implement a Serializable interface)

Version:
0.1
Author:
Marija Mikic-Rakic
See Also:
Connector

Field Summary
static int ACTIVE
           
static int BOTTOM_BROADCAST
          Broadcast notifications to all attached components and connectors
static int BOTTOM_GROUPCAST
          Groupcast notifications and requests to all attached components and connectors that belong to the specified group.
static int BOTTOM_UNICAST
          Unicast notifications to the fully resolved brick object
static int BROADCAST
          Broadcast notifications and requests to all attached components and connectors
static int GROUPCAST
          Groupcast notifications and requests to all attached components and connectors that belong to the specified group.
static int INACTIVE
           
 boolean isBlockedForSend
          Boolean indicating whether the connector will block after sending a request until it receives a notification.
static int MAX_TRY
           
static long TIME_BETWEEN_PINGS
           
static long TIME_BETWEEN_RETRY
           
static int TOP_BROADCAST
          Broadcast requests to all attached components and connectors
static int TOP_GROUPCAST
          Groupcast requests to all attached components and connectors that belong to the specified group.
static int TOP_UNICAST
          Unicast requests to the fully resolved brick object
static int UNICAST
          Unicast notifications and requests to the fully resolved brick object
static int WAIT_FOR_RECONNECTION
           
 
Fields inherited from class Prism.framework.Brick
bottomId, myId, name, scaffold, sideId, topId
 
Fields inherited from interface Prism.framework.ArchitectureEventConstants
NOTIF_BEING_HDLD, NOTIF_HDLD, NOTIF_RECD, NOTIF_SENT, PEER_BEING_HDLD, PEER_HDLD, PEER_RECD, PEER_SENT, REQ_BEING_HDLD, REQ_HDLD, REQ_RECD, REQ_SENT
 
Fields inherited from interface Prism.framework.ScaffoldConstants
DISPATCH, MONITOR, SCHEDULER
 
Constructor Summary
TopBorderConnector(java.lang.String name)
          Constructor
 
Method Summary
 void connect(java.lang.String hostName, int portNum, java.lang.String myProcName)
          This method is used to create a connection between this TopBorderConnector and the desired BottomBorderConnector.
 java.util.Vector getConnections()
          Get the vector of connections
 java.lang.String getDegradedTag(java.lang.String msgName)
           
 double getPercentConnected(int connNumber)
          Method for retrieving the percent of the time a connection with a given identificator was active.
 double getPercentDisconnected(int connNumber)
          Method for retrieving the percent of the time a connection with a given identificator was inactive.
 void handle(Notification n)
          This method will be invoked when a new notification arrives via the socket.
 void handle(Request r)
          This method will dispatch the request trhough all of its active connections.
 int hasActiveConnections()
          This method returns the index of the first active collection or -1 if there are no active connections.
 void syncHandle(Notification notifyMsg)
          This method will be invoked once a notification has been received and which has been expected by the connector (the connector was blocked until it received this notification - used in synchronous communication).
 void synchronousSend(Request r)
          This method is used when the connector should block after sending, in order to receive a remote notification synchronously.
 void tearDownConnections()
          this method is purely for simulating link failures, while processes at both sides are up and running.
 void updateConnections(Prism.conn.distribution.top.TopConnection newconn)
           
 
Methods inherited from class Prism.framework.Connector
addToBottom, addToTop, getBottom, getTop, handle, hasBottom, hasTop, removeFromBottom, removeFromTop, toString, toString
 
Methods inherited from class Prism.framework.Brick
add, fireEvent, getBottomId, getSideId, getTopId, setBottomId, setName, setNameAfterTheFact, setScaffold, setSideId, setTopId, start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isBlockedForSend

public boolean isBlockedForSend
Boolean indicating whether the connector will block after sending a request until it receives a notification.

BROADCAST

public static final int BROADCAST
Broadcast notifications and requests to all attached components and connectors

UNICAST

public static final int UNICAST
Unicast notifications and requests to the fully resolved brick object

GROUPCAST

public static final int GROUPCAST
Groupcast notifications and requests to all attached components and connectors that belong to the specified group.

TOP_BROADCAST

public static final int TOP_BROADCAST
Broadcast requests to all attached components and connectors

TOP_UNICAST

public static final int TOP_UNICAST
Unicast requests to the fully resolved brick object

TOP_GROUPCAST

public static final int TOP_GROUPCAST
Groupcast requests to all attached components and connectors that belong to the specified group.

BOTTOM_BROADCAST

public static final int BOTTOM_BROADCAST
Broadcast notifications to all attached components and connectors

BOTTOM_UNICAST

public static final int BOTTOM_UNICAST
Unicast notifications to the fully resolved brick object

BOTTOM_GROUPCAST

public static final int BOTTOM_GROUPCAST
Groupcast notifications and requests to all attached components and connectors that belong to the specified group.

ACTIVE

public static final int ACTIVE

WAIT_FOR_RECONNECTION

public static final int WAIT_FOR_RECONNECTION

INACTIVE

public static final int INACTIVE

TIME_BETWEEN_PINGS

public static final long TIME_BETWEEN_PINGS

TIME_BETWEEN_RETRY

public static final long TIME_BETWEEN_RETRY

MAX_TRY

public static final int MAX_TRY
Constructor Detail

TopBorderConnector

public TopBorderConnector(java.lang.String name)
Constructor
Parameters:
name - Name of the connector.
Method Detail

connect

public void connect(java.lang.String hostName,
                    int portNum,
                    java.lang.String myProcName)
This method is used to create a connection between this TopBorderConnector and the desired BottomBorderConnector.
Parameters:
hostName - Name of the host to which this connector is connecting. It is in the form of IP address or hostname.
portNum - Port to which this connection will be binded.
myProcName - Unique identifier of local process

handle

public void handle(Request r)
This method will dispatch the request trhough all of its active connections.
Overrides:
handle in class Connector
Parameters:
r - Request to be handled by this connector

synchronousSend

public void synchronousSend(Request r)
This method is used when the connector should block after sending, in order to receive a remote notification synchronously.
Parameters:
r - Request to be sent.

syncHandle

public void syncHandle(Notification notifyMsg)
This method will be invoked once a notification has been received and which has been expected by the connector (the connector was blocked until it received this notification - used in synchronous communication).
Parameters:
notifyMsg - Notification which has been received.

handle

public void handle(Notification n)
This method will be invoked when a new notification arrives via the socket.
Overrides:
handle in class Connector
Parameters:
n - Notification to be handled

getConnections

public java.util.Vector getConnections()
Get the vector of connections
Returns:
returns a vector of connections

hasActiveConnections

public int hasActiveConnections()
This method returns the index of the first active collection or -1 if there are no active connections.
Returns:
the index of the first active collection or -1 if there are no active connections

getPercentConnected

public double getPercentConnected(int connNumber)
Method for retrieving the percent of the time a connection with a given identificator was active.
Parameters:
connNumber - Identificator of the connection
Returns:
returns the percent of time this connection was active

getPercentDisconnected

public double getPercentDisconnected(int connNumber)
Method for retrieving the percent of the time a connection with a given identificator was inactive.
Parameters:
connNumber - Identificator of the connection
Returns:
returns the percent of time this connection was inactive

tearDownConnections

public void tearDownConnections()
this method is purely for simulating link failures, while processes at both sides are up and running. it brutely tears down all active connections by closing the sockets, etc.

updateConnections

public void updateConnections(Prism.conn.distribution.top.TopConnection newconn)

getDegradedTag

public java.lang.String getDegradedTag(java.lang.String msgName)