ptolemy.distributed.rmi
Class DistributedServerRMIGeneric

java.lang.Object
  extended by ptolemy.distributed.rmi.DistributedServerRMIGeneric
All Implemented Interfaces:
java.util.EventListener, net.jini.discovery.DiscoveryListener, net.jini.lookup.ServiceIDListener

public class DistributedServerRMIGeneric
extends java.lang.Object
implements net.jini.lookup.ServiceIDListener, net.jini.discovery.DiscoveryListener

A distributed server to execute ptolemy actors in a distributed manner. It uses Jini as discovery protocol. It performs the following tasks:

Since:
Ptolemy II 5.1
Version:
$Id: DistributedServerRMIGeneric.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Daniel Lazaro Cuadrado (kapokasa@kom.aau.dk)
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (kapokasa)

Field Summary
private  java.lang.String codebase
          Codebase.
private  net.jini.core.entry.Entry[] entries
          Entries loaded from the config file.
private  net.jini.export.Exporter exporter
          An abstraction for exporting a single remote object such that it can receive remote method invocations
private  java.lang.String[] groups
          Groups loaded from the config file.
private  java.rmi.Remote proxy
          Proxy that allows for RMI calls to the service.
private static java.lang.String SERVER
          Entry of the configuration file we want ot load.
private  java.rmi.Remote service
          Service provided.
private  net.jini.core.lookup.ServiceID serviceID
          ID of the service.
private  java.io.File serviceIdFile
          File that stores the serviceID.
private  net.jini.core.discovery.LookupLocator[] unicastLocators
          UnicastLocators loaded from the config file.
 
Constructor Summary
DistributedServerRMIGeneric(java.lang.String configFileName)
          Construct a DistributedServerRMIGeneric with a configuration file.
 
Method Summary
 void discarded(net.jini.discovery.DiscoveryEvent evt)
          Called when one or more lookup service registrars has been discarded.
 void discovered(net.jini.discovery.DiscoveryEvent evt)
          Called when one or more lookup service registrars has been discovered.
private  void getConfiguration(java.lang.String configFileName)
          Loads various settings from a configuration file.
static void main(java.lang.String[] args)
          Create a new instance of this application, passing it the first command-line argument (configuration file).
 void serviceIDNotify(net.jini.core.lookup.ServiceID serviceID)
          Required by the ServiceIDListener interface.
 void tryRetrieveServiceId(java.io.File serviceIdFile)
          Try to load the service ID from file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVER

private static final java.lang.String SERVER
Entry of the configuration file we want ot load.

See Also:
Constant Field Values

proxy

private java.rmi.Remote proxy
Proxy that allows for RMI calls to the service.


service

private java.rmi.Remote service
Service provided.


exporter

private net.jini.export.Exporter exporter
An abstraction for exporting a single remote object such that it can receive remote method invocations


groups

private java.lang.String[] groups
Groups loaded from the config file.


entries

private net.jini.core.entry.Entry[] entries
Entries loaded from the config file.


unicastLocators

private net.jini.core.discovery.LookupLocator[] unicastLocators
UnicastLocators loaded from the config file.


serviceIdFile

private java.io.File serviceIdFile
File that stores the serviceID.


codebase

private java.lang.String codebase
Codebase.


serviceID

private net.jini.core.lookup.ServiceID serviceID
ID of the service.

Constructor Detail

DistributedServerRMIGeneric

public DistributedServerRMIGeneric(java.lang.String configFileName)
Construct a DistributedServerRMIGeneric with a configuration file. It performs the following tasks: - Prepares for discovery of a service locator: - Loading of various settings as Unicast locators and service class. - Discovers the service locator (unicast, multicast or both). - Creates and exports the service proxy (that allows for RMI calls).

Parameters:
configFileName - The configuration file.
Method Detail

discarded

public void discarded(net.jini.discovery.DiscoveryEvent evt)
Called when one or more lookup service registrars has been discarded. The method should return quickly; e.g., it should not make remote calls.

Specified by:
discarded in interface net.jini.discovery.DiscoveryListener
Parameters:
evt - The event that describes the discovered registrars.

discovered

public void discovered(net.jini.discovery.DiscoveryEvent evt)
Called when one or more lookup service registrars has been discovered. The method should return quickly; e.g., it should not make remote calls.

Specified by:
discovered in interface net.jini.discovery.DiscoveryListener
Parameters:
evt - The event that describes the discovered registrars.

main

public static void main(java.lang.String[] args)
Create a new instance of this application, passing it the first command-line argument (configuration file). It stays alive.

Parameters:
args - The command-line arguments.

serviceIDNotify

public void serviceIDNotify(net.jini.core.lookup.ServiceID serviceID)
Required by the ServiceIDListener interface. Called when the JoinManager gets a valid ServiceID from a lookup service.

Specified by:
serviceIDNotify in interface net.jini.lookup.ServiceIDListener
Parameters:
serviceID - the service ID assigned by the lookup service.

tryRetrieveServiceId

public void tryRetrieveServiceId(java.io.File serviceIdFile)
Try to load the service ID from file. It isn't an error if we can't load it, because maybe this is the first time this service was run.

Parameters:
serviceIdFile - name of the file where the serviceID is stored.

getConfiguration

private void getConfiguration(java.lang.String configFileName)
Loads various settings from a configuration file. This file contains information about: - codebase: location of the code. - exporter: export to be used. - groups: groups to join. - unicast locators: Know service locators can be specified here. - entries: Other info e.g. name and comments - service: The service to be located.

Parameters:
configFileName - The configuration file.