prueba1.platform
Class Platform

java.lang.Object
  |
  +--prueba1.platform.Platform

public class Platform
extends java.lang.Object


Field Summary
 AccessService AS
           
 java.lang.String dnsServer
           
static int EXISTING
          The newcomming platform when booting
 prueba1.hosting.HostingService HS
           
 PlatformProxy myProxy
          The Proxy that the agents have instead of having a PlatformObject
static int NEW
          The newcomming platform when booting
 prueba1.naming.NamingService NS
           
 
Constructor Summary
protected Platform(PlatformProxy _pp)
          The constructor that just starts running the platform.
 
Method Summary
 void addAgent(Agent _agent)
          This method adds the agent into the platform
 int addPlatform(java.lang.String _ip, int _number)
          This method adds a new platform to the vector so it is considered by this platform to be in the ring.
 void agentCreation(java.lang.String _agentClassName)
          This method allows PlatformProxy to create an agent and add it, after the platform has been created
 void fillData(prueba1.transport.aux.PlatformMessage _pmsg, int _type)
          This method gets the data from the message and fills in the platform's vector and so....
 java.lang.String getLocation(java.lang.String _agentName)
          THis method gets the IP of the machine in which the agent passed as parameter is hosted.
 java.lang.String getMyIP()
          This method returns the IP of this platform
 int getNumber()
          This method retrieves the number of the platform
 java.util.Vector getPlatforms()
          This method returns the Vector that have the platforms connected to the ring.
 Proxy getProxy(java.lang.String _agentName)
          This method gets a proxy to an agent
 void messageReceived()
          This method tells the platform when it has been received a BOOTMESSAGE and the platform (hopefully) has been accepted by the ring
 int nextPlatformToJoin()
          This method checks the size of the Vector that holds the platforms and calculates which is gonna be the next number for the next platform
 void sendAgent(int _secs, int _num, java.lang.String _a, int _p, Agent _ag)
          The service of the platform to send the agent.
 void sendCircularMessage(prueba1.transport.aux.PlatformMessage _pmsg)
          This method sends a message to another platform when another one is booting
 void startup(java.lang.String _tutorPlatform)
          This method in necessary for the platform to boot up.
 void stop()
          This is the method that cleans up everything when the platform stops.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW

public static final int NEW
The newcomming platform when booting

EXISTING

public static final int EXISTING
The newcomming platform when booting

dnsServer

public java.lang.String dnsServer

myProxy

public PlatformProxy myProxy
The Proxy that the agents have instead of having a PlatformObject

NS

public prueba1.naming.NamingService NS

HS

public prueba1.hosting.HostingService HS

AS

public AccessService AS
Constructor Detail

Platform

protected Platform(PlatformProxy _pp)
The constructor that just starts running the platform.
Method Detail

startup

public void startup(java.lang.String _tutorPlatform)
This method in necessary for the platform to boot up. In fact it's not included in the constructor because it has to wait till the ring accepts it.
Parameters:
_tutorPlatform - The platform, already being part of the ring, that is going to start the message that will make the platform part of it also. In the case that the platform is the first to join the ring the argument must be ""

messageReceived

public void messageReceived()
This method tells the platform when it has been received a BOOTMESSAGE and the platform (hopefully) has been accepted by the ring

sendAgent

public void sendAgent(int _secs,
                      int _num,
                      java.lang.String _a,
                      int _p,
                      Agent _ag)
The service of the platform to send the agent. It uses TransportService class.
Parameters:
_a - address of the destination platform
_p - port of the destination platform listening to agents to go
_ag - the actual agent to be sent

agentCreation

public void agentCreation(java.lang.String _agentClassName)
This method allows PlatformProxy to create an agent and add it, after the platform has been created

addAgent

public void addAgent(Agent _agent)
This method adds the agent into the platform

nextPlatformToJoin

public int nextPlatformToJoin()
This method checks the size of the Vector that holds the platforms and calculates which is gonna be the next number for the next platform
Returns:
The number for the next platform to use as its number

getPlatforms

public java.util.Vector getPlatforms()
This method returns the Vector that have the platforms connected to the ring. The Vector returned already holds the address for the platform that has joined the ring the last one.

getMyIP

public java.lang.String getMyIP()
This method returns the IP of this platform
Returns:
THe IP of this platform. In the case that it occurs an exception it yields empty String

getLocation

public java.lang.String getLocation(java.lang.String _agentName)
THis method gets the IP of the machine in which the agent passed as parameter is hosted.

getNumber

public int getNumber()
This method retrieves the number of the platform

getProxy

public Proxy getProxy(java.lang.String _agentName)
This method gets a proxy to an agent

addPlatform

public int addPlatform(java.lang.String _ip,
                       int _number)
This method adds a new platform to the vector so it is considered by this platform to be in the ring. The platform is added the last one.
Parameters:
_number - is only to check if it's the same as the position in which is being added
Returns:
0 if the platform has not been added, 1 if it has

sendCircularMessage

public void sendCircularMessage(prueba1.transport.aux.PlatformMessage _pmsg)
This method sends a message to another platform when another one is booting

fillData

public void fillData(prueba1.transport.aux.PlatformMessage _pmsg,
                     int _type)
This method gets the data from the message and fills in the platform's vector and so....

stop

public void stop()
This is the method that cleans up everything when the platform stops.