Boeing Simulation 3.1 API Specification

server
Class Server

java.lang.Object
  |
  +--server.Server
All Implemented Interfaces:
Runnable

public class Server
extends Object
implements Runnable

The server component links all the pieces together. It generates some components at run time via the ServerComponentGenerator while other components connect to it asynchronously. The server maintains the world state and provides way for components to connect to other components.

Version:
$Revision: 1.44 $
Author:
Dave Jurgens

Field Summary
private  ServerSocket componentSS
          ServerSocket for receiving all connecting components.
private  world.WorldState currentState
          Current state of the world, as provided by the PerspectiveUnifier.
private static boolean DEBUG
          standard debugging flag
static int DEFAULT_PORT
          If no port is specified, the server will be initialized on this port.
private  util.WorkerThread imageProcessor
          This thread processes WorldImages by dequeueing an image from the worldImageQueue and then calling process on the PerspectiveUnifier passing in the dequeued WorldImage as the parameter.
private  connect.SupplierChannel missionControlChannel
          Supplier objects for the key server components
private  boolean missionControlConnected
          Boolean flags regarding the connection status of server critical components.
private  util.ConsumerQueue missionControlQueue
          The multithreaded Queue object for reading in off the key servercomponents.
private  boolean perspectiveUnifierConnected
           
private  int port
          port represents the actual port that the Server is listening in on.
private  connect.SupplierChannel puChannel
          Supplier objects for the key server components
private  util.ConsumerQueue puQueue
          The multithreaded Queue object for reading in off the key servercomponents.
private static long serialVersionUID
           
private static boolean SHOW_CONNECTION_ATTEMPTS
           
private static boolean SHOW_STATE
          This flag will show the servers functional state when any component attempts to wait for initialization.
private  connect.SupplierChannel uavManagerChannel
          Supplier objects for the key server components
private  boolean uavManagerConnected
           
private  util.ConsumerQueue uavManagerQueue
          The multithreaded Queue object for reading in off the key servercomponents.
