INF 123: Software Architectures, Distributed Systems, and Interoperability - PowerPoint PPT Presentation

About This Presentation
Title:

INF 123: Software Architectures, Distributed Systems, and Interoperability

Description:

INF 123: Software Architectures, Distributed Systems, and Interoperability. Discussion Session ... (SpacecraftStateIntf) registry.lookup('SpacecraftStates' ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 16
Provided by: rosalvagal
Learn more at: https://ics.uci.edu
Category:

less

Transcript and Presenter's Notes

Title: INF 123: Software Architectures, Distributed Systems, and Interoperability


1
INF 123 Software Architectures, Distributed
Systems, and Interoperability
  • Discussion Session
  • Week 8 - Spring 2008
  • Instructor Prof. Richard N. Taylor
  • TA Rosalva Gallardo

2
Overview
  • Comments about Assignment 2
  • Assignment 3
  • Lunar Lander Game Server (RMI)

3
Assignment 3
  • Assignment 3 and the Discussions Slides for Week
    7 and 8 are in eee.
  • Assignment 3 Discussion

4
Deployment
Server Machine
Client Machine
rmiregistry
Lunar Lander Code
Network
edu.uci.inf123 - ServerRMI.java -
SpacecraftStateIntf.java - SpacecraftState.java
edu.uci.inf123 - SpacecraftStateIntf.java -
SpacecraftState.java
5
Implementation Interface
  • package edu.uci.inf123
  • import java.rmi.Remote
  • import java.rmi.RemoteException
  • import java.util.HashMap
  • public interface SpacecraftStateIntf extends
    Remote
  • SpacecraftState getState(String identifier)
    throws RemoteException
  • void setState(String identifier,
    SpacecraftState state) throws RemoteException
  • void clearState(String identifier) throws
    RemoteException
  • HashMapltString, SpacecraftStategt getStates()
    throws RemoteException

6
Implementation Spacecraft Status Bean
  • package edu.uci.inf123
  • public class SpacecraftState implements
    java.io.Serializable
  • private static final long serialVersionUID 1L
  • double altitude
  • double velocity
  • double fuel
  • public SpacecraftState()
  • altitude 0.0
  • velocity 0.0
  • fuel 0.0
  • public void setAltitude(double pAltitude)
  • altitude pAltitude

7
Implementation Server
  • package edu.uci.inf123
  • import java.rmi.registry.Registry
  • import java.rmi.registry.LocateRegistry
  • import java.rmi.RemoteException
  • import java.rmi.server.UnicastRemoteObject
  • import java.util.HashMap
  • public class ServerRMI implements
    SpacecraftStateIntf
  • HashMapltString, SpacecraftStategt states
  • public ServerRMI()
  • states new HashMapltString,
    SpacecraftStategt()
  • public SpacecraftState getState(String
    identifier) throws RemoteException
  • return (SpacecraftState)states.get(identif
    ier)

8
Implementation Server (cont.)
  • public static void main(String args)
  • try
  • ServerRMI obj new ServerRMI()
  • SpacecraftStateIntf stub (SpacecraftStateIntf)
    UnicastRemoteObject.exportObject(obj, 0)
  • // Bind the remote object's stub in the registry
  • System.setProperty("java.rmi.server.hostname",
    "tps.ics.uci.edu")
  • Registry registry LocateRegistry.getRegistry()
  • registry.bind("SpacecraftStates", stub)
  • System.err.println("Server ready")
  • catch (Exception e)
  • System.err.println("Server exception "
    e.toString())
  • e.printStackTrace()

9
Implementation RMI Client
  • package edu.uci.inf123
  • import java.rmi.registry.LocateRegistry
  • import java.rmi.registry.Registry
  • import java.util.HashMap
  • import java.util.Iterator
  • public class ClientRMI
  • private ClientRMI()
  • public static void main(String args)
  • String host "tps.ics.uci.edu"
  • try
  • Registry registry LocateRegistry.getRegistry
    (host)
  • SpacecraftStateIntf stub (SpacecraftStateInt
    f) registry.lookup("SpacecraftStates")
  • SpacecraftState ss1, ss2

10
Implementation RMI Client
  • ss1.setVelocity(100.00)
  • System.out.println("\nState set for
    rgallard_MyLL")
  • stub.setState("rgallard_MyLL", ss1)
  • System.out.println("\nCurrent States")
  • printStates(stub.getStates())
  • System.out.println("\nState get for
    rgallard_MyLL")
  • ss2 stub.getState("rgallard_MyLL")
  • System.out.println("\nCurrent States")
  • printStates(stub.getStates())
  • System.out.println("\nState cleared for
    rgallard_MyLL")
  • stub.clearState("rgallard_MyLL")
  • System.out.println("\nCurrent States")

11
Output of RMI Client
12
Important Considerations
  • For the name of the Local Spacecraft and Remote
    Spacecraft you should use the following pattern
  • uciNetID_NameYouLike
  • Ex rgallard_Ariadne
  • Make sure you will clean the state of your Local
    Spacecraft when your game finishes. If it is
    necessary run the ClientRMI to clean the states
    you create during your tests

13
Important Considerations
  • Make sure you press Return after you enter the
    value in the text fields in the Lunar Lander
    Launcher menu. If you only use your mouse the
    value of the text fields will be null. Be
    careful. You are welcome to change the
    implementation to improve this, but this is not
    required.

14
Important Considerations
  • Testing options
  • Using one machine
  • Test your application with the name for the Local
    Spacecraft and Remote Spacecraft being the same.
  • Test your application using two different
    installations of Eclipse.
  • Test your application using two different
    machines. You can ask for help to your classmates.

15
Important Considerations
  • If you choose to test using two different
    installations of Eclipse. Make sure that you have
    the following in your new Eclipse installation
  • SubEclipse Plug-in
  • ArchStudio Plug-in
  • Check out source code of Myx.fw
  • Check out your source code of LL from your SVN
    repository. If you see error makes sure the
    installation of the OpenGL libraries is correct.
Write a Comment
User Comments (0)
About PowerShow.com