de.fhg.igd.semoa.net.farsight
Class UpdateDaemon

java.lang.Object
  extended byde.fhg.igd.semoa.net.farsight.UpdateDaemon
All Implemented Interfaces:
Runnable

public class UpdateDaemon
extends Object
implements Runnable

The update daemon communicates with the other FarSight services inside the local network (see Vicinity) to synchronize the contact lists. While it's running it will listen to a given multicast address. On this address update packets are sent (broadcast) and recieved. Depending on the type of recieved packets the update daemon can add or remove contacts to or from Farsight's contact list.

The update daemon will only run if Farsight has been started in the shared data mode (see FarSightImpl).

Version:
"$id: $"
Author:
Jan Haevecker

Field Summary
private  InetAddress addr_
          The multicast address
private  String hostId_
          The distinguished name of the owner (certificate) of the currently running SeMoA system.
private  Map hosts_
          A reference to the real contact map of farsight (not a copy).
private static Logger log_
          The Logger instance for this class
static int MAX_PACKET_SIZE
          The maximum supported size of datagrams.
private  int port_
          The multicast port
private  Thread selfRunner_
          The thread that runs the run method of this class.
private  boolean sharedMode_
          see FarSightImpl.
private  MulticastSocket socket_
          The MulticastSocket that is used for listening and sending packets.
 
Constructor Summary
UpdateDaemon(Map contacts, boolean sharedMode, InetAddress addr, int port)
          Sole construtor.
 
Method Summary
 void broadcast(UpdatePacket packet)
           
 void broadcastAdd(String key, String value)
          broadcast add
 void broadcastRemove(String key)
          broadcast remove
private  void handleAdded(UpdatePacket packet)
           
 void handlePacket(DatagramPacket datagram)
          This method handles received datagram packets.
private  void handleRemoved(UpdatePacket packet)
           
private  void listen()
          Listens for FarSights UpdatePackets.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log_

private static Logger log_
The Logger instance for this class


port_

private int port_
The multicast port


socket_

private MulticastSocket socket_
The MulticastSocket that is used for listening and sending packets.


addr_

private InetAddress addr_
The multicast address


MAX_PACKET_SIZE

public static final int MAX_PACKET_SIZE
The maximum supported size of datagrams.

See Also:
Constant Field Values

sharedMode_

private boolean sharedMode_
see FarSightImpl.


hosts_

private Map hosts_
A reference to the real contact map of farsight (not a copy).


hostId_

private String hostId_
The distinguished name of the owner (certificate) of the currently running SeMoA system.


selfRunner_

private Thread selfRunner_
The thread that runs the run method of this class.

Constructor Detail

UpdateDaemon

public UpdateDaemon(Map contacts,
                    boolean sharedMode,
                    InetAddress addr,
                    int port)
             throws FileNotFoundException,
                    IOException
Sole construtor.

Parameters:
contacts - This must be the real contacts map, not just a copy.
sharedMode - See FarSightImpl.
addr - The address that should be used for multicasting.
port - The port that should be used for multicasting.
Method Detail

broadcast

public void broadcast(UpdatePacket packet)
               throws IOException
Throws:
IOException

broadcastAdd

public void broadcastAdd(String key,
                         String value)
                  throws BadNameException,
                         IOException
broadcast add

Throws:
BadNameException
IOException

broadcastRemove

public void broadcastRemove(String key)
                     throws BadNameException,
                            IOException
broadcast remove

Throws:
BadNameException
IOException

handlePacket

public void handlePacket(DatagramPacket datagram)
                  throws IOException,
                         CorruptedCodeException
This method handles received datagram packets.

Parameters:
datagram - The datagram packet that was received.
Throws:
IOException - if anI/O error occurs.
CorruptedCodeException - if the packet cannot be decoded properly.

run

public void run()
Specified by:
run in interface Runnable

handleAdded

private void handleAdded(UpdatePacket packet)

handleRemoved

private void handleRemoved(UpdatePacket packet)

listen

private void listen()
             throws IOException
Listens for FarSights UpdatePackets.

Throws:
IOException
See Also:
<{UpdatePacket}>


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.