private  util.PriorityProvider uavPriorities
          This object allows us to adjust the priority (i.e.
private  List uavs
          List containing all active uavs.
private  connect.SupplierChannel ucavManagerChannel
          Supplier objects for the key server components
private  boolean ucavManagerConnected
           
private  util.ConsumerQueue ucavManagerQueue
          The multithreaded Queue object for reading in off the key servercomponents.
private  util.FairWeightedQueue worldImageQueue
          This queue hold all waiting-to-be-processed images from the ucavs.
private  PropertyChangeSupport worldUpdates
          Interested parties may register with this PropertyChangeSupport to be notified when the current WorldState has been changed.
 
Constructor Summary
Server()
           
Server(int port)
           
 
Method Summary
protected  boolean accept(connect.ComponentEmissary requesting)
          Returns whether the Server will an incoming request for connection of the component type specified in the ComponentEmissary.
protected  boolean allowMethod(util.MethodRequest request)
          Returns whether the Server component will all the MethodRequest to be invoked.
private  void debug(String s)
          private method for sending out debug messages
private  util.PriorityEnqueueable generatePriorityEnqueueable(Object evalObject, Object enqueueable)
          Generates a PriorityEnqueueable with the specified arguements.
 connect.CreatesConnection getConnection()
          Returns the CreatesConnection that will connect an outside Component to the Server.
 connect.CreatesConnection getUAVManagerConnection()
          Returns the CreatesConnection that will connect with the UCAVManager component.
 connect.CreatesConnection getUCAVManagerConnection()
          Returns the CreatesConnection that will connect with the UAVManager component.
protected  void initializeServerComponents()
          Calls on the ServerComponentFactory to generate the components that the server will need, as specified by the class types passed in.
protected  boolean isFullyFunctional()
          Returns whether the server has all of its key component currently connected.
protected  void listenForComponents()
          Continually listens on the incoming channel for new Component connetions.
static void main(String[] args)
           
protected  void notifyOfInitialization()
          This method notifies the blocking initialization method when all the criticial components have connected, thus assuring full functionality the server.
protected  void processCommandControl(connect.ComponentEmissary cc, connect.ChannelBundle channels)
          Listens for I/O between the server and the CommandControl component
protected  void processMissionControl(connect.ComponentEmissary mc, connect.ChannelBundle channels)
          Listens for I/O between the server and the MissionControl component.
protected  void processNewComponent(connect.ComponentEmissary accepted, connect.ChannelBundle channels)
          When a component is accepted, the server should determine what to do with the connection.
protected  void processObjectLocater(connect.ComponentEmissary ol, connect.ChannelBundle channels)
          Since the ObjectLocater has connected, we need a reference to the UAV that it is listening for.
protected  void processPerspectiveUnifier(connect.ComponentEmissary pu, connect.ChannelBundle channels)
          Begins listening for I/O between the server and the PerspectiveUnifier component.
protected  void processUAVManager(connect.ComponentEmissary uav, connect.ChannelBundle channels)
          The UAVManager provides mediated access to the uavs.
protected  void processUCAVManager(connect.ComponentEmissary uav, connect.ChannelBundle channels)
          The UCAVManager provides mediated access to the UCAVs.
protected  void processVisualizer(connect.ComponentEmissary viz, connect.ChannelBundle channels)
          Adds a PropertyChangeListener for updates in the current WorldState and then writes out the new value upon update.
 mission.MissionHandle requestMission(mission.Mission request)
          Request that the MissionControl process this mission.
 void run()
          The server begins by trying to accept new Components via its ServerSocket.
protected  void updateWorldState(world.WorldImage newImage)
          Updates the current WorldState by communication with the PerspectiveUnifier.
protected  void waitForInitialization()
          This method should be called by any thread that should not proceed until the Server is in a fully consistent state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
If no port is specified, the server will be initialized on this port.

See Also:
Constant Field Values

port

private final int port
port represents the actual port that the Server is listening in on. This will be defined at run time due the server having an optional constructor to initialize on the non default value.


DEBUG

private static final boolean DEBUG
standard debugging flag

See Also:
Constant Field Values

SHOW_STATE

private static final boolean SHOW_STATE
This flag will show the servers functional state when any component attempts to wait for initialization.

See Also:
Constant Field Values

SHOW_CONNECTION_ATTEMPTS

private static final boolean SHOW_CONNECTION_ATTEMPTS
See Also:
Constant Field Values

componentSS

private final ServerSocket componentSS
ServerSocket for receiving all connecting components.


worldImageQueue

private final util.FairWeightedQueue worldImageQueue
This queue hold all waiting-to-be-processed images from the ucavs. Multiple threads enqueue on this object, but only one thread dequeues, thus ensuring a consistent world state for each object enqueueing. This is to say that for an object enqueueing, no enqueuable will be processed out of order. This does not guarantee that the objects enqueued will be dequeued at the same rate as other objects being enqueued. At implementation time, this is made a FairWeightedQueue. This is done because certain uavs may have their priority deemed higher, and therefore should be processed more often than others.


uavPriorities

private final util.PriorityProvider uavPriorities
This object allows us to adjust the priority (i.e. update rate) for uavs by altering how often they are pulled off the FairWeightedQueue.


worldUpdates

private final PropertyChangeSupport worldUpdates
Interested parties may register with this PropertyChangeSupport to be notified when the current WorldState has been changed.


uavs

private final List uavs
List containing all active uavs.


imageProcessor

private final util.WorkerThread imageProcessor
This thread processes WorldImages by dequeueing an image from the worldImageQueue and then calling process on the PerspectiveUnifier passing in the dequeued WorldImage as the parameter.


currentState

private world.WorldState currentState
Current state of the world, as provided by the PerspectiveUnifier.


puChannel

private connect.SupplierChannel puChannel
Supplier objects for the key server components


missionControlChannel

private connect.SupplierChannel missionControlChannel
Supplier objects for the key server components


uavManagerChannel

private connect.SupplierChannel uavManagerChannel
Supplier objects for the key server components


ucavManagerChannel

private connect.SupplierChannel ucavManagerChannel
Supplier objects for the key server components


puQueue

private util.ConsumerQueue puQueue
The multithreaded Queue object for reading in off the key servercomponents.


missionControlQueue

private util.ConsumerQueue missionControlQueue
The multithreaded Queue object for reading in off the key servercomponents.


uavManagerQueue

private util.ConsumerQueue uavManagerQueue
The multithreaded Queue object for reading in off the key servercomponents.


ucavManagerQueue

private util.ConsumerQueue ucavManagerQueue
The multithreaded Queue object for reading in off the key servercomponents.


missionControlConnected

private boolean missionControlConnected
Boolean flags regarding the connection status of server critical components.


perspectiveUnifierConnected

private boolean perspectiveUnifierConnected

uavManagerConnected

private boolean uavManagerConnected

ucavManagerConnected

private boolean ucavManagerConnected
Constructor Detail

Server

public Server()

Server

public Server(int port)
Method Detail

run

public void run()
The server begins by trying to accept new Components via its ServerSocket. Onces the ServerSocket has been initialized, then the generate call on the ServerComponentFactory will generate all the necessary components for the server and have them connect using the CreatesConnection for this server. Because the server is in an inconsistent state before the initialize returns, the subsequent method calls that listenForComponents exhibit blocking behavior until notified. The notify call takes place once all the critical components have connected.

Specified by:
run in interface Runnable

requestMission

public mission.MissionHandle requestMission(mission.Mission request)
Request that the MissionControl process this mission. Return the MissionHandle associated with it.

Parameters:
request - the Mission object that will be relayed to the MissionControl
Returns:
a handle that can be used to reaccess the requested Mission without having to reconstruct it

initializeServerComponents

protected void initializeServerComponents()
Calls on the ServerComponentFactory to generate the components that the server will need, as specified by the class types passed in. These components will connect using the CreatesConnection passed in. This method will then block until all the components have registered themselves.

See Also:
getConnection()

listenForComponents

protected void listenForComponents()
Continually listens on the incoming channel for new Component connetions. Upon hearing a new connection, the Server will attempt to read in a ComponentEmissary which will denote the requesting Component. If the Server will accept the connection to a Component of that type, then a ReturnValue with a true Boolean will be sent back, and the channels will be dispatched based on the type specified by the ComponentEmissary. If the request is rejected, a false Boolean will be sent back and the channel will be closed.


getConnection

public connect.CreatesConnection getConnection()
Returns the CreatesConnection that will connect an outside Component to the Server. The value returned is created dynamically by system property lookups.

Returns:
a CreatesConnetion that links back to the Server.

getUCAVManagerConnection

public connect.CreatesConnection getUCAVManagerConnection()
Returns the CreatesConnection that will connect with the UAVManager component.


getUAVManagerConnection

public connect.CreatesConnection getUAVManagerConnection()
Returns the CreatesConnection that will connect with the UCAVManager component.


accept

protected boolean accept(connect.ComponentEmissary requesting)
Returns whether the Server will an incoming request for connection of the component type specified in the ComponentEmissary.

Returns:
the component acceptance status

processNewComponent

protected void processNewComponent(connect.ComponentEmissary accepted,
                                   connect.ChannelBundle channels)
When a component is accepted, the server should determine what to do with the connection. This method should use differentiated behavior based on component type and then call the appropriate methods to interact with the components. The server acts as a many-to-one upon receiving connections in that all types connect to a single entry point. However, from the entry point, service becomes varied and exhibits one-to-many behavior based on what has connected (i.e. component type)


processCommandControl

protected void processCommandControl(connect.ComponentEmissary cc,
                                     connect.ChannelBundle channels)
Listens for I/O between the server and the CommandControl component


processMissionControl

protected void processMissionControl(connect.ComponentEmissary mc,
                                     connect.ChannelBundle channels)
Listens for I/O between the server and the MissionControl component.


processPerspectiveUnifier

protected void processPerspectiveUnifier(connect.ComponentEmissary pu,
                                         connect.ChannelBundle channels)
Begins listening for I/O between the server and the PerspectiveUnifier component.


processUAVManager

protected void processUAVManager(connect.ComponentEmissary uav,
                                 connect.ChannelBundle channels)
The UAVManager provides mediated access to the uavs. It may be queried for the CreatesConnection of all, some, or a specific uav. In addition, will query the server for a CreatesConnection to a ObjectLocater.


processUCAVManager

protected void processUCAVManager(connect.ComponentEmissary uav,
                                  connect.ChannelBundle channels)
The UCAVManager provides mediated access to the UCAVs. It may be queried for the CreatesConnection of all, some, or a specific uav. In addition, will query the server for a CreatesConnection to a ObjectLocater.


processObjectLocater

protected void processObjectLocater(connect.ComponentEmissary ol,
                                    connect.ChannelBundle channels)
Since the ObjectLocater has connected, we need a reference to the UAV that it is listening for. Once we get that, then we begin waiting for WorldImage updates and then putting them on the queue.


generatePriorityEnqueueable

private util.PriorityEnqueueable generatePriorityEnqueueable(Object evalObject,
                                                             Object enqueueable)
Generates a PriorityEnqueueable with the specified arguements.


processVisualizer

protected void processVisualizer(connect.ComponentEmissary viz,
                                 connect.ChannelBundle channels)
Adds a PropertyChangeListener for updates in the current WorldState and then writes out the new value upon update.


allowMethod

protected boolean allowMethod(util.MethodRequest request)
Returns whether the Server component will all the MethodRequest to be invoked.


updateWorldState

protected void updateWorldState(world.WorldImage newImage)
Updates the current WorldState by communication with the PerspectiveUnifier. The process is done by taking in new images and sending them out to the PerspectiveUnifier, which sends back a DeltaState that is used to update our currentState object. This method does not need to exhibit blocking behavior because the PerspectiveUnifier is guaranteed to be initialzed before this method has been called. This invariant is maintained because no Component is allowed to connect fully before the PerspectiveUnifier has been set, which means that no UAV could cause a WorldImage to enqueue on the worldImageQueue, which causes this method to be called.


notifyOfInitialization

protected void notifyOfInitialization()
This method notifies the blocking initialization method when all the criticial components have connected, thus assuring full functionality the server.


waitForInitialization

protected void waitForInitialization()
This method should be called by any thread that should not proceed until the Server is in a fully consistent state. This method will only block if the server is not fully functional.


isFullyFunctional

protected boolean isFullyFunctional()
Returns whether the server has all of its key component currently connected.


debug

private void debug(String s)
private method for sending out debug messages


main

public static void main(String[] args)

Boeing Simulation 3.1 API Specification

To submit a bug or feature email the author of that class. Funding for this research was provided by Boeing and DARPA